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

Commit e5861ff

Browse files
authored
Merge pull request #358 from HewlettPackard/upgrade/600/server-profiles
Upgrade/600/server profiles
2 parents 82f9dbf + 9fd2110 commit e5861ff

File tree

5 files changed

+64
-53
lines changed

5 files changed

+64
-53
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Extends support of the SDK to OneView Rest API version 600 (OneView v4.0).
2222
- SAS logical interconnect
2323
- SAS logical interconnect group
2424
- Server hardware
25+
- Server profile
2526
- Server profile template
2627
- Switch
2728
- Switch type

endpoints-support.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -447,23 +447,23 @@
447447
|<sub>/rest/server-profile-templates/{id}/transformation</sub> | GET | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark:
448448
|<sub>/rest/server-profile-templates/available-networks</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark:
449449
| **Server Profiles** |
450-
|<sub>/rest/server-profiles</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
451-
|<sub>/rest/server-profiles</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
452-
|<sub>/rest/server-profiles</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: |
453-
|<sub>/rest/server-profiles/available-networks</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
454-
|<sub>/rest/server-profiles/available-servers</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
455-
|<sub>/rest/server-profiles/available-storage-system</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
456-
|<sub>/rest/server-profiles/available-storage-systems</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
457-
|<sub>/rest/server-profiles/available-targets</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
458-
|<sub>/rest/server-profiles/profile-ports</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
459-
|<sub>/rest/server-profiles/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
460-
|<sub>/rest/server-profiles/{id}</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
461-
|<sub>/rest/server-profiles/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: |
462-
|<sub>/rest/server-profiles/{id}</sub> | PATCH | :white_check_mark: | :white_check_mark: | :white_check_mark: |
463-
|<sub>/rest/server-profiles/{id}/compliance-preview</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
464-
|<sub>/rest/server-profiles/{id}/new-profile-template</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
465-
|<sub>/rest/server-profiles/{id}/messages</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
466-
|<sub>/rest/server-profiles/{id}/transformation</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
450+
|<sub>/rest/server-profiles</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
451+
|<sub>/rest/server-profiles</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
452+
|<sub>/rest/server-profiles</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
453+
|<sub>/rest/server-profiles/available-networks</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
454+
|<sub>/rest/server-profiles/available-servers</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
455+
|<sub>/rest/server-profiles/available-storage-system</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :heavy_minus_sign:
456+
|<sub>/rest/server-profiles/available-storage-systems</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :heavy_minus_sign:
457+
|<sub>/rest/server-profiles/available-targets</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
458+
|<sub>/rest/server-profiles/profile-ports</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
459+
|<sub>/rest/server-profiles/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
460+
|<sub>/rest/server-profiles/{id}</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
461+
|<sub>/rest/server-profiles/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
462+
|<sub>/rest/server-profiles/{id}</sub> | PATCH | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
463+
|<sub>/rest/server-profiles/{id}/compliance-preview</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
464+
|<sub>/rest/server-profiles/{id}/new-profile-template</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | :white_check_mark:
465+
|<sub>/rest/server-profiles/{id}/messages</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :heavy_minus_sign:
466+
|<sub>/rest/server-profiles/{id}/transformation</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark:
467467
| **Storage Pools** |
468468
|<sub>/rest/storage-pools</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
469469
|<sub>/rest/storage-pools</sub> | POST | :white_check_mark: | :white_check_mark: | :heavy_minus_sign: |

examples/server_profiles.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@
109109
profile = oneview_client.server_profiles.get(profile_uri)
110110
pprint(profile)
111111

112-
# Retrieve ServerProfile schema
113-
print("\nRetrieve the generated ServerProfile schema")
114-
schema = oneview_client.server_profiles.get_schema()
115-
pprint(schema)
112+
if oneview_client.api_version <= 500:
113+
# Retrieve ServerProfile schema
114+
# This method available only for API version <= 500
115+
print("\nRetrieve the generated ServerProfile schema")
116+
schema = oneview_client.server_profiles.get_schema()
117+
pprint(schema)
116118

