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

Commit e54af3c

Browse files
authored
Merge pull request #360 from HewlettPackard/api600_logical_enclosure
Api600 support for Logical Enclosure
2 parents e5861ff + ab5281d commit e54af3c

File tree

5 files changed

+32
-21
lines changed

5 files changed

+32
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Extends support of the SDK to OneView Rest API version 600 (OneView v4.0).
1313
- FCoE network
1414
- Interconnect type
1515
- Internal link set
16+
- Logical enclosure
1617
- Logical interconnect
1718
- Logical interconnect group
1819
- Logical switch

endpoints-support.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,17 @@
227227
|<sub>/rest/logical-downlinks/withoutEthernet</sub> |GET | :white_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: |
228228
|<sub>/rest/logical-downlinks/{id}/withoutEthernet</sub> |GET | :white_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: |
229229
| **Logical Enclosures** |
230-
|<sub>/rest/logical-enclosures</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
231-
|<sub>/rest/logical-enclosures</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
232-
|<sub>/rest/logical-enclosures/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
233-
|<sub>/rest/logical-enclosures/{id}</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
234-
|<sub>/rest/logical-enclosures/{id}</sub> | PATCH | :white_check_mark: | :white_check_mark: | :white_check_mark: |
235-
|<sub>/rest/logical-enclosures/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: |
236-
|<sub>/rest/logical-enclosures/{id}/configuration</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
237-
|<sub>/rest/logical-enclosures/{id}/script</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
238-
|<sub>/rest/logical-enclosures/{id}/script</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
239-
|<sub>/rest/logical-enclosures/{id}/support-dumps</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
240-
|<sub>/rest/logical-enclosures/{id}/updateFromGroup</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
230+
|<sub>/rest/logical-enclosures</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
231+
|<sub>/rest/logical-enclosures</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
232+
|<sub>/rest/logical-enclosures/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
233+
|<sub>/rest/logical-enclosures/{id}</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
234+
|<sub>/rest/logical-enclosures/{id}</sub> | PATCH | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
235+
|<sub>/rest/logical-enclosures/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
236+
|<sub>/rest/logical-enclosures/{id}/configuration</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
237+
|<sub>/rest/logical-enclosures/{id}/script</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
238+
|<sub>/rest/logical-enclosures/{id}/script</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
239+
|<sub>/rest/logical-enclosures/{id}/support-dumps</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
240+
|<sub>/rest/logical-enclosures/{id}/updateFromGroup</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
241241
| **Logical Interconnect Groups** |
242242
|<sub>/rest/logical-interconnect-groups</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
243243
|<sub>/rest/logical-interconnect-groups</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |

examples/logical_enclosures.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
config = try_load_from_file(config)
3939

4040
oneview_client = OneViewClient(config)
41-
4241
try:
4342
# The valid enclosure URIs need to be inserted sorted by URI
4443
# The number of enclosure URIs must be equal to the enclosure count in the enclosure group
@@ -60,7 +59,7 @@
6059
enclosure_uris = []
6160
for i in range(0, enclosure_count):
6261
enclosure_uris.append(enclosures[i]["uri"])
63-
options["enclosureUris"] = enclosure_uris
62+
options["enclosureUris"] = sorted(enclosure_uris)
6463

6564
# Create a logical enclosure
6665
# This method is only available on HPE Synergy.
@@ -117,6 +116,14 @@
117116
print("Got logical enclosure by name '{name}'\n uri: '{uri}'".format(**logical_enclosure_by_name))
118117
except HPOneViewException as e:
119118
print(e.msg)
119+
# Get Logical Enclosure by scope_uris
120+
if oneview_client.api_version == 600:
121+
le_by_scope_uris = oneview_client.logical_enclosures.get_all(scope_uris="\"'/rest/scopes/cd237b60-09e2-45c4-829e-082e318a6d2a'\"")
122+
if len(le_by_scope_uris) > 0:
123+
print("Got Logical Enclosure by scope_uris: '%s'.\n uri = '%s'" % (le_by_scope_uris[0]['name'], le_by_scope_uris[0]['uri']))
124+
pprint(le_by_scope_uris)
125+
else:
126+
print("No Logical Enclosure found by scope_uris")
120127

