Skip to content

Commit

Permalink
Merge pull request #161 from HewlettPackard/6.2Validation
Browse files Browse the repository at this point in the history
6.20 Validation
  • Loading branch information
yuvirani authored Jul 1, 2021
2 parents 5a37f0d + f434934 commit 1245bc5
Show file tree
Hide file tree
Showing 9 changed files with 488 additions and 398 deletions.
45 changes: 43 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,51 @@ Extends support of the SDK to OneView REST API version 3000 (OneView v6.20)
#### Bug fixes & Enhancements
- [#157] (https://github.com/HewlettPackard/oneview-python/issues/157) Add appliance ha-nodes endpoint to sdk

#### Features supported
- Appliance Node Information
##### Features supported with the current release
- Appliance Configuration Timeconfig
- Appliance Health Status
- Appliance Node Information
- Appliance SNMPv1 Trap Destinations
- Appliance SNMPv3 Trap Destinations
- Appliance SNMPv3 Users
- Appliance SSH Access
- Appliance Time and Locale Configuration
- Connection Templates
- Enclosures
- Enclosure Groups
- Ethernet network
- FC network
- FCOE network
- Firmware Drivers
- HA Nodes
- Hypervisor Cluster Profiles
- Hypervisor Managers
- ID Pools
- ID Pool IPv4 Range
- ID Pool IPv4 Subnets
- Index Resources
- Interconnects
- Interconnect Types
- Labels
- Logical Enclosures
- Logical Interconnects
- Logical Interconnect Group
- Network set
- Restores
- Scopes
- Server Hardware
- Server Hardware Types
- Server Profiles
- Server Profile Templates
- Storage Pools
- Storage Systems
- Storage Templates
- Storage Volume Attachments
- Storage Volume
- Tasks
- Uplink set
- Users
- Version

# 6.1.0
#### Notes
Expand Down
677 changes: 339 additions & 338 deletions endpoints-support.md

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions examples/appliance_device_snmp_v3_trap_destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,24 @@
appliance_device_snmp_v3_users = oneview_client.appliance_device_snmp_v3_users

# Get all snmpv3 users
# snmp v3 user must be there to create this
snmp_users = appliance_device_snmp_v3_users.get_all()
snmp_userId = snmp_users[0]['id']
if snmp_users:
snmp_userId = snmp_users[0]['id']
# Adding userId to snmpv3 users payload
options['userId'] = snmp_userId
# Add appliance device SNMP v3 Trap Destination
snmp_v3_trap = appliance_device_snmp_v3_trap_destinations.create(options)
print("\n## Created appliance SNMPv3 trap destination successfully!")
pprint(snmp_v3_trap.data)

# Adding userId to snmpv3 users payload
options['userId'] = snmp_userId

# Lists the appliance device SNMP v3 Trap Destination
print("\n## Get list of appliance SNMPv3 trap destination")
snmp_v3_trap_all = appliance_device_snmp_v3_trap_destinations.get_all()
for snmp_trap in snmp_v3_trap_all:
print(' - {}: {}'.format(snmp_trap['destinationAddress'], snmp_trap['uri']))

# Add appliance device SNMP v3 Trap Destination
snmp_v3_trap = appliance_device_snmp_v3_trap_destinations.create(options)
print("\n## Created appliance SNMPv3 trap destination successfully!")
pprint(snmp_v3_trap.data)

# Get by name
print("\n## Find an SNMPv3 trap destination by name")
snmp_v3_trap = appliance_device_snmp_v3_trap_destinations.get_by_name(snmp_v3_trap.data['destinationAddress'])
Expand Down
6 changes: 6 additions & 0 deletions examples/appliance_device_snmp_v3_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,9 @@
# Delete Created Entry
snmp_v3_user.delete()
print("\n## Delete appliance SNMP v3 user successfully!")

# Add appliance device SNMP v3 users for Automation
snmp_v3_user = appliance_device_snmp_v3_users.create(options)
snmp_v3_user_uri = snmp_v3_user.data['uri']
print("\n## Created appliance SNMP v3 user")
pprint(snmp_v3_user.data)
9 changes: 7 additions & 2 deletions examples/config-rename.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ip": "",
"image_streamer_ip": "",
"api_version": 800,
"api_version": 3000,
"ssl_certificate": "",
"credentials": {
"userName": "",
Expand All @@ -22,5 +22,10 @@
"storage_system_password": "",
"power_device_hostname": "",
"power_device_username": "",
"power_device_password": ""
"power_device_password": "",
"subnet_networkid": "",
"subnet_mask": "",
"subnet_gateway": "",
"range_start_address": "",
"range_end_address": ""
}
64 changes: 38 additions & 26 deletions examples/id_pools_ipv4_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
config = try_load_from_file(config)

oneview_client = OneViewClient(config)
enclosure_groups = oneview_client.enclosure_groups
id_pool_ipv4_range = oneview_client.id_pools_ipv4_ranges
id_pool_ipv4_subnet = oneview_client.id_pools_ipv4_subnets

options = {
"name": "IPv4",
Expand All @@ -41,25 +44,29 @@
"subnetUri": ""
}

subnet_options = {
"name": "iscsi_Subnet",
"networkId": config['subnet_networkid'],
"subnetmask": config['subnet_mask'],
"gateway": config['subnet_gateway'],
"domain": "example.com",
}

print('\n Create IPv4 subnet to have Range of IPs')
ipv4_subnet = id_pool_ipv4_subnet.create(subnet_options)
pprint(ipv4_subnet.data)

option = {
"name": "IPv4",
"startStopFragments": [
{
"startAddress": "<start_ip>",
"endAddress": "<end_ip>"
"startAddress": config['range_start_address'],
"endAddress": config['range_end_address']
}
],
"subnetUri": "<network_id>"
"subnetUri": ipv4_subnet.data['uri']
}

id_pool_ipv4_range = oneview_client.id_pools_ipv4_ranges
id_pool_ipv4_subnet = oneview_client.id_pools_ipv4_subnets

subnet_uri = id_pool_ipv4_subnet.get_by_field('networkId', option['subnetUri'])
if subnet_uri:
option["subnetUri"] = subnet_uri.data['uri']

print("\n Create an IPv4 Range for id pools")
if oneview_client.api_version > 1000:
ipv4_range = id_pool_ipv4_range.create(option).data
Expand Down Expand Up @@ -90,19 +97,24 @@
ipv4_range.data['uri'])
print(" IPv4 range enabled successfully.")

