Add 'in-progress-aborted' handling to the VIM fw update orchestration

This update
 - adds 'in-progress-abort' handling to fwupdate orchestration
 - adds sw-manager command completion support to fw-update-strategy command.

Change-Id: Ic8895c7fc6b235f22d7807cf3db3cf51ecaa39fd
Story: 2007875
Task: 40346
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
This commit is contained in:
Eric MacDonald 2020-07-14 11:15:03 -04:00
parent b39bc8c034
commit 99c045802d
4 changed files with 105 additions and 9 deletions

View File

@ -183,7 +183,7 @@ def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value
help='defaults to serial')
fw_update_create_strategy_cmd.add_argument(
'--max-parallel-worker-hosts', type=int, choices=range(2, 11),
'--max-parallel-worker-hosts', type=int, choices=range(2, 6),
help='maximum worker hosts to update in parallel')
fw_update_create_strategy_cmd.add_argument('--instance-action',

View File

@ -21,6 +21,7 @@ function _swmanager()
local subcommands="
patch-strategy
upgrade-strategy
fw-update-strategy
"
if [ $COMP_CWORD -gt 1 ]; then
@ -172,6 +173,83 @@ function _swmanager()
esac
fi
# Provide actions for completion
COMPREPLY=($(compgen -W "${actions}" -- ${cur}))
return 0
;;
fw-update-strategy)
local actions="
create
delete
apply
abort
show
"
if [ $COMP_CWORD -gt 2 ]; then
local action=${COMP_WORDS[2]}
#
# Complete the arguments for each action
#
case "$action" in
create)
local createopts="
--controller-apply-type
--storage-apply-type
--worker-apply-type
--max-parallel-worker-hosts
--instance-action
--alarm-restrictions
"
local createopt=${prev}
case "$createopt" in
--controller-apply-type|--storage-apply-type)
COMPREPLY=($(compgen -W "ignore" -- ${cur}))
return 0
;;
--worker-apply-type)
COMPREPLY=($(compgen -W "serial parallel ignore" -- ${cur}))
return 0
;;
--max-parallel-worker-hosts)
COMPREPLY=( $(compgen -- ${cur}))
return 0
;;
--instance-action)
COMPREPLY=($(compgen -W "migrate stop-start" -- ${cur}))
return 0
;;
--alarm-restrictions)
COMPREPLY=($(compgen -W "strict relaxed" -- ${cur}))
return 0
;;
*)
;;
esac
COMPREPLY=($(compgen -W "${createopts}" -- ${cur}))
return 0
;;
apply|abort)
if [ "${prev}" = "${action}" ]; then
COMPREPLY=($(compgen -W "--stage-id" -- ${cur}))
fi
return 0
;;
show)
if [ "${prev}" = "${action}" ]; then
COMPREPLY=($(compgen -W "--details" -- ${cur}))
fi
return 0
;;
delete)
# These subcommands have no options/arguments
COMPREPLY=( $(compgen -- ${cur}) )
return 0
;;
*)
;;
esac
fi
# Provide actions for completion
COMPREPLY=($(compgen -W "${actions}" -- ${cur}))
return 0

View File

@ -47,5 +47,6 @@ class FirmwareUpdateLabels(object):
DEVICE_IMAGE_UPDATE_IN_PROGRESS = Constant('in-progress')
DEVICE_IMAGE_UPDATE_COMPLETED = Constant('completed')
DEVICE_IMAGE_UPDATE_FAILED = Constant('failed')
DEVICE_IMAGE_UPDATE_IN_PROGRESS_ABORTED = Constant('in-progress-aborted')
FW_UPDATE_LABEL = FirmwareUpdateLabels()

View File

@ -1777,7 +1777,7 @@ class QueryFwUpdateHostStep(strategy.StrategyStep):
response = (yield)
DLOG.verbose("Get-Host %s callback response=%s." %
(self._host_names[0], response))
(self._host_names[0], response))
if response['completed']:
if self.strategy is not None:
@ -1793,6 +1793,8 @@ class QueryFwUpdateHostStep(strategy.StrategyStep):
DLOG.info("%s requires firmware update" % hostname)
elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_IN_PROGRESS:
DLOG.info("%s firmware update in-progress" % hostname)
elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_IN_PROGRESS_ABORTED:
DLOG.info("%s firmware update in-progress-aborted" % hostname)
elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_COMPLETED:
DLOG.info("%s firmware update complete" % hostname)
elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_FAILED:
@ -1878,10 +1880,14 @@ class FwUpdateHostsStep(strategy.StrategyStep):
if device_image_update is None:
DLOG.verbose("%s no firmware update required" % hostname)
elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_PENDING:
self.strategy.fw_update_hosts.append(hostname)
DLOG.info("%s requires firmware update" % hostname)
DLOG.warn("%s is still in pending state" % hostname)
elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_IN_PROGRESS:
DLOG.info("%s firmware update in-progress" % hostname)
elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_IN_PROGRESS_ABORTED:
if self._host_completed[hostname][0] is False:
failed_msg = hostname + ' firmware update aborted while in progress'
self._host_completed[hostname] = (True, False, failed_msg)
DLOG.error(failed_msg)
elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_COMPLETED:
if self._host_completed[hostname][0] is False:
self._host_completed[hostname] = (True, True, '')
@ -1893,7 +1899,10 @@ class FwUpdateHostsStep(strategy.StrategyStep):
DLOG.error(failed_msg)
else:
if self._host_completed[hostname][0] is False:
failed_msg = hostname + ' firmware update failed ; unknown state ' + device_image_update
failed_msg = hostname + \
' firmware update failed ;' \
' unknown state [' + \
device_image_update + ']'
self._host_completed[hostname] = (True, False, failed_msg)
DLOG.error(failed_msg)
@ -1993,7 +2002,9 @@ class FwUpdateHostsStep(strategy.StrategyStep):
for host in self._hosts:
if self._host_completed[host.name][0] is True:
DLOG.info("%s update already done")
DLOG.info("%s firmware update already done ; pass=%s" %
(host.name,
self._host_completed[host.name][1]))
continue
nfvi.nfvi_get_host(host.uuid,
@ -2007,9 +2018,15 @@ class FwUpdateHostsStep(strategy.StrategyStep):
def abort(self):
"""
Returns the abort step related to this step
Returns the abort step with applicable host list
"""
return [FwUpdateAbortHostsStep(self._hosts)]
# abort all hosts that are not in the completed state
hosts = list()
for host in self._hosts:
if self._host_completed[host.name][0] is False:
hosts.append(host)
return [FwUpdateAbortHostsStep(hosts)]
def from_dict(self, data):
"""
@ -2052,7 +2069,7 @@ class FwUpdateAbortHostsStep(strategy.StrategyStep):
"""
def __init__(self, hosts):
super(FwUpdateAbortHostsStep, self).__init__(
STRATEGY_STEP_NAME.FW_UPDATE_ABORT_HOSTS, timeout_in_secs=3600)
STRATEGY_STEP_NAME.FW_UPDATE_ABORT_HOSTS, timeout_in_secs=600)
self._hosts = hosts
self._host_names = list()