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

Commit

Permalink
Small refactor in HPOneViewException: msg has error message (str) and…
Browse files Browse the repository at this point in the history
… oneview_response has rest json response (dict).
  • Loading branch information
GustavoHennig committed Sep 13, 2016
1 parent 2d5b46d commit 37bd768
Show file tree
Hide file tree
Showing 34 changed files with 175 additions and 93 deletions.
4 changes: 2 additions & 2 deletions examples/connection_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
con_template_byname = oneview_client.connection_templates.get_by('name', connection_template_name)[0]
pprint(con_template_byname)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get by Id and update name
try:
Expand All @@ -79,4 +79,4 @@
(con_template_byid['uri']))
print(" with attribute {'name': '%s'}" % con_template_byid['name'])
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)
6 changes: 3 additions & 3 deletions examples/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
cons_interconnectUri = oneview_client.connections.get_all(filter=filter)
pprint(cons_interconnectUri)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get first 10 connections, sorted by name
print("Get first 10 connections, sorting by name")
Expand All @@ -65,7 +65,7 @@
'name', "name981375475-1465399560370")
pprint(con_byName)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)


# Get by Uri
Expand All @@ -75,4 +75,4 @@
'/rest/connections/58ffb307-3087-4c9d-8574-44e8a79e0d6e')
pprint(con_byUri)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)
6 changes: 3 additions & 3 deletions examples/enclosure_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@
eg_byid = oneview_client.enclosure_groups.get('54184fae-42d5-4248-a732-cfe5115f7857')
pprint(eg_byid)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get by uri
try:
print("Get an Enclosure Group by uri")
eg_byuri = oneview_client.enclosure_groups.get(egs[0]["uri"])
pprint(eg_byuri)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Update an Enclosure Group Script
print("Update an Enclosure Group Script")
Expand All @@ -132,7 +132,7 @@
script = oneview_client.enclosure_groups.get_script(egs[0]["uri"])
print(script)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Delete an Enclosure Group
print("Delete the created Enclosure Group")
Expand Down
12 changes: 6 additions & 6 deletions examples/enclosures.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,36 @@
oneview_client.enclosures.update_configuration(enclosure['uri'])
print(" Done.")
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

print("Retrieve the environmental configuration data for the enclosure")
try:
environmental_configuration = oneview_client.enclosures.get_environmental_configuration(enclosure['uri'])
print(" Enclosure calibratedMaxPower = %s" % environmental_configuration['calibratedMaxPower'])
except HPOneViewException as e:
print(" %s" % e.msg['message'])
print(" %s" % e.msg)

print("Refreshing the enclosure")
try:
config = {"refreshState": "RefreshPending"}
enclosure = oneview_client.enclosures.refresh_state(enclosure['uri'], config)
print(" Done")
except HPOneViewException as e:
print(" %s" % e.msg['message'])
print(" %s" % e.msg)

print("Get the enclosure script")
try:
script = oneview_client.enclosures.get_script(enclosure['uri'])
pprint(script)
except HPOneViewException as e:
print(" %s" % e.msg['message'])
print(" %s" % e.msg)

print("Build the SSO (Single Sign-On) URL parameters for the enclosure")
try:
sso_url_parameters = oneview_client.enclosures.get_sso(enclosure['uri'], 'Active')
pprint(sso_url_parameters)
except HPOneViewException as e:
print(" %s" % e.msg['message'])
print(" %s" % e.msg)