print("Allocates a set of IDs from an IPv4 range. The maximum number of IDs in a request is 100.")
print("The allocator returned contains the list of IDs successfully allocated. Associate the IPv4 address range with a resource before requesting IDs from it.")
print("\nAssociate EG with range for allocation")
eg_options = {
"name": "RangeEG",
"ipAddressingMode": "ipPool",
"ipRangeUris": [ipv4_range['uri']],
"enclosureCount": 3,
}
enclosure_group = enclosure_groups.create(eg_options)

print("\nAllocates a set of IDs from an IPv4 range")

ipv4_range_updated = ipv4Range.update_allocator({
"count": 7,
"idList": [
"",
"",
]
"count": 2,
}, ipv4_range['uri'])
pprint(ipv4_range_updated)
print("Allocated set of ID to ipv4 Range")


print("\n Get all allocated fragments in IPv4 range")
allocated_fragments = ipv4Range.get_allocated_fragments(ipv4_range['uri'])
pprint(allocated_fragments)
Expand All @@ -111,6 +123,15 @@
allocated_fragments = ipv4Range.get_free_fragments(ipv4_range['uri'])
pprint(allocated_fragments)

print("Collects a set of IDs back to an IPv4 range.")
ipv4_range_collector = ipv4Range.update_collector({
"idList": ipv4_range_updated['idList']
}, ipv4_range['uri'])
print(ipv4_range_collector)

print("\nRemove associated EG before deletion")
enclosure_group.delete()

