From a5a4ef9c831c67f028b08973c16b18417320c18e Mon Sep 17 00:00:00 2001 From: Lin Yang Date: Thu, 30 May 2019 10:40:45 -0700 Subject: [PATCH] Add missing attribute in UpdateService in RSD 2.2 Change-Id: Ie13069389f6a961a7552f053687e2d021f320180 --- .../v2_2/update_service/action_info.py | 4 +- .../v2_2/update_service/update_service.py | 45 +++++++------ .../update_service/test_update_service.py | 64 +++++++++++-------- 3 files changed, 64 insertions(+), 49 deletions(-) diff --git a/rsd_lib/resources/v2_2/update_service/action_info.py b/rsd_lib/resources/v2_2/update_service/action_info.py index 91c5087..228564f 100644 --- a/rsd_lib/resources/v2_2/update_service/action_info.py +++ b/rsd_lib/resources/v2_2/update_service/action_info.py @@ -20,7 +20,7 @@ NAME_MAPPING = { "Name": "name", "Required": "required", "DataType": "data_type", - "AllowableValues": "allowable_values" + "AllowableValues": "allowable_values", } @@ -37,7 +37,7 @@ class ActionInfo(base.ResourceBase): refresh, this property is reset. """ parameters = [] - for i in self.json.get('Parameters'): + for i in self.json.get("Parameters"): item = {} for key in i.keys(): item[NAME_MAPPING[key]] = i.get(key, None) diff --git a/rsd_lib/resources/v2_2/update_service/update_service.py b/rsd_lib/resources/v2_2/update_service/update_service.py index b472e5d..ebac703 100644 --- a/rsd_lib/resources/v2_2/update_service/update_service.py +++ b/rsd_lib/resources/v2_2/update_service/update_service.py @@ -16,7 +16,7 @@ from sushy.resources import base from sushy import utils -from rsd_lib import common as rsd_lib_common +from rsd_lib import base as rsd_lib_base from rsd_lib.resources.v2_2.update_service import action_info @@ -33,32 +33,37 @@ class ActionsField(base.CompositeField): """The actions oem""" -class UpdateService(base.ResourceBase): - identity = base.Field("Id") - """The update service identity""" +class UpdateService(rsd_lib_base.ResourceBase): + """UpdateService resource class - name = base.Field("Name") - """The update service name""" + This is the schema definition for the Update Service. It represents the + properties for the service itself and has links to collections of + firmware and software inventory. + """ - status = rsd_lib_common.StatusField('Status') - """The update service name""" + status = rsd_lib_base.StatusField("Status") + """This indicates the known state of the resource, such as if it is + enabled. + """ service_enabled = base.Field("ServiceEnabled", adapter=bool) - """Whether the update service is enabled""" + """This indicates whether this service is enabled.""" + + http_push_uri = base.Field("HttpPushUri") + """The URI used to perform an HTTP or HTTPS push update to the Update + Service. + """ actions = ActionsField("Actions") """The update service actions""" - oem = base.Field("Oem") - """The update service oem""" - - odata_context = base.Field("@odata.context") - """The update service odata context""" - def _get_action_info_path(self): """Helper function to find the ActionInfo path""" - return self.json.get("Actions").get("#UpdateService.SimpleUpdate").get( - "@Redfish.ActionInfo") + return ( + self.json.get("Actions") + .get("#UpdateService.SimpleUpdate") + .get("@Redfish.ActionInfo") + ) @property @utils.cache_it @@ -69,5 +74,7 @@ class UpdateService(base.ResourceBase): refresh, this property is reset. """ return action_info.ActionInfo( - self._conn, self._get_action_info_path(), - redfish_version=self.redfish_version) + self._conn, + self._get_action_info_path(), + redfish_version=self.redfish_version, + ) diff --git a/rsd_lib/tests/unit/resources/v2_2/update_service/test_update_service.py b/rsd_lib/tests/unit/resources/v2_2/update_service/test_update_service.py index d732eef..a4ab42b 100644 --- a/rsd_lib/tests/unit/resources/v2_2/update_service/test_update_service.py +++ b/rsd_lib/tests/unit/resources/v2_2/update_service/test_update_service.py @@ -14,7 +14,6 @@ # under the License. import json - import mock import testtools @@ -23,17 +22,17 @@ from rsd_lib.resources.v2_2.update_service import update_service class UpdateServiceTestCase(testtools.TestCase): - def setUp(self): super(UpdateServiceTestCase, self).setUp() self.conn = mock.Mock() - with open('rsd_lib/tests/unit/json_samples/v2_2/update_service.json', - 'r') as f: + with open( + "rsd_lib/tests/unit/json_samples/v2_2/update_service.json", "r" + ) as f: self.conn.get.return_value.json.return_value = json.loads(f.read()) self.update_service_inst = update_service.UpdateService( - self.conn, '/redfish/v1/UpdateService', - redfish_version='1.1.0') + self.conn, "/redfish/v1/UpdateService", redfish_version="1.1.0" + ) def test__parse_attributes(self): self.update_service_inst._parse_attributes() @@ -43,60 +42,69 @@ class UpdateServiceTestCase(testtools.TestCase): self.assertEqual(None, self.update_service_inst.status.health) self.assertEqual(None, self.update_service_inst.status.health_rollup) self.assertEqual(False, self.update_service_inst.service_enabled) - self.assertEqual("/redfish/v1/UpdateService/Actions/SimpleUpdate", - self.update_service_inst.actions.simple_update.target) + self.assertEqual( + "/redfish/v1/UpdateService/Actions/SimpleUpdate", + self.update_service_inst.actions.simple_update.target, + ) self.assertEqual({}, self.update_service_inst.actions.oem) - self.assertEqual({}, self.update_service_inst.oem) - self.assertEqual("/redfish/v1/$metadata#UpdateService/$entity", - self.update_service_inst.odata_context) def test__get_action_info_path(self): - expected = '/redfish/v1/UpdateService/SimpleUpdateActionInfo' + expected = "/redfish/v1/UpdateService/SimpleUpdateActionInfo" result = self.update_service_inst._get_action_info_path() self.assertEqual(expected, result) def test_action_info(self): # | GIVEN | self.conn.get.return_value.json.reset_mock() - with open('rsd_lib/tests/unit/json_samples/v2_2/' - 'update_service_action_info.json', 'r') as f: + with open( + "rsd_lib/tests/unit/json_samples/v2_2/" + "update_service_action_info.json", + "r", + ) as f: self.conn.get.return_value.json.return_value = json.loads(f.read()) # | WHEN | actual_action_info = self.update_service_inst.action_info # | THEN | - self.assertIsInstance(actual_action_info, - action_info.ActionInfo) + self.assertIsInstance(actual_action_info, action_info.ActionInfo) self.conn.get.return_value.json.assert_called_once_with() # reset mock self.conn.get.return_value.json.reset_mock() # | WHEN & THEN | # tests for same object on invoking subsequently - self.assertIs(actual_action_info, - self.update_service_inst.action_info) + self.assertIs(actual_action_info, self.update_service_inst.action_info) self.conn.get.return_value.json.assert_not_called() def test_action_info_on_refresh(self): # | GIVEN | - with open('rsd_lib/tests/unit/json_samples/v2_2/' - 'update_service_action_info.json', 'r') as f: + with open( + "rsd_lib/tests/unit/json_samples/v2_2/" + "update_service_action_info.json", + "r", + ) as f: self.conn.get.return_value.json.return_value = json.loads(f.read()) # | WHEN & THEN | - self.assertIsInstance(self.update_service_inst.action_info, - action_info.ActionInfo) + self.assertIsInstance( + self.update_service_inst.action_info, action_info.ActionInfo + ) # On refreshing the update service instance... - with open('rsd_lib/tests/unit/json_samples/v2_2/' - 'update_service.json', 'r') as f: + with open( + "rsd_lib/tests/unit/json_samples/v2_2/" "update_service.json", "r" + ) as f: self.conn.get.return_value.json.return_value = json.loads(f.read()) self.update_service_inst.invalidate() self.update_service_inst.refresh(force=False) # | GIVEN | - with open('rsd_lib/tests/unit/json_samples/v2_2/' - 'update_service_action_info.json', 'r') as f: + with open( + "rsd_lib/tests/unit/json_samples/v2_2/" + "update_service_action_info.json", + "r", + ) as f: self.conn.get.return_value.json.return_value = json.loads(f.read()) # | WHEN & THEN | - self.assertIsInstance(self.update_service_inst.action_info, - action_info.ActionInfo) + self.assertIsInstance( + self.update_service_inst.action_info, action_info.ActionInfo + )