# Get Statistics specifying parameters
print("Get the enclosure statistics")
Expand All @@ -116,7 +116,7 @@
view='day')
pprint(enclosure_statistics)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Remove the recently added enclosure
oneview_client.enclosures.remove(enclosure)
Expand Down
2 changes: 1 addition & 1 deletion examples/fabrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
fabrics_byid = oneview_client.fabrics.get(fabric_id)
pprint(fabrics_byid)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get by name
print("\nGet a fabrics by name")
Expand Down
2 changes: 1 addition & 1 deletion examples/fc_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
fc_nets_byid = oneview_client.fc_networks.get('3518be0e-17c1-4189-8f81-83f3724f6155')
pprint(fc_nets_byid)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get by Uri
print("Get a fc-network by uri")
Expand Down
2 changes: 1 addition & 1 deletion examples/fcoe_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
fcoe_nets_byid = oneview_client.fcoe_networks.get('452cf2a8-e5a0-4b9c-9961-0dc6deb80d01')
pprint(fcoe_nets_byid)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get by Uri
print("Get a fcoe-network by uri")
Expand Down
2 changes: 1 addition & 1 deletion examples/id_pools_vmac_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
successfully_collected_ids = oneview_client.id_pools_vmac_ranges.collect(
information, vmac_range['uri'])
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Disable a vmac range
information = {
Expand Down
2 changes: 1 addition & 1 deletion examples/id_pools_vsn_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
successfully_collected_ids = oneview_client.id_pools_vsn_ranges.collect(
information, vsn_range['uri'])
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Disable a vsn range
information = {
Expand Down
2 changes: 1 addition & 1 deletion examples/id_pools_vwwn_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
successfully_collected_ids = oneview_client.id_pools_vwwn_ranges.collect(
information, vwwn_range['uri'])
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Disable a vwwn range
information = {
Expand Down
4 changes: 2 additions & 2 deletions examples/interconnect_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
'e28949fa-8681-433d-9808-a9146feb8048')
pprint(interconnect_types_byid, depth=1)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get by name
try:
Expand All @@ -66,4 +66,4 @@
'name', 'HP VC Flex-10 Enet Module')[0]
pprint(interconnect_type_byname, depth=1)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)
22 changes: 11 additions & 11 deletions examples/interconnects.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
interconnects = oneview_client.interconnects.get_all(0, 2)
pprint(interconnects)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get Interconnects Statistics
print("Get an interconnect statistics")
Expand All @@ -75,7 +75,7 @@
else:
pprint("There are no statistics for the interconnect {0}".format(interconnect_id))
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get the Statistics from a port of an Interconnects
print("Get the port statistics for downlink port 1 on the interconnect "
Expand All @@ -84,7 +84,7 @@
statistics = oneview_client.interconnects.get_statistics(interconnect_id, port_d1["portName"])
pprint(statistics)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get the subport Statistics from a port of an Interconnects
print("Get the subport statistics for subport 1 on downlink port 2 on the interconnect "
Expand All @@ -95,31 +95,31 @@
port_d1["bayNumber"])
pprint(statistics)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get by ID
print("Get Interconnect that matches the specified ID")
try:
interconnect = oneview_client.interconnects.get(interconnect_id)
pprint(interconnect)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get by hostName
print("Get an interconnect by hostName")
try:
interconnect = oneview_client.interconnects.get_by('hostName', interconnect["hostName"])[0]
pprint(interconnect)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get by name
print("Get an interconnect by name")
try:
interconnect = oneview_client.interconnects.get_by_name(interconnect["name"])
pprint(interconnect)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Turn the power off
print("Turn the power off and the UID light to 'Off' for interconnect " +
Expand All @@ -144,15 +144,15 @@
updated = oneview_client.interconnects.update_port(port_for_update, interconnect_id)
pprint(updated)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Reset of port protection.
print("Trigger a reset of port protection of the interconnect that matches the specified ID")
try:
result = oneview_client.interconnects.reset_port_protection(interconnect_id)
pprint(result)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get name servers
print("Get the named servers for the interconnect that matches the specified ID")
Expand All @@ -161,7 +161,7 @@
interconnect_ns = oneview_client.interconnects.get_name_servers(interconnect_id)
pprint(interconnect_ns)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Updates the interconnect ports.
print("Update the interconnect ports")
Expand All @@ -175,4 +175,4 @@

pprint(updated_ports)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)
4 changes: 2 additions & 2 deletions examples/logical_downlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
log_downlink = oneview_client.logical_downlinks.get(logical_downlink_id)
pprint(log_downlink)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get logical downlink by id without Ethernet networks
try:
print("Get logical downlink by id without Ethernet networks")
log_downlink_without_ethernet = oneview_client.logical_downlinks.get_without_ethernet(logical_downlink_id)
pprint(log_downlink_without_ethernet)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get all logical downlinks
print("Get all logical downlinks")
Expand Down
8 changes: 4 additions & 4 deletions examples/logical_enclosures.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
print("Got logical enclosure '{}' by id: 'acb17b89-6724-4602-818a-1ee20ed4ec60'\n uri: '{}'".format(
logical_enclosure_by_id['name'], logical_enclosure_by_id['uri']))
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get logical enclosure by uri
logical_enclosure = oneview_client.logical_enclosures.get(
Expand All @@ -79,7 +79,7 @@
logical_enclosure_by_name = oneview_client.logical_enclosures.get_by('name', logical_enclosure['name'])[0]
print("Got logical enclosure by name '{name}'\n uri: '{uri}'".format(**logical_enclosure_by_name))
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Update configuration
print("Reapply the appliance's configuration to the logical enclosure")
Expand All @@ -88,7 +88,7 @@
logical_enclosure['uri'])
print(" Done.")
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# update and get script
print("Update script")
Expand Down Expand Up @@ -116,7 +116,7 @@
logical_enclosure['uri'])
print(" Done")
except HPOneViewException as e:
print(" %s" % e.msg['message'])
print(" %s" % e.msg)

