Use Etag in precondition header when setting boot options
If provided by the end point, use the Etag in the If-* precondition when setting the boot option. Change-Id: I021d1116613e2b35352ca9749f8bc8a84bf655a1
This commit is contained in:
parent
528d502520
commit
7e2db9853b
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
If available, uses headers with an Etag to set the boot options.
|
|
@ -272,7 +272,12 @@ class System(base.ResourceBase):
|
|||
|
||||
# TODO(lucasagomes): Check the return code and response body ?
|
||||
# Probably we should call refresh() as well.
|
||||
self._conn.patch(self.path, data=data)
|
||||
|
||||
headers = None
|
||||
etag = self._get_etag()
|
||||
if etag is not None:
|
||||
headers = {"If-Match": etag}
|
||||
self._conn.patch(self.path, data=data, headers=headers)
|
||||
|
||||
# TODO(etingof): we should remove this method, eventually
|
||||
def set_system_boot_source(
|
||||
|
|
|
@ -37,6 +37,7 @@ class SystemTestCase(base.TestCase):
|
|||
def setUp(self):
|
||||
super(SystemTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
self.conn.get.return_value.headers = {'Allow': 'GET,HEAD'}
|
||||
with open('sushy/tests/unit/json_samples/system.json') as f:
|
||||
self.json_doc = json.load(f)
|
||||
|
||||
|
@ -281,7 +282,8 @@ class SystemTestCase(base.TestCase):
|
|||
'/redfish/v1/Systems/437XR1138R2',
|
||||
data={'Boot': {'BootSourceOverrideEnabled': 'Continuous',
|
||||
'BootSourceOverrideTarget': 'Pxe',
|
||||
'BootSourceOverrideMode': 'UEFI'}})
|
||||
'BootSourceOverrideMode': 'UEFI'}},
|
||||
headers=None)
|
||||
|
||||
def test_set_system_boot_options_no_mode_specified(self):
|
||||
self.sys_inst.set_system_boot_options(
|
||||
|
@ -290,7 +292,8 @@ class SystemTestCase(base.TestCase):
|
|||
self.sys_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2',
|
||||
data={'Boot': {'BootSourceOverrideEnabled': 'Once',
|
||||
'BootSourceOverrideTarget': 'Hdd'}})
|
||||
'BootSourceOverrideTarget': 'Hdd'}},
|
||||
headers=None)
|
||||
|
||||
def test_set_system_boot_options_no_target_specified(self):
|
||||
self.sys_inst.set_system_boot_options(
|
||||
|
@ -299,7 +302,8 @@ class SystemTestCase(base.TestCase):
|
|||
self.sys_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2',
|
||||
data={'Boot': {'BootSourceOverrideEnabled': 'Continuous',
|
||||
'BootSourceOverrideMode': 'UEFI'}})
|
||||
'BootSourceOverrideMode': 'UEFI'}},
|
||||
headers=None)
|
||||
|
||||
def test_set_system_boot_options_no_freq_specified(self):
|
||||
self.sys_inst.set_system_boot_options(
|
||||
|
@ -308,12 +312,14 @@ class SystemTestCase(base.TestCase):
|
|||
self.sys_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2',
|
||||
data={'Boot': {'BootSourceOverrideTarget': 'Pxe',
|
||||
'BootSourceOverrideMode': 'UEFI'}})
|
||||
'BootSourceOverrideMode': 'UEFI'}},
|
||||
headers=None)
|
||||
|
||||
def test_set_system_boot_options_nothing_specified(self):
|
||||
self.sys_inst.set_system_boot_options()
|
||||
self.sys_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2', data={})
|
||||
'/redfish/v1/Systems/437XR1138R2', data={},
|
||||
headers=None)
|
||||
|
||||
def test_set_system_boot_options_invalid_target(self):
|
||||
self.assertRaises(exceptions.InvalidParameterValueError,
|
||||
|
@ -343,7 +349,8 @@ class SystemTestCase(base.TestCase):
|
|||
self.sys_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2',
|
||||
data={'Boot': {'BootSourceOverrideEnabled': 'Once',
|
||||
'BootSourceOverrideTarget': 'UsbCd'}})
|
||||
'BootSourceOverrideTarget': 'UsbCd'}},
|
||||
headers=None)
|
||||
|
||||
def test_set_system_boot_options_supermicro_no_usb_cd_boot(self):
|
||||
|
||||
|
@ -355,7 +362,8 @@ class SystemTestCase(base.TestCase):
|
|||
self.sys_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2',
|
||||
data={'Boot': {'BootSourceOverrideEnabled': 'Once',
|
||||
'BootSourceOverrideTarget': 'Cd'}})
|
||||
'BootSourceOverrideTarget': 'Cd'}},
|
||||
headers=None)
|
||||
|
||||
def test_set_system_boot_source(self):
|
||||
self.sys_inst.set_system_boot_source(
|
||||
|
@ -366,7 +374,21 @@ class SystemTestCase(base.TestCase):
|
|||
'/redfish/v1/Systems/437XR1138R2',
|
||||
data={'Boot': {'BootSourceOverrideEnabled': 'Continuous',
|
||||
'BootSourceOverrideTarget': 'Pxe',
|
||||
'BootSourceOverrideMode': 'UEFI'}})
|
||||
'BootSourceOverrideMode': 'UEFI'}},
|
||||
headers=None)
|
||||
|
||||
def test_set_system_boot_source_with_etag(self):
|
||||
self.conn.get.return_value.headers = {'ETag': '"3d7b838291941d"'}
|
||||
self.sys_inst.set_system_boot_source(
|
||||
sushy.BOOT_SOURCE_TARGET_PXE,
|
||||
enabled=sushy.BOOT_SOURCE_ENABLED_CONTINUOUS,
|
||||
mode=sushy.BOOT_SOURCE_MODE_UEFI)
|
||||
self.sys_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2',
|
||||
data={'Boot': {'BootSourceOverrideEnabled': 'Continuous',
|
||||
'BootSourceOverrideTarget': 'Pxe',
|
||||
'BootSourceOverrideMode': 'UEFI'}},
|
||||
headers={'If-Match': '"3d7b838291941d"'})
|
||||
|
||||
def test_set_system_boot_source_no_mode_specified(self):
|
||||
self.sys_inst.set_system_boot_source(
|
||||
|
@ -375,7 +397,8 @@ class SystemTestCase(base.TestCase):
|
|||
self.sys_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2',
|
||||
data={'Boot': {'BootSourceOverrideEnabled': 'Once',
|
||||
'BootSourceOverrideTarget': 'Hdd'}})
|
||||
'BootSourceOverrideTarget': 'Hdd'}},
|
||||
headers=None)
|
||||
|
||||
def test_set_system_boot_source_invalid_target(self):
|
||||
self.assertRaises(exceptions.InvalidParameterValueError,
|
||||
|
|
Loading…
Reference in New Issue