From 1831b87d83c00e0b598d8f2a192f20a301a1ddec Mon Sep 17 00:00:00 2001 From: Aija Jaunteva Date: Thu, 28 Jun 2018 17:42:15 +0300 Subject: [PATCH] Remove etag from Bios Previously implemented etag will not work as intended. The property @odata.etag will never be populated for BIOS resource. etag value should come from HTTP headers. At the moment sushy does not support retrieving ETag from headers, so this is removed for now. Change-Id: I7a6ebaac3d4f9a8a722aad32dfaec69153e7bd3a --- sushy/resources/settings.py | 6 ++---- sushy/resources/system/bios.py | 5 +---- sushy/tests/unit/resources/system/test_bios.py | 7 ++----- sushy/tests/unit/resources/test_settings.py | 13 +------------ 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/sushy/resources/settings.py b/sushy/resources/settings.py index 29254fdf..fb3cb2f5 100644 --- a/sushy/resources/settings.py +++ b/sushy/resources/settings.py @@ -78,7 +78,7 @@ class SettingsField(base.CompositeField): """Represents the results of the last time the values of the Settings resource were applied to the server""" - def commit(self, connector, value, etag=None): + def commit(self, connector, value): """Commits new settings values The new values will be applied when the system or a service @@ -92,9 +92,7 @@ class SettingsField(base.CompositeField): the new values will not be committed """ - connector.patch(self.resource_uri, - data=value, - headers={'If-Match': etag} if etag else None) + connector.patch(self.resource_uri, data=value) @property def resource_uri(self): diff --git a/sushy/resources/system/bios.py b/sushy/resources/system/bios.py index 3ccfeb97..23861389 100644 --- a/sushy/resources/system/bios.py +++ b/sushy/resources/system/bios.py @@ -56,8 +56,6 @@ class Bios(base.ResourceBase): _actions = ActionsField('Actions') - _etag = base.Field('@odata.etag') - _pending_settings_resource = None @property @@ -98,8 +96,7 @@ class Bios(base.ResourceBase): :param value: Key-value pairs for attribute name and value """ self._settings.commit(self._conn, - {'Attributes': value}, - self._etag) + {'Attributes': value}) if self._pending_settings_resource: self._pending_settings_resource.invalidate() diff --git a/sushy/tests/unit/resources/system/test_bios.py b/sushy/tests/unit/resources/system/test_bios.py index 1497c073..95577eca 100644 --- a/sushy/tests/unit/resources/system/test_bios.py +++ b/sushy/tests/unit/resources/system/test_bios.py @@ -48,7 +48,6 @@ class BiosTestCase(base.TestCase): self.assertEqual('BIOS Configuration Current Settings', self.sys_bios.name) self.assertIsNone(self.sys_bios.description) - self.assertEqual('123', self.sys_bios._etag) self.assertEqual('BiosAttributeRegistryP89.v1_0_0', self.sys_bios.attribute_registry) self.assertEqual('', self.sys_bios.attributes['AdminPhone']) @@ -65,8 +64,7 @@ class BiosTestCase(base.TestCase): self.sys_bios.set_attribute('ProcTurboMode', 'Disabled') self.sys_bios._conn.patch.assert_called_once_with( '/redfish/v1/Systems/437XR1138R2/BIOS/Settings', - data={'Attributes': {'ProcTurboMode': 'Disabled'}}, - headers={'If-Match': '123'}) + data={'Attributes': {'ProcTurboMode': 'Disabled'}}) def test_set_attribute_on_refresh(self): # make it to instantiate pending attributes @@ -83,8 +81,7 @@ class BiosTestCase(base.TestCase): self.sys_bios._conn.patch.assert_called_once_with( '/redfish/v1/Systems/437XR1138R2/BIOS/Settings', data={'Attributes': {'ProcTurboMode': 'Disabled', - 'UsbControl': 'UsbDisabled'}}, - headers={'If-Match': '123'}) + 'UsbControl': 'UsbDisabled'}}) def test_set_attributes_on_refresh(self): # make it to instantiate pending attributes diff --git a/sushy/tests/unit/resources/test_settings.py b/sushy/tests/unit/resources/test_settings.py index fd212c2a..e4d88304 100644 --- a/sushy/tests/unit/resources/test_settings.py +++ b/sushy/tests/unit/resources/test_settings.py @@ -60,15 +60,4 @@ class SettingsFieldTestCase(base.TestCase): instance.commit(conn, {'Attributes': {'key': 'value'}}) conn.patch.assert_called_once_with( '/redfish/v1/Systems/437XR1138R2/BIOS/Settings', - data={'Attributes': {'key': 'value'}}, headers=None) - - def test_commit_with_etag(self): - conn = mock.Mock() - instance = self.settings._load(self.json, conn) - instance.commit(conn, - {'Attributes': {'key': 'value'}}, - '123') - conn.patch.assert_called_once_with( - '/redfish/v1/Systems/437XR1138R2/BIOS/Settings', - data={'Attributes': {'key': 'value'}}, - headers={'If-Match': '123'}) + data={'Attributes': {'key': 'value'}})