# Get all logical enclosures
print("Get all logical enclosures")
Expand Down
4 changes: 2 additions & 2 deletions examples/logical_interconnect_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@
lig_byid = oneview_client.logical_interconnect_groups.get('f0a0a113-ec97-41b4-83ce-d7c92b900e7c')
pprint(lig_byid)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get by uri
try:
print("Get a Logical Interconnect Group by uri")
lig_byuri = oneview_client.logical_interconnect_groups.get(created_lig["uri"])
pprint(lig_byuri)
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get default settings
print("Get the default interconnect settings for a logical interconnect group")
Expand Down
6 changes: 3 additions & 3 deletions examples/logical_interconnects.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
interconnect_snmp = logical_interconnect['snmpConfiguration']
print(" Updated SNMP configuration at uri: {uri}\n with 'enabled': '{enabled}'".format(**interconnect_snmp))
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get a collection of uplink ports from the member interconnects which are eligible for assignment to an analyzer port
print("Get a collection of uplink ports from the member interconnects which are eligible for assignment to "
Expand All @@ -162,7 +162,7 @@
print(" Updated port monitor at uri: {uri}\n with 'enablePortMonitor': '{enablePortMonitor}'".format(
**monitor_configuration))
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get the telemetry configuration of the logical interconnect
print("Get the telemetry configuration of the logical interconnect")
Expand Down Expand Up @@ -218,4 +218,4 @@
li = oneview_client.logical_interconnects.update_qos_aggregated_configuration(logical_interconnect['uri'], qos)
pprint(li['qosConfiguration'])
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)
4 changes: 2 additions & 2 deletions examples/logical_switch_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@
lsg_byid = oneview_client.logical_switch_groups.get(lsg_id)
print(" Found logical switch group '{name}' by id at uri '{uri}'".format(**lsg_byid))
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Get by uri
try:
print("Get a Logical Switch Group by uri")
lsg_byuri = oneview_client.logical_switch_groups.get(created_lsg["uri"])
print(" Found logical switch group '{name}' by uri '{uri}'".format(**lsg_byuri))
except HPOneViewException as e:
print(e.msg['message'])
print(e.msg)

# Delete a logical switch group
print("Delete the created logical switch group")
Expand Down
Loading

0 comments on commit 37bd768

Please sign in to comment.