Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Upgrade/500 600/id pools #390

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 5.0.0 (Unrelased)

#### Features supported with current release:
- Id pool

# 4.7.1
#### Bug fixes
- [#364] (https://github.com/HewlettPackard/python-hpOneView/issues/364) Bug in index_resources.get_all()
Expand Down
16 changes: 8 additions & 8 deletions endpoints-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@
|<sub>/rest/firmware-drivers/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/firmware-drivers/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **ID Pools** |
|<sub>/rest/id-pools/{poolType}</sub> | GET | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}</sub> | PUT | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/allocator</sub> | PUT | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/checkrangeavailability</sub> | GET | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/collector</sub> | PUT | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/generate</sub> | GET | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/validate</sub> | GET | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/validate</sub> | PUT | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/allocator</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/checkrangeavailability</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/collector</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/generate</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/validate</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}/validate</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **ID Pools IPv4 Ranges** |
|<sub>/rest/id-pools/ipv4/ranges</sub> | POST | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/ipv4/ranges/{id}</sub> | GET | :white_check_mark: | :white_check_mark: |
Expand Down
78 changes: 42 additions & 36 deletions examples/enclosures.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,23 @@
###

from pprint import pprint

from hpOneView.oneview_client import OneViewClient
from hpOneView.exceptions import HPOneViewException
from hpOneView.exceptions import HPOneViewException, HPOneViewTaskError
from config_loader import try_load_from_file

# This example is compatible only for C7000 enclosures

config = {
"ip": "<oneview_ip>",
"ip": "",
"credentials": {
"userName": "<username>",
"password": "<password>"
}
"userName": "",
"password": ""
},
"enclosure_group_uri": "",
"enclosure_hostname": "",
"enclosure_username": "",
"enclosure_password": "",
}

# Declare a CA signed certificate file path.
Expand All @@ -44,53 +49,55 @@

# The hostname, enclosure group URI, username, and password must be set on the configuration file
options = {
"name": "Encl1-Updated-Updated-Updated",
"enclosureGroupUri": config['enclosure_group_uri'],
"hostname": config['enclosure_hostname'],
"username": config['enclosure_username'],
"password": config['enclosure_password'],
"licensingIntent": "OneView"
}

# Get OneView client
oneview_client = OneViewClient(config)

# Add an Enclosure
enclosure = oneview_client.enclosures.add(options)
enclosure_uri = enclosure['uri']
print("Added enclosure '{name}'.\n URI = '{uri}'".format(**enclosure))

# Perform a patch operation, replacing the name of the enclosure
enclosure_name = enclosure['name'] + "-Updated"
# Add an enclosure
try:
# This will return an enclosure object
enclosure = oneview_client.enclosures.add(options)
print("Added enclosure '{name}'.\n URI = '{uri}'".format(**enclosure.data))
except HPOneViewTaskError, e:
print(e)
# Get the reosurce by name
enclosure = oneview_client.enclosures.get_by_name(options['name'])

# Perform a patch operation on the enclosure, replacing name of the enclosure
enclosure_name = "Encl1-Updated"
print("Updating the enclosure to have a name of " + enclosure_name)
enclosure = oneview_client.enclosures.patch(enclosure_uri, 'replace', '/name', enclosure_name)
print(" Done.\n URI = '{uri}', name = {name}".format(**enclosure))

# Find the recently added enclosure by name
print("Find an enclosure by name")
enclosure = oneview_client.enclosures.get_by('name', enclosure['name'])[0]
print(" URI = '{uri}'".format(**enclosure))
enclosure.patch('replace', '/name', enclosure_name)
print(" Done.\n URI = '{uri}', name = {name}".format(**enclosure.data))

# Get by URI
print("Find an enclosure by URI")
enclosure = oneview_client.enclosures.get(enclosure_uri)
pprint(enclosure)
enclosure = enclosure.get_by_uri(enclosure.data['uri'])
pprint(enclosure.data)

# Get all enclosures
print("Get all enclosures")
enclosures = oneview_client.enclosures.get_all()
enclosures = enclosure.get_all()
for enc in enclosures:
print(' {name}'.format(**enc))

# Update configuration
print("Reapplying the appliance's configuration on the enclosure")
try:
oneview_client.enclosures.update_configuration(enclosure_uri)
enclosure.update_configuration()
print(" Done.")
except HPOneViewException as e:
print(e.msg)

