Translate VM name to UUID to avoid redirect issue
This change attempts to resolve redirect issue triggered by passing VM name to UpdateService.SimpleUpdate by making an additional call to libvirtdriver uuid method. Change-Id: Ie20846b5c0fcce51465feeefb59ec521de7b2770
This commit is contained in:
parent
e402462e30
commit
4ff52c56f1
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Resolves the issue where UpdateService.SimpleUpdate action cannot
|
||||||
|
complete successfully due to connections from UpdateService to System
|
||||||
|
being redirected by libvirt system driver alias handling code.
|
@ -47,14 +47,24 @@ def update_service_simple_update():
|
|||||||
if "Manager" in target:
|
if "Manager" in target:
|
||||||
message = "Manager is not currently a supported Target."
|
message = "Manager is not currently a supported Target."
|
||||||
return flask.render_template('error.json', message=message), 400
|
return flask.render_template('error.json', message=message), 400
|
||||||
|
try:
|
||||||
|
name = target.rstrip("/").rsplit('/', 1)[-1]
|
||||||
|
uuid = flask.current_app.systems.uuid(name)
|
||||||
|
except error.AliasAccessError as exc:
|
||||||
|
api_utils.debug('Received a redirect in respose to GET System '
|
||||||
|
'"%s". New System ID: "%s"', name, exc)
|
||||||
|
uuid = str(exc)
|
||||||
|
except Exception as exc:
|
||||||
|
api_utils.debug('Encountered exception "%s" while attempting to '
|
||||||
|
'GET System "%s"', exc, name)
|
||||||
|
raise
|
||||||
|
|
||||||
identity = target.rsplit('/', 1)[-1]
|
|
||||||
# NOTE(janders) iterate over the array? narrow down which one is needed
|
# NOTE(janders) iterate over the array? narrow down which one is needed
|
||||||
# first? I suppose the former since we may want to update multiple
|
# first? I suppose the former since we may want to update multiple
|
||||||
api_utils.debug('Fetching BIOS information for System "%s"',
|
api_utils.debug('Fetching BIOS information for System "%s"',
|
||||||
target)
|
uuid)
|
||||||
try:
|
try:
|
||||||
versions = flask.current_app.systems.get_versions(identity)
|
versions = flask.current_app.systems.get_versions(uuid)
|
||||||
|
|
||||||
except error.NotSupportedError as ex:
|
except error.NotSupportedError as ex:
|
||||||
api_utils.warning(
|
api_utils.warning(
|
||||||
@ -67,7 +77,7 @@ def update_service_simple_update():
|
|||||||
|
|
||||||
api_utils.debug('Current BIOS version for System "%s" is "%s" ,'
|
api_utils.debug('Current BIOS version for System "%s" is "%s" ,'
|
||||||
'attempting upgrade.',
|
'attempting upgrade.',
|
||||||
target, bios_version)
|
uuid, bios_version)
|
||||||
|
|
||||||
bios_version = bios_version.split('.')
|
bios_version = bios_version.split('.')
|
||||||
bios_version[1] = str(int(bios_version[1]) + 1)
|
bios_version[1] = str(int(bios_version[1]) + 1)
|
||||||
@ -75,7 +85,7 @@ def update_service_simple_update():
|
|||||||
firmware_versions = {"BiosVersion": bios_version}
|
firmware_versions = {"BiosVersion": bios_version}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
flask.current_app.systems.set_versions(identity, firmware_versions)
|
flask.current_app.systems.set_versions(uuid, firmware_versions)
|
||||||
except error.NotSupportedError as ex:
|
except error.NotSupportedError as ex:
|
||||||
api_utils.warning('System failed to update bios with exception %s',
|
api_utils.warning('System failed to update bios with exception %s',
|
||||||
ex)
|
ex)
|
||||||
@ -84,5 +94,5 @@ def update_service_simple_update():
|
|||||||
|
|
||||||
api_utils.info(
|
api_utils.info(
|
||||||
'Emulated BIOS upgrade has been successful for '
|
'Emulated BIOS upgrade has been successful for '
|
||||||
'System %s, new version is "%s".', target, bios_version)
|
'System %s, new version is "%s".', uuid, bios_version)
|
||||||
return '', 204, {'Location': '/redfish/v1/TaskService/Tasks/42'}
|
return '', 204, {'Location': '/redfish/v1/TaskService/Tasks/42'}
|
||||||
|
Loading…
Reference in New Issue
Block a user