117119
try:
118120
# Server profile compliance preview

hpOneView/resources/servers/server_profiles.py

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,34 +44,39 @@ class ServerProfiles(object):
4444
DEFAULT_VALUES = {
4545
'200': {"type": "ServerProfileV5"},
4646
'300': {"type": "ServerProfileV6"},
47-
'500': {"type": "ServerProfileV7"}
47+
'500': {"type": "ServerProfileV7"},
48+
'600': {"type": "ServerProfileV8"},
49+
4850
}
4951

5052
def __init__(self, con):
5153
self._connection = con
5254
self._client = ResourceClient(con, self.URI)
5355

54-
def create(self, resource, timeout=-1):
56+
def create(self, resource, timeout=-1, force=''):
5557
"""
5658
Creates a server profile using the information provided in the resource parameter.
5759
5860
Args:
5961
resource (dict): Object to create.
6062
timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation
6163
in OneView, just stop waiting for its completion.
64+
force: Comma separated list of flags for ignoring specific warning.
6265
6366
Returns:
6467
dict: Created server profile.
6568
"""
66-
return self._client.create(resource=resource, timeout=timeout, default_values=self.DEFAULT_VALUES)
69+
uri = self.__build_uri_with_query_string({"force": force})
70+
return self._client.create(resource=resource, uri=uri, timeout=timeout, default_values=self.DEFAULT_VALUES)
6771