print("Retrieve the environmental configuration data for the enclosure")
try:
environmental_configuration = oneview_client.enclosures.get_environmental_configuration(enclosure_uri)
environmental_configuration = enclosure.get_environmental_configuration()
print(" Enclosure calibratedMaxPower = {calibratedMaxPower}".format(**environmental_configuration))
except HPOneViewException as e:
print(e.msg)
Expand All @@ -99,34 +106,33 @@
print("Refreshing the enclosure")
try:
refresh_state = {"refreshState": "RefreshPending"}
enclosure = oneview_client.enclosures.refresh_state(enclosure_uri, refresh_state)
enclosure.refresh_state(refresh_state)
print(" Done")
except HPOneViewException as e:
print(e.msg)

# Get the enclosure script
print("Get the enclosure script")
try:
script = oneview_client.enclosures.get_script(enclosure_uri)
script = enclosure.get_script()
pprint(script)
except HPOneViewException as e:
print(e.msg)

# Buid the SSO URL parameters
print("Build the SSO (Single Sign-On) URL parameters for the enclosure")
try:
sso_url_parameters = oneview_client.enclosures.get_sso(enclosure_uri, 'Active')
sso_url_parameters = enclosure.get_sso('Active')
pprint(sso_url_parameters)
except HPOneViewException as e:
print(e.msg)

# Get Statistics specifying parameters
print("Get the enclosure statistics")
try:
enclosure_statistics = oneview_client.enclosures.get_utilization(enclosure_uri,
fields='AveragePower',
filter='startDate=2016-06-30T03:29:42.000Z',
view='day')
enclosure_statistics = enclosure.get_utilization(fields='AveragePower',
filter='startDate=2016-06-30T03:29:42.000Z',
view='day')
pprint(enclosure_statistics)
except HPOneViewException as e:
print(e.msg)
Expand All @@ -143,14 +149,14 @@
"commonName": ""
}
try:
oneview_client.enclosures.generate_csr(csr_data, enclosure_uri, bay_number=bay_number)
enclosure.generate_csr(csr_data, bay_number=bay_number)
print("Generated CSR for the enclosure.")
except HPOneViewException as e:
print(e.msg)

# Get the certificate Signing Request (CSR) that was generated by previous POST.
try:
csr = oneview_client.enclosures.get_csr(enclosure_uri, bay_number=bay_number)
csr = enclosure.get_csr(bay_number=bay_number)
with open('enclosure.csr', 'w') as csr_file:
csr_file.write(csr["base64Data"])
print("Saved CSR(generated by previous POST) to 'enclosure.csr' file")
Expand All @@ -160,7 +166,7 @@
try:
# Get Enclosure by scope_uris
if oneview_client.api_version >= 600:
enclosures_by_scope_uris = oneview_client.enclosures.get_all(scope_uris="\"'/rest/scopes/3bb0c754-fd38-45af-be8a-4d4419de06e9'\"")
enclosures_by_scope_uris = enclosure.get_all(scope_uris="\"'/rest/scopes/3bb0c754-fd38-45af-be8a-4d4419de06e9'\"")
if len(enclosures_by_scope_uris) > 0:
print("Found %d Enclosures" % (len(enclosures_by_scope_uris)))
i = 0
Expand All @@ -185,11 +191,11 @@
"base64Data": certificate
}

oneview_client.enclosures.import_certificate(certificate_data, enclosure_uri, bay_number=bay_number)
enclosure.import_certificate(certificate_data, enclosure.data['uri'], bay_number=bay_number)
print("Imported Signed Certificate to the enclosure.")
except HPOneViewException as e:
print(e.msg)

# Remove the recently added enclosure
oneview_client.enclosures.remove(enclosure)
enclosure.remove()
print("Enclosure removed successfully")
77 changes: 36 additions & 41 deletions examples/fc_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,90 +27,85 @@
from config_loader import try_load_from_file

config = {
"ip": "<oneview_ip>",
"ip": "",
"credentials": {
"userName": "<username>",
"password": "<password>"
}
"userName": "",
"password": ""
},
}

options = {
"name": "OneViewSDK Test FC Network",
"name": "fc_test",
"connectionTemplateUri": None,
"autoLoginRedistribution": True,
"fabricType": "FabricAttach",
"linkStabilityTime": 30,
}

