diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..58993fd17 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +docutils<0.18 +sphinx==1.8.5 \ No newline at end of file diff --git a/endpoints-support.md b/endpoints-support.md index 6e24ac24d..0a328fd1f 100755 --- a/endpoints-support.md +++ b/endpoints-support.md @@ -18,8 +18,8 @@ ## HPE OneView -| Endpoints | Verb | V800 | V1000 | V1200 | V1600 | V1800 | V2000 | V2200 | V2400 | V2600 | V2800 | V3000 | V3200 | -| --------------------------------------------------------------------------------------- | ------------------ | :------------------: | :------------------:| :------------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | +| Endpoints | Verb | V800 | V1000 | V1200 | V1600 | V1800 | V2000 | V2200 | V2400 | V2600 | V2800 | V3000 | V3200 | V3400 | +| --------------------------------------------------------------------------------------- | ------------------ | :------------------: | :------------------:| :------------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | | **Appliance Configuration Timeconfig** |/rest/appliance/configuration/timeconfig/locales |GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | **Appliance Node Information** @@ -360,6 +360,13 @@ |/rest/server-hardware/{id}/firmware | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | |/rest/server-hardware/discovery | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | |/rest/server-hardware/{id}/localStorageV2 | POST | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +|/rest/server-hardware/{id}/chassis | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/server-hardware/{id}/firmwareInventory | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/server-hardware/{id}/networkAdapters | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/server-hardware/{id}/powerSupplies | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/server-hardware/{id}/processors | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/server-hardware/{id}/softwareInventory | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/server-hardware/{id}/thermal | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | | **Server Hardware Types** |/rest/server-hardware-types | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | |/rest/server-hardware-types/{id} | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | diff --git a/examples/server_hardware.py b/examples/server_hardware.py index 4b81fb656..f42806dff 100644 --- a/examples/server_hardware.py +++ b/examples/server_hardware.py @@ -219,3 +219,73 @@ print("Server removed successfully") except HPEOneViewException as e: print(e.msg) + +# This operation works from Oneview API Version 3400. +if oneview_client.api_version >= 3400 and server: + try: + # Gets the settings that describe about chasis configuration of server. + print("Get the settings that describe the chasis configuration of server") + server_chasisConf = server.get_chasis_configuration() + pprint(server_chasisConf) + except HPEOneViewException as e: + print(e.msg) + +# This operation works from Oneview API Version 3400. +if oneview_client.api_version >= 3400 and server: + try: + # Gets the settings that describe about firmwareInventory configuration of server. + print("Get the settings that describe the firmwareInventory configuration of server") + server_firmwareConf = server.get_firmware_configuration() + pprint(server_firmwareConf) + except HPEOneViewException as e: + print(e.msg) + +# This operation works from Oneview API Version 3400. +if oneview_client.api_version >= 3400 and server: + try: + # Gets the settings that describe about networkAdapters configuration of server. + print("Get the settings that describe the networkAdapters configuration of server") + server_networkAdaptersConf = server.get_network_adapters_configuration() + pprint(server_networkAdaptersConf) + except HPEOneViewException as e: + print(e.msg) + +# This operation works from Oneview API Version 3400. +if oneview_client.api_version >= 3400 and server: + try: + # Gets the settings that describe about powerSupplies configuration of server. + print("Get the settings that describe the powerSupplies configuration of server") + server_powerSuppliesConf = server.get_power_supplies_configuration() + pprint(server_powerSuppliesConf) + except HPEOneViewException as e: + print(e.msg) + +# This operation works from Oneview API Version 3400. +if oneview_client.api_version >= 3400 and server: + try: + # Gets the settings that describe about processors configuration of server. + print("Get the settings that describe the processors configuration of server") + server_processorsConf = server.get_processors_configuration() + pprint(server_processorsConf) + except HPEOneViewException as e: + print(e.msg) + +# This operation works from Oneview API Version 3400. +if oneview_client.api_version >= 3400 and server: + try: + # Gets the settings that describe about softwareInventory configuration of server. + print("Get the settings that describe the softwareInventory configuration of server") + server_softwareInventoryConf = server.get_software_inventory_configuration() + pprint(server_softwareInventoryConf) + except HPEOneViewException as e: + print(e.msg) + +# This operation works from Oneview API Version 3400. +if oneview_client.api_version >= 3400 and server: + try: + # Gets the settings that describe about thermal configuration of server. + print("Get the settings that describe the thermal configuration of server") + server_thermalConf = server.get_thermal_configuration() + pprint(server_thermalConf) + except HPEOneViewException as e: + print(e.msg) diff --git a/hpeOneView/resources/resource.py b/hpeOneView/resources/resource.py index deeb962c4..935874740 100755 --- a/hpeOneView/resources/resource.py +++ b/hpeOneView/resources/resource.py @@ -166,6 +166,7 @@ def create(self, data=None, uri=None, timeout=-1, custom_headers=None, force=Fal timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion. custom_headers: Allows set specific HTTP headers. + Returns: Created resource. """ @@ -202,11 +203,15 @@ def update(self, data=None, timeout=-1, custom_headers=None, force=False): """Makes a PUT request to update a resource when a request body is required. Args: - data: Data to update the resource. - timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation + data: + Data to update the resource. + timeout: + Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion. - custom_headers: Allows to add custom HTTP headers. - force: Force the update operation. + custom_headers: + Allows to add custom HTTP headers. + force: + Force the update operation. Returns: A dict with the updated resource data. @@ -451,6 +456,7 @@ def create(self, data=None, uri=None, timeout=-1, custom_headers=None, force=Fal timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion. custom_headers: Allows set specific HTTP headers. + Returns: Created resource. """ @@ -491,13 +497,18 @@ def update(self, resource, uri=None, force=False, timeout=-1, custom_headers=Non """Makes a PUT request to update a resource when a request body is required. Args: - resource: Data to update the resource. - uri: Resource uri - force: If set to true, the operation completes despite any problems + resource: + Data to update the resource. + uri: + Resource uri + force: + If set to true, the operation completes despite any problems with network connectivity or errors on the resource itself. The default is false. - timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation + timeout: + Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion. - custom_headers: Allows to add custom HTTP headers. + custom_headers: + Allows to add custom HTTP headers. Returns: A dict with the updated resource data. @@ -1364,8 +1375,7 @@ def update(self, resource, uri=None, force=False, timeout=-1, custom_headers=Non '300': {"type": "logical-switch-groupV300"} } - Returns: - Updated resource. + Returns: Updated resource. """ if not resource: logger.exception(RESOURCE_CLIENT_RESOURCE_WAS_NOT_PROVIDED) @@ -1849,9 +1859,11 @@ def merge_item(resource): def transform_list_to_dict(list): """ - Transforms a list into a dictionary, putting values as keys + Transforms a list into a dictionary, putting values as keys + Args: id: + Returns: dict: dictionary built """ diff --git a/hpeOneView/resources/servers/server_hardware.py b/hpeOneView/resources/servers/server_hardware.py index e888acad4..88ccd7bc5 100644 --- a/hpeOneView/resources/servers/server_hardware.py +++ b/hpeOneView/resources/servers/server_hardware.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ### -# (C) Copyright [2020] Hewlett Packard Enterprise Development LP +# (C) Copyright [2021] Hewlett Packard Enterprise Development LP # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -326,3 +326,80 @@ def get_local_storage(self, ip=None): uri = "{}?ip={}".format(uri, ip) return self._helper.do_get(uri) + + @ensure_resource_client + def get_chassis(self): + """ + Gets the list of chassis values currently set on the physical server. + + Returns: + dict: Dictionary of chassis values. + """ + uri = "{}/chassis".format(self.data["uri"]) + return self._helper.do_get(uri) + + @ensure_resource_client + def get_firmware_inventory(self): + """ + Gets the list of firmwareInventory values currently set on the physical server. + + Returns: + dict: Dictionary of firmwareInventory values. + """ + uri = "{}/firmwareInventory".format(self.data["uri"]) + return self._helper.do_get(uri) + + @ensure_resource_client + def get_network_adapters(self): + """ + Gets the list of networkAdapters values currently set on the physical server. + + Returns: + dict: Dictionary of networkAdapters values. + """ + uri = "{}/networkAdapters".format(self.data["uri"]) + return self._helper.do_get(uri) + + @ensure_resource_client + def get_power_supplies(self): + """ + Gets the list of powerSupplies values currently set on the physical server. + + Returns: + dict: Dictionary of powerSupplies values. + """ + uri = "{}/powerSupplies".format(self.data["uri"]) + return self._helper.do_get(uri) + + @ensure_resource_client + def get_processors(self): + """ + Gets the list of processors values currently set on the physical server. + + Returns: + dict: Dictionary of processors values. + """ + uri = "{}/processors".format(self.data["uri"]) + return self._helper.do_get(uri) + + @ensure_resource_client + def get_software_inventory(self): + """ + Gets the list of softwareInventory values currently set on the physical server. + + Returns: + dict: Dictionary of softwareInventory values. + """ + uri = "{}/softwareInventory".format(self.data["uri"]) + return self._helper.do_get(uri) + + @ensure_resource_client + def get_thermal(self): + """ + Gets the list of thermal values currently set on the physical server. + + Returns: + dict: Dictionary of thermal values. + """ + uri = "{}/thermal".format(self.data["uri"]) + return self._helper.do_get(uri) diff --git a/tests/unit/resources/servers/test_server_hardware.py b/tests/unit/resources/servers/test_server_hardware.py index 38aea7d0c..2fe1ddbd8 100644 --- a/tests/unit/resources/servers/test_server_hardware.py +++ b/tests/unit/resources/servers/test_server_hardware.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ### -# (C) Copyright [2020] Hewlett Packard Enterprise Development LP +# (C) Copyright [2021] Hewlett Packard Enterprise Development LP # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -281,3 +281,59 @@ def test_get_local_storage_with_ip(self, mock_get): self._server_hardware.get_local_storage(ip='172.16.8.4') mock_get.assert_called_once_with(uri_rest_call) + + @mock.patch.object(ResourceHelper, 'do_get') + def test_get_chassis(self, mock_get): + uri_rest_call = '{}/chassis'.format(self.uri) + + self._server_hardware.get_chassis() + + mock_get.assert_called_once_with(uri_rest_call) + + @mock.patch.object(ResourceHelper, 'do_get') + def test_get_firmwareInventory(self, mock_get): + uri_rest_call = '{}/firmwareInventory'.format(self.uri) + + self._server_hardware.get_firmware_inventory() + + mock_get.assert_called_once_with(uri_rest_call) + + @mock.patch.object(ResourceHelper, 'do_get') + def test_get_networkAdapters(self, mock_get): + uri_rest_call = '{}/networkAdapters'.format(self.uri) + + self._server_hardware.get_network_adapters() + + mock_get.assert_called_once_with(uri_rest_call) + + @mock.patch.object(ResourceHelper, 'do_get') + def test_get_powerSupplies(self, mock_get): + uri_rest_call = '{}/powerSupplies'.format(self.uri) + + self._server_hardware.get_power_supplies() + + mock_get.assert_called_once_with(uri_rest_call) + + @mock.patch.object(ResourceHelper, 'do_get') + def test_get_processors(self, mock_get): + uri_rest_call = '{}/processors'.format(self.uri) + + self._server_hardware.get_processors() + + mock_get.assert_called_once_with(uri_rest_call) + + @mock.patch.object(ResourceHelper, 'do_get') + def test_get_thermal(self, mock_get): + uri_rest_call = '{}/thermal'.format(self.uri) + + self._server_hardware.get_thermal() + + mock_get.assert_called_once_with(uri_rest_call) + + @mock.patch.object(ResourceHelper, 'do_get') + def test_get_softwareInventory(self, mock_get): + uri_rest_call = '{}/softwareInventory'.format(self.uri) + + self._server_hardware.get_software_inventory() + + mock_get.assert_called_once_with(uri_rest_call)