Make UpdateService.simple_update() operational
This change fixes a bug in `simple_update` implementation giving HTTP POST method a chance to succeed. Also, `UpdateService` action field refactored to better align with the rest of sushy. Change-Id: I3fdf58ec6c38282c67bd87729675636d8d90db1e Story: 2003853 Task: 26652
This commit is contained in:
parent
2858bb605b
commit
0bd97a054a
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes bug in ``UpdateService.simple_update`` method making it operational.
|
|
@ -27,25 +27,9 @@ from sushy import utils
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SimpleUpdateActionField(common.ActionField):
|
||||
|
||||
image_uri = base.Field('ImageURI')
|
||||
"""The URI of the software image to be installed"""
|
||||
|
||||
targets = base.Field('Targets')
|
||||
"""The array of URIs indicating where the update image is to be""" + \
|
||||
"""applied"""
|
||||
|
||||
transfer_protocol = base.MappedField(
|
||||
'TransferProtocol',
|
||||
up_maps.TRANSFER_PROTOCOL_TYPE_VALUE_MAP)
|
||||
"""The network protocol used by the Update Service"""
|
||||
|
||||
|
||||
class ActionsField(base.CompositeField):
|
||||
|
||||
simple_update = SimpleUpdateActionField(
|
||||
'#UpdateService.SimpleUpdate')
|
||||
simple_update = common.ActionField('#UpdateService.SimpleUpdate')
|
||||
|
||||
|
||||
class UpdateService(base.ResourceBase):
|
||||
|
@ -116,13 +100,13 @@ class UpdateService(base.ResourceBase):
|
|||
"""
|
||||
simple_update_action = self._get_simple_update_element()
|
||||
|
||||
if not simple_update_action.transfer_protocol:
|
||||
LOG.warning(
|
||||
'Could not figure out the allowed values for the simple '
|
||||
'update action for UpdateService %s', self.identity)
|
||||
if not getattr(simple_update_action, 'transfer_protocol', None):
|
||||
LOG.debug(
|
||||
'Server does not constrain allowed transfer protocols for '
|
||||
'simple update action of UpdateService %s', self.identity)
|
||||
return set(up_maps.TRANSFER_PROTOCOL_TYPE_VALUE_MAP_REV)
|
||||
|
||||
return set(simple_update_action.transfer_protocol)
|
||||
return {simple_update_action.transfer_protocol}
|
||||
|
||||
def simple_update(self, image_uri, targets,
|
||||
transfer_protocol=up_cons.UPDATE_PROTOCOL_HTTP):
|
||||
|
@ -143,10 +127,16 @@ class UpdateService(base.ResourceBase):
|
|||
|
||||
LOG.warning(
|
||||
'Legacy transfer protocol constant %s is being used. '
|
||||
'Consider migrating to any of: %s',
|
||||
'Consider migrating to any of: %s', transfer_protocol,
|
||||
', '.join(up_maps.TRANSFER_PROTOCOL_TYPE_VALUE_MAP_REV))
|
||||
|
||||
self._conn.post(data={
|
||||
target_uri = self._get_simple_update_element().target_uri
|
||||
|
||||
LOG.debug(
|
||||
'Updating software component %s via '
|
||||
'%s ...', image_uri, target_uri)
|
||||
|
||||
self._conn.post(target_uri, data={
|
||||
'ImageURI': image_uri,
|
||||
'Targets': targets,
|
||||
'TransferProtocol': transfer_protocol})
|
||||
|
|
|
@ -57,12 +57,13 @@ class UpdateServiceTestCase(base.TestCase):
|
|||
def test_simple_update(self):
|
||||
self.upd_serv.simple_update(
|
||||
image_uri='local.server/update.exe',
|
||||
targets='/redfish/v1/UpdateService/Actions/SimpleUpdate',
|
||||
targets=['/redfish/v1/UpdateService/FirmwareInventory/BMC'],
|
||||
transfer_protocol=ups_cons.UPDATE_PROTOCOL_HTTPS)
|
||||
self.upd_serv._conn.post.assert_called_once_with(
|
||||
'/redfish/v1/UpdateService/Actions/SimpleUpdate',
|
||||
data={
|
||||
'ImageURI': 'local.server/update.exe',
|
||||
'Targets': '/redfish/v1/UpdateService/Actions/SimpleUpdate',
|
||||
'Targets': ['/redfish/v1/UpdateService/FirmwareInventory/BMC'],
|
||||
'TransferProtocol': 'HTTPS'})
|
||||
|
||||
def test_simple_update_backward_compatible_protocol(self):
|
||||
|
@ -71,6 +72,7 @@ class UpdateServiceTestCase(base.TestCase):
|
|||
targets='/redfish/v1/UpdateService/Actions/SimpleUpdate',
|
||||
transfer_protocol='HTTPS')
|
||||
self.upd_serv._conn.post.assert_called_once_with(
|
||||
'/redfish/v1/UpdateService/Actions/SimpleUpdate',
|
||||
data={
|
||||
'ImageURI': 'local.server/update.exe',
|
||||
'Targets': '/redfish/v1/UpdateService/Actions/SimpleUpdate',
|
||||
|
|
Loading…
Reference in New Issue