# FC Network ID to perform a get by ID
fc_network_id = ""

# Scope name to perform the patch operation
scope_name = ""
scope_name = "sample"

# Try load config from a file (if there is a config file)
config = try_load_from_file(config)

oneview_client = OneViewClient(config)

# Create a FC Network
fc_network = oneview_client.fc_networks.create(options)
print("\nCreated fc-network '%s' successfully.\n uri = '%s'" % (fc_network['name'], fc_network['uri']))
# Create a FcNetWork with the options provided
try:
fc_network = oneview_client.fc_networks.create(data=options)
print("\nCreated a fc-network with name: '%s'.\n uri = '%s'" % (fc_network.data['name'], fc_network.data['uri']))
except HPOneViewException, e:
print(e[0])

# Find recently created network by name
fc_network = oneview_client.fc_networks.get_by('name', 'OneViewSDK Test FC Network')[0]
print("\nFound fc-network by name: '%s'.\n uri = '%s'" % (fc_network['name'], fc_network['uri']))
fc_network = oneview_client.fc_networks.get_by_name(options['name'])
print("\nFound fc-network by name: '%s'.\n uri = '%s'" % (fc_network.data['name'], fc_network.data['uri']))

# Update autoLoginRedistribution from recently created network
fc_network['autoLoginRedistribution'] = False
fc_network = oneview_client.fc_networks.update(fc_network)
print("\nUpdated fc-network '%s' successfully.\n uri = '%s'" % (fc_network['name'], fc_network['uri']))
print(" with attribute {'autoLoginRedistribution': %s}" % fc_network['autoLoginRedistribution'])
data_to_update = {'autoLoginRedistribution': False,
'name': 'Updated FC'}
resource = fc_network.update(data=data_to_update)
print("\nUpdated fc-network '%s' successfully.\n uri = '%s'" % (resource.data['name'], resource.data['uri']))
print(" with attribute {'autoLoginRedistribution': %s}" % resource.data['autoLoginRedistribution'])

# Get all, with defaults
print("\nGet all fc-networks")
fc_nets = oneview_client.fc_networks.get_all()
fc_nets = fc_network.get_all()
pprint(fc_nets)

# Filter by name
print("\nGet all fc-networks filtering by name")
fc_nets_filtered = oneview_client.fc_networks.get_all(filter="\"'name'='OneViewSDK Test FC Network'\"")
fc_nets_filtered = fc_network.get_all(filter="\"'name'='Updated FC'\"")
pprint(fc_nets_filtered)

# Get all sorting by name descending
print("\nGet all fc-networks sorting by name")
fc_nets_sorted = oneview_client.fc_networks.get_all(sort='name:descending')
fc_nets_sorted = fc_network.get_all(sort='name:descending')
pprint(fc_nets_sorted)

# Get the first 10 records
print("\nGet the first ten fc-networks")
fc_nets_limited = oneview_client.fc_networks.get_all(0, 10)
fc_nets_limited = fc_network.get_all(0, 10)
pprint(fc_nets_limited)

# Get by Id
if fc_network_id:
try:
print("\nGet a fc-network by id")
fc_nets_byid = oneview_client.fc_networks.get(fc_network_id)
pprint(fc_nets_byid)
except HPOneViewException as e:
print(e.msg)

# Get by Uri
# Get by uri
print("\nGet a fc-network by uri")
fc_nets_by_uri = oneview_client.fc_networks.get(fc_network['uri'])
pprint(fc_nets_by_uri)
fc_nets_by_uri = fc_network.get_by_uri(resource.data['uri'])
pprint(fc_nets_by_uri.data)

# Adds ethernet to scope defined
if scope_name:
print("\nGet scope then add the network to it")
scope = oneview_client.scopes.get_by_name(scope_name)
fc_with_scope = oneview_client.fc_networks.patch(fc_network['uri'],
'replace',
'/scopeUris',
[scope['uri']])
pprint(fc_with_scope)
scope = oneview_client.scopes.get_by_name(scope_name) # TODO: This has to updated
try:
fc_with_scope = fc_network.patch(resource.data['uri'],
'replace',
'/scopeUris',
[scope['uri']])
pprint(fc_with_scope)
except HPOneViewException, e:
print(e)

# Delete the created network
oneview_client.fc_networks.delete(fc_network)
fc_network.delete()
print("\nSuccessfully deleted fc-network")
Loading