68-
def update(self, resource, id_or_uri):
72+
def update(self, resource, id_or_uri, force=''):
6973
"""
7074
Allows the configuration of a server profile object to be modified.
7175
7276
Args:
7377
id_or_uri: Can be either the server profile id or the server profile uri.
7478
resource (dict): Object to update.
79+
force: Comma separated list of flags for ignoring specific warning.
7580
7681
Returns:
7782
dict: The server profile resource.
@@ -80,7 +85,9 @@ def update(self, resource, id_or_uri):
8085
if resource.get('serverHardwareUri') is None:
8186
resource.pop('enclosureBay', None)
8287
resource.pop('enclosureUri', None)
83-
return self._client.update(resource=resource, uri=id_or_uri, default_values=self.DEFAULT_VALUES)
88+
89+
uri = self. __build_uri_with_query_string({'force': force}, id_or_uri=id_or_uri)
90+
return self._client.update(resource=resource, uri=uri, default_values=self.DEFAULT_VALUES)
8491

8592
def patch(self, id_or_uri, operation, path, value, timeout=-1):
8693
"""
@@ -305,24 +312,23 @@ def get_available_networks(self, **kwargs):
305312
server profile, along with their respective ports.
306313
307314
Args:
308-
enclosureGroupUri (str):
309-
The URI of the enclosure group associated with the resource.
310-
functionType (str):
311-
The FunctionType (Ethernet or FibreChannel) to filter the list of networks returned.
312-
serverHardwareTypeUri (str):
313-
The URI of the server hardware type associated with the resource.
314-
serverHardwareUri (str):
315-
The URI of the server hardware associated with the resource.
316-
view (str):
317-
Returns a specific subset of the attributes of the resource or collection, by specifying the name of a
318-
predefined view. The default view is expand (show all attributes of the resource and all elements of
319-
collections of resources).
315+
enclosureGroupUri (str): The URI of the enclosure group associated with the resource.
316+
functionType (str): The FunctionType (Ethernet or FibreChannel) to filter the list of networks returned.
317+
serverHardwareTypeUri (str): The URI of the server hardware type associated with the resource.
318+
serverHardwareUri (str): The URI of the server hardware associated with the resource.
319+
view (str): Returns a specific subset of the attributes of the resource or collection, by
320+
specifying the name of a predefined view. The default view is expand (show all attributes
321+
of the resource and all elements of collections of resources).
320322
321323
Values:
322324
Ethernet
323325
Specifies that the connection is to an Ethernet network or a network set.
324326
FibreChannel
325327
Specifies that the connection is to a Fibre Channel network.
328+
profileUri (str): If the URI of the server profile is provided the list of available networks will
329+
include only networks that share a scope with the server profile.
330+
scopeUris (str): An expression to restrict the resources returned according to the scopes
331+
to which they are assigned
326332
327333
Returns:
328334
list: Available networks.
@@ -335,12 +341,11 @@ def get_available_servers(self, **kwargs):
335341
Retrieves the list of available servers.
336342
337343
Args:
338-
enclosureGroupUri (str):
339-
The URI of the enclosure group associated with the resource.
340-
serverHardwareTypeUri (str):
341-
The URI of the server hardware type associated with the resource.
342-
profileUri (str):
343-
The URI of the server profile resource.
344+
enclosureGroupUri (str): The URI of the enclosure group associated with the resource.
345+
serverHardwareTypeUri (str): The URI of the server hardware type associated with the resource.
346+
profileUri (str): The URI of the server profile resource.
347+
scopeUris (str): An expression to restrict the resources returned according to
348+
the scopes to which they are assigned.
344349
345350
Returns:
346351
list: Available servers.
@@ -403,20 +408,19 @@ def get_available_targets(self, **kwargs):
403408
profile.
404409
405410
Args:
406-
enclosureGroupUri (str):
407-
The URI of the enclosure group associated with the resource.
408-
serverHardwareTypeUri (str):
409-
The URI of the server hardware type associated with the resource.
410-
profileUri (str):
411-
The URI of the server profile associated with the resource.
411+
enclosureGroupUri (str): The URI of the enclosure group associated with the resource.
412+
serverHardwareTypeUri (str): The URI of the server hardware type associated with the resource.
413+
profileUri (str): The URI of the server profile associated with the resource.
414+
scopeUris (str): An expression to restrict the resources returned according to
415+
the scopes to which they are assigned.
412416
413417
Returns:
414418
list: List of available servers and bays.
415419
"""
416420
uri = self.__build_uri_with_query_string(kwargs, '/available-targets')
417421
return self._client.get(uri)
418422

419-
def __build_uri_with_query_string(self, kwargs, sufix_path, id_or_uri=None):
423+
def __build_uri_with_query_string(self, kwargs, sufix_path='', id_or_uri=None):
420424
uri = self.URI
421425
if id_or_uri:
422426
uri = self._client.build_uri(id_or_uri)

tests/unit/resources/servers/test_server_profiles.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,28 @@ def test_get_by_name(self, mock_get_by_name):
7070

7171
@mock.patch.object(ResourceClient, 'create')
7272
def test_create(self, mock_create):
73+
force = ""
74+
uri = "/rest/server-profiles?force=%s" % (force)
7375
template = dict(name="Server Profile Test")
7476

7577
expected_template = template.copy()
7678

7779
self._resource.create(resource=template, timeout=TIMEOUT)
78-
mock_create.assert_called_once_with(resource=expected_template, timeout=TIMEOUT,
80+
mock_create.assert_called_once_with(resource=expected_template, uri=uri, timeout=TIMEOUT,
7981
default_values=self._resource.DEFAULT_VALUES)
8082

8183
@mock.patch.object(ResourceClient, 'update')
8284
def test_update(self, mock_update):
85+
force = ""
8386
uri = "/rest/server-profiles/4ff2327f-7638-4b66-ad9d-283d4940a4ae"
87+
rest_uri = "/rest/server-profiles/4ff2327f-7638-4b66-ad9d-283d4940a4ae?force=%s" % (force)
8488
template = dict(name="Server Profile Test", macType="Virtual",
8589
enclosureUri='/rest/fake', enclosureBay=3)
8690

8791
expected_template = dict(name="Server Profile Test", macType="Virtual")
8892

8993
self._resource.update(resource=template, id_or_uri=uri)
90-
mock_update.assert_called_once_with(resource=expected_template, uri=uri,
94+
mock_update.assert_called_once_with(resource=expected_template, uri=rest_uri,
9195
default_values=self._resource.DEFAULT_VALUES)
9296

9397
@mock.patch.object(ResourceClient, 'delete')

0 commit comments

Comments
 (0)