121128
# Update configuration
122129
print("Reapply the appliance's configuration to the logical enclosure")

hpOneView/resources/servers/logical_enclosures.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def delete(self, resource, force=False, timeout=-1):
8585
"""
8686
return self._client.delete(resource, force=force, timeout=timeout)
8787

88-
def get_all(self, start=0, count=-1, filter='', sort=''):
88+
def get_all(self, start=0, count=-1, filter='', sort='', scope_uris=''):
8989
"""
9090
Returns a list of logical enclosures matching the specified filter. A maximum of 40 logical enclosures are
9191
returned to the caller. Additional calls can be made to retrieve any other logical enclosures matching the
@@ -105,11 +105,14 @@ def get_all(self, start=0, count=-1, filter='', sort=''):
105105
sort:
106106
The sort order of the returned data set. By default, the sort order is based
107107
on create time with the oldest entry first.
108+
scope_uris:
109+
An expression to restrict the resources returned according to the scopes to
110+
which they are assigned.
108111
109112
Returns:
110113
list: A list of logical enclosures.
111114
"""
112-
return self._client.get_all(start, count, filter=filter, sort=sort)
115+
return self._client.get_all(start, count, filter=filter, sort=sort, scope_uris=scope_uris)
113116

114117
def get_by(self, field, value):
115118
"""
@@ -182,8 +185,7 @@ def patch(self, id_or_uri, operation, path, value, timeout=-1):
182185
Returns:
183186
dict: Updated logical enclosure.
184187
"""
185-
headers = {'If-Match': '*'}
186-
return self._client.patch(id_or_uri, operation, path, value, timeout=timeout, custom_headers=headers)
188+
return self._client.patch(id_or_uri, operation, path, value, timeout=timeout)
187189

188190
def update_configuration(self, id_or_uri, timeout=-1):
189191
"""

tests/unit/resources/servers/test_logical_enclosures.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,17 @@ def test_delete_called_once_with_force(self, mock_delete):
7171
def test_get_all_called_once(self, mock_get_all):
7272
filter = 'name=TestName'
7373
sort = 'name:ascending'
74+
scope_uris = 'rest/scopes/cd237b60-09e2-45c4-829e-082e318a6d2a'
7475

75-
self._logical_enclosures.get_all(2, 500, filter, sort)
76+
self._logical_enclosures.get_all(2, 500, filter, sort, scope_uris)
7677

77-
mock_get_all.assert_called_once_with(2, 500, filter=filter, sort=sort)
78+
mock_get_all.assert_called_once_with(2, 500, filter=filter, sort=sort, scope_uris=scope_uris)
7879

7980
@mock.patch.object(ResourceClient, 'get_all')
8081
def test_get_all_called_once_with_default_values(self, mock_get_all):
8182
self._logical_enclosures.get_all()
8283

83-
mock_get_all.assert_called_once_with(0, -1, filter='', sort='')
84+
mock_get_all.assert_called_once_with(0, -1, filter='', sort='', scope_uris='')
8485

8586
@mock.patch.object(ResourceClient, 'get_by')
8687
def test_get_by_called_once(self, mock_get_by):
@@ -130,7 +131,7 @@ def test_patch_should_use_user_defined_values(self, mock_patch):
130131
self._logical_enclosures.patch(
131132
'123a53cz', 'replace', '/name', 'new_name', 1)
132133
mock_patch.assert_called_once_with(
133-
'123a53cz', 'replace', '/name', 'new_name', timeout=1, custom_headers={u'If-Match': u'*'})
134+
'123a53cz', 'replace', '/name', 'new_name', timeout=1)
134135

135136
@mock.patch.object(ResourceClient, 'update_with_zero_body')
136137
def test_update_configuration_by_uri(self, mock_update_with_zero_body):

0 commit comments

Comments
 (0)