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

Commit 37bd768

Browse files
committed
Small refactor in HPOneViewException: msg has error message (str) and oneview_response has rest json response (dict).
1 parent 2d5b46d commit 37bd768

34 files changed

+175
-93
lines changed

examples/connection_templates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
con_template_byname = oneview_client.connection_templates.get_by('name', connection_template_name)[0]
6565
pprint(con_template_byname)
6666
except HPOneViewException as e:
67-
print(e.msg['message'])
67+
print(e.msg)
6868

6969
# Get by Id and update name
7070
try:
@@ -79,4 +79,4 @@
7979
(con_template_byid['uri']))
8080
print(" with attribute {'name': '%s'}" % con_template_byid['name'])
8181
except HPOneViewException as e:
82-
print(e.msg['message'])
82+
print(e.msg)

examples/connections.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
cons_interconnectUri = oneview_client.connections.get_all(filter=filter)
5252
pprint(cons_interconnectUri)
5353
except HPOneViewException as e:
54-
print(e.msg['message'])
54+
print(e.msg)
5555

5656
# Get first 10 connections, sorted by name
5757
print("Get first 10 connections, sorting by name")
@@ -65,7 +65,7 @@
6565
'name', "name981375475-1465399560370")
6666
pprint(con_byName)
6767
except HPOneViewException as e:
68-
print(e.msg['message'])
68+
print(e.msg)
6969

7070

7171
# Get by Uri
@@ -75,4 +75,4 @@
7575
'/rest/connections/58ffb307-3087-4c9d-8574-44e8a79e0d6e')
7676
pprint(con_byUri)
7777
except HPOneViewException as e:
78-
print(e.msg['message'])
78+
print(e.msg)

examples/enclosure_groups.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@
110110
eg_byid = oneview_client.enclosure_groups.get('54184fae-42d5-4248-a732-cfe5115f7857')
111111
pprint(eg_byid)
112112
except HPOneViewException as e:
113-
print(e.msg['message'])
113+
print(e.msg)
114114

115115
# Get by uri
116116
try:
117117
print("Get an Enclosure Group by uri")
118118
eg_byuri = oneview_client.enclosure_groups.get(egs[0]["uri"])
119119
pprint(eg_byuri)
120120
except HPOneViewException as e:
121-
print(e.msg['message'])
121+
print(e.msg)
122122

123123
# Update an Enclosure Group Script
124124
print("Update an Enclosure Group Script")
@@ -132,7 +132,7 @@
132132
script = oneview_client.enclosure_groups.get_script(egs[0]["uri"])
133133
print(script)
134134
except HPOneViewException as e:
135-
print(e.msg['message'])
135+
print(e.msg)
136136

137137
# Delete an Enclosure Group
138138
print("Delete the created Enclosure Group")

examples/enclosures.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,36 @@
7676
oneview_client.enclosures.update_configuration(enclosure['uri'])
7777
print(" Done.")
7878
except HPOneViewException as e:
79-
print(e.msg['message'])
79+
print(e.msg)
8080

8181
print("Retrieve the environmental configuration data for the enclosure")
8282
try:
8383
environmental_configuration = oneview_client.enclosures.get_environmental_configuration(enclosure['uri'])
8484
print(" Enclosure calibratedMaxPower = %s" % environmental_configuration['calibratedMaxPower'])
8585
except HPOneViewException as e:
86-
print(" %s" % e.msg['message'])
86+
print(" %s" % e.msg)
8787

8888
print("Refreshing the enclosure")
8989
try:
9090
config = {"refreshState": "RefreshPending"}
9191
enclosure = oneview_client.enclosures.refresh_state(enclosure['uri'], config)
9292
print(" Done")
9393
except HPOneViewException as e:
94-
print(" %s" % e.msg['message'])
94+
print(" %s" % e.msg)
9595

9696
print("Get the enclosure script")
9797
try:
9898
script = oneview_client.enclosures.get_script(enclosure['uri'])
9999
pprint(script)
100100
except HPOneViewException as e:
101-
print(" %s" % e.msg['message'])
101+
print(" %s" % e.msg)
102102

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

110110
# Get Statistics specifying parameters
111111
print("Get the enclosure statistics")
@@ -116,7 +116,7 @@
116116
view='day')
117117
pprint(enclosure_statistics)
118118
except HPOneViewException as e:
119-
print(e.msg['message'])
119+
print(e.msg)
120120

121121
# Remove the recently added enclosure
122122
oneview_client.enclosures.remove(enclosure)

examples/fabrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
fabrics_byid = oneview_client.fabrics.get(fabric_id)
6060
pprint(fabrics_byid)
6161
except HPOneViewException as e:
62-
print(e.msg['message'])
62+
print(e.msg)
6363

6464
# Get by name
6565
print("\nGet a fabrics by name")

examples/fc_networks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
fc_nets_byid = oneview_client.fc_networks.get('3518be0e-17c1-4189-8f81-83f3724f6155')
8787
pprint(fc_nets_byid)
8888
except HPOneViewException as e:
89-
print(e.msg['message'])
89+
print(e.msg)
9090

9191
# Get by Uri
9292
print("Get a fc-network by uri")

examples/fcoe_networks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
fcoe_nets_byid = oneview_client.fcoe_networks.get('452cf2a8-e5a0-4b9c-9961-0dc6deb80d01')
8686
pprint(fcoe_nets_byid)
8787
except HPOneViewException as e:
88-
print(e.msg['message'])
88+
print(e.msg)
8989

9090
# Get by Uri
9191
print("Get a fcoe-network by uri")

examples/id_pools_vmac_ranges.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
successfully_collected_ids = oneview_client.id_pools_vmac_ranges.collect(
129129
information, vmac_range['uri'])
130130
except HPOneViewException as e:
131-
print(e.msg['message'])
131+
print(e.msg)
132132

133133
# Disable a vmac range
134134
information = {

examples/id_pools_vsn_ranges.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
successfully_collected_ids = oneview_client.id_pools_vsn_ranges.collect(
129129
information, vsn_range['uri'])
130130
except HPOneViewException as e:
131-
print(e.msg['message'])
131+
print(e.msg)
132132

133133
# Disable a vsn range
134134
information = {

examples/id_pools_vwwn_ranges.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
successfully_collected_ids = oneview_client.id_pools_vwwn_ranges.collect(
130130
information, vwwn_range['uri'])
131131
except HPOneViewException as e:
132-
print(e.msg['message'])
132+
print(e.msg)
133133

134134
# Disable a vwwn range
135135
information = {

0 commit comments

Comments
 (0)