print("\n Disable an IPv4 range")
ipv4_range = ipv4Range.enable({
"type": "Range",
Expand All @@ -121,12 +142,3 @@
print("\n Delete the IPv4_range")
ipv4Range.delete()
print(" Successfully deleted IPv4 range")

print("Collects a set of IDs back to an IPv4 range.")
ipv4_range = ipv4Range.update_collector({
"idList": [
"",
"",
]
}, ipv4_range['uri'])
print(ipv4_range)
56 changes: 37 additions & 19 deletions examples/id_pools_ipv4_subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@

options = {
"name": "IPv4Subnet",
"networkId": '192.169.1.0',
"subnetmask": "255.255.255.0",
"gateway": "192.169.1.1",
"networkId": config['subnet_networkid'],
"subnetmask": config['subnet_mask'],
"gateway": config['subnet_gateway'],
"domain": "example.com",
"dnsServers": ["192.169.1.215"]
"dnsServers": []
}

id_pools_ipv4_subnets = oneview_client.id_pools_ipv4_subnets
ethernet_networks = oneview_client.ethernet_networks

print('\n Create IPv4 subnet for id pools')
ipv4_subnet = id_pools_ipv4_subnets.create(options)
Expand All @@ -60,10 +61,38 @@
all_subnets = id_pools_ipv4_subnets.get_all()
pprint(all_subnets)

print('\nAssociate Subnet with Ethernet for ID allocation')
options = {
"name": "SubnetEthernet",
"vlanId": 209,
"ethernetNetworkType": "Tagged",
"purpose": "General",
"smartLink": False,
"privateNetwork": False,
"connectionTemplateUri": None,
"subnetUri": ipv4_subnet.data['uri']
}

ethernet_network = ethernet_networks.create(options)

print('\nCreate Range with set of IDs')
option = {
"name": "IPv4",
"startStopFragments": [
{
"startAddress": config['range_start_address'],
"endAddress": config['range_end_address']
}
],
"subnetUri": ipv4_subnet.data['uri']
}
id_pool_ipv4_range = oneview_client.id_pools_ipv4_ranges
ipv4_range = id_pool_ipv4_range.create(option).data

subnet_id = ipv4_subnet.data['allocatorUri'].split('/')[-2]
print("\n Allocates a set of IDs from a pool")
try:
allocated_ids = id_pools_ipv4_subnets.allocate({"count": 10}, subnet_id)
allocated_ids = id_pools_ipv4_subnets.allocate({"count": 2}, subnet_id)
pprint(allocated_ids)
except HPEOneViewException as e:
print(e.msg)
Expand All @@ -75,20 +104,9 @@
except HPEOneViewException as e:
print(e.msg)

print('\nDelete assocaited resource before deleting subnet')
ethernet_network.delete()

print('\n Delete IPv4 subnet')
ipv4_subnet.delete()
print(" Successfully deleted IPv4 subnet")

# Create iscsi subnet for automation purpose

iscsi_options = {
"name": "iscsi_Subnet",
"networkId": '192.168.10.0',
"subnetmask": "255.255.255.0",
"gateway": "192.168.10.1",
"domain": "iscsi.com",
}

print('\n Create IPv4 subnet for iscsi')
ipv4_subnet = id_pools_ipv4_subnets.create(iscsi_options)
pprint(ipv4_subnet.data)
8 changes: 7 additions & 1 deletion examples/server_profile_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
hardware_type_for_transformation = "SY 480 Gen9 2"
enclosure_group_for_transformation = "EG-2"
scope_name = "SampleScope"
mgmt_nw_name = "mgmt_nw"
mgmt_nw_name = "mgmt"

hardware_type = hardware_types.get_by_name(hardware_type_name)
enclosure_group = enclosure_groups.get_by_name(enclosure_group_name)
Expand Down Expand Up @@ -127,6 +127,12 @@
template.update(template_to_update)
pprint(template.data)

# Patch operation to refresh the template
print("\nUpdate the template configuration with RefreshPending")
if oneview_client.api_version >= 1800 and template:
template.patch(operation="replace", path="/refreshState", value="RefreshPending")
pprint(template.data)

# Get new profile
print("\nGet new profile")
if template:
Expand Down
4 changes: 2 additions & 2 deletions hpeOneView/resources/servers/server_profile_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

from copy import deepcopy

from hpeOneView.resources.resource import Resource, ensure_resource_client
from hpeOneView.resources.resource import Resource, ResourcePatchMixin, ensure_resource_client


class ServerProfileTemplate(Resource):
class ServerProfileTemplate(Resource, ResourcePatchMixin):
"""
The server profile template resource provides methods to create, retrieve, modify, and delete server
profile templates.
Expand Down

0 comments on commit 1245bc5

Please sign in to comment.