Merge remote-tracking branch 'origin/master' into f/centos8
Signed-off-by: Charles Short <charles.short@windriver.com> Change-Id: I814dbac0f84da0de57fb0a2462e4a5668aed8ab4
This commit is contained in:
commit
96fa4281d7
@ -29,8 +29,8 @@
|
|||||||
- job:
|
- job:
|
||||||
name: nfv-tox-py27
|
name: nfv-tox-py27
|
||||||
parent: tox
|
parent: tox
|
||||||
nodeset: ubuntu-xenial
|
|
||||||
description: Run py27 for nfv
|
description: Run py27 for nfv
|
||||||
|
nodeset: ubuntu-xenial
|
||||||
required-projects:
|
required-projects:
|
||||||
- starlingx/fault
|
- starlingx/fault
|
||||||
vars:
|
vars:
|
||||||
@ -40,8 +40,8 @@
|
|||||||
- job:
|
- job:
|
||||||
name: nfv-tox-py36
|
name: nfv-tox-py36
|
||||||
parent: tox
|
parent: tox
|
||||||
nodeset: ubuntu-bionic
|
|
||||||
description: Run py36 for nfv
|
description: Run py36 for nfv
|
||||||
|
nodeset: ubuntu-bionic
|
||||||
required-projects:
|
required-projects:
|
||||||
- starlingx/fault
|
- starlingx/fault
|
||||||
vars:
|
vars:
|
||||||
@ -52,7 +52,6 @@
|
|||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: nfv-tox-pep8
|
name: nfv-tox-pep8
|
||||||
nodeset: ubuntu-xenial
|
|
||||||
parent: tox
|
parent: tox
|
||||||
description: Run pep8 for nfv
|
description: Run pep8 for nfv
|
||||||
required-projects:
|
required-projects:
|
||||||
@ -63,9 +62,9 @@
|
|||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: nfv-tox-pylint
|
name: nfv-tox-pylint
|
||||||
nodeset: ubuntu-xenial
|
|
||||||
parent: tox
|
parent: tox
|
||||||
description: Run pylint for nfv
|
description: Run pylint for nfv
|
||||||
|
nodeset: ubuntu-xenial
|
||||||
required-projects:
|
required-projects:
|
||||||
- starlingx/fault
|
- starlingx/fault
|
||||||
vars:
|
vars:
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
SRC_DIR="src"
|
SRC_DIR="src"
|
||||||
TIS_PATCH_VER=142
|
TIS_PATCH_VER=PKG_GITREVCOUNT+129
|
||||||
BUILD_IS_SLOW=5
|
BUILD_IS_SLOW=5
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
#daily
|
## Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
|
##
|
||||||
|
## SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
/var/log/guestAgent.log
|
/var/log/guestAgent.log
|
||||||
{
|
{
|
||||||
nodateext
|
create 0640 root root
|
||||||
size 10M
|
|
||||||
rotate 5
|
|
||||||
start 1
|
start 1
|
||||||
missingok
|
rotate 5
|
||||||
notifempty
|
size 10M
|
||||||
compress
|
compress
|
||||||
sharedscripts
|
notifempty
|
||||||
|
missingok
|
||||||
postrotate
|
postrotate
|
||||||
systemctl reload syslog-ng > /dev/null 2>&1 || true
|
systemctl reload syslog-ng > /dev/null 2>&1 || true
|
||||||
endscript
|
endscript
|
||||||
|
delaycompress
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
#daily
|
## Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
nodateext
|
##
|
||||||
|
## SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
/var/log/guestServer.log
|
/var/log/guestServer.log
|
||||||
{
|
{
|
||||||
nodateext
|
create 0640 root root
|
||||||
size 10M
|
|
||||||
rotate 5
|
|
||||||
start 1
|
start 1
|
||||||
missingok
|
rotate 5
|
||||||
notifempty
|
size 10M
|
||||||
compress
|
compress
|
||||||
sharedscripts
|
notifempty
|
||||||
|
missingok
|
||||||
postrotate
|
postrotate
|
||||||
systemctl reload syslog-ng > /dev/null 2>&1 || true
|
systemctl reload syslog-ng > /dev/null 2>&1 || true
|
||||||
endscript
|
endscript
|
||||||
|
delaycompress
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2016,2020 Wind River Systems, Inc.
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -231,6 +231,10 @@ def create_strategy(token_id, url, strategy_name, controller_apply_type,
|
|||||||
elif 'fw-update' == strategy_name:
|
elif 'fw-update' == strategy_name:
|
||||||
api_cmd_payload['controller-apply-type'] = controller_apply_type
|
api_cmd_payload['controller-apply-type'] = controller_apply_type
|
||||||
api_cmd_payload['default-instance-action'] = default_instance_action
|
api_cmd_payload['default-instance-action'] = default_instance_action
|
||||||
|
elif 'kube-upgrade' == strategy_name:
|
||||||
|
# required: 'to_version' passed to strategy as 'to-version'
|
||||||
|
api_cmd_payload['to-version'] = kwargs['to_version']
|
||||||
|
api_cmd_payload['default-instance-action'] = default_instance_action
|
||||||
elif 'sw-upgrade' == strategy_name:
|
elif 'sw-upgrade' == strategy_name:
|
||||||
if 'start_upgrade' in kwargs and kwargs['start_upgrade']:
|
if 'start_upgrade' in kwargs and kwargs['start_upgrade']:
|
||||||
api_cmd_payload['start-upgrade'] = True
|
api_cmd_payload['start-upgrade'] = True
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2016,2020 Wind River Systems, Inc.
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -11,6 +11,369 @@ import sys
|
|||||||
from nfv_client import sw_update
|
from nfv_client import sw_update
|
||||||
|
|
||||||
|
|
||||||
|
REGISTERED_STRATEGIES = {}
|
||||||
|
|
||||||
|
|
||||||
|
def register_strategy(cmd_area, strategy_name):
|
||||||
|
"""
|
||||||
|
Registers a parser command with an update strategy name
|
||||||
|
|
||||||
|
:param cmd_area: the parser command to register
|
||||||
|
:param strategy_name: the strategy to associate with this parser
|
||||||
|
"""
|
||||||
|
REGISTERED_STRATEGIES[cmd_area] = strategy_name
|
||||||
|
|
||||||
|
|
||||||
|
def get_strategy_name(cmd_area):
|
||||||
|
"""
|
||||||
|
Determines the strategy name for a parser command
|
||||||
|
|
||||||
|
:param cmd_area: the parser command to lookup
|
||||||
|
:returns: the strategy name associated with the parser
|
||||||
|
:raises: ValueError if the parser was never registered
|
||||||
|
"""
|
||||||
|
strategy_name = REGISTERED_STRATEGIES.get(cmd_area, None)
|
||||||
|
if strategy_name is None:
|
||||||
|
raise ValueError("Unknown command area, %s, given" % cmd_area)
|
||||||
|
return strategy_name
|
||||||
|
|
||||||
|
|
||||||
|
def get_extra_create_args(cmd_area, args):
|
||||||
|
"""
|
||||||
|
Return the extra create arguments supported by a strategy type
|
||||||
|
|
||||||
|
:param cmd_area: the strategy that supports additional create arguments
|
||||||
|
:param args: the parsed arguments to extract the additional fields from
|
||||||
|
:returns: a dictionary of additional kwargs for the create_strategy command
|
||||||
|
:raises: ValueError if a strategy has been registered but not update here
|
||||||
|
"""
|
||||||
|
if 'patch-strategy' == cmd_area:
|
||||||
|
# no additional kwargs for patch
|
||||||
|
return {}
|
||||||
|
elif 'upgrade-strategy' == cmd_area:
|
||||||
|
# upgrade supports: complete_upgrade
|
||||||
|
return {'complete_upgrade': args.complete_upgrade}
|
||||||
|
elif 'fw-update-strategy' == cmd_area:
|
||||||
|
# no additional kwargs for firmware update
|
||||||
|
return {}
|
||||||
|
elif 'kube-upgrade-strategy' == cmd_area:
|
||||||
|
# kube upgrade supports: to_version
|
||||||
|
return {'to_version': args.to_version}
|
||||||
|
else:
|
||||||
|
raise ValueError("Unknown command area, %s, given" % cmd_area)
|
||||||
|
|
||||||
|
|
||||||
|
def add_list_arg(some_cmd, some_arg, some_list):
|
||||||
|
"""
|
||||||
|
Adds an argument to a command accepting a list of valid values.
|
||||||
|
|
||||||
|
:param some_cmd: a command parser object that is adding a new argument
|
||||||
|
:param some_arg: a string indicating the new argument. ex: --foo
|
||||||
|
:param some_list: a list of valid values for the argument.
|
||||||
|
|
||||||
|
The list cannot be empty. The first item in the list is the default
|
||||||
|
"""
|
||||||
|
default = some_list[0]
|
||||||
|
some_cmd.add_argument(some_arg,
|
||||||
|
default=default,
|
||||||
|
choices=some_list,
|
||||||
|
help='defaults to ' + default)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_abort_cmd(parser):
|
||||||
|
"""
|
||||||
|
Sets up an 'abort' command for a strategy command parser.
|
||||||
|
|
||||||
|
ex: sw-manager patch-strategy abort <some args>
|
||||||
|
|
||||||
|
:param parser: the strategy parser to add the create command to.
|
||||||
|
"""
|
||||||
|
abort_cmd = parser.add_parser('abort',
|
||||||
|
help='Abort a strategy')
|
||||||
|
abort_cmd.set_defaults(cmd='abort')
|
||||||
|
abort_cmd.add_argument('--stage-id',
|
||||||
|
help='stage identifier to abort')
|
||||||
|
return abort_cmd
|
||||||
|
|
||||||
|
|
||||||
|
def setup_apply_cmd(parser):
|
||||||
|
"""
|
||||||
|
Sets up an 'apply' command for a strategy command parser.
|
||||||
|
|
||||||
|
ex: sw-manager patch-strategy apply <some args>
|
||||||
|
|
||||||
|
:param parser: the strategy parser to register the command under
|
||||||
|
"""
|
||||||
|
apply_cmd = parser.add_parser('apply',
|
||||||
|
help='Apply a strategy')
|
||||||
|
apply_cmd.set_defaults(cmd='apply')
|
||||||
|
apply_cmd.add_argument('--stage-id',
|
||||||
|
default=None,
|
||||||
|
help='stage identifier to apply')
|
||||||
|
return apply_cmd
|
||||||
|
|
||||||
|
|
||||||
|
def setup_create_cmd(parser,
|
||||||
|
controller_types,
|
||||||
|
storage_types,
|
||||||
|
worker_types,
|
||||||
|
instance_actions,
|
||||||
|
alarm_restrictions,
|
||||||
|
min_parallel=1,
|
||||||
|
max_parallel=5):
|
||||||
|
"""
|
||||||
|
Sets up a 'create' command for a strategy command parser.
|
||||||
|
|
||||||
|
ex: sw-manager patch-strategy create <some args>
|
||||||
|
|
||||||
|
:param parser: the strategy parser to register the command under
|
||||||
|
:param controller_types: list of the valid apply types for controller
|
||||||
|
:param storage_types: list of the valid apply types for storage
|
||||||
|
:param worker_types: list of the valid apply types for worker
|
||||||
|
:param instance_actions: list of valid VM actions during worker apply
|
||||||
|
:param alarm_restrictions: list of valid alarm restrictions
|
||||||
|
:param min_parallel: minimum value (inclusive) for updating parallel hosts
|
||||||
|
:param max_parallel: maximum value (inclusive) for updating parallel hosts
|
||||||
|
|
||||||
|
The lists cannot be empty. The first item in the lists is the default
|
||||||
|
"""
|
||||||
|
create_cmd = parser.add_parser('create', help='Create a strategy')
|
||||||
|
create_cmd.set_defaults(cmd='create')
|
||||||
|
|
||||||
|
add_list_arg(create_cmd, '--controller-apply-type', controller_types)
|
||||||
|
add_list_arg(create_cmd, '--storage-apply-type', storage_types)
|
||||||
|
add_list_arg(create_cmd, '--worker-apply-type', worker_types)
|
||||||
|
add_list_arg(create_cmd, '--instance-action', instance_actions)
|
||||||
|
add_list_arg(create_cmd, '--alarm-restrictions', alarm_restrictions)
|
||||||
|
create_cmd.add_argument('--max-parallel-worker-hosts',
|
||||||
|
type=int,
|
||||||
|
choices=range(min_parallel, max_parallel + 1),
|
||||||
|
help='maximum worker hosts to update in parallel')
|
||||||
|
|
||||||
|
return create_cmd
|
||||||
|
|
||||||
|
|
||||||
|
def setup_delete_cmd(parser):
|
||||||
|
"""
|
||||||
|
Sets up a 'delete' command for a strategy command parser.
|
||||||
|
|
||||||
|
ex: sw-manager patch-strategy delete <some args>
|
||||||
|
|
||||||
|
:param parser: the strategy parser to register the command under
|
||||||
|
"""
|
||||||
|
delete_cmd = parser.add_parser('delete', help='Delete a strategy')
|
||||||
|
delete_cmd.set_defaults(cmd='delete')
|
||||||
|
delete_cmd.add_argument('--force',
|
||||||
|
action='store_true',
|
||||||
|
help=argparse.SUPPRESS)
|
||||||
|
return delete_cmd
|
||||||
|
|
||||||
|
|
||||||
|
def setup_show_cmd(parser):
|
||||||
|
"""
|
||||||
|
Sets up a 'show' command for a strategy command parser.
|
||||||
|
|
||||||
|
ex: sw-manager patch-strategy show <some args>
|
||||||
|
|
||||||
|
:param parser: the strategy parser to register the command under
|
||||||
|
"""
|
||||||
|
show_cmd = parser.add_parser('show', help='Show a strategy')
|
||||||
|
show_cmd.set_defaults(cmd='show')
|
||||||
|
show_cmd.add_argument('--details',
|
||||||
|
action='store_true',
|
||||||
|
help='show strategy details')
|
||||||
|
show_cmd.add_argument('--active',
|
||||||
|
action='store_true',
|
||||||
|
help='show currently active strategy step')
|
||||||
|
return show_cmd
|
||||||
|
|
||||||
|
|
||||||
|
def setup_fw_update_parser(commands):
|
||||||
|
"""Firmware Update Strategy Commands"""
|
||||||
|
|
||||||
|
cmd_area = 'fw-update-strategy'
|
||||||
|
register_strategy(cmd_area, sw_update.STRATEGY_NAME_FW_UPDATE)
|
||||||
|
cmd_parser = commands.add_parser(cmd_area,
|
||||||
|
help='Firmware Update Strategy')
|
||||||
|
cmd_parser.set_defaults(cmd_area=cmd_area)
|
||||||
|
|
||||||
|
sub_cmds = cmd_parser.add_subparsers(title='Firmware Update Commands',
|
||||||
|
metavar='')
|
||||||
|
sub_cmds.required = True
|
||||||
|
|
||||||
|
# define the create command
|
||||||
|
# alarm restrictions, defaults to strict
|
||||||
|
create_strategy_cmd = setup_create_cmd(
|
||||||
|
sub_cmds,
|
||||||
|
[sw_update.APPLY_TYPE_IGNORE], # controller supports ignore
|
||||||
|
[sw_update.APPLY_TYPE_IGNORE], # storage supports ignore
|
||||||
|
[sw_update.APPLY_TYPE_SERIAL, # worker supports serial and parallel
|
||||||
|
sw_update.APPLY_TYPE_PARALLEL,
|
||||||
|
sw_update.APPLY_TYPE_IGNORE],
|
||||||
|
[sw_update.INSTANCE_ACTION_STOP_START, # instance actions
|
||||||
|
sw_update.INSTANCE_ACTION_MIGRATE],
|
||||||
|
[sw_update.ALARM_RESTRICTIONS_STRICT, # alarm restrictions
|
||||||
|
sw_update.ALARM_RESTRICTIONS_RELAXED],
|
||||||
|
min_parallel=2,
|
||||||
|
max_parallel=5 # fw update supports 2..5 workers in parallel
|
||||||
|
)
|
||||||
|
# There are no additional create options for firmware update
|
||||||
|
|
||||||
|
# define the delete command
|
||||||
|
delete_strategy_cmd = setup_delete_cmd(sub_cmds)
|
||||||
|
# define the apply command
|
||||||
|
apply_strategy_cmd = setup_apply_cmd(sub_cmds)
|
||||||
|
# define the abort command
|
||||||
|
abort_strategy_cmd = setup_abort_cmd(sub_cmds)
|
||||||
|
# define the show command
|
||||||
|
show_strategy_cmd = setup_show_cmd(sub_cmds)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_kube_upgrade_parser(commands):
|
||||||
|
"""Kubernetes Upgrade Strategy Commands"""
|
||||||
|
|
||||||
|
cmd_area = 'kube-upgrade-strategy'
|
||||||
|
register_strategy(cmd_area, sw_update.STRATEGY_NAME_KUBE_UPGRADE)
|
||||||
|
cmd_parser = commands.add_parser(cmd_area,
|
||||||
|
help='Kubernetes Upgrade Strategy')
|
||||||
|
cmd_parser.set_defaults(cmd_area=cmd_area)
|
||||||
|
|
||||||
|
sub_cmds = cmd_parser.add_subparsers(title='Kubernetes Upgrade Commands',
|
||||||
|
metavar='')
|
||||||
|
sub_cmds.required = True
|
||||||
|
|
||||||
|
# define the create command
|
||||||
|
create_strategy_cmd = setup_create_cmd(
|
||||||
|
sub_cmds,
|
||||||
|
[sw_update.APPLY_TYPE_SERIAL, # controller supports serial only
|
||||||
|
sw_update.APPLY_TYPE_IGNORE],
|
||||||
|
[sw_update.APPLY_TYPE_SERIAL, # storage supports serial only
|
||||||
|
sw_update.APPLY_TYPE_IGNORE],
|
||||||
|
[sw_update.APPLY_TYPE_SERIAL, # worker supports serial and parallel
|
||||||
|
sw_update.APPLY_TYPE_PARALLEL,
|
||||||
|
sw_update.APPLY_TYPE_IGNORE],
|
||||||
|
[sw_update.INSTANCE_ACTION_STOP_START, # instance actions
|
||||||
|
sw_update.INSTANCE_ACTION_MIGRATE],
|
||||||
|
[sw_update.ALARM_RESTRICTIONS_STRICT, # alarm restrictions
|
||||||
|
sw_update.ALARM_RESTRICTIONS_RELAXED],
|
||||||
|
min_parallel=2,
|
||||||
|
max_parallel=10 # kube upgrade supports 2..10 workers in parallel
|
||||||
|
)
|
||||||
|
|
||||||
|
# add kube specific arguments to the create command
|
||||||
|
# The get_extra_create_args method is updated to align with these
|
||||||
|
# kube upgrade create requires 'to-version'
|
||||||
|
create_strategy_cmd.add_argument(
|
||||||
|
'--to-version',
|
||||||
|
required=True,
|
||||||
|
help='The kubernetes version')
|
||||||
|
|
||||||
|
# define the delete command
|
||||||
|
delete_strategy_cmd = setup_delete_cmd(sub_cmds)
|
||||||
|
# define the apply command
|
||||||
|
apply_strategy_cmd = setup_apply_cmd(sub_cmds)
|
||||||
|
# define the abort command
|
||||||
|
abort_strategy_cmd = setup_abort_cmd(sub_cmds)
|
||||||
|
# define the show command
|
||||||
|
show_strategy_cmd = setup_show_cmd(sub_cmds)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_patch_parser(commands):
|
||||||
|
"""Patch Strategy Commands"""
|
||||||
|
|
||||||
|
cmd_area = 'patch-strategy'
|
||||||
|
register_strategy(cmd_area, sw_update.STRATEGY_NAME_SW_PATCH)
|
||||||
|
cmd_parser = commands.add_parser(cmd_area,
|
||||||
|
help='Patch Strategy')
|
||||||
|
cmd_parser.set_defaults(cmd_area=cmd_area)
|
||||||
|
|
||||||
|
sub_cmds = cmd_parser.add_subparsers(title='Software Patch Commands',
|
||||||
|
metavar='')
|
||||||
|
sub_cmds.required = True
|
||||||
|
|
||||||
|
# define the create command
|
||||||
|
# alarm restrictions, defaults to strict
|
||||||
|
create_strategy_cmd = setup_create_cmd(
|
||||||
|
sub_cmds,
|
||||||
|
[sw_update.APPLY_TYPE_SERIAL, # controller supports serial
|
||||||
|
sw_update.APPLY_TYPE_IGNORE],
|
||||||
|
[sw_update.APPLY_TYPE_SERIAL, # storage supports serial and parallel
|
||||||
|
sw_update.APPLY_TYPE_PARALLEL,
|
||||||
|
sw_update.APPLY_TYPE_IGNORE],
|
||||||
|
[sw_update.APPLY_TYPE_SERIAL, # worker supports serial and parallel
|
||||||
|
sw_update.APPLY_TYPE_PARALLEL,
|
||||||
|
sw_update.APPLY_TYPE_IGNORE],
|
||||||
|
[sw_update.INSTANCE_ACTION_STOP_START, # instance actions
|
||||||
|
sw_update.INSTANCE_ACTION_MIGRATE],
|
||||||
|
[sw_update.ALARM_RESTRICTIONS_STRICT, # alarm restrictions
|
||||||
|
sw_update.ALARM_RESTRICTIONS_RELAXED],
|
||||||
|
min_parallel=2,
|
||||||
|
max_parallel=100 # patch supports 2..100 workers in parallel
|
||||||
|
)
|
||||||
|
|
||||||
|
# define the delete command
|
||||||
|
delete_strategy_cmd = setup_delete_cmd(sub_cmds)
|
||||||
|
# define the apply command
|
||||||
|
apply_strategy_cmd = setup_apply_cmd(sub_cmds)
|
||||||
|
# define the abort command
|
||||||
|
abort_strategy_cmd = setup_abort_cmd(sub_cmds)
|
||||||
|
# define the show command
|
||||||
|
show_strategy_cmd = setup_show_cmd(sub_cmds)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_upgrade_parser(commands):
|
||||||
|
"""Upgrade Strategy Commands"""
|
||||||
|
|
||||||
|
cmd_area = 'upgrade-strategy'
|
||||||
|
register_strategy(cmd_area, sw_update.STRATEGY_NAME_SW_UPGRADE)
|
||||||
|
cmd_parser = commands.add_parser(cmd_area,
|
||||||
|
help='Upgrade Strategy')
|
||||||
|
cmd_parser.set_defaults(cmd_area=cmd_area)
|
||||||
|
|
||||||
|
sub_cmds = cmd_parser.add_subparsers(title='Software Upgrade Commands',
|
||||||
|
metavar='')
|
||||||
|
sub_cmds.required = True
|
||||||
|
|
||||||
|
# define the create command
|
||||||
|
# alarm restrictions, defaults to strict
|
||||||
|
create_strategy_cmd = setup_create_cmd(
|
||||||
|
sub_cmds,
|
||||||
|
[sw_update.APPLY_TYPE_SERIAL], # hard coded to serial
|
||||||
|
[sw_update.APPLY_TYPE_SERIAL, # storage supports serial and parallel
|
||||||
|
sw_update.APPLY_TYPE_PARALLEL,
|
||||||
|
sw_update.APPLY_TYPE_IGNORE],
|
||||||
|
[sw_update.APPLY_TYPE_SERIAL, # worker supports serial and parallel
|
||||||
|
sw_update.APPLY_TYPE_PARALLEL,
|
||||||
|
sw_update.APPLY_TYPE_IGNORE],
|
||||||
|
[sw_update.INSTANCE_ACTION_MIGRATE], # hardcoded to migrate
|
||||||
|
[sw_update.ALARM_RESTRICTIONS_STRICT, # alarm restrictions
|
||||||
|
sw_update.ALARM_RESTRICTIONS_RELAXED],
|
||||||
|
min_parallel=2,
|
||||||
|
max_parallel=10 # upgrade supports 2..10 workers in parallel
|
||||||
|
)
|
||||||
|
|
||||||
|
# add upgrade specific arguments to the create command
|
||||||
|
# The get_extra_create_args method is updated to align with these
|
||||||
|
|
||||||
|
# Disable support for --start-upgrade as it was not completed
|
||||||
|
# create_strategy_cmd.add_argument('--start-upgrade',
|
||||||
|
# action='store_true',
|
||||||
|
# help=argparse.SUPPRESS)
|
||||||
|
|
||||||
|
create_strategy_cmd.add_argument('--complete-upgrade',
|
||||||
|
action='store_true',
|
||||||
|
help=argparse.SUPPRESS)
|
||||||
|
|
||||||
|
# define the delete command
|
||||||
|
delete_strategy_cmd = setup_delete_cmd(sub_cmds)
|
||||||
|
# define the apply command
|
||||||
|
apply_strategy_cmd = setup_apply_cmd(sub_cmds)
|
||||||
|
# define the abort command
|
||||||
|
abort_strategy_cmd = setup_abort_cmd(sub_cmds)
|
||||||
|
# define the show command
|
||||||
|
show_strategy_cmd = setup_show_cmd(sub_cmds)
|
||||||
|
|
||||||
|
|
||||||
def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value
|
def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value
|
||||||
"""
|
"""
|
||||||
Client - Main
|
Client - Main
|
||||||
@ -30,197 +393,17 @@ def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value
|
|||||||
commands = parser.add_subparsers(title='Commands', metavar='')
|
commands = parser.add_subparsers(title='Commands', metavar='')
|
||||||
commands.required = True
|
commands.required = True
|
||||||
|
|
||||||
# Software Patch Commands
|
# Add firmware update strategy commands
|
||||||
sw_patch_parser = commands.add_parser('patch-strategy',
|
setup_fw_update_parser(commands)
|
||||||
help='Patch Strategy')
|
|
||||||
sw_patch_parser.set_defaults(cmd_area='patch-strategy')
|
|
||||||
|
|
||||||
sw_patch_cmds = sw_patch_parser.add_subparsers(
|
# Add kubernetes upgrade strategy commands
|
||||||
title='Software Patch Commands', metavar='')
|
setup_kube_upgrade_parser(commands)
|
||||||
sw_patch_cmds.required = True
|
|
||||||
|
|
||||||
sw_patch_create_strategy_cmd \
|
# Add software patch strategy commands
|
||||||
= sw_patch_cmds.add_parser('create', help='Create a strategy')
|
setup_patch_parser(commands)
|
||||||
sw_patch_create_strategy_cmd.set_defaults(cmd='create')
|
|
||||||
sw_patch_create_strategy_cmd.add_argument(
|
|
||||||
'--controller-apply-type', default=sw_update.APPLY_TYPE_SERIAL,
|
|
||||||
choices=[sw_update.APPLY_TYPE_SERIAL, sw_update.APPLY_TYPE_IGNORE],
|
|
||||||
help='defaults to serial')
|
|
||||||
sw_patch_create_strategy_cmd.add_argument(
|
|
||||||
'--storage-apply-type', default=sw_update.APPLY_TYPE_SERIAL,
|
|
||||||
choices=[sw_update.APPLY_TYPE_SERIAL, sw_update.APPLY_TYPE_PARALLEL,
|
|
||||||
sw_update.APPLY_TYPE_IGNORE],
|
|
||||||
help='defaults to serial')
|
|
||||||
sw_patch_create_strategy_cmd.add_argument(
|
|
||||||
'--worker-apply-type', default=sw_update.APPLY_TYPE_SERIAL,
|
|
||||||
choices=[sw_update.APPLY_TYPE_SERIAL, sw_update.APPLY_TYPE_PARALLEL,
|
|
||||||
sw_update.APPLY_TYPE_IGNORE],
|
|
||||||
help='defaults to serial')
|
|
||||||
sw_patch_create_strategy_cmd.add_argument(
|
|
||||||
'--max-parallel-worker-hosts', type=int, choices=range(2, 101),
|
|
||||||
help='maximum worker hosts to patch in parallel')
|
|
||||||
sw_patch_create_strategy_cmd.add_argument(
|
|
||||||
'--instance-action', default=sw_update.INSTANCE_ACTION_STOP_START,
|
|
||||||
choices=[sw_update.INSTANCE_ACTION_MIGRATE,
|
|
||||||
sw_update.INSTANCE_ACTION_STOP_START],
|
|
||||||
help='defaults to stop-start')
|
|
||||||
sw_patch_create_strategy_cmd.add_argument(
|
|
||||||
'--alarm-restrictions', default=sw_update.ALARM_RESTRICTIONS_STRICT,
|
|
||||||
choices=[sw_update.ALARM_RESTRICTIONS_STRICT,
|
|
||||||
sw_update.ALARM_RESTRICTIONS_RELAXED],
|
|
||||||
help='defaults to strict')
|
|
||||||
|
|
||||||
sw_patch_delete_strategy_cmd \
|
# Add software upgrade strategy commands
|
||||||
= sw_patch_cmds.add_parser('delete', help='Delete a strategy')
|
setup_upgrade_parser(commands)
|
||||||
sw_patch_delete_strategy_cmd.set_defaults(cmd='delete')
|
|
||||||
sw_patch_delete_strategy_cmd.add_argument(
|
|
||||||
'--force', action='store_true', help=argparse.SUPPRESS)
|
|
||||||
|
|
||||||
sw_patch_apply_strategy_cmd \
|
|
||||||
= sw_patch_cmds.add_parser('apply', help='Apply a strategy')
|
|
||||||
sw_patch_apply_strategy_cmd.set_defaults(cmd='apply')
|
|
||||||
sw_patch_apply_strategy_cmd.add_argument(
|
|
||||||
'--stage-id', default=None, help='stage identifier to apply')
|
|
||||||
|
|
||||||
sw_patch_abort_strategy_cmd \
|
|
||||||
= sw_patch_cmds.add_parser('abort', help='Abort a strategy')
|
|
||||||
sw_patch_abort_strategy_cmd.set_defaults(cmd='abort')
|
|
||||||
sw_patch_abort_strategy_cmd.add_argument(
|
|
||||||
'--stage-id', help='stage identifier to abort')
|
|
||||||
|
|
||||||
sw_patch_show_strategy_cmd \
|
|
||||||
= sw_patch_cmds.add_parser('show', help='Show a strategy')
|
|
||||||
sw_patch_show_strategy_cmd.set_defaults(cmd='show')
|
|
||||||
sw_patch_show_strategy_cmd.add_argument(
|
|
||||||
'--details', action='store_true', help='show strategy details')
|
|
||||||
|
|
||||||
# Software Upgrade Commands
|
|
||||||
sw_upgrade_parser = commands.add_parser('upgrade-strategy',
|
|
||||||
help='Upgrade Strategy')
|
|
||||||
sw_upgrade_parser.set_defaults(cmd_area='upgrade-strategy')
|
|
||||||
|
|
||||||
sw_upgrade_cmds = sw_upgrade_parser.add_subparsers(
|
|
||||||
title='Software Upgrade Commands', metavar='')
|
|
||||||
sw_upgrade_cmds.required = True
|
|
||||||
|
|
||||||
sw_upgrade_create_strategy_cmd \
|
|
||||||
= sw_upgrade_cmds.add_parser('create', help='Create a strategy')
|
|
||||||
sw_upgrade_create_strategy_cmd.set_defaults(cmd='create')
|
|
||||||
sw_upgrade_create_strategy_cmd.add_argument(
|
|
||||||
'--storage-apply-type', default=sw_update.APPLY_TYPE_SERIAL,
|
|
||||||
choices=[sw_update.APPLY_TYPE_SERIAL, sw_update.APPLY_TYPE_PARALLEL,
|
|
||||||
sw_update.APPLY_TYPE_IGNORE],
|
|
||||||
help='defaults to serial')
|
|
||||||
sw_upgrade_create_strategy_cmd.add_argument(
|
|
||||||
'--worker-apply-type', default=sw_update.APPLY_TYPE_SERIAL,
|
|
||||||
choices=[sw_update.APPLY_TYPE_SERIAL, sw_update.APPLY_TYPE_PARALLEL,
|
|
||||||
sw_update.APPLY_TYPE_IGNORE],
|
|
||||||
help='defaults to serial')
|
|
||||||
sw_upgrade_create_strategy_cmd.add_argument(
|
|
||||||
'--max-parallel-worker-hosts', type=int, choices=range(2, 11),
|
|
||||||
help='maximum worker hosts to upgrade in parallel')
|
|
||||||
# Disable support for --start-upgrade as it was not completed
|
|
||||||
# sw_upgrade_create_strategy_cmd.add_argument(
|
|
||||||
# '--start-upgrade', action='store_true',
|
|
||||||
# help=argparse.SUPPRESS)
|
|
||||||
sw_upgrade_create_strategy_cmd.add_argument(
|
|
||||||
'--complete-upgrade', action='store_true', help=argparse.SUPPRESS)
|
|
||||||
sw_upgrade_create_strategy_cmd.add_argument(
|
|
||||||
'--alarm-restrictions', default=sw_update.ALARM_RESTRICTIONS_STRICT,
|
|
||||||
choices=[sw_update.ALARM_RESTRICTIONS_STRICT,
|
|
||||||
sw_update.ALARM_RESTRICTIONS_RELAXED],
|
|
||||||
help='defaults to strict')
|
|
||||||
|
|
||||||
sw_upgrade_delete_strategy_cmd \
|
|
||||||
= sw_upgrade_cmds.add_parser('delete', help='Delete a strategy')
|
|
||||||
sw_upgrade_delete_strategy_cmd.set_defaults(cmd='delete')
|
|
||||||
sw_upgrade_delete_strategy_cmd.add_argument(
|
|
||||||
'--force', action='store_true', help=argparse.SUPPRESS)
|
|
||||||
|
|
||||||
sw_upgrade_apply_strategy_cmd \
|
|
||||||
= sw_upgrade_cmds.add_parser('apply', help='Apply a strategy')
|
|
||||||
sw_upgrade_apply_strategy_cmd.set_defaults(cmd='apply')
|
|
||||||
sw_upgrade_apply_strategy_cmd.add_argument(
|
|
||||||
'--stage-id', default=None, help='stage identifier to apply')
|
|
||||||
|
|
||||||
sw_upgrade_abort_strategy_cmd \
|
|
||||||
= sw_upgrade_cmds.add_parser('abort', help='Abort a strategy')
|
|
||||||
sw_upgrade_abort_strategy_cmd.set_defaults(cmd='abort')
|
|
||||||
sw_upgrade_abort_strategy_cmd.add_argument(
|
|
||||||
'--stage-id', help='stage identifier to abort')
|
|
||||||
|
|
||||||
sw_upgrade_show_strategy_cmd \
|
|
||||||
= sw_upgrade_cmds.add_parser('show', help='Show a strategy')
|
|
||||||
sw_upgrade_show_strategy_cmd.set_defaults(cmd='show')
|
|
||||||
sw_upgrade_show_strategy_cmd.add_argument(
|
|
||||||
'--details', action='store_true', help='show strategy details')
|
|
||||||
|
|
||||||
# Firmware Update Commands
|
|
||||||
fw_update_parser = commands.add_parser('fw-update-strategy',
|
|
||||||
help='Firmware Update Strategy')
|
|
||||||
fw_update_parser.set_defaults(cmd_area='fw-update-strategy')
|
|
||||||
|
|
||||||
fw_update_cmds = fw_update_parser.add_subparsers(
|
|
||||||
title='Firmware Update Commands', metavar='')
|
|
||||||
fw_update_cmds.required = True
|
|
||||||
|
|
||||||
fw_update_create_strategy_cmd \
|
|
||||||
= fw_update_cmds.add_parser('create', help='Create a strategy')
|
|
||||||
fw_update_create_strategy_cmd.set_defaults(cmd='create')
|
|
||||||
fw_update_create_strategy_cmd.add_argument('--controller-apply-type',
|
|
||||||
default=sw_update.APPLY_TYPE_IGNORE,
|
|
||||||
choices=[sw_update.APPLY_TYPE_IGNORE],
|
|
||||||
help='defaults to ignore')
|
|
||||||
fw_update_create_strategy_cmd.add_argument('--storage-apply-type',
|
|
||||||
default=sw_update.APPLY_TYPE_IGNORE,
|
|
||||||
choices=[sw_update.APPLY_TYPE_IGNORE],
|
|
||||||
help='defaults to ignore')
|
|
||||||
fw_update_create_strategy_cmd.add_argument('--worker-apply-type',
|
|
||||||
default=sw_update.APPLY_TYPE_SERIAL,
|
|
||||||
choices=[sw_update.APPLY_TYPE_SERIAL,
|
|
||||||
sw_update.APPLY_TYPE_PARALLEL,
|
|
||||||
sw_update.APPLY_TYPE_IGNORE],
|
|
||||||
help='defaults to serial')
|
|
||||||
|
|
||||||
fw_update_create_strategy_cmd.add_argument(
|
|
||||||
'--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',
|
|
||||||
default=sw_update.INSTANCE_ACTION_STOP_START,
|
|
||||||
choices=[sw_update.INSTANCE_ACTION_MIGRATE,
|
|
||||||
sw_update.INSTANCE_ACTION_STOP_START],
|
|
||||||
help='defaults to stop-start')
|
|
||||||
|
|
||||||
fw_update_create_strategy_cmd.add_argument('--alarm-restrictions',
|
|
||||||
default=sw_update.ALARM_RESTRICTIONS_STRICT,
|
|
||||||
choices=[sw_update.ALARM_RESTRICTIONS_STRICT,
|
|
||||||
sw_update.ALARM_RESTRICTIONS_RELAXED],
|
|
||||||
help='defaults to strict')
|
|
||||||
|
|
||||||
fw_update_delete_strategy_cmd \
|
|
||||||
= fw_update_cmds.add_parser('delete', help='Delete a strategy')
|
|
||||||
fw_update_delete_strategy_cmd.set_defaults(cmd='delete')
|
|
||||||
fw_update_delete_strategy_cmd.add_argument(
|
|
||||||
'--force', action='store_true', help=argparse.SUPPRESS)
|
|
||||||
|
|
||||||
fw_update_apply_strategy_cmd \
|
|
||||||
= fw_update_cmds.add_parser('apply', help='Apply a strategy')
|
|
||||||
fw_update_apply_strategy_cmd.set_defaults(cmd='apply')
|
|
||||||
fw_update_apply_strategy_cmd.add_argument(
|
|
||||||
'--stage-id', default=None, help='stage identifier to apply')
|
|
||||||
|
|
||||||
fw_update_abort_strategy_cmd \
|
|
||||||
= fw_update_cmds.add_parser('abort', help='Abort a strategy')
|
|
||||||
fw_update_abort_strategy_cmd.set_defaults(cmd='abort')
|
|
||||||
fw_update_abort_strategy_cmd.add_argument(
|
|
||||||
'--stage-id', help='stage identifier to abort')
|
|
||||||
|
|
||||||
fw_update_show_strategy_cmd \
|
|
||||||
= fw_update_cmds.add_parser('show', help='Show a strategy')
|
|
||||||
fw_update_show_strategy_cmd.set_defaults(cmd='show')
|
|
||||||
fw_update_show_strategy_cmd.add_argument(
|
|
||||||
'--details', action='store_true', help='show strategy details')
|
|
||||||
|
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
@ -287,189 +470,74 @@ def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value
|
|||||||
print("Openstack interface not given")
|
print("Openstack interface not given")
|
||||||
return
|
return
|
||||||
|
|
||||||
if 'patch-strategy' == args.cmd_area:
|
strategy_name = get_strategy_name(args.cmd_area)
|
||||||
if 'create' == args.cmd:
|
if 'create' == args.cmd:
|
||||||
sw_update.create_strategy(
|
extra_create_args = get_extra_create_args(args.cmd_area, args)
|
||||||
args.os_auth_url, args.os_project_name,
|
sw_update.create_strategy(args.os_auth_url,
|
||||||
args.os_project_domain_name, args.os_username, args.os_password,
|
args.os_project_name,
|
||||||
args.os_user_domain_name, args.os_region_name,
|
args.os_project_domain_name,
|
||||||
args.os_interface,
|
args.os_username,
|
||||||
sw_update.STRATEGY_NAME_SW_PATCH,
|
args.os_password,
|
||||||
args.controller_apply_type,
|
args.os_user_domain_name,
|
||||||
args.storage_apply_type, sw_update.APPLY_TYPE_IGNORE,
|
args.os_region_name,
|
||||||
args.worker_apply_type,
|
args.os_interface,
|
||||||
args.max_parallel_worker_hosts,
|
strategy_name,
|
||||||
args.instance_action,
|
args.controller_apply_type,
|
||||||
args.alarm_restrictions)
|
args.storage_apply_type,
|
||||||
|
sw_update.APPLY_TYPE_IGNORE,
|
||||||
elif 'delete' == args.cmd:
|
args.worker_apply_type,
|
||||||
sw_update.delete_strategy(args.os_auth_url, args.os_project_name,
|
args.max_parallel_worker_hosts,
|
||||||
args.os_project_domain_name,
|
args.instance_action,
|
||||||
args.os_username, args.os_password,
|
args.alarm_restrictions,
|
||||||
args.os_user_domain_name,
|
**extra_create_args)
|
||||||
args.os_region_name, args.os_interface,
|
elif 'delete' == args.cmd:
|
||||||
sw_update.STRATEGY_NAME_SW_PATCH,
|
sw_update.delete_strategy(args.os_auth_url,
|
||||||
args.force)
|
args.os_project_name,
|
||||||
|
args.os_project_domain_name,
|
||||||
elif 'apply' == args.cmd:
|
args.os_username,
|
||||||
sw_update.apply_strategy(args.os_auth_url, args.os_project_name,
|
args.os_password,
|
||||||
args.os_project_domain_name,
|
args.os_user_domain_name,
|
||||||
args.os_username, args.os_password,
|
args.os_region_name,
|
||||||
args.os_user_domain_name,
|
args.os_interface,
|
||||||
args.os_region_name, args.os_interface,
|
strategy_name,
|
||||||
sw_update.STRATEGY_NAME_SW_PATCH,
|
force=args.force)
|
||||||
args.stage_id)
|
elif 'apply' == args.cmd:
|
||||||
|
sw_update.apply_strategy(args.os_auth_url,
|
||||||
elif 'abort' == args.cmd:
|
args.os_project_name,
|
||||||
sw_update.abort_strategy(args.os_auth_url, args.os_project_name,
|
args.os_project_domain_name,
|
||||||
args.os_project_domain_name,
|
args.os_username,
|
||||||
args.os_username, args.os_password,
|
args.os_password,
|
||||||
args.os_user_domain_name,
|
args.os_user_domain_name,
|
||||||
args.os_region_name, args.os_interface,
|
args.os_region_name,
|
||||||
sw_update.STRATEGY_NAME_SW_PATCH,
|
args.os_interface,
|
||||||
args.stage_id)
|
strategy_name,
|
||||||
|
stage_id=args.stage_id)
|
||||||
elif 'show' == args.cmd:
|
elif 'abort' == args.cmd:
|
||||||
sw_update.show_strategy(args.os_auth_url, args.os_project_name,
|
sw_update.abort_strategy(args.os_auth_url,
|
||||||
args.os_project_domain_name,
|
args.os_project_name,
|
||||||
args.os_username, args.os_password,
|
args.os_project_domain_name,
|
||||||
args.os_user_domain_name,
|
args.os_username,
|
||||||
args.os_region_name, args.os_interface,
|
args.os_password,
|
||||||
sw_update.STRATEGY_NAME_SW_PATCH,
|
args.os_user_domain_name,
|
||||||
args.details)
|
args.os_region_name,
|
||||||
|
args.os_interface,
|
||||||
else:
|
strategy_name,
|
||||||
raise ValueError("Unknown command, %s, given for patch-strategy"
|
stage_id=args.stage_id)
|
||||||
% args.cmd)
|
elif 'show' == args.cmd:
|
||||||
elif 'upgrade-strategy' == args.cmd_area:
|
sw_update.show_strategy(args.os_auth_url,
|
||||||
if 'create' == args.cmd:
|
args.os_project_name,
|
||||||
sw_update.create_strategy(
|
args.os_project_domain_name,
|
||||||
args.os_auth_url, args.os_project_name,
|
args.os_username,
|
||||||
args.os_project_domain_name, args.os_username, args.os_password,
|
args.os_password,
|
||||||
args.os_user_domain_name, args.os_region_name,
|
args.os_user_domain_name,
|
||||||
args.os_interface,
|
args.os_region_name,
|
||||||
sw_update.STRATEGY_NAME_SW_UPGRADE,
|
args.os_interface,
|
||||||
sw_update.APPLY_TYPE_IGNORE,
|
strategy_name,
|
||||||
args.storage_apply_type, sw_update.APPLY_TYPE_IGNORE,
|
details=args.details,
|
||||||
args.worker_apply_type,
|
active=args.active)
|
||||||
args.max_parallel_worker_hosts,
|
|
||||||
None, args.alarm_restrictions,
|
|
||||||
# start_upgrade=args.start_upgrade,
|
|
||||||
complete_upgrade=args.complete_upgrade
|
|
||||||
)
|
|
||||||
|
|
||||||
elif 'delete' == args.cmd:
|
|
||||||
sw_update.delete_strategy(args.os_auth_url, args.os_project_name,
|
|
||||||
args.os_project_domain_name,
|
|
||||||
args.os_username, args.os_password,
|
|
||||||
args.os_user_domain_name,
|
|
||||||
args.os_region_name, args.os_interface,
|
|
||||||
sw_update.STRATEGY_NAME_SW_UPGRADE,
|
|
||||||
args.force)
|
|
||||||
|
|
||||||
elif 'apply' == args.cmd:
|
|
||||||
sw_update.apply_strategy(args.os_auth_url, args.os_project_name,
|
|
||||||
args.os_project_domain_name,
|
|
||||||
args.os_username, args.os_password,
|
|
||||||
args.os_user_domain_name,
|
|
||||||
args.os_region_name, args.os_interface,
|
|
||||||
sw_update.STRATEGY_NAME_SW_UPGRADE,
|
|
||||||
args.stage_id)
|
|
||||||
|
|
||||||
elif 'abort' == args.cmd:
|
|
||||||
sw_update.abort_strategy(args.os_auth_url, args.os_project_name,
|
|
||||||
args.os_project_domain_name,
|
|
||||||
args.os_username, args.os_password,
|
|
||||||
args.os_user_domain_name,
|
|
||||||
args.os_region_name, args.os_interface,
|
|
||||||
sw_update.STRATEGY_NAME_SW_UPGRADE,
|
|
||||||
args.stage_id)
|
|
||||||
|
|
||||||
elif 'show' == args.cmd:
|
|
||||||
sw_update.show_strategy(args.os_auth_url, args.os_project_name,
|
|
||||||
args.os_project_domain_name,
|
|
||||||
args.os_username, args.os_password,
|
|
||||||
args.os_user_domain_name,
|
|
||||||
args.os_region_name, args.os_interface,
|
|
||||||
sw_update.STRATEGY_NAME_SW_UPGRADE,
|
|
||||||
args.details)
|
|
||||||
|
|
||||||
else:
|
|
||||||
raise ValueError("Unknown command, %s, given for upgrade-strategy"
|
|
||||||
% args.cmd)
|
|
||||||
elif 'fw-update-strategy' == args.cmd_area:
|
|
||||||
if 'create' == args.cmd:
|
|
||||||
sw_update.create_strategy(
|
|
||||||
args.os_auth_url,
|
|
||||||
args.os_project_name,
|
|
||||||
args.os_project_domain_name,
|
|
||||||
args.os_username,
|
|
||||||
args.os_password,
|
|
||||||
args.os_user_domain_name,
|
|
||||||
args.os_region_name,
|
|
||||||
args.os_interface,
|
|
||||||
sw_update.STRATEGY_NAME_FW_UPDATE,
|
|
||||||
args.controller_apply_type,
|
|
||||||
args.storage_apply_type,
|
|
||||||
sw_update.APPLY_TYPE_IGNORE,
|
|
||||||
args.worker_apply_type,
|
|
||||||
args.max_parallel_worker_hosts,
|
|
||||||
args.instance_action,
|
|
||||||
args.alarm_restrictions)
|
|
||||||
|
|
||||||
elif 'delete' == args.cmd:
|
|
||||||
sw_update.delete_strategy(args.os_auth_url,
|
|
||||||
args.os_project_name,
|
|
||||||
args.os_project_domain_name,
|
|
||||||
args.os_username,
|
|
||||||
args.os_password,
|
|
||||||
args.os_user_domain_name,
|
|
||||||
args.os_region_name,
|
|
||||||
args.os_interface,
|
|
||||||
sw_update.STRATEGY_NAME_FW_UPDATE,
|
|
||||||
args.force)
|
|
||||||
|
|
||||||
elif 'apply' == args.cmd:
|
|
||||||
sw_update.apply_strategy(args.os_auth_url,
|
|
||||||
args.os_project_name,
|
|
||||||
args.os_project_domain_name,
|
|
||||||
args.os_username,
|
|
||||||
args.os_password,
|
|
||||||
args.os_user_domain_name,
|
|
||||||
args.os_region_name,
|
|
||||||
args.os_interface,
|
|
||||||
sw_update.STRATEGY_NAME_FW_UPDATE,
|
|
||||||
args.stage_id)
|
|
||||||
|
|
||||||
elif 'abort' == args.cmd:
|
|
||||||
sw_update.abort_strategy(args.os_auth_url,
|
|
||||||
args.os_project_name,
|
|
||||||
args.os_project_domain_name,
|
|
||||||
args.os_username,
|
|
||||||
args.os_password,
|
|
||||||
args.os_user_domain_name,
|
|
||||||
args.os_region_name,
|
|
||||||
args.os_interface,
|
|
||||||
sw_update.STRATEGY_NAME_FW_UPDATE,
|
|
||||||
args.stage_id)
|
|
||||||
|
|
||||||
elif 'show' == args.cmd:
|
|
||||||
sw_update.show_strategy(args.os_auth_url,
|
|
||||||
args.os_project_name,
|
|
||||||
args.os_project_domain_name,
|
|
||||||
args.os_username,
|
|
||||||
args.os_password,
|
|
||||||
args.os_user_domain_name,
|
|
||||||
args.os_region_name,
|
|
||||||
args.os_interface,
|
|
||||||
sw_update.STRATEGY_NAME_FW_UPDATE,
|
|
||||||
args.details)
|
|
||||||
else:
|
|
||||||
raise ValueError("Unknown command, %s, "
|
|
||||||
"given for fw-update-strategy"
|
|
||||||
% args.cmd)
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown command area, %s, given" % args.cmd_area)
|
raise ValueError("Unknown command, %s, given for %s"
|
||||||
|
% (args.cmd, args.cmd_area))
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Keyboard Interrupt received.")
|
print("Keyboard Interrupt received.")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2016, 2020 Wind River Systems, Inc.
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -15,5 +15,6 @@ from nfv_client.sw_update._sw_update import INSTANCE_ACTION_MIGRATE # noqa: F40
|
|||||||
from nfv_client.sw_update._sw_update import INSTANCE_ACTION_STOP_START # noqa: F401
|
from nfv_client.sw_update._sw_update import INSTANCE_ACTION_STOP_START # noqa: F401
|
||||||
from nfv_client.sw_update._sw_update import show_strategy # noqa: F401
|
from nfv_client.sw_update._sw_update import show_strategy # noqa: F401
|
||||||
from nfv_client.sw_update._sw_update import STRATEGY_NAME_FW_UPDATE # noqa: F401
|
from nfv_client.sw_update._sw_update import STRATEGY_NAME_FW_UPDATE # noqa: F401
|
||||||
|
from nfv_client.sw_update._sw_update import STRATEGY_NAME_KUBE_UPGRADE # noqa: F401
|
||||||
from nfv_client.sw_update._sw_update import STRATEGY_NAME_SW_PATCH # noqa: F401
|
from nfv_client.sw_update._sw_update import STRATEGY_NAME_SW_PATCH # noqa: F401
|
||||||
from nfv_client.sw_update._sw_update import STRATEGY_NAME_SW_UPGRADE # noqa: F401
|
from nfv_client.sw_update._sw_update import STRATEGY_NAME_SW_UPGRADE # noqa: F401
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2016, 2020 Wind River Systems, Inc.
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -9,6 +9,7 @@ from nfv_client.openstack import sw_update
|
|||||||
STRATEGY_NAME_SW_PATCH = 'sw-patch'
|
STRATEGY_NAME_SW_PATCH = 'sw-patch'
|
||||||
STRATEGY_NAME_SW_UPGRADE = 'sw-upgrade'
|
STRATEGY_NAME_SW_UPGRADE = 'sw-upgrade'
|
||||||
STRATEGY_NAME_FW_UPDATE = 'fw-update'
|
STRATEGY_NAME_FW_UPDATE = 'fw-update'
|
||||||
|
STRATEGY_NAME_KUBE_UPGRADE = 'kube-upgrade'
|
||||||
|
|
||||||
APPLY_TYPE_SERIAL = 'serial'
|
APPLY_TYPE_SERIAL = 'serial'
|
||||||
APPLY_TYPE_PARALLEL = 'parallel'
|
APPLY_TYPE_PARALLEL = 'parallel'
|
||||||
@ -27,10 +28,16 @@ def _print(indent_by, field, value, remains=''):
|
|||||||
remains))
|
remains))
|
||||||
|
|
||||||
|
|
||||||
def _display_strategy_step(strategy_step):
|
def _display_strategy_step(strategy_step, active=False):
|
||||||
"""
|
"""
|
||||||
Software Update - Display Strategy Step Information
|
Software Update - Display Strategy Step Information
|
||||||
"""
|
"""
|
||||||
|
# If active flag is passed
|
||||||
|
# skip steps that are not started:'initial' or completed cleanly: 'success'
|
||||||
|
# this leaves failed and in-progress states
|
||||||
|
if active:
|
||||||
|
if strategy_step.result in ['initial', 'success']:
|
||||||
|
return False
|
||||||
_print(12, "step-id", strategy_step.step_id)
|
_print(12, "step-id", strategy_step.step_id)
|
||||||
_print(12, "step-name", strategy_step.step_name)
|
_print(12, "step-name", strategy_step.step_name)
|
||||||
if 0 < len(strategy_step.entity_type):
|
if 0 < len(strategy_step.entity_type):
|
||||||
@ -46,12 +53,17 @@ def _display_strategy_step(strategy_step):
|
|||||||
_print(12, "end-date-time", strategy_step.end_date_time)
|
_print(12, "end-date-time", strategy_step.end_date_time)
|
||||||
_print(12, "result", strategy_step.result)
|
_print(12, "result", strategy_step.result)
|
||||||
_print(12, "reason", strategy_step.reason)
|
_print(12, "reason", strategy_step.reason)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _display_strategy_stage(strategy_stage, details=False):
|
def _display_strategy_stage(strategy_stage, details=False, active=False):
|
||||||
"""
|
"""
|
||||||
Software Update - Display Strategy Stage Information
|
Software Update - Display Strategy Stage Information
|
||||||
"""
|
"""
|
||||||
|
# If active flag is passed, only display a stage that is in progress
|
||||||
|
if active:
|
||||||
|
if not strategy_stage.inprogress:
|
||||||
|
return False
|
||||||
_print(8, "stage-id", strategy_stage.stage_id)
|
_print(8, "stage-id", strategy_stage.stage_id)
|
||||||
_print(8, "stage-name", strategy_stage.stage_name)
|
_print(8, "stage-name", strategy_stage.stage_name)
|
||||||
_print(8, "total-steps", strategy_stage.total_steps)
|
_print(8, "total-steps", strategy_stage.total_steps)
|
||||||
@ -65,17 +77,22 @@ def _display_strategy_stage(strategy_stage, details=False):
|
|||||||
_print(8, "result", strategy_stage.result)
|
_print(8, "result", strategy_stage.result)
|
||||||
_print(8, "reason", strategy_stage.reason)
|
_print(8, "reason", strategy_stage.reason)
|
||||||
|
|
||||||
if details:
|
if details or active:
|
||||||
print(" steps:")
|
print(" steps:")
|
||||||
for step in strategy_stage.steps:
|
for step in strategy_stage.steps:
|
||||||
_display_strategy_step(step)
|
if _display_strategy_step(step, active):
|
||||||
print("")
|
print("")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _display_strategy_phase(strategy_phase, details=False):
|
def _display_strategy_phase(strategy_phase, details=False, active=False):
|
||||||
"""
|
"""
|
||||||
Software Update - Display Strategy Phase Information
|
Software Update - Display Strategy Phase Information
|
||||||
"""
|
"""
|
||||||
|
# If active flag is passed, only display a phase that is in progress
|
||||||
|
if active:
|
||||||
|
if not strategy_phase.inprogress:
|
||||||
|
return
|
||||||
print(" %s-phase:" % strategy_phase.phase_name)
|
print(" %s-phase:" % strategy_phase.phase_name)
|
||||||
_print(4, "total-stages", strategy_phase.total_stages)
|
_print(4, "total-stages", strategy_phase.total_stages)
|
||||||
_print(4, "current-stage", strategy_phase.current_stage)
|
_print(4, "current-stage", strategy_phase.current_stage)
|
||||||
@ -91,14 +108,14 @@ def _display_strategy_phase(strategy_phase, details=False):
|
|||||||
_print(4, "result", strategy_phase.result)
|
_print(4, "result", strategy_phase.result)
|
||||||
_print(4, "reason", strategy_phase.reason)
|
_print(4, "reason", strategy_phase.reason)
|
||||||
|
|
||||||
if details:
|
if details or active:
|
||||||
print(" stages:")
|
print(" stages:")
|
||||||
for stage in strategy_phase.stages:
|
for stage in strategy_phase.stages:
|
||||||
_display_strategy_stage(stage, details)
|
if _display_strategy_stage(stage, details, active):
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
def _display_strategy(strategy, details=False):
|
def _display_strategy(strategy, details=False, active=False):
|
||||||
"""
|
"""
|
||||||
Software Update - Display Strategy Information
|
Software Update - Display Strategy Information
|
||||||
"""
|
"""
|
||||||
@ -108,6 +125,8 @@ def _display_strategy(strategy, details=False):
|
|||||||
print("Strategy Upgrade Strategy:")
|
print("Strategy Upgrade Strategy:")
|
||||||
elif strategy.name == STRATEGY_NAME_FW_UPDATE:
|
elif strategy.name == STRATEGY_NAME_FW_UPDATE:
|
||||||
print("Strategy Firmware Update Strategy:")
|
print("Strategy Firmware Update Strategy:")
|
||||||
|
elif strategy.name == STRATEGY_NAME_KUBE_UPGRADE:
|
||||||
|
print("Strategy Kubernetes Upgrade Strategy:")
|
||||||
else:
|
else:
|
||||||
print("Strategy Unknown Strategy:")
|
print("Strategy Unknown Strategy:")
|
||||||
|
|
||||||
@ -125,15 +144,15 @@ def _display_strategy(strategy, details=False):
|
|||||||
("%s%%" % strategy.current_phase_completion_percentage))
|
("%s%%" % strategy.current_phase_completion_percentage))
|
||||||
_print(2, "state", strategy.state)
|
_print(2, "state", strategy.state)
|
||||||
|
|
||||||
if details:
|
if details or active:
|
||||||
if 0 < strategy.build_phase.total_stages:
|
if 0 < strategy.build_phase.total_stages:
|
||||||
_display_strategy_phase(strategy.build_phase, details)
|
_display_strategy_phase(strategy.build_phase, details, active)
|
||||||
|
|
||||||
if 0 < strategy.apply_phase.total_stages:
|
if 0 < strategy.apply_phase.total_stages:
|
||||||
_display_strategy_phase(strategy.apply_phase, details)
|
_display_strategy_phase(strategy.apply_phase, details, active)
|
||||||
|
|
||||||
if 0 < strategy.abort_phase.total_stages:
|
if 0 < strategy.abort_phase.total_stages:
|
||||||
_display_strategy_phase(strategy.abort_phase, details)
|
_display_strategy_phase(strategy.abort_phase, details, active)
|
||||||
else:
|
else:
|
||||||
if strategy.current_phase == strategy.build_phase.phase_name:
|
if strategy.current_phase == strategy.build_phase.phase_name:
|
||||||
if strategy.build_phase.inprogress:
|
if strategy.build_phase.inprogress:
|
||||||
@ -273,7 +292,7 @@ def abort_strategy(os_auth_uri, os_project_name, os_project_domain_name,
|
|||||||
|
|
||||||
def show_strategy(os_auth_uri, os_project_name, os_project_domain_name,
|
def show_strategy(os_auth_uri, os_project_name, os_project_domain_name,
|
||||||
os_username, os_password, os_user_domain_name, os_region_name,
|
os_username, os_password, os_user_domain_name, os_region_name,
|
||||||
os_interface, strategy_name, details=False):
|
os_interface, strategy_name, details=False, active=False):
|
||||||
"""
|
"""
|
||||||
Software Update - Show Strategy
|
Software Update - Show Strategy
|
||||||
"""
|
"""
|
||||||
@ -292,4 +311,4 @@ def show_strategy(os_auth_uri, os_project_name, os_project_domain_name,
|
|||||||
print("No strategy available")
|
print("No strategy available")
|
||||||
return
|
return
|
||||||
|
|
||||||
_display_strategy(strategy, details)
|
_display_strategy(strategy, details, active)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2016-2017 Wind River Systems, Inc.
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -22,6 +22,7 @@ function _swmanager()
|
|||||||
patch-strategy
|
patch-strategy
|
||||||
upgrade-strategy
|
upgrade-strategy
|
||||||
fw-update-strategy
|
fw-update-strategy
|
||||||
|
kube-upgrade-strategy
|
||||||
"
|
"
|
||||||
|
|
||||||
if [ $COMP_CWORD -gt 1 ]; then
|
if [ $COMP_CWORD -gt 1 ]; then
|
||||||
@ -88,7 +89,7 @@ function _swmanager()
|
|||||||
;;
|
;;
|
||||||
show)
|
show)
|
||||||
if [ "${prev}" = "${action}" ]; then
|
if [ "${prev}" = "${action}" ]; then
|
||||||
COMPREPLY=($(compgen -W "--details" -- ${cur}))
|
COMPREPLY=($(compgen -W "--details --active" -- ${cur}))
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
@ -159,7 +160,7 @@ function _swmanager()
|
|||||||
;;
|
;;
|
||||||
show)
|
show)
|
||||||
if [ "${prev}" = "${action}" ]; then
|
if [ "${prev}" = "${action}" ]; then
|
||||||
COMPREPLY=($(compgen -W "--details" -- ${cur}))
|
COMPREPLY=($(compgen -W "--details --active" -- ${cur}))
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
@ -236,7 +237,89 @@ function _swmanager()
|
|||||||
;;
|
;;
|
||||||
show)
|
show)
|
||||||
if [ "${prev}" = "${action}" ]; then
|
if [ "${prev}" = "${action}" ]; then
|
||||||
COMPREPLY=($(compgen -W "--details" -- ${cur}))
|
COMPREPLY=($(compgen -W "--details --active" -- ${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
|
||||||
|
;;
|
||||||
|
kube-upgrade-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
|
||||||
|
--to-version
|
||||||
|
"
|
||||||
|
local createopt=${prev}
|
||||||
|
case "$createopt" in
|
||||||
|
--controller-apply-type|--storage-apply-type)
|
||||||
|
COMPREPLY=($(compgen -W "serial" -- ${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
|
||||||
|
;;
|
||||||
|
--to-version)
|
||||||
|
COMPREPLY=( $(compgen -- ${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 --active" -- ${cur}))
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -44,6 +44,9 @@ class _AlarmType(Constants):
|
|||||||
FW_UPDATE_AUTO_APPLY_INPROGRESS = Constant('fw-update-auto-apply-inprogress')
|
FW_UPDATE_AUTO_APPLY_INPROGRESS = Constant('fw-update-auto-apply-inprogress')
|
||||||
FW_UPDATE_AUTO_APPLY_ABORTING = Constant('fw-update-auto-apply-aborting')
|
FW_UPDATE_AUTO_APPLY_ABORTING = Constant('fw-update-auto-apply-aborting')
|
||||||
FW_UPDATE_AUTO_APPLY_FAILED = Constant('fw-update-auto-apply-failed')
|
FW_UPDATE_AUTO_APPLY_FAILED = Constant('fw-update-auto-apply-failed')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_INPROGRESS = Constant('kube-upgrade-auto-apply-inprogress')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_ABORTING = Constant('kube-upgrade-auto-apply-aborting')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_FAILED = Constant('kube-upgrade-auto-apply-failed')
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(Singleton)
|
@six.add_metaclass(Singleton)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -171,6 +171,17 @@ class _EventId(Constants):
|
|||||||
FW_UPDATE_AUTO_APPLY_ABORT_REJECTED = Constant('fw-update-auto-apply-abort-rejected')
|
FW_UPDATE_AUTO_APPLY_ABORT_REJECTED = Constant('fw-update-auto-apply-abort-rejected')
|
||||||
FW_UPDATE_AUTO_APPLY_ABORT_FAILED = Constant('fw-update-auto-apply-abort-failed')
|
FW_UPDATE_AUTO_APPLY_ABORT_FAILED = Constant('fw-update-auto-apply-abort-failed')
|
||||||
FW_UPDATE_AUTO_APPLY_ABORTED = Constant('fw-update-auto-apply-aborted')
|
FW_UPDATE_AUTO_APPLY_ABORTED = Constant('fw-update-auto-apply-aborted')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_START = Constant('kube-upgrade-auto-apply-started')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_INPROGRESS = Constant('kube-upgrade-auto-apply-inprogress')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_REJECTED = Constant('kube-upgrade-auto-apply-rejected')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_CANCELLED = Constant('kube-upgrade-auto-apply-cancelled')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_FAILED = Constant('kube-upgrade-auto-apply-failed')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_COMPLETED = Constant('kube-upgrade-auto-apply-completed')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_ABORT = Constant('kube-upgrade-auto-apply-abort')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_ABORTING = Constant('kube-upgrade-auto-apply-aborting')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_ABORT_REJECTED = Constant('kube-upgrade-auto-apply-abort-rejected')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_ABORT_FAILED = Constant('kube-upgrade-auto-apply-abort-failed')
|
||||||
|
KUBE_UPGRADE_AUTO_APPLY_ABORTED = Constant('kube-upgrade-auto-apply-aborted')
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(Singleton)
|
@six.add_metaclass(Singleton)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -324,6 +324,8 @@ class StrategyStage(object):
|
|||||||
self._step_timer_id = None
|
self._step_timer_id = None
|
||||||
|
|
||||||
step.start_date_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
step.start_date_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
DLOG.debug("Stage (%s) Step (%s) (apply) called"
|
||||||
|
% (self.name, step.name))
|
||||||
step.result, step.result_reason = step.apply()
|
step.result, step.result_reason = step.apply()
|
||||||
self._current_step = idx
|
self._current_step = idx
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -78,6 +78,12 @@ _fm_alarm_id_mapping = dict([
|
|||||||
fm_constants.FM_ALARM_ID_FW_UPDATE_AUTO_APPLY_ABORTING),
|
fm_constants.FM_ALARM_ID_FW_UPDATE_AUTO_APPLY_ABORTING),
|
||||||
(alarm_objects_v1.ALARM_TYPE.FW_UPDATE_AUTO_APPLY_FAILED,
|
(alarm_objects_v1.ALARM_TYPE.FW_UPDATE_AUTO_APPLY_FAILED,
|
||||||
fm_constants.FM_ALARM_ID_FW_UPDATE_AUTO_APPLY_FAILED),
|
fm_constants.FM_ALARM_ID_FW_UPDATE_AUTO_APPLY_FAILED),
|
||||||
|
(alarm_objects_v1.ALARM_TYPE.KUBE_UPGRADE_AUTO_APPLY_INPROGRESS,
|
||||||
|
fm_constants.FM_ALARM_ID_KUBE_UPGRADE_AUTO_APPLY_INPROGRESS),
|
||||||
|
(alarm_objects_v1.ALARM_TYPE.KUBE_UPGRADE_AUTO_APPLY_ABORTING,
|
||||||
|
fm_constants.FM_ALARM_ID_KUBE_UPGRADE_AUTO_APPLY_ABORTING),
|
||||||
|
(alarm_objects_v1.ALARM_TYPE.KUBE_UPGRADE_AUTO_APPLY_FAILED,
|
||||||
|
fm_constants.FM_ALARM_ID_KUBE_UPGRADE_AUTO_APPLY_FAILED),
|
||||||
])
|
])
|
||||||
|
|
||||||
_fm_alarm_type_mapping = dict([
|
_fm_alarm_type_mapping = dict([
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2016,2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -334,6 +334,28 @@ _fm_event_id_mapping = dict([
|
|||||||
fm_constants.FM_LOG_ID_FW_UPDATE_AUTO_APPLY_ABORT_FAILED),
|
fm_constants.FM_LOG_ID_FW_UPDATE_AUTO_APPLY_ABORT_FAILED),
|
||||||
(event_log_objects_v1.EVENT_ID.FW_UPDATE_AUTO_APPLY_ABORTED,
|
(event_log_objects_v1.EVENT_ID.FW_UPDATE_AUTO_APPLY_ABORTED,
|
||||||
fm_constants.FM_LOG_ID_FW_UPDATE_AUTO_APPLY_ABORTED),
|
fm_constants.FM_LOG_ID_FW_UPDATE_AUTO_APPLY_ABORTED),
|
||||||
|
(event_log_objects_v1.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_START,
|
||||||
|
fm_constants.FM_LOG_ID_KUBE_UPGRADE_AUTO_APPLY_START),
|
||||||
|
(event_log_objects_v1.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_INPROGRESS,
|
||||||
|
fm_constants.FM_LOG_ID_KUBE_UPGRADE_AUTO_APPLY_INPROGRESS),
|
||||||
|
(event_log_objects_v1.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_REJECTED,
|
||||||
|
fm_constants.FM_LOG_ID_KUBE_UPGRADE_AUTO_APPLY_REJECTED),
|
||||||
|
(event_log_objects_v1.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_CANCELLED,
|
||||||
|
fm_constants.FM_LOG_ID_KUBE_UPGRADE_AUTO_APPLY_CANCELLED),
|
||||||
|
(event_log_objects_v1.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_FAILED,
|
||||||
|
fm_constants.FM_LOG_ID_KUBE_UPGRADE_AUTO_APPLY_FAILED),
|
||||||
|
(event_log_objects_v1.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_COMPLETED,
|
||||||
|
fm_constants.FM_LOG_ID_KUBE_UPGRADE_AUTO_APPLY_COMPLETED),
|
||||||
|
(event_log_objects_v1.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORT,
|
||||||
|
fm_constants.FM_LOG_ID_KUBE_UPGRADE_AUTO_APPLY_ABORT),
|
||||||
|
(event_log_objects_v1.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORTING,
|
||||||
|
fm_constants.FM_LOG_ID_KUBE_UPGRADE_AUTO_APPLY_ABORTING),
|
||||||
|
(event_log_objects_v1.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORT_REJECTED,
|
||||||
|
fm_constants.FM_LOG_ID_KUBE_UPGRADE_AUTO_APPLY_ABORT_REJECTED),
|
||||||
|
(event_log_objects_v1.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORT_FAILED,
|
||||||
|
fm_constants.FM_LOG_ID_KUBE_UPGRADE_AUTO_APPLY_ABORT_FAILED),
|
||||||
|
(event_log_objects_v1.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORTED,
|
||||||
|
fm_constants.FM_LOG_ID_KUBE_UPGRADE_AUTO_APPLY_ABORTED),
|
||||||
])
|
])
|
||||||
|
|
||||||
_fm_event_type_mapping = dict([
|
_fm_event_type_mapping = dict([
|
||||||
|
@ -124,3 +124,4 @@ neutron.delete_host_services=40
|
|||||||
glance.upload_image_data_by_file=180
|
glance.upload_image_data_by_file=180
|
||||||
glance.upload_image_data_by_url=180
|
glance.upload_image_data_by_url=180
|
||||||
sysinv=45
|
sysinv=45
|
||||||
|
patching.apply_patch=180
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -839,6 +839,704 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
callback.send(response)
|
callback.send(response)
|
||||||
callback.close()
|
callback.close()
|
||||||
|
|
||||||
|
def _extract_kube_host_upgrade_list(self,
|
||||||
|
kube_host_upgrade_list,
|
||||||
|
host_list):
|
||||||
|
"""
|
||||||
|
Return a list of KubeHostUpgrade objects from sysinv api results.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Map the ID to the uuid from host_list
|
||||||
|
host_map = dict()
|
||||||
|
for host in host_list:
|
||||||
|
host_map[host['id']] = host['uuid']
|
||||||
|
result_list = []
|
||||||
|
for host_data in kube_host_upgrade_list:
|
||||||
|
host_uuid = host_map[host_data['host_id']]
|
||||||
|
result_list.append(
|
||||||
|
nfvi.objects.v1.KubeHostUpgrade(
|
||||||
|
host_data['host_id'],
|
||||||
|
host_uuid,
|
||||||
|
host_data['target_version'],
|
||||||
|
host_data['control_plane_version'],
|
||||||
|
host_data['kubelet_version'],
|
||||||
|
host_data['status'])
|
||||||
|
)
|
||||||
|
return result_list
|
||||||
|
|
||||||
|
def get_kube_host_upgrade_list(self, future, callback):
|
||||||
|
"""
|
||||||
|
Get information about the kube host upgrade list from the plugin
|
||||||
|
"""
|
||||||
|
response = dict()
|
||||||
|
response['completed'] = False
|
||||||
|
response['reason'] = ''
|
||||||
|
|
||||||
|
activity = "SysInv get-kube-host-upgrades"
|
||||||
|
|
||||||
|
try:
|
||||||
|
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||||
|
|
||||||
|
if self._platform_token is None or \
|
||||||
|
self._platform_token.is_expired():
|
||||||
|
future.work(openstack.get_token, self._platform_directory)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete() or \
|
||||||
|
future.result.data is None:
|
||||||
|
DLOG.error("OpenStack get-token did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._platform_token = future.result.data
|
||||||
|
|
||||||
|
# Query the kube host upgrade list
|
||||||
|
future.work(sysinv.get_kube_host_upgrades, self._platform_token)
|
||||||
|
future.result = (yield)
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("Sysinv Get Kube Host Upgrades did not complete.")
|
||||||
|
return
|
||||||
|
kube_host_upgrade_list = future.result.data["kube_host_upgrades"]
|
||||||
|
|
||||||
|
# Also query the host list, kube_host_upgrades does not have uuid
|
||||||
|
future.work(sysinv.get_hosts, self._platform_token)
|
||||||
|
future.result = (yield)
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("Sysinv Get-Hosts did not complete.")
|
||||||
|
return
|
||||||
|
host_list = future.result.data["ihosts"]
|
||||||
|
|
||||||
|
results_obj = \
|
||||||
|
self._extract_kube_host_upgrade_list(kube_host_upgrade_list,
|
||||||
|
host_list)
|
||||||
|
response['result-data'] = results_obj
|
||||||
|
response['completed'] = True
|
||||||
|
|
||||||
|
except exceptions.OpenStackRestAPIException as e:
|
||||||
|
if httplib.UNAUTHORIZED == e.http_status_code:
|
||||||
|
response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED
|
||||||
|
if self._platform_token is not None:
|
||||||
|
self._platform_token.set_expired()
|
||||||
|
|
||||||
|
else:
|
||||||
|
DLOG.exception("Caught exception kube host upgrade list err=%s"
|
||||||
|
% e)
|
||||||
|
except Exception as e:
|
||||||
|
DLOG.exception("Caught exception kube host upgrade list err=%s"
|
||||||
|
% e)
|
||||||
|
finally:
|
||||||
|
callback.send(response)
|
||||||
|
callback.close()
|
||||||
|
|
||||||
|
def _extract_kube_upgrade(self, kube_upgrade_data_list):
|
||||||
|
"""
|
||||||
|
Return a KubeUpgrade object from sysinv api results.
|
||||||
|
|
||||||
|
Returns None if there are no items in the list.
|
||||||
|
Returns first kube upgrade object, but the API should never return
|
||||||
|
more than one object.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if 1 < len(kube_upgrade_data_list):
|
||||||
|
DLOG.critical("Too many kube upgrades returned, num=%i"
|
||||||
|
% len(kube_upgrade_data_list))
|
||||||
|
|
||||||
|
elif 0 == len(kube_upgrade_data_list):
|
||||||
|
DLOG.info("No kube upgrade exists, num=%i"
|
||||||
|
% len(kube_upgrade_data_list))
|
||||||
|
|
||||||
|
kube_upgrade_obj = None
|
||||||
|
for kube_upgrade_data in kube_upgrade_data_list:
|
||||||
|
kube_upgrade_obj = nfvi.objects.v1.KubeUpgrade(
|
||||||
|
kube_upgrade_data['state'],
|
||||||
|
kube_upgrade_data['from_version'],
|
||||||
|
kube_upgrade_data['to_version'])
|
||||||
|
break
|
||||||
|
return kube_upgrade_obj
|
||||||
|
|
||||||
|
def get_kube_upgrade(self, future, callback):
|
||||||
|
"""
|
||||||
|
Get information about the kube upgrade from the plugin
|
||||||
|
"""
|
||||||
|
response = dict()
|
||||||
|
response['completed'] = False
|
||||||
|
response['reason'] = ''
|
||||||
|
action_type = 'get-kube-upgrade'
|
||||||
|
|
||||||
|
try:
|
||||||
|
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||||
|
|
||||||
|
if self._platform_token is None or \
|
||||||
|
self._platform_token.is_expired():
|
||||||
|
future.work(openstack.get_token, self._platform_directory)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete() or \
|
||||||
|
future.result.data is None:
|
||||||
|
DLOG.error("OpenStack get-token did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._platform_token = future.result.data
|
||||||
|
|
||||||
|
future.work(sysinv.get_kube_upgrade, self._platform_token)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("SysInv get-kube-upgrade did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
kube_upgrade_data_list = future.result.data['kube_upgrades']
|
||||||
|
kube_upgrade_obj = \
|
||||||
|
self._extract_kube_upgrade(kube_upgrade_data_list)
|
||||||
|
response['result-data'] = kube_upgrade_obj
|
||||||
|
response['completed'] = True
|
||||||
|
|
||||||
|
except exceptions.OpenStackRestAPIException as e:
|
||||||
|
if httplib.UNAUTHORIZED == e.http_status_code:
|
||||||
|
response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED
|
||||||
|
if self._platform_token is not None:
|
||||||
|
self._platform_token.set_expired()
|
||||||
|
|
||||||
|
else:
|
||||||
|
DLOG.exception("Caught API exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
DLOG.exception("Caught exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
callback.send(response)
|
||||||
|
callback.close()
|
||||||
|
|
||||||
|
def _extract_kube_version(self, kube_data):
|
||||||
|
"""
|
||||||
|
Return a KubeVersion from sysinv API results.
|
||||||
|
"""
|
||||||
|
# sysinv api returns a field called 'version' which is a reserved field
|
||||||
|
# in vim object data structure. It is stored as kube_version
|
||||||
|
return nfvi.objects.v1.KubeVersion(kube_data['version'],
|
||||||
|
kube_data['state'],
|
||||||
|
kube_data['target'],
|
||||||
|
kube_data['upgrade_from'],
|
||||||
|
kube_data['downgrade_to'],
|
||||||
|
kube_data['applied_patches'],
|
||||||
|
kube_data['available_patches'])
|
||||||
|
|
||||||
|
def get_kube_version_list(self, future, callback):
|
||||||
|
"""
|
||||||
|
Get information about the kube versions list from the plugin
|
||||||
|
"""
|
||||||
|
response = dict()
|
||||||
|
response['completed'] = False
|
||||||
|
response['reason'] = ''
|
||||||
|
action_type = 'get-kube-versions'
|
||||||
|
|
||||||
|
try:
|
||||||
|
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||||
|
if self._platform_token is None or \
|
||||||
|
self._platform_token.is_expired():
|
||||||
|
future.work(openstack.get_token, self._platform_directory)
|
||||||
|
future.result = (yield)
|
||||||
|
if not future.result.is_complete() or \
|
||||||
|
future.result.data is None:
|
||||||
|
DLOG.error("OpenStack get-token did not complete.")
|
||||||
|
return
|
||||||
|
self._platform_token = future.result.data
|
||||||
|
|
||||||
|
# get_kube_versions only returns a limited amount of data about the
|
||||||
|
# kubernetes versions. Individual API calls get the patch info.
|
||||||
|
future.work(sysinv.get_kube_versions, self._platform_token)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("%s did not complete." % action_type)
|
||||||
|
return
|
||||||
|
|
||||||
|
# walk the list of versions and get the patch info
|
||||||
|
kube_versions_list = list()
|
||||||
|
limited_kube_version_list = future.result.data['kube_versions']
|
||||||
|
for kube_list_entry in limited_kube_version_list:
|
||||||
|
kube_ver = kube_list_entry['version']
|
||||||
|
future.work(sysinv.get_kube_version,
|
||||||
|
self._platform_token,
|
||||||
|
kube_ver)
|
||||||
|
future.result = (yield)
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("%s for version:%s did not complete."
|
||||||
|
% (action_type, kube_ver))
|
||||||
|
return
|
||||||
|
# returns a single object
|
||||||
|
kube_ver_data = future.result.data
|
||||||
|
kube_versions_list.append(
|
||||||
|
self._extract_kube_version(kube_ver_data))
|
||||||
|
|
||||||
|
response['result-data'] = kube_versions_list
|
||||||
|
response['completed'] = True
|
||||||
|
|
||||||
|
except exceptions.OpenStackRestAPIException as e:
|
||||||
|
if httplib.UNAUTHORIZED == e.http_status_code:
|
||||||
|
response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED
|
||||||
|
if self._platform_token is not None:
|
||||||
|
self._platform_token.set_expired()
|
||||||
|
else:
|
||||||
|
DLOG.exception("Caught API exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
except Exception as e:
|
||||||
|
DLOG.exception("Caught exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
finally:
|
||||||
|
callback.send(response)
|
||||||
|
callback.close()
|
||||||
|
|
||||||
|
def kube_host_upgrade_control_plane(self,
|
||||||
|
future,
|
||||||
|
host_uuid,
|
||||||
|
host_name,
|
||||||
|
force,
|
||||||
|
callback):
|
||||||
|
"""
|
||||||
|
Start kube host upgrade 'control plane' for a particular controller
|
||||||
|
"""
|
||||||
|
response = dict()
|
||||||
|
response['completed'] = False
|
||||||
|
response['host_uuid'] = host_uuid
|
||||||
|
response['host_name'] = host_name
|
||||||
|
response['reason'] = ''
|
||||||
|
action_type = 'kube-host-upgrade-control-plane'
|
||||||
|
sysinv_method = sysinv.kube_host_upgrade_control_plane
|
||||||
|
|
||||||
|
try:
|
||||||
|
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||||
|
|
||||||
|
if self._platform_token is None or \
|
||||||
|
self._platform_token.is_expired():
|
||||||
|
future.work(openstack.get_token, self._platform_directory)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete() or \
|
||||||
|
future.result.data is None:
|
||||||
|
DLOG.error("OpenStack get-token did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._platform_token = future.result.data
|
||||||
|
|
||||||
|
# invoke the actual kube_host_upgrade method
|
||||||
|
future.work(sysinv_method,
|
||||||
|
self._platform_token,
|
||||||
|
host_uuid,
|
||||||
|
force)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("%s did not complete." % action_type)
|
||||||
|
return
|
||||||
|
# result was a host object. Need to query to get kube upgrade obj
|
||||||
|
future.work(sysinv.get_kube_upgrade, self._platform_token)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("SysInv get-kube-upgrade did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
kube_upgrade_data_list = future.result.data['kube_upgrades']
|
||||||
|
kube_upgrade_obj = \
|
||||||
|
self._extract_kube_upgrade(kube_upgrade_data_list)
|
||||||
|
response['result-data'] = kube_upgrade_obj
|
||||||
|
response['completed'] = True
|
||||||
|
|
||||||
|
except exceptions.OpenStackRestAPIException as e:
|
||||||
|
if httplib.UNAUTHORIZED == e.http_status_code:
|
||||||
|
response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED
|
||||||
|
if self._platform_token is not None:
|
||||||
|
self._platform_token.set_expired()
|
||||||
|
|
||||||
|
else:
|
||||||
|
DLOG.exception("Caught API exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
response['reason'] = e.http_response_reason
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
DLOG.exception("Caught exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
callback.send(response)
|
||||||
|
callback.close()
|
||||||
|
|
||||||
|
def kube_host_upgrade_kubelet(self,
|
||||||
|
future,
|
||||||
|
host_uuid,
|
||||||
|
host_name,
|
||||||
|
force,
|
||||||
|
callback):
|
||||||
|
"""
|
||||||
|
Start kube host upgrade 'kubelet' for a particular host
|
||||||
|
"""
|
||||||
|
response = dict()
|
||||||
|
response['completed'] = False
|
||||||
|
response['host_uuid'] = host_uuid
|
||||||
|
response['host_name'] = host_name
|
||||||
|
response['reason'] = ''
|
||||||
|
action_type = 'kube-host-upgrade-kubelet'
|
||||||
|
sysinv_method = sysinv.kube_host_upgrade_kubelet
|
||||||
|
|
||||||
|
try:
|
||||||
|
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||||
|
|
||||||
|
if self._platform_token is None or \
|
||||||
|
self._platform_token.is_expired():
|
||||||
|
future.work(openstack.get_token, self._platform_directory)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete() or \
|
||||||
|
future.result.data is None:
|
||||||
|
DLOG.error("OpenStack get-token did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._platform_token = future.result.data
|
||||||
|
|
||||||
|
# invoke the actual kube_host_upgrade method
|
||||||
|
future.work(sysinv_method,
|
||||||
|
self._platform_token,
|
||||||
|
host_uuid,
|
||||||
|
force)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("%s did not complete." % action_type)
|
||||||
|
return
|
||||||
|
# result was a host object. Need to query to get kube upgrade obj
|
||||||
|
future.work(sysinv.get_kube_upgrade, self._platform_token)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("SysInv get-kube-upgrade did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
kube_upgrade_data_list = future.result.data['kube_upgrades']
|
||||||
|
kube_upgrade_obj = \
|
||||||
|
self._extract_kube_upgrade(kube_upgrade_data_list)
|
||||||
|
response['result-data'] = kube_upgrade_obj
|
||||||
|
response['completed'] = True
|
||||||
|
|
||||||
|
except exceptions.OpenStackRestAPIException as e:
|
||||||
|
if httplib.UNAUTHORIZED == e.http_status_code:
|
||||||
|
response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED
|
||||||
|
if self._platform_token is not None:
|
||||||
|
self._platform_token.set_expired()
|
||||||
|
|
||||||
|
else:
|
||||||
|
DLOG.exception("Caught API exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
response['reason'] = e.http_response_reason
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
DLOG.exception("Caught exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
callback.send(response)
|
||||||
|
callback.close()
|
||||||
|
|
||||||
|
def kube_upgrade_cleanup(self, future, callback):
|
||||||
|
"""
|
||||||
|
kube upgrade cleanup
|
||||||
|
"""
|
||||||
|
response = dict()
|
||||||
|
response['completed'] = False
|
||||||
|
response['reason'] = ''
|
||||||
|
action_type = 'kube-upgrade-cleanup'
|
||||||
|
|
||||||
|
try:
|
||||||
|
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||||
|
|
||||||
|
if self._platform_token is None or \
|
||||||
|
self._platform_token.is_expired():
|
||||||
|
future.work(openstack.get_token, self._platform_directory)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete() or \
|
||||||
|
future.result.data is None:
|
||||||
|
DLOG.error("OpenStack get-token did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._platform_token = future.result.data
|
||||||
|
|
||||||
|
future.work(sysinv.kube_upgrade_cleanup, self._platform_token)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("%s did not complete." % action_type)
|
||||||
|
return
|
||||||
|
|
||||||
|
# The result should be empty. no result data to report back
|
||||||
|
response['completed'] = True
|
||||||
|
|
||||||
|
except exceptions.OpenStackRestAPIException as e:
|
||||||
|
if httplib.UNAUTHORIZED == e.http_status_code:
|
||||||
|
response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED
|
||||||
|
if self._platform_token is not None:
|
||||||
|
self._platform_token.set_expired()
|
||||||
|
|
||||||
|
else:
|
||||||
|
DLOG.exception("Caught API exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
response['reason'] = e.http_response_reason
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
DLOG.exception("Caught exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
callback.send(response)
|
||||||
|
callback.close()
|
||||||
|
|
||||||
|
def kube_upgrade_complete(self, future, callback):
|
||||||
|
"""
|
||||||
|
kube upgrade complete
|
||||||
|
"""
|
||||||
|
response = dict()
|
||||||
|
response['completed'] = False
|
||||||
|
response['reason'] = ''
|
||||||
|
action_type = 'kube-upgrade-complete'
|
||||||
|
|
||||||
|
try:
|
||||||
|
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||||
|
|
||||||
|
if self._platform_token is None or \
|
||||||
|
self._platform_token.is_expired():
|
||||||
|
future.work(openstack.get_token, self._platform_directory)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete() or \
|
||||||
|
future.result.data is None:
|
||||||
|
DLOG.error("OpenStack get-token did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._platform_token = future.result.data
|
||||||
|
|
||||||
|
future.work(sysinv.kube_upgrade_complete, self._platform_token)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("%s did not complete." % action_type)
|
||||||
|
return
|
||||||
|
|
||||||
|
kube_upgrade_data = future.result.data
|
||||||
|
kube_upgrade_obj = nfvi.objects.v1.KubeUpgrade(
|
||||||
|
kube_upgrade_data['state'],
|
||||||
|
kube_upgrade_data['from_version'],
|
||||||
|
kube_upgrade_data['to_version'])
|
||||||
|
|
||||||
|
response['result-data'] = kube_upgrade_obj
|
||||||
|
response['completed'] = True
|
||||||
|
|
||||||
|
except exceptions.OpenStackRestAPIException as e:
|
||||||
|
if httplib.UNAUTHORIZED == e.http_status_code:
|
||||||
|
response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED
|
||||||
|
if self._platform_token is not None:
|
||||||
|
self._platform_token.set_expired()
|
||||||
|
|
||||||
|
else:
|
||||||
|
DLOG.exception("Caught API exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
response['reason'] = e.http_response_reason
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
DLOG.exception("Caught exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
callback.send(response)
|
||||||
|
callback.close()
|
||||||
|
|
||||||
|
def kube_upgrade_download_images(self, future, callback):
|
||||||
|
"""
|
||||||
|
Start kube upgrade download images
|
||||||
|
"""
|
||||||
|
response = dict()
|
||||||
|
response['completed'] = False
|
||||||
|
response['reason'] = ''
|
||||||
|
action_type = 'kube-upgrade-download-images'
|
||||||
|
|
||||||
|
try:
|
||||||
|
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||||
|
|
||||||
|
if self._platform_token is None or \
|
||||||
|
self._platform_token.is_expired():
|
||||||
|
future.work(openstack.get_token, self._platform_directory)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete() or \
|
||||||
|
future.result.data is None:
|
||||||
|
DLOG.error("OpenStack get-token did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._platform_token = future.result.data
|
||||||
|
|
||||||
|
future.work(sysinv.kube_upgrade_download_images,
|
||||||
|
self._platform_token)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("%s did not complete." % action_type)
|
||||||
|
return
|
||||||
|
|
||||||
|
kube_upgrade_data = future.result.data
|
||||||
|
kube_upgrade_obj = nfvi.objects.v1.KubeUpgrade(
|
||||||
|
kube_upgrade_data['state'],
|
||||||
|
kube_upgrade_data['from_version'],
|
||||||
|
kube_upgrade_data['to_version'])
|
||||||
|
|
||||||
|
response['result-data'] = kube_upgrade_obj
|
||||||
|
response['completed'] = True
|
||||||
|
|
||||||
|
except exceptions.OpenStackRestAPIException as e:
|
||||||
|
if httplib.UNAUTHORIZED == e.http_status_code:
|
||||||
|
response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED
|
||||||
|
if self._platform_token is not None:
|
||||||
|
self._platform_token.set_expired()
|
||||||
|
|
||||||
|
else:
|
||||||
|
DLOG.exception("Caught API exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
DLOG.exception("Caught exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
callback.send(response)
|
||||||
|
callback.close()
|
||||||
|
|
||||||
|
def kube_upgrade_networking(self, future, callback):
|
||||||
|
"""
|
||||||
|
Start kube upgrade networking
|
||||||
|
"""
|
||||||
|
response = dict()
|
||||||
|
response['completed'] = False
|
||||||
|
response['reason'] = ''
|
||||||
|
action_type = 'kube-upgrade-networking'
|
||||||
|
|
||||||
|
try:
|
||||||
|
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||||
|
|
||||||
|
if self._platform_token is None or \
|
||||||
|
self._platform_token.is_expired():
|
||||||
|
future.work(openstack.get_token, self._platform_directory)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete() or \
|
||||||
|
future.result.data is None:
|
||||||
|
DLOG.error("OpenStack get-token did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._platform_token = future.result.data
|
||||||
|
|
||||||
|
future.work(sysinv.kube_upgrade_networking, self._platform_token)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("%s did not complete." % action_type)
|
||||||
|
return
|
||||||
|
|
||||||
|
kube_upgrade_data = future.result.data
|
||||||
|
kube_upgrade_obj = nfvi.objects.v1.KubeUpgrade(
|
||||||
|
kube_upgrade_data['state'],
|
||||||
|
kube_upgrade_data['from_version'],
|
||||||
|
kube_upgrade_data['to_version'])
|
||||||
|
|
||||||
|
response['result-data'] = kube_upgrade_obj
|
||||||
|
response['completed'] = True
|
||||||
|
|
||||||
|
except exceptions.OpenStackRestAPIException as e:
|
||||||
|
if httplib.UNAUTHORIZED == e.http_status_code:
|
||||||
|
response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED
|
||||||
|
if self._platform_token is not None:
|
||||||
|
self._platform_token.set_expired()
|
||||||
|
|
||||||
|
else:
|
||||||
|
DLOG.exception("Caught API exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
DLOG.exception("Caught exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
callback.send(response)
|
||||||
|
callback.close()
|
||||||
|
|
||||||
|
def kube_upgrade_start(self, future, to_version, force, alarm_ignore_list,
|
||||||
|
callback):
|
||||||
|
"""
|
||||||
|
Start a kube upgrade
|
||||||
|
"""
|
||||||
|
response = dict()
|
||||||
|
response['completed'] = False
|
||||||
|
response['reason'] = ''
|
||||||
|
action_type = 'kube-upgrade-start'
|
||||||
|
|
||||||
|
try:
|
||||||
|
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||||
|
|
||||||
|
if self._platform_token is None or \
|
||||||
|
self._platform_token.is_expired():
|
||||||
|
future.work(openstack.get_token, self._platform_directory)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete() or \
|
||||||
|
future.result.data is None:
|
||||||
|
DLOG.error("OpenStack get-token did not complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._platform_token = future.result.data
|
||||||
|
|
||||||
|
future.work(sysinv.kube_upgrade_start,
|
||||||
|
self._platform_token,
|
||||||
|
to_version,
|
||||||
|
force=force,
|
||||||
|
alarm_ignore_list=alarm_ignore_list)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("SysInv kube-upgrade-start did not complete.")
|
||||||
|
response['reason'] = "did not complete."
|
||||||
|
return
|
||||||
|
|
||||||
|
future.work(sysinv.get_kube_upgrade, self._platform_token)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("SysInv get-kube-upgrade did not complete.")
|
||||||
|
response['reason'] = "did not complete."
|
||||||
|
return
|
||||||
|
|
||||||
|
kube_upgrade_data_list = future.result.data['kube_upgrades']
|
||||||
|
kube_upgrade_obj = \
|
||||||
|
self._extract_kube_upgrade(kube_upgrade_data_list)
|
||||||
|
response['result-data'] = kube_upgrade_obj
|
||||||
|
response['completed'] = True
|
||||||
|
|
||||||
|
except exceptions.OpenStackRestAPIException as e:
|
||||||
|
if httplib.UNAUTHORIZED == e.http_status_code:
|
||||||
|
response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED
|
||||||
|
if self._platform_token is not None:
|
||||||
|
self._platform_token.set_expired()
|
||||||
|
|
||||||
|
else:
|
||||||
|
DLOG.exception("Caught API exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
response['reason'] = e.http_response_reason
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
DLOG.exception("Caught exception while trying %s. error=%s"
|
||||||
|
% (action_type, e))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
callback.send(response)
|
||||||
|
callback.close()
|
||||||
|
|
||||||
def get_upgrade(self, future, callback):
|
def get_upgrade(self, future, callback):
|
||||||
"""
|
"""
|
||||||
Get information about the upgrade from the plugin
|
Get information about the upgrade from the plugin
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2016-2018 Wind River Systems, Inc.
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -216,6 +216,74 @@ class NFVISwMgmtAPI(nfvi.api.v1.NFVISwMgmtAPI):
|
|||||||
callback.send(response)
|
callback.send(response)
|
||||||
callback.close()
|
callback.close()
|
||||||
|
|
||||||
|
def apply_patches(self, future, patch_names, callback):
|
||||||
|
"""
|
||||||
|
Apply a software patch that has already been uploaded
|
||||||
|
"""
|
||||||
|
response = dict()
|
||||||
|
response['completed'] = False
|
||||||
|
response['reason'] = ''
|
||||||
|
|
||||||
|
try:
|
||||||
|
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||||
|
|
||||||
|
if self._token is None or self._token.is_expired():
|
||||||
|
future.work(openstack.get_token, self._directory)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete() or \
|
||||||
|
future.result.data is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
self._token = future.result.data
|
||||||
|
|
||||||
|
for patch_name in patch_names:
|
||||||
|
future.work(patching.apply_patch, self._token, patch_name)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
return
|
||||||
|
|
||||||
|
# query the patches and return their state
|
||||||
|
future.work(patching.query_patches, self._token)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
return
|
||||||
|
|
||||||
|
sw_patches = list()
|
||||||
|
|
||||||
|
if future.result.data is not None:
|
||||||
|
sw_patch_data_list = future.result.data.get('pd', [])
|
||||||
|
for sw_patch_name in sw_patch_data_list.keys():
|
||||||
|
sw_patch_data = sw_patch_data_list[sw_patch_name]
|
||||||
|
sw_patch = nfvi.objects.v1.SwPatch(
|
||||||
|
sw_patch_name, sw_patch_data['sw_version'],
|
||||||
|
sw_patch_data['repostate'], sw_patch_data['patchstate'])
|
||||||
|
sw_patches.append(sw_patch)
|
||||||
|
|
||||||
|
response['result-data'] = sw_patches
|
||||||
|
response['completed'] = True
|
||||||
|
|
||||||
|
except exceptions.OpenStackRestAPIException as e:
|
||||||
|
if httplib.UNAUTHORIZED == e.http_status_code:
|
||||||
|
response['error-code'] = nfvi.NFVI_ERROR_CODE.TOKEN_EXPIRED
|
||||||
|
if self._token is not None:
|
||||||
|
self._token.set_expired()
|
||||||
|
|
||||||
|
else:
|
||||||
|
DLOG.exception("Caught exception while trying to apply "
|
||||||
|
"software patches [%s], error=%s."
|
||||||
|
% (patch_names, e))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
DLOG.exception("Caught exception while trying to apply "
|
||||||
|
"software patches [%s], error=%s."
|
||||||
|
% (patch_names, e))
|
||||||
|
finally:
|
||||||
|
callback.send(response)
|
||||||
|
callback.close()
|
||||||
|
|
||||||
def update_hosts(self, future, host_names, callback):
|
def update_hosts(self, future, host_names, callback):
|
||||||
"""
|
"""
|
||||||
Apply a software update to a list of hosts
|
Apply a software update to a list of hosts
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2016-2018 Wind River Systems, Inc.
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -10,6 +10,10 @@ from nfv_plugins.nfvi_plugins.openstack.rest_api import rest_api_request
|
|||||||
|
|
||||||
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.patching')
|
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.patching')
|
||||||
|
|
||||||
|
# WARNING: Any change to this timeout must be reflected in the config.ini
|
||||||
|
# file for the nfvi plugins.
|
||||||
|
REST_API_PATCH_APPLY_TIMEOUT = 180
|
||||||
|
|
||||||
|
|
||||||
def query_patches(token):
|
def query_patches(token):
|
||||||
"""
|
"""
|
||||||
@ -39,6 +43,21 @@ def query_hosts(token):
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def apply_patch(token, patch_name):
|
||||||
|
"""
|
||||||
|
Asks Patch Controller to apply a patch that is already uploaded
|
||||||
|
"""
|
||||||
|
url = token.get_service_url(PLATFORM_SERVICE.PATCHING, strip_version=True)
|
||||||
|
if url is None:
|
||||||
|
raise ValueError("OpenStack Patching URL is invalid")
|
||||||
|
|
||||||
|
api_cmd = url + "/v1/apply/%s" % str(patch_name)
|
||||||
|
|
||||||
|
response = rest_api_request(token, "POST", api_cmd,
|
||||||
|
timeout_in_secs=REST_API_PATCH_APPLY_TIMEOUT)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
def host_install_async(token, host_name):
|
def host_install_async(token, host_name):
|
||||||
"""
|
"""
|
||||||
Asks Patch Controller to perform a software upgrade on a host
|
Asks Patch Controller to perform a software upgrade on a host
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
import copy
|
||||||
import json
|
import json
|
||||||
from nfv_common import debug
|
from nfv_common import debug
|
||||||
|
|
||||||
@ -97,6 +98,211 @@ def get_host_labels(token, host_uuid):
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def get_kube_host_upgrades(token):
|
||||||
|
"""
|
||||||
|
Asks System Inventory for information about the kube host upgrades
|
||||||
|
"""
|
||||||
|
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
|
||||||
|
if url is None:
|
||||||
|
raise ValueError("OpenStack SysInv URL is invalid")
|
||||||
|
|
||||||
|
api_cmd = url + "/kube_host_upgrades"
|
||||||
|
|
||||||
|
response = rest_api_request(token, "GET", api_cmd,
|
||||||
|
timeout_in_secs=REST_API_REQUEST_TIMEOUT)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def get_kube_upgrade(token):
|
||||||
|
"""
|
||||||
|
Asks System Inventory for information about the kube upgrade
|
||||||
|
"""
|
||||||
|
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
|
||||||
|
if url is None:
|
||||||
|
raise ValueError("OpenStack SysInv URL is invalid")
|
||||||
|
|
||||||
|
api_cmd = url + "/kube_upgrade"
|
||||||
|
|
||||||
|
response = rest_api_request(token, "GET", api_cmd,
|
||||||
|
timeout_in_secs=REST_API_REQUEST_TIMEOUT)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def get_kube_version(token, kube_version):
|
||||||
|
"""
|
||||||
|
Asks System Inventory for information a kube version
|
||||||
|
"""
|
||||||
|
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
|
||||||
|
if url is None:
|
||||||
|
raise ValueError("OpenStack SysInv URL is invalid")
|
||||||
|
|
||||||
|
api_cmd = url + "/kube_versions/" + kube_version
|
||||||
|
|
||||||
|
response = rest_api_request(token, "GET", api_cmd,
|
||||||
|
timeout_in_secs=REST_API_REQUEST_TIMEOUT)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def get_kube_versions(token):
|
||||||
|
"""
|
||||||
|
Asks System Inventory for information about the kube versions
|
||||||
|
"""
|
||||||
|
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
|
||||||
|
if url is None:
|
||||||
|
raise ValueError("OpenStack SysInv URL is invalid")
|
||||||
|
|
||||||
|
api_cmd = url + "/kube_versions"
|
||||||
|
|
||||||
|
response = rest_api_request(token, "GET", api_cmd,
|
||||||
|
timeout_in_secs=REST_API_REQUEST_TIMEOUT)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def kube_upgrade_start(token, to_version, force=False, alarm_ignore_list=None):
|
||||||
|
"""
|
||||||
|
Ask System Inventory to start a kube upgrade
|
||||||
|
"""
|
||||||
|
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
|
||||||
|
if url is None:
|
||||||
|
raise ValueError("OpenStack SysInv URL is invalid")
|
||||||
|
|
||||||
|
api_cmd = url + "/kube_upgrade"
|
||||||
|
|
||||||
|
api_cmd_headers = dict()
|
||||||
|
api_cmd_headers['Content-Type'] = "application/json"
|
||||||
|
api_cmd_headers['User-Agent'] = "vim/1.0"
|
||||||
|
|
||||||
|
api_cmd_payload = dict()
|
||||||
|
api_cmd_payload['to_version'] = to_version
|
||||||
|
api_cmd_payload['force'] = force
|
||||||
|
if alarm_ignore_list is not None:
|
||||||
|
api_cmd_payload['alarm_ignore_list'] = copy.copy(alarm_ignore_list)
|
||||||
|
|
||||||
|
response = rest_api_request(token,
|
||||||
|
"POST",
|
||||||
|
api_cmd,
|
||||||
|
api_cmd_headers,
|
||||||
|
json.dumps(api_cmd_payload),
|
||||||
|
timeout_in_secs=REST_API_REQUEST_TIMEOUT)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def _patch_kube_upgrade_state(token, new_value):
|
||||||
|
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
|
||||||
|
if url is None:
|
||||||
|
raise ValueError("OpenStack SysInv URL is invalid")
|
||||||
|
|
||||||
|
api_cmd = url + "/kube_upgrade"
|
||||||
|
|
||||||
|
api_cmd_headers = dict()
|
||||||
|
api_cmd_headers['Content-Type'] = "application/json"
|
||||||
|
api_cmd_headers['User-Agent'] = "vim/1.0"
|
||||||
|
|
||||||
|
api_cmd_payload = list()
|
||||||
|
host_data = dict()
|
||||||
|
host_data['path'] = "/state"
|
||||||
|
host_data['value'] = new_value
|
||||||
|
host_data['op'] = "replace"
|
||||||
|
api_cmd_payload.append(host_data)
|
||||||
|
|
||||||
|
return rest_api_request(token,
|
||||||
|
"PATCH",
|
||||||
|
api_cmd,
|
||||||
|
api_cmd_headers,
|
||||||
|
json.dumps(api_cmd_payload),
|
||||||
|
timeout_in_secs=REST_API_REQUEST_TIMEOUT)
|
||||||
|
|
||||||
|
|
||||||
|
def kube_upgrade_cleanup(token):
|
||||||
|
"""
|
||||||
|
Ask System Inventory to delete the kube upgrade
|
||||||
|
"""
|
||||||
|
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
|
||||||
|
if url is None:
|
||||||
|
raise ValueError("OpenStack SysInv URL is invalid")
|
||||||
|
|
||||||
|
api_cmd = url + "/kube_upgrade"
|
||||||
|
|
||||||
|
api_cmd_headers = dict()
|
||||||
|
api_cmd_headers['Content-Type'] = "application/json"
|
||||||
|
api_cmd_headers['User-Agent'] = "vim/1.0"
|
||||||
|
|
||||||
|
response = rest_api_request(token, "DELETE", api_cmd, api_cmd_headers,
|
||||||
|
timeout_in_secs=REST_API_REQUEST_TIMEOUT)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def kube_upgrade_complete(token):
|
||||||
|
"""
|
||||||
|
Ask System Inventory to kube upgrade complete
|
||||||
|
"""
|
||||||
|
return _patch_kube_upgrade_state(token, "upgrade-complete")
|
||||||
|
|
||||||
|
|
||||||
|
def kube_upgrade_download_images(token):
|
||||||
|
"""
|
||||||
|
Ask System Inventory to kube upgrade download images
|
||||||
|
"""
|
||||||
|
return _patch_kube_upgrade_state(token, "downloading-images")
|
||||||
|
|
||||||
|
|
||||||
|
def kube_upgrade_networking(token):
|
||||||
|
"""
|
||||||
|
Ask System Inventory to kube upgrade networking
|
||||||
|
"""
|
||||||
|
return _patch_kube_upgrade_state(token, "upgrading-networking")
|
||||||
|
|
||||||
|
|
||||||
|
def _kube_host_upgrade(token, host_uuid, target_operation, force):
|
||||||
|
"""
|
||||||
|
Invoke a POST for a host kube-upgrade operation
|
||||||
|
|
||||||
|
target_operation one of: kube_upgrade_control_plane, kube_upgrade_kubelet
|
||||||
|
force is a 'string'
|
||||||
|
"""
|
||||||
|
|
||||||
|
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
|
||||||
|
if url is None:
|
||||||
|
raise ValueError("OpenStack SysInv URL is invalid")
|
||||||
|
|
||||||
|
api_cmd = url + "/ihosts/%s/%s" % (host_uuid, target_operation)
|
||||||
|
|
||||||
|
api_cmd_headers = dict()
|
||||||
|
api_cmd_headers['Content-Type'] = "application/json"
|
||||||
|
api_cmd_headers['User-Agent'] = "vim/1.0"
|
||||||
|
|
||||||
|
api_cmd_payload = dict()
|
||||||
|
api_cmd_payload['force'] = force
|
||||||
|
|
||||||
|
response = rest_api_request(token,
|
||||||
|
"POST",
|
||||||
|
api_cmd,
|
||||||
|
api_cmd_headers,
|
||||||
|
json.dumps(api_cmd_payload),
|
||||||
|
timeout_in_secs=REST_API_REQUEST_TIMEOUT)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def kube_host_upgrade_control_plane(token, host_uuid, force="true"):
|
||||||
|
"""
|
||||||
|
Ask System Inventory to kube HOST upgrade control plane
|
||||||
|
"""
|
||||||
|
return _kube_host_upgrade(token,
|
||||||
|
host_uuid,
|
||||||
|
"kube_upgrade_control_plane",
|
||||||
|
force)
|
||||||
|
|
||||||
|
|
||||||
|
def kube_host_upgrade_kubelet(token, host_uuid, force="true"):
|
||||||
|
"""
|
||||||
|
Ask System Inventory to kube HOST upgrade kubelet
|
||||||
|
"""
|
||||||
|
return _kube_host_upgrade(token,
|
||||||
|
host_uuid,
|
||||||
|
"kube_upgrade_kubelet",
|
||||||
|
force)
|
||||||
|
|
||||||
|
|
||||||
def get_upgrade(token):
|
def get_upgrade(token):
|
||||||
"""
|
"""
|
||||||
Asks System Inventory for information about the upgrade
|
Asks System Inventory for information about the upgrade
|
||||||
|
@ -3,11 +3,9 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
nodateext
|
|
||||||
|
|
||||||
/var/log/nfv-vim-alarms.log
|
/var/log/nfv-vim-alarms.log
|
||||||
{
|
{
|
||||||
nodateext
|
|
||||||
size 10M
|
size 10M
|
||||||
start 1
|
start 1
|
||||||
missingok
|
missingok
|
||||||
@ -18,7 +16,6 @@ nodateext
|
|||||||
|
|
||||||
/var/log/nfv-vim-events.log
|
/var/log/nfv-vim-events.log
|
||||||
{
|
{
|
||||||
nodateext
|
|
||||||
size 10M
|
size 10M
|
||||||
start 1
|
start 1
|
||||||
missingok
|
missingok
|
||||||
@ -29,7 +26,6 @@ nodateext
|
|||||||
|
|
||||||
/var/log/nfvi-openstack.log
|
/var/log/nfvi-openstack.log
|
||||||
{
|
{
|
||||||
nodateext
|
|
||||||
size 10M
|
size 10M
|
||||||
start 1
|
start 1
|
||||||
missingok
|
missingok
|
||||||
|
1182
nfv/nfv-tests/nfv_unit_tests/tests/test_kube_upgrade_strategy.py
Executable file
1182
nfv/nfv-tests/nfv_unit_tests/tests/test_kube_upgrade_strategy.py
Executable file
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
import copy
|
||||||
import mock
|
import mock
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -34,6 +35,15 @@ class TestNFVClientShell(testcase.NFVTestCase):
|
|||||||
mock_usage.assert_called_once()
|
mock_usage.assert_called_once()
|
||||||
mock_message.assert_called_once()
|
mock_message.assert_called_once()
|
||||||
|
|
||||||
|
# --- Help Cases ----
|
||||||
|
# -h will print_help and SystemExit
|
||||||
|
@mock.patch('argparse.ArgumentParser.print_help')
|
||||||
|
def _test_shell_help(self, mock_help=None, shell_args=None):
|
||||||
|
self.assertRaises(SystemExit, shell.process_main, shell_args)
|
||||||
|
mock_help.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
class TestNFVClientShellRobustness(TestNFVClientShell):
|
||||||
# invalid arguments causes process_main to exit
|
# invalid arguments causes process_main to exit
|
||||||
def test_shell_bad_args(self):
|
def test_shell_bad_args(self):
|
||||||
shell_args = ['invalid-arg', ]
|
shell_args = ['invalid-arg', ]
|
||||||
@ -44,86 +54,221 @@ class TestNFVClientShell(testcase.NFVTestCase):
|
|||||||
shell_args = []
|
shell_args = []
|
||||||
self._test_shell_bad_or_empty_args(shell_args=shell_args)
|
self._test_shell_bad_or_empty_args(shell_args=shell_args)
|
||||||
|
|
||||||
# upgrade-strategy expects additional arguments
|
|
||||||
def test_shell_upgrade_strategy_incomplete_args(self):
|
|
||||||
shell_args = ['upgrade-strategy', ]
|
|
||||||
self._test_shell_bad_or_empty_args(shell_args=shell_args)
|
|
||||||
|
|
||||||
# patch-strategy expects additional arguments
|
class StrategyMixin(object):
|
||||||
def test_shell_patch_strategy_incomplete_args(self):
|
|
||||||
shell_args = ['patch-strategy', ]
|
|
||||||
self._test_shell_bad_or_empty_args(shell_args=shell_args)
|
|
||||||
|
|
||||||
# fw-update-strategy expects additional arguments
|
MOCK_ENV = {
|
||||||
def test_shell_fw_update_strategy_incomplete_args(self):
|
'OS_AUTH_URL': 'FAKE_OS_AUTH_URL',
|
||||||
shell_args = ['fw-update-strategy', ]
|
'OS_PROJECT_NAME': 'FAKE_OS_PROJECT_NAME',
|
||||||
self._test_shell_bad_or_empty_args(shell_args=shell_args)
|
'OS_PROJECT_DOMAIN_NAME': 'FAKE_OS_PROJECT_DOMAIN_NAME',
|
||||||
|
'OS_USERNAME': 'FAKE_OS_USERNAME',
|
||||||
|
'OS_PASSWORD': 'FAKE_OS_PASSWORD',
|
||||||
|
'OS_USER_DOMAIN_NAME': 'FAKE_OS_USER_DOMAIN_NAME',
|
||||||
|
'OS_REGION_NAME': 'FAKE_OS_REGION_NAME',
|
||||||
|
'OS_INTERFACE': 'FAKE_OS_INTERFACE'
|
||||||
|
}
|
||||||
|
|
||||||
# --- Help Cases ----
|
MOCK_ENV_OVERRIDES = {
|
||||||
# -h will print_help and SystemExit
|
'OS_AUTH_URL': '--os-auth-url=FAKE_OS_AUTH_URL',
|
||||||
@mock.patch('argparse.ArgumentParser.print_help')
|
'OS_PROJECT_NAME': '--os-project-name=FAKE_OS_PROJECT_NAME',
|
||||||
def _test_shell_help(self, mock_help=None, shell_args=None):
|
'OS_PROJECT_DOMAIN_NAME':
|
||||||
self.assertRaises(SystemExit, shell.process_main, shell_args)
|
'--os-project-domain-name=FAKE_OS_PROJECT_DOMAIN_NAME',
|
||||||
mock_help.assert_called_once()
|
'OS_USERNAME': '--os-username=FAKE_OS_USERNAME',
|
||||||
|
'OS_PASSWORD': '--os-password=FAKE_OS_PASSWORD',
|
||||||
|
'OS_USER_DOMAIN_NAME':
|
||||||
|
'--os-user-domain-name=FAKE_OS_USER_DOMAIN_NAME',
|
||||||
|
'OS_REGION_NAME': '--os-region-name=FAKE_OS_REGION_NAME',
|
||||||
|
'OS_INTERFACE': '--os-interface=FAKE_OS_INTERFACE'
|
||||||
|
}
|
||||||
|
|
||||||
def test_shell_upgrade_strategy_help(self):
|
def set_strategy(self, strategy):
|
||||||
shell_args = ['upgrade-strategy', '-h', ]
|
"""Invoked by the child class setupmethod to set the strategy"""
|
||||||
self._test_shell_help(shell_args=shell_args)
|
self.strategy = strategy
|
||||||
|
|
||||||
def test_shell_patch_strategy_help(self):
|
def required_create_fields(self):
|
||||||
shell_args = ['patch-strategy', '-h', ]
|
"""Override in the child class if create has required fields"""
|
||||||
self._test_shell_help(shell_args=shell_args)
|
return []
|
||||||
|
|
||||||
def test_shell_fw_update_strategy_help(self):
|
def optional_create_fields(self):
|
||||||
shell_args = ['fw-update-strategy', '-h', ]
|
"""Override in the child class if create has optional fields"""
|
||||||
self._test_shell_help(shell_args=shell_args)
|
return []
|
||||||
|
|
||||||
# -- Show commands --
|
# -- Show commands --
|
||||||
# Both patch-strategy and upgrade-strategy use the same underlying
|
# The strategy commands use the same underling sw_update class, but
|
||||||
# sw_update class, but with different modes
|
# but with different modes
|
||||||
|
|
||||||
# Test the show commands are not invoked when env values missing
|
# Test the show commands are not invoked when env values missing
|
||||||
@mock.patch('nfv_client.sw_update.show_strategy')
|
@mock.patch('nfv_client.sw_update.show_strategy')
|
||||||
def _test_shell_show_missing_env(self, mock_show=None, shell_args=None):
|
def _test_shell_show_missing_env(self, mock_show=None, shell_args=None):
|
||||||
shell.process_main(shell_args)
|
shell.process_main(shell_args)
|
||||||
mock_show.assert_not_called()
|
mock_show.assert_not_called()
|
||||||
|
|
||||||
def test_shell_upgrade_strategy_show_missing_env(self):
|
|
||||||
shell_args = ['upgrade-strategy', 'show', ]
|
|
||||||
self._test_shell_show_missing_env(shell_args=shell_args)
|
|
||||||
|
|
||||||
def test_shell_patch_strategy_show_missing_env(self):
|
|
||||||
shell_args = ['patch-strategy', 'show', ]
|
|
||||||
self._test_shell_show_missing_env(shell_args=shell_args)
|
|
||||||
|
|
||||||
def test_shell_fw_update_strategy_show_missing_env(self):
|
|
||||||
shell_args = ['fw-update-strategy', 'show', ]
|
|
||||||
self._test_shell_show_missing_env(shell_args=shell_args)
|
|
||||||
|
|
||||||
# Test the show commands are invoked when env values detected
|
# Test the show commands are invoked when env values detected
|
||||||
@mock.patch.dict(os.environ,
|
|
||||||
{'OS_AUTH_URL': 'FAKE_OS_AUTH_URL',
|
|
||||||
'OS_PROJECT_NAME': 'FAKE_OS_PROJECT_NAME',
|
|
||||||
'OS_PROJECT_DOMAIN_NAME': 'FAKE_OS_PROJECT_DOMAIN_NAME',
|
|
||||||
'OS_USERNAME': 'FAKE_OS_USERNAME',
|
|
||||||
'OS_PASSWORD': 'FAKE_OS_PASSWORD',
|
|
||||||
'OS_USER_DOMAIN_NAME': 'FAKE_OS_USER_DOMAIN_NAME',
|
|
||||||
'OS_REGION_NAME': 'FAKE_OS_REGION_NAME',
|
|
||||||
'OS_INTERFACE': 'FAKE_OS_INTERFACE'
|
|
||||||
})
|
|
||||||
@mock.patch('nfv_client.sw_update.show_strategy')
|
@mock.patch('nfv_client.sw_update.show_strategy')
|
||||||
def _test_shell_show(self, mock_show=None, shell_args=None):
|
def _test_shell_show(self, mock_show=None, shell_args=None):
|
||||||
shell.process_main(shell_args)
|
with mock.patch.dict(os.environ, self.MOCK_ENV):
|
||||||
|
shell.process_main(shell_args)
|
||||||
mock_show.assert_called_once()
|
mock_show.assert_called_once()
|
||||||
|
|
||||||
def test_shell_upgrade_strategy_show(self):
|
@mock.patch('nfv_client.sw_update.show_strategy')
|
||||||
shell_args = ['upgrade-strategy', 'show', ]
|
def _test_shell_show_incomplete_env(self,
|
||||||
|
mock_show=None,
|
||||||
|
shell_args=None,
|
||||||
|
pop_env=None,
|
||||||
|
expect_fails=True):
|
||||||
|
# setup a mostly complete environment
|
||||||
|
test_env = copy.copy(self.MOCK_ENV)
|
||||||
|
test_env.pop(pop_env)
|
||||||
|
with mock.patch.dict(os.environ, test_env):
|
||||||
|
shell.process_main(shell_args)
|
||||||
|
if expect_fails:
|
||||||
|
mock_show.assert_not_called()
|
||||||
|
else:
|
||||||
|
mock_show.assert_called_once()
|
||||||
|
|
||||||
|
def test_shell_strategy_missing_subcommand(self):
|
||||||
|
"""Test the strategy fails with a missing subcommand"""
|
||||||
|
shell_args = [self.strategy, ]
|
||||||
|
self._test_shell_bad_or_empty_args(shell_args=shell_args)
|
||||||
|
|
||||||
|
def test_shell_strategy_invalid_subcommand(self):
|
||||||
|
"""Test the strategy fails with an invalid subcommand"""
|
||||||
|
shell_args = [self.strategy, 'foo']
|
||||||
|
self._test_shell_bad_or_empty_args(shell_args=shell_args)
|
||||||
|
|
||||||
|
def test_shell_strategy_help(self):
|
||||||
|
"""Test the strategy supports the help subcommand"""
|
||||||
|
shell_args = [self.strategy, '-h', ]
|
||||||
|
self._test_shell_help(shell_args=shell_args)
|
||||||
|
|
||||||
|
def test_shell_strategy_show_incomplete_env(self):
|
||||||
|
"""Test that if any required env variable is missing, it fails"""
|
||||||
|
shell_args = [self.strategy, 'show', ]
|
||||||
|
for pop_env in self.MOCK_ENV.keys():
|
||||||
|
# remove the pop_env variable from the environment
|
||||||
|
self._test_shell_show_incomplete_env(shell_args=shell_args,
|
||||||
|
pop_env=pop_env)
|
||||||
|
|
||||||
|
def test_shell_strategy_show_env_overrides(self):
|
||||||
|
"""
|
||||||
|
Tests that passing certain values to the CLI override the env and
|
||||||
|
that removing that value from the env will not cause failure
|
||||||
|
"""
|
||||||
|
for env_val, override_val in self.MOCK_ENV_OVERRIDES.items():
|
||||||
|
shell_args = [override_val, self.strategy, 'show', ]
|
||||||
|
self._test_shell_show_incomplete_env(shell_args=shell_args,
|
||||||
|
pop_env=env_val,
|
||||||
|
expect_fails=False)
|
||||||
|
|
||||||
|
def test_shell_strategy_show(self):
|
||||||
|
shell_args = [self.strategy, 'show', ]
|
||||||
self._test_shell_show(shell_args=shell_args)
|
self._test_shell_show(shell_args=shell_args)
|
||||||
|
|
||||||
def test_shell_patch_strategy_show(self):
|
def test_shell_strategy_show_bad_extra_arg(self):
|
||||||
shell_args = ['patch-strategy', 'show', ]
|
shell_args = [self.strategy, 'show', '--bad']
|
||||||
|
self._test_shell_bad_or_empty_args(shell_args=shell_args)
|
||||||
|
|
||||||
|
def test_shell_strategy_show_debug(self):
|
||||||
|
shell_args = ["--debug", self.strategy, 'show']
|
||||||
self._test_shell_show(shell_args=shell_args)
|
self._test_shell_show(shell_args=shell_args)
|
||||||
|
|
||||||
def test_shell_fw_update_strategy_show(self):
|
def test_shell_strategy_show_details(self):
|
||||||
shell_args = ['fw-update-strategy', 'show', ]
|
shell_args = [self.strategy, 'show', '--details']
|
||||||
self._test_shell_show(shell_args=shell_args)
|
self._test_shell_show(shell_args=shell_args)
|
||||||
|
|
||||||
|
def test_shell_strategy_show_active(self):
|
||||||
|
shell_args = [self.strategy, 'show', '--active']
|
||||||
|
self._test_shell_show(shell_args=shell_args)
|
||||||
|
|
||||||
|
def test_shell_strategy_show_active_details(self):
|
||||||
|
shell_args = [self.strategy, 'show', '--details', '--active']
|
||||||
|
self._test_shell_show(shell_args=shell_args)
|
||||||
|
|
||||||
|
# -- Abort command --
|
||||||
|
# Test the abort command can be invoked. Requires the env to be set
|
||||||
|
@mock.patch('nfv_client.sw_update.abort_strategy')
|
||||||
|
def _test_shell_abort(self, mock_abort=None, shell_args=None):
|
||||||
|
with mock.patch.dict(os.environ, self.MOCK_ENV):
|
||||||
|
shell.process_main(shell_args)
|
||||||
|
mock_abort.assert_called_once()
|
||||||
|
|
||||||
|
def test_shell_strategy_abort(self):
|
||||||
|
shell_args = [self.strategy, 'abort']
|
||||||
|
self._test_shell_abort(shell_args=shell_args)
|
||||||
|
|
||||||
|
# -- Apply command --
|
||||||
|
# Test the apply command can be invoked. Requires the env to be set
|
||||||
|
@mock.patch('nfv_client.sw_update.apply_strategy')
|
||||||
|
def _test_shell_apply(self, mock_apply=None, shell_args=None):
|
||||||
|
with mock.patch.dict(os.environ, self.MOCK_ENV):
|
||||||
|
shell.process_main(shell_args)
|
||||||
|
mock_apply.assert_called_once()
|
||||||
|
|
||||||
|
def test_shell_strategy_apply(self):
|
||||||
|
shell_args = [self.strategy, 'apply']
|
||||||
|
self._test_shell_apply(shell_args=shell_args)
|
||||||
|
|
||||||
|
# -- Delete command --
|
||||||
|
# Test the delete command can be invoked. Requires the env to be set
|
||||||
|
@mock.patch('nfv_client.sw_update.delete_strategy')
|
||||||
|
def _test_shell_delete(self, mock_delete=None, shell_args=None):
|
||||||
|
with mock.patch.dict(os.environ, self.MOCK_ENV):
|
||||||
|
shell.process_main(shell_args)
|
||||||
|
mock_delete.assert_called_once()
|
||||||
|
|
||||||
|
def test_shell_strategy_delete(self):
|
||||||
|
shell_args = [self.strategy, 'delete']
|
||||||
|
self._test_shell_delete(shell_args=shell_args)
|
||||||
|
|
||||||
|
# -- Create command --
|
||||||
|
# Test the create command can be invoked. Requires the env to be set
|
||||||
|
@mock.patch('nfv_client.sw_update.create_strategy')
|
||||||
|
def _test_shell_create(self, mock_create=None, shell_args=None):
|
||||||
|
with mock.patch.dict(os.environ, self.MOCK_ENV):
|
||||||
|
shell.process_main(shell_args)
|
||||||
|
mock_create.assert_called_once()
|
||||||
|
|
||||||
|
# -- Create command --
|
||||||
|
def test_shell_strategy_create(self):
|
||||||
|
shell_args = [self.strategy, 'create']
|
||||||
|
# create may have 'required' additional fields
|
||||||
|
shell_args.extend(self.required_create_fields())
|
||||||
|
self._test_shell_create(shell_args=shell_args)
|
||||||
|
|
||||||
|
def test_shell_strategy_create_optional(self):
|
||||||
|
shell_args = [self.strategy, 'create']
|
||||||
|
# create may have 'required' additional fields and optional ones
|
||||||
|
shell_args.extend(self.required_create_fields())
|
||||||
|
shell_args.extend(self.optional_create_fields())
|
||||||
|
self._test_shell_create(shell_args=shell_args)
|
||||||
|
|
||||||
|
|
||||||
|
class TestCLIUpgradeStrategy(TestNFVClientShell,
|
||||||
|
StrategyMixin):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestCLIUpgradeStrategy, self).setUp()
|
||||||
|
self.set_strategy('upgrade-strategy')
|
||||||
|
|
||||||
|
|
||||||
|
class TestCLIPatchStrategy(TestNFVClientShell,
|
||||||
|
StrategyMixin):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestCLIPatchStrategy, self).setUp()
|
||||||
|
self.set_strategy('patch-strategy')
|
||||||
|
|
||||||
|
|
||||||
|
class TestCLIFwUpdateStrategy(TestNFVClientShell,
|
||||||
|
StrategyMixin):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestCLIFwUpdateStrategy, self).setUp()
|
||||||
|
self.set_strategy('fw-update-strategy')
|
||||||
|
|
||||||
|
|
||||||
|
class TestCLIKubeUpgradeStrategy(TestNFVClientShell,
|
||||||
|
StrategyMixin):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestCLIKubeUpgradeStrategy, self).setUp()
|
||||||
|
self.set_strategy('kube-upgrade-strategy')
|
||||||
|
|
||||||
|
def required_create_fields(self):
|
||||||
|
"""Kube Upgrade requires a to-version for create"""
|
||||||
|
return ['--to-version=1.2.3']
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,7 @@ from nfv_vim.objects import HOST_PERSONALITY
|
|||||||
from nfv_vim.objects import SW_UPDATE_ALARM_RESTRICTION
|
from nfv_vim.objects import SW_UPDATE_ALARM_RESTRICTION
|
||||||
from nfv_vim.objects import SW_UPDATE_APPLY_TYPE
|
from nfv_vim.objects import SW_UPDATE_APPLY_TYPE
|
||||||
from nfv_vim.objects import SwUpgrade
|
from nfv_vim.objects import SwUpgrade
|
||||||
|
from nfv_vim.strategy._strategy import strategy_rebuild_from_dict
|
||||||
from nfv_vim.strategy._strategy import SwUpgradeStrategy
|
from nfv_vim.strategy._strategy import SwUpgradeStrategy
|
||||||
|
|
||||||
from nfv_vim.nfvi.objects.v1 import UPGRADE_STATE
|
from nfv_vim.nfvi.objects.v1 import UPGRADE_STATE
|
||||||
@ -22,10 +23,27 @@ from nfv_vim.nfvi.objects.v1 import UPGRADE_STATE
|
|||||||
from . import sw_update_testcase # noqa: H304
|
from . import sw_update_testcase # noqa: H304
|
||||||
|
|
||||||
|
|
||||||
@mock.patch('nfv_vim.event_log._instance._event_issue', sw_update_testcase.fake_event_issue)
|
# utility method for the formatting of unlock-hosts stage as dict
|
||||||
@mock.patch('nfv_vim.objects._sw_update.SwUpdate.save', sw_update_testcase.fake_save)
|
# workers default to 5 retries with 120 second delay between attempts
|
||||||
@mock.patch('nfv_vim.objects._sw_update.timers.timers_create_timer', sw_update_testcase.fake_timer)
|
# std controllers and storage have 0 retries
|
||||||
@mock.patch('nfv_vim.nfvi.nfvi_compute_plugin_disabled', sw_update_testcase.fake_nfvi_compute_plugin_disabled)
|
def _unlock_hosts_stage_as_dict(host_names, retry_count=5, retry_delay=120):
|
||||||
|
return {
|
||||||
|
'name': 'unlock-hosts',
|
||||||
|
'entity_names': host_names,
|
||||||
|
'retry_count': retry_count,
|
||||||
|
'retry_delay': retry_delay,
|
||||||
|
'timeout': 1800,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@mock.patch('nfv_vim.event_log._instance._event_issue',
|
||||||
|
sw_update_testcase.fake_event_issue)
|
||||||
|
@mock.patch('nfv_vim.objects._sw_update.SwUpdate.save',
|
||||||
|
sw_update_testcase.fake_save)
|
||||||
|
@mock.patch('nfv_vim.objects._sw_update.timers.timers_create_timer',
|
||||||
|
sw_update_testcase.fake_timer)
|
||||||
|
@mock.patch('nfv_vim.nfvi.nfvi_compute_plugin_disabled',
|
||||||
|
sw_update_testcase.fake_nfvi_compute_plugin_disabled)
|
||||||
class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
||||||
|
|
||||||
def create_sw_upgrade_strategy(self,
|
def create_sw_upgrade_strategy(self,
|
||||||
@ -35,7 +53,8 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
alarm_restrictions=SW_UPDATE_ALARM_RESTRICTION.STRICT,
|
alarm_restrictions=SW_UPDATE_ALARM_RESTRICTION.STRICT,
|
||||||
start_upgrade=False,
|
start_upgrade=False,
|
||||||
complete_upgrade=False,
|
complete_upgrade=False,
|
||||||
nfvi_upgrade=None
|
nfvi_upgrade=None,
|
||||||
|
single_controller=False
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Create a software update strategy
|
Create a software update strategy
|
||||||
@ -48,7 +67,8 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
alarm_restrictions=alarm_restrictions,
|
alarm_restrictions=alarm_restrictions,
|
||||||
start_upgrade=start_upgrade,
|
start_upgrade=start_upgrade,
|
||||||
complete_upgrade=complete_upgrade,
|
complete_upgrade=complete_upgrade,
|
||||||
ignore_alarms=[]
|
ignore_alarms=[],
|
||||||
|
single_controller=single_controller,
|
||||||
)
|
)
|
||||||
strategy.nfvi_upgrade = nfvi_upgrade
|
strategy.nfvi_upgrade = nfvi_upgrade
|
||||||
return strategy
|
return strategy
|
||||||
@ -74,9 +94,10 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
"test_instance_1",
|
"test_instance_1",
|
||||||
'compute-1')
|
'compute-1')
|
||||||
|
|
||||||
self.create_instance_group('instance_group_1',
|
self.create_instance_group(
|
||||||
['test_instance_0', 'test_instance_1'],
|
'instance_group_1',
|
||||||
[nfvi.objects.v1.INSTANCE_GROUP_POLICY.ANTI_AFFINITY])
|
['test_instance_0', 'test_instance_1'],
|
||||||
|
[nfvi.objects.v1.INSTANCE_GROUP_POLICY.ANTI_AFFINITY])
|
||||||
|
|
||||||
worker_hosts = []
|
worker_hosts = []
|
||||||
for host in self._host_table.values():
|
for host in self._host_table.values():
|
||||||
@ -160,9 +181,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-2', 'compute-3']},
|
'entity_names': ['compute-2', 'compute-3']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-2', 'compute-3']},
|
'entity_names': ['compute-2', 'compute-3']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-2', 'compute-3']),
|
||||||
'entity_names': ['compute-2', 'compute-3']},
|
{'name': 'wait-alarms-clear',
|
||||||
{'name': 'system-stabilize'}
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{'name': 'sw-upgrade-worker-hosts',
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
@ -176,9 +197,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-0']},
|
'entity_names': ['compute-0']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-0']},
|
'entity_names': ['compute-0']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-0']),
|
||||||
'entity_names': ['compute-0']},
|
{'name': 'wait-alarms-clear',
|
||||||
{'name': 'system-stabilize'}
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{'name': 'sw-upgrade-worker-hosts',
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
@ -192,9 +213,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-1']},
|
'entity_names': ['compute-1']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-1']},
|
'entity_names': ['compute-1']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-1']),
|
||||||
'entity_names': ['compute-1']},
|
{'name': 'wait-alarms-clear',
|
||||||
{'name': 'system-stabilize'}
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -263,9 +284,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-1', 'compute-5']},
|
'entity_names': ['compute-1', 'compute-5']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-1', 'compute-5']},
|
'entity_names': ['compute-1', 'compute-5']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-1', 'compute-5']),
|
||||||
'entity_names': ['compute-1', 'compute-5']},
|
{'name': 'wait-alarms-clear',
|
||||||
{'name': 'system-stabilize'}
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{'name': 'sw-upgrade-worker-hosts',
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
@ -281,9 +302,10 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-0', 'compute-2', 'compute-3']},
|
'entity_names': ['compute-0', 'compute-2', 'compute-3']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-0', 'compute-2', 'compute-3']},
|
'entity_names': ['compute-0', 'compute-2', 'compute-3']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(
|
||||||
'entity_names': ['compute-0', 'compute-2', 'compute-3']},
|
['compute-0', 'compute-2', 'compute-3']),
|
||||||
{'name': 'system-stabilize'}
|
{'name': 'wait-alarms-clear',
|
||||||
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{'name': 'sw-upgrade-worker-hosts',
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
@ -299,9 +321,10 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-4', 'compute-6', 'compute-7']},
|
'entity_names': ['compute-4', 'compute-6', 'compute-7']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-4', 'compute-6', 'compute-7']},
|
'entity_names': ['compute-4', 'compute-6', 'compute-7']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(
|
||||||
'entity_names': ['compute-4', 'compute-6', 'compute-7']},
|
['compute-4', 'compute-6', 'compute-7']),
|
||||||
{'name': 'system-stabilize'}
|
{'name': 'wait-alarms-clear',
|
||||||
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{'name': 'sw-upgrade-worker-hosts',
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
@ -316,9 +339,10 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-8', 'compute-9']},
|
'entity_names': ['compute-8', 'compute-9']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-8', 'compute-9']},
|
'entity_names': ['compute-8', 'compute-9']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(
|
||||||
'entity_names': ['compute-8', 'compute-9']},
|
['compute-8', 'compute-9']),
|
||||||
{'name': 'system-stabilize'}
|
{'name': 'wait-alarms-clear',
|
||||||
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -327,6 +351,146 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
sw_update_testcase.validate_strategy_persists(strategy)
|
sw_update_testcase.validate_strategy_persists(strategy)
|
||||||
sw_update_testcase.validate_phase(apply_phase, expected_results)
|
sw_update_testcase.validate_phase(apply_phase, expected_results)
|
||||||
|
|
||||||
|
@mock.patch('nfv_vim.strategy._strategy.get_local_host_name',
|
||||||
|
sw_update_testcase.fake_host_name_controller_1)
|
||||||
|
def test_sw_upgrade_strategy_worker_stages_parallel_migrate_for_aio(self):
|
||||||
|
"""
|
||||||
|
Test the sw_upgrade strategy add worker strategy stages:
|
||||||
|
- parallel apply
|
||||||
|
- migrate instance action
|
||||||
|
Verify:
|
||||||
|
- AIO hosts upgraded first in serial
|
||||||
|
- hosts with no instances upgraded next
|
||||||
|
- instances migrated
|
||||||
|
- for AIO controllers, the last step is wait-data-sync
|
||||||
|
- for workers, the last step is wait-alarms-clear (openstack workers)
|
||||||
|
"""
|
||||||
|
self.create_host('compute-0')
|
||||||
|
self.create_host('compute-1')
|
||||||
|
self.create_host('compute-2')
|
||||||
|
self.create_host('compute-3')
|
||||||
|
self.create_host('compute-4')
|
||||||
|
self.create_host('controller-0', aio=True)
|
||||||
|
self.create_host('controller-1', aio=True)
|
||||||
|
|
||||||
|
self.create_instance('small', "test_instance_0", 'compute-0')
|
||||||
|
self.create_instance('small', "test_instance_2", 'compute-2')
|
||||||
|
self.create_instance('small', "test_instance_3", 'compute-3')
|
||||||
|
self.create_instance('small', "test_instance_4", 'compute-4')
|
||||||
|
self.create_instance('small', "test_instance_6", 'controller-0')
|
||||||
|
self.create_instance('small', "test_instance_7", 'controller-1')
|
||||||
|
|
||||||
|
worker_hosts = []
|
||||||
|
for host in self._host_table.values():
|
||||||
|
if HOST_PERSONALITY.WORKER in host.personality:
|
||||||
|
worker_hosts.append(host)
|
||||||
|
# Sort worker hosts so the order of the steps is deterministic
|
||||||
|
sorted_worker_hosts = sorted(worker_hosts, key=lambda host: host.name)
|
||||||
|
|
||||||
|
strategy = self.create_sw_upgrade_strategy(
|
||||||
|
worker_apply_type=SW_UPDATE_APPLY_TYPE.PARALLEL,
|
||||||
|
max_parallel_worker_hosts=3
|
||||||
|
)
|
||||||
|
|
||||||
|
strategy._add_worker_strategy_stages(
|
||||||
|
worker_hosts=sorted_worker_hosts,
|
||||||
|
reboot=True)
|
||||||
|
|
||||||
|
apply_phase = strategy.apply_phase.as_dict()
|
||||||
|
|
||||||
|
expected_results = {
|
||||||
|
'total_stages': 5,
|
||||||
|
'stages': [
|
||||||
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
|
'total_steps': 8,
|
||||||
|
'steps': [
|
||||||
|
{'name': 'query-alarms'},
|
||||||
|
{'name': 'disable-host-services'},
|
||||||
|
{'name': 'migrate-instances',
|
||||||
|
'entity_names': ['test_instance_6']},
|
||||||
|
{'name': 'swact-hosts',
|
||||||
|
'entity_names': ['controller-0']},
|
||||||
|
{'name': 'lock-hosts',
|
||||||
|
'entity_names': ['controller-0']},
|
||||||
|
{'name': 'upgrade-hosts',
|
||||||
|
'entity_names': ['controller-0']},
|
||||||
|
_unlock_hosts_stage_as_dict(['controller-0']),
|
||||||
|
{'name': 'wait-data-sync',
|
||||||
|
'timeout': 14400}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
|
'total_steps': 8,
|
||||||
|
'steps': [
|
||||||
|
{'name': 'query-alarms'},
|
||||||
|
{'name': 'disable-host-services'},
|
||||||
|
{'name': 'migrate-instances',
|
||||||
|
'entity_names': ['test_instance_7']},
|
||||||
|
{'name': 'swact-hosts',
|
||||||
|
'entity_names': ['controller-1']},
|
||||||
|
{'name': 'lock-hosts',
|
||||||
|
'entity_names': ['controller-1']},
|
||||||
|
{'name': 'upgrade-hosts',
|
||||||
|
'entity_names': ['controller-1']},
|
||||||
|
_unlock_hosts_stage_as_dict(['controller-1']),
|
||||||
|
{'name': 'wait-data-sync',
|
||||||
|
'timeout': 14400}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
|
'total_steps': 5,
|
||||||
|
'steps': [
|
||||||
|
{'name': 'query-alarms'},
|
||||||
|
{'name': 'lock-hosts',
|
||||||
|
'entity_names': ['compute-1']},
|
||||||
|
{'name': 'upgrade-hosts',
|
||||||
|
'entity_names': ['compute-1']},
|
||||||
|
_unlock_hosts_stage_as_dict(['compute-1']),
|
||||||
|
{'name': 'wait-alarms-clear',
|
||||||
|
'timeout': 600}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
|
'total_steps': 7,
|
||||||
|
'steps': [
|
||||||
|
{'name': 'query-alarms'},
|
||||||
|
{'name': 'disable-host-services'},
|
||||||
|
{'name': 'migrate-instances',
|
||||||
|
'entity_names': ['test_instance_0',
|
||||||
|
'test_instance_2',
|
||||||
|
'test_instance_3']},
|
||||||
|
{'name': 'lock-hosts',
|
||||||
|
'entity_names': ['compute-0', 'compute-2', 'compute-3']},
|
||||||
|
{'name': 'upgrade-hosts',
|
||||||
|
'entity_names': ['compute-0', 'compute-2', 'compute-3']},
|
||||||
|
_unlock_hosts_stage_as_dict(
|
||||||
|
['compute-0', 'compute-2', 'compute-3']),
|
||||||
|
{'name': 'wait-alarms-clear',
|
||||||
|
'timeout': 600}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
|
'total_steps': 7,
|
||||||
|
'steps': [
|
||||||
|
{'name': 'query-alarms'},
|
||||||
|
{'name': 'disable-host-services'},
|
||||||
|
{'name': 'migrate-instances',
|
||||||
|
'entity_names': ['test_instance_4']},
|
||||||
|
{'name': 'lock-hosts',
|
||||||
|
'entity_names': ['compute-4']},
|
||||||
|
{'name': 'upgrade-hosts',
|
||||||
|
'entity_names': ['compute-4']},
|
||||||
|
_unlock_hosts_stage_as_dict(['compute-4']),
|
||||||
|
{'name': 'wait-alarms-clear',
|
||||||
|
'timeout': 600}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
sw_update_testcase.validate_strategy_persists(strategy)
|
||||||
|
sw_update_testcase.validate_phase(apply_phase, expected_results)
|
||||||
|
|
||||||
@mock.patch('nfv_vim.strategy._strategy.get_local_host_name',
|
@mock.patch('nfv_vim.strategy._strategy.get_local_host_name',
|
||||||
sw_update_testcase.fake_host_name_controller_1)
|
sw_update_testcase.fake_host_name_controller_1)
|
||||||
def test_sw_upgrade_strategy_worker_stages_parallel_migrate_fifty_hosts(self):
|
def test_sw_upgrade_strategy_worker_stages_parallel_migrate_fifty_hosts(self):
|
||||||
@ -405,9 +569,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': stage_hosts[0]},
|
'entity_names': stage_hosts[0]},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': stage_hosts[0]},
|
'entity_names': stage_hosts[0]},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(stage_hosts[0]),
|
||||||
'entity_names': stage_hosts[0]},
|
{'name': 'wait-alarms-clear',
|
||||||
{'name': 'system-stabilize'}
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -426,9 +590,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': stage_hosts[x]},
|
'entity_names': stage_hosts[x]},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': stage_hosts[x]},
|
'entity_names': stage_hosts[x]},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(stage_hosts[x]),
|
||||||
'entity_names': stage_hosts[x]},
|
{'name': 'wait-alarms-clear',
|
||||||
{'name': 'system-stabilize'}
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -489,9 +653,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-2']},
|
'entity_names': ['compute-2']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-2']},
|
'entity_names': ['compute-2']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-2']),
|
||||||
'entity_names': ['compute-2']},
|
{'name': 'wait-alarms-clear',
|
||||||
{'name': 'system-stabilize'}
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{'name': 'sw-upgrade-worker-hosts',
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
@ -502,9 +666,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-3']},
|
'entity_names': ['compute-3']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-3']},
|
'entity_names': ['compute-3']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-3']),
|
||||||
'entity_names': ['compute-3']},
|
{'name': 'wait-alarms-clear',
|
||||||
{'name': 'system-stabilize'}
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{'name': 'sw-upgrade-worker-hosts',
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
@ -517,9 +681,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-0']},
|
'entity_names': ['compute-0']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-0']},
|
'entity_names': ['compute-0']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-0']),
|
||||||
'entity_names': ['compute-0']},
|
{'name': 'wait-alarms-clear',
|
||||||
{'name': 'system-stabilize'}
|
'timeout': 600}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{'name': 'sw-upgrade-worker-hosts',
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
@ -532,8 +696,97 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-1']},
|
'entity_names': ['compute-1']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-1']},
|
'entity_names': ['compute-1']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-1']),
|
||||||
|
{'name': 'wait-alarms-clear',
|
||||||
|
'timeout': 600}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
sw_update_testcase.validate_strategy_persists(strategy)
|
||||||
|
sw_update_testcase.validate_phase(apply_phase, expected_results)
|
||||||
|
|
||||||
|
@mock.patch('nfv_vim.strategy._strategy.get_local_host_name',
|
||||||
|
sw_update_testcase.fake_host_name_controller_1)
|
||||||
|
def test_sw_upgrade_strategy_non_openstack_worker_stages_serial(self):
|
||||||
|
"""
|
||||||
|
Test the sw_upgrade strategy add worker strategy stages:
|
||||||
|
- workers with no openstack installed
|
||||||
|
- serial apply
|
||||||
|
- no migrate instance action
|
||||||
|
Verify:
|
||||||
|
- final step is SystemStabilize
|
||||||
|
"""
|
||||||
|
self.create_host('compute-0', openstack_installed=False)
|
||||||
|
self.create_host('compute-1', openstack_installed=False)
|
||||||
|
self.create_host('compute-2', openstack_installed=False)
|
||||||
|
self.create_host('compute-3', openstack_installed=False)
|
||||||
|
|
||||||
|
worker_hosts = []
|
||||||
|
for host in self._host_table.values():
|
||||||
|
if HOST_PERSONALITY.WORKER in host.personality:
|
||||||
|
worker_hosts.append(host)
|
||||||
|
# Sort worker hosts so the order of the steps is deterministic
|
||||||
|
sorted_worker_hosts = sorted(worker_hosts, key=lambda host: host.name)
|
||||||
|
|
||||||
|
strategy = self.create_sw_upgrade_strategy(
|
||||||
|
worker_apply_type=SW_UPDATE_APPLY_TYPE.SERIAL
|
||||||
|
)
|
||||||
|
|
||||||
|
strategy._add_worker_strategy_stages(worker_hosts=sorted_worker_hosts,
|
||||||
|
reboot=True)
|
||||||
|
|
||||||
|
apply_phase = strategy.apply_phase.as_dict()
|
||||||
|
|
||||||
|
expected_results = {
|
||||||
|
'total_stages': 4,
|
||||||
|
'stages': [
|
||||||
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
|
'total_steps': 5,
|
||||||
|
'steps': [
|
||||||
|
{'name': 'query-alarms'},
|
||||||
|
{'name': 'lock-hosts',
|
||||||
|
'entity_names': ['compute-0']},
|
||||||
|
{'name': 'upgrade-hosts',
|
||||||
|
'entity_names': ['compute-0']},
|
||||||
|
_unlock_hosts_stage_as_dict(['compute-0']),
|
||||||
|
{'name': 'system-stabilize'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
|
'total_steps': 5,
|
||||||
|
'steps': [
|
||||||
|
{'name': 'query-alarms'},
|
||||||
|
{'name': 'lock-hosts',
|
||||||
'entity_names': ['compute-1']},
|
'entity_names': ['compute-1']},
|
||||||
|
{'name': 'upgrade-hosts',
|
||||||
|
'entity_names': ['compute-1']},
|
||||||
|
_unlock_hosts_stage_as_dict(['compute-1']),
|
||||||
|
{'name': 'system-stabilize'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
|
'total_steps': 5,
|
||||||
|
'steps': [
|
||||||
|
{'name': 'query-alarms'},
|
||||||
|
{'name': 'lock-hosts',
|
||||||
|
'entity_names': ['compute-2']},
|
||||||
|
{'name': 'upgrade-hosts',
|
||||||
|
'entity_names': ['compute-2']},
|
||||||
|
_unlock_hosts_stage_as_dict(['compute-2']),
|
||||||
|
{'name': 'system-stabilize'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
|
'total_steps': 5,
|
||||||
|
'steps': [
|
||||||
|
{'name': 'query-alarms'},
|
||||||
|
{'name': 'lock-hosts',
|
||||||
|
'entity_names': ['compute-3']},
|
||||||
|
{'name': 'upgrade-hosts',
|
||||||
|
'entity_names': ['compute-3']},
|
||||||
|
_unlock_hosts_stage_as_dict(['compute-3']),
|
||||||
{'name': 'system-stabilize'}
|
{'name': 'system-stabilize'}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -684,8 +937,7 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['storage-0']},
|
'entity_names': ['storage-0']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['storage-0']},
|
'entity_names': ['storage-0']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['storage-0'], retry_count=0),
|
||||||
'entity_names': ['storage-0']},
|
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'timeout': 7200}
|
'timeout': 7200}
|
||||||
]
|
]
|
||||||
@ -698,8 +950,8 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['storage-1', 'storage-2']},
|
'entity_names': ['storage-1', 'storage-2']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['storage-1', 'storage-2']},
|
'entity_names': ['storage-1', 'storage-2']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['storage-1', 'storage-2'],
|
||||||
'entity_names': ['storage-1', 'storage-2']},
|
retry_count=0),
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'timeout': 7200}
|
'timeout': 7200}
|
||||||
]
|
]
|
||||||
@ -712,8 +964,7 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['storage-3']},
|
'entity_names': ['storage-3']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['storage-3']},
|
'entity_names': ['storage-3']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['storage-3'], retry_count=0),
|
||||||
'entity_names': ['storage-3']},
|
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'timeout': 7200}
|
'timeout': 7200}
|
||||||
]
|
]
|
||||||
@ -770,10 +1021,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['storage-0']},
|
'entity_names': ['storage-0']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['storage-0']},
|
'entity_names': ['storage-0']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['storage-0'], retry_count=0),
|
||||||
'entity_names': ['storage-0']},
|
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 7200}
|
'timeout': 7200}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -785,10 +1035,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['storage-1']},
|
'entity_names': ['storage-1']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['storage-1']},
|
'entity_names': ['storage-1']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['storage-1'], retry_count=0),
|
||||||
'entity_names': ['storage-1']},
|
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 7200}
|
'timeout': 7200}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -800,10 +1049,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['storage-2']},
|
'entity_names': ['storage-2']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['storage-2']},
|
'entity_names': ['storage-2']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['storage-2'], retry_count=0),
|
||||||
'entity_names': ['storage-2']},
|
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 7200}
|
'timeout': 7200}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -815,10 +1063,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['storage-3']},
|
'entity_names': ['storage-3']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['storage-3']},
|
'entity_names': ['storage-3']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['storage-3'], retry_count=0),
|
||||||
'entity_names': ['storage-3']},
|
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 7200}
|
'timeout': 7200}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -864,10 +1111,10 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['controller-0']},
|
'entity_names': ['controller-0']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['controller-0']},
|
'entity_names': ['controller-0']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['controller-0'],
|
||||||
'entity_names': ['controller-0']},
|
retry_count=0),
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 14400}
|
'timeout': 14400}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -912,10 +1159,10 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['controller-1']},
|
'entity_names': ['controller-1']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['controller-1']},
|
'entity_names': ['controller-1']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['controller-1'],
|
||||||
'entity_names': ['controller-1']},
|
retry_count=0),
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 14400}
|
'timeout': 14400}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -929,10 +1176,10 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['controller-0']},
|
'entity_names': ['controller-0']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['controller-0']},
|
'entity_names': ['controller-0']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['controller-0'],
|
||||||
'entity_names': ['controller-0']},
|
retry_count=0),
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 14400}
|
'timeout': 14400}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -950,10 +1197,10 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
- aio hosts
|
- aio hosts
|
||||||
- serial apply
|
- serial apply
|
||||||
Verify:
|
Verify:
|
||||||
- controller-0 upgraded
|
- controller-0 and controller-1 upgraded
|
||||||
"""
|
"""
|
||||||
self.create_host('controller-0', aio=True)
|
self.create_host('controller-0', aio=True, openstack_installed=False)
|
||||||
self.create_host('controller-1', aio=True)
|
self.create_host('controller-1', aio=True, openstack_installed=False)
|
||||||
|
|
||||||
controller_hosts = []
|
controller_hosts = []
|
||||||
for host in self._host_table.values():
|
for host in self._host_table.values():
|
||||||
@ -961,15 +1208,106 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
HOST_NAME.CONTROLLER_0 == host.name):
|
HOST_NAME.CONTROLLER_0 == host.name):
|
||||||
controller_hosts.append(host)
|
controller_hosts.append(host)
|
||||||
|
|
||||||
strategy = self.create_sw_upgrade_strategy()
|
worker_hosts = []
|
||||||
|
for host in self._host_table.values():
|
||||||
|
if HOST_PERSONALITY.WORKER in host.personality:
|
||||||
|
worker_hosts.append(host)
|
||||||
|
# Sort worker hosts so the order of the steps is deterministic
|
||||||
|
sorted_worker_hosts = sorted(worker_hosts, key=lambda host: host.name)
|
||||||
|
|
||||||
|
strategy = self.create_sw_upgrade_strategy(worker_apply_type=SW_UPDATE_APPLY_TYPE.SERIAL)
|
||||||
|
|
||||||
success, reason = strategy._add_controller_strategy_stages(
|
success, reason = strategy._add_controller_strategy_stages(
|
||||||
controllers=controller_hosts,
|
controllers=controller_hosts,
|
||||||
reboot=True)
|
reboot=True)
|
||||||
|
|
||||||
assert success is False, "Strategy creation did not fail"
|
assert success is True, ""
|
||||||
assert reason == "cannot apply software upgrades to AIO configuration", \
|
apply_phase = strategy.apply_phase.as_dict()
|
||||||
"Invalid failure reason"
|
expected_results = {
|
||||||
|
'total_stages': 0,
|
||||||
|
}
|
||||||
|
sw_update_testcase.validate_strategy_persists(strategy)
|
||||||
|
sw_update_testcase.validate_phase(apply_phase, expected_results)
|
||||||
|
|
||||||
|
strategy._add_worker_strategy_stages(
|
||||||
|
worker_hosts=sorted_worker_hosts,
|
||||||
|
reboot=True)
|
||||||
|
|
||||||
|
apply_phase = strategy.apply_phase.as_dict()
|
||||||
|
|
||||||
|
expected_results = {
|
||||||
|
'total_stages': 2,
|
||||||
|
'stages': [
|
||||||
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
|
'total_steps': 6,
|
||||||
|
'steps': [
|
||||||
|
{'name': 'query-alarms'},
|
||||||
|
{'name': 'swact-hosts',
|
||||||
|
'entity_names': ['controller-0']},
|
||||||
|
{'name': 'lock-hosts',
|
||||||
|
'entity_names': ['controller-0']},
|
||||||
|
{'name': 'upgrade-hosts',
|
||||||
|
'entity_names': ['controller-0']},
|
||||||
|
_unlock_hosts_stage_as_dict(['controller-0']),
|
||||||
|
{'name': 'wait-data-sync',
|
||||||
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
|
'timeout': 14400}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
|
'total_steps': 6,
|
||||||
|
'steps': [
|
||||||
|
{'name': 'query-alarms'},
|
||||||
|
{'name': 'swact-hosts',
|
||||||
|
'entity_names': ['controller-1']},
|
||||||
|
{'name': 'lock-hosts',
|
||||||
|
'entity_names': ['controller-1']},
|
||||||
|
{'name': 'upgrade-hosts',
|
||||||
|
'entity_names': ['controller-1']},
|
||||||
|
_unlock_hosts_stage_as_dict(['controller-1']),
|
||||||
|
{'name': 'wait-data-sync',
|
||||||
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
|
'timeout': 14400}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
sw_update_testcase.validate_strategy_persists(strategy)
|
||||||
|
sw_update_testcase.validate_phase(apply_phase, expected_results)
|
||||||
|
|
||||||
|
@mock.patch('nfv_vim.strategy._strategy.get_local_host_name',
|
||||||
|
sw_update_testcase.fake_host_name_controller_1)
|
||||||
|
def test_sw_upgrade_strategy_aiosx_stages_serial(self):
|
||||||
|
"""
|
||||||
|
Test the sw_upgrade strategy add controller strategy stages:
|
||||||
|
- aio-sx hosts
|
||||||
|
- serial apply
|
||||||
|
Verify:
|
||||||
|
- failure
|
||||||
|
"""
|
||||||
|
self.create_host('controller-0', aio=True)
|
||||||
|
|
||||||
|
controller_hosts = []
|
||||||
|
for host in self._host_table.values():
|
||||||
|
if (HOST_PERSONALITY.CONTROLLER in host.personality and
|
||||||
|
HOST_NAME.CONTROLLER_0 == host.name):
|
||||||
|
controller_hosts.append(host)
|
||||||
|
|
||||||
|
strategy = self.create_sw_upgrade_strategy(single_controller=True)
|
||||||
|
|
||||||
|
success, reason = strategy._add_controller_strategy_stages(
|
||||||
|
controllers=controller_hosts,
|
||||||
|
reboot=True)
|
||||||
|
|
||||||
|
assert success is False
|
||||||
|
assert reason == "not enough controllers to apply software upgrades"
|
||||||
|
apply_phase = strategy.apply_phase.as_dict()
|
||||||
|
expected_results = {
|
||||||
|
'total_stages': 0,
|
||||||
|
}
|
||||||
|
sw_update_testcase.validate_strategy_persists(strategy)
|
||||||
|
sw_update_testcase.validate_phase(apply_phase, expected_results)
|
||||||
|
|
||||||
@testtools.skip('No support for start_upgrade')
|
@testtools.skip('No support for start_upgrade')
|
||||||
def test_sw_upgrade_strategy_build_complete_serial_migrate_start_complete(self):
|
def test_sw_upgrade_strategy_build_complete_serial_migrate_start_complete(self):
|
||||||
@ -1027,27 +1365,23 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['controller-1']},
|
'entity_names': ['controller-1']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['controller-1']},
|
'entity_names': ['controller-1']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['controller-1']),
|
||||||
'entity_names': ['controller-1']},
|
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 14400}
|
'timeout': 14400}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{'name': 'sw-upgrade-controllers',
|
{'name': 'sw-upgrade-controllers',
|
||||||
'total_steps': 6,
|
'total_steps': 5,
|
||||||
'steps': [
|
'steps': [
|
||||||
{'name': 'query-alarms'},
|
{'name': 'query-alarms'},
|
||||||
{'name': 'swact-hosts',
|
|
||||||
'entity_names': ['controller-0']},
|
|
||||||
{'name': 'lock-hosts',
|
{'name': 'lock-hosts',
|
||||||
'entity_names': ['controller-0']},
|
'entity_names': ['controller-0']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['controller-0']},
|
'entity_names': ['controller-0']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['controller-0']),
|
||||||
'entity_names': ['controller-0']},
|
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 14400}
|
'timeout': 14400}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -1059,10 +1393,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['storage-0']},
|
'entity_names': ['storage-0']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['storage-0']},
|
'entity_names': ['storage-0']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['storage-0']),
|
||||||
'entity_names': ['storage-0']},
|
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 7200}
|
'timeout': 7200}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -1074,10 +1407,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['storage-1']},
|
'entity_names': ['storage-1']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['storage-1']},
|
'entity_names': ['storage-1']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['storage-1']),
|
||||||
'entity_names': ['storage-1']},
|
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 7200}
|
'timeout': 7200}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -1089,8 +1421,7 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-1']},
|
'entity_names': ['compute-1']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-1']},
|
'entity_names': ['compute-1']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-1']),
|
||||||
'entity_names': ['compute-1']},
|
|
||||||
{'name': 'system-stabilize',
|
{'name': 'system-stabilize',
|
||||||
'timeout': 60}
|
'timeout': 60}
|
||||||
]
|
]
|
||||||
@ -1105,8 +1436,7 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-0']},
|
'entity_names': ['compute-0']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-0']},
|
'entity_names': ['compute-0']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-0']),
|
||||||
'entity_names': ['compute-0']},
|
|
||||||
{'name': 'system-stabilize',
|
{'name': 'system-stabilize',
|
||||||
'timeout': 60}
|
'timeout': 60}
|
||||||
]
|
]
|
||||||
@ -1173,10 +1503,10 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['controller-1']},
|
'entity_names': ['controller-1']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['controller-1']},
|
'entity_names': ['controller-1']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['controller-1'],
|
||||||
'entity_names': ['controller-1']},
|
retry_count=0),
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 14400}
|
'timeout': 14400}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -1190,10 +1520,10 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['controller-0']},
|
'entity_names': ['controller-0']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['controller-0']},
|
'entity_names': ['controller-0']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['controller-0'],
|
||||||
'entity_names': ['controller-0']},
|
retry_count=0),
|
||||||
{'name': 'wait-data-sync',
|
{'name': 'wait-data-sync',
|
||||||
'ignore_alarms': ['900.005', '900.201'],
|
'ignore_alarms': ['900.005', '900.201', '750.006'],
|
||||||
'timeout': 14400}
|
'timeout': 14400}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -1205,10 +1535,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-1']},
|
'entity_names': ['compute-1']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-1']},
|
'entity_names': ['compute-1']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-1']),
|
||||||
'entity_names': ['compute-1']},
|
{'name': 'wait-alarms-clear',
|
||||||
{'name': 'system-stabilize',
|
'timeout': 600}
|
||||||
'timeout': 60}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{'name': 'sw-upgrade-worker-hosts',
|
{'name': 'sw-upgrade-worker-hosts',
|
||||||
@ -1221,10 +1550,9 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
'entity_names': ['compute-0']},
|
'entity_names': ['compute-0']},
|
||||||
{'name': 'upgrade-hosts',
|
{'name': 'upgrade-hosts',
|
||||||
'entity_names': ['compute-0']},
|
'entity_names': ['compute-0']},
|
||||||
{'name': 'unlock-hosts',
|
_unlock_hosts_stage_as_dict(['compute-0']),
|
||||||
'entity_names': ['compute-0']},
|
{'name': 'wait-alarms-clear',
|
||||||
{'name': 'system-stabilize',
|
'timeout': 600}
|
||||||
'timeout': 60}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -1451,7 +1779,8 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
expected_results = {
|
expected_results = {
|
||||||
'total_stages': 0,
|
'total_stages': 0,
|
||||||
'result': 'failed',
|
'result': 'failed',
|
||||||
'result_reason': 'all controller hosts must be unlocked-enabled-available'
|
'result_reason':
|
||||||
|
'all controller hosts must be unlocked-enabled-available'
|
||||||
}
|
}
|
||||||
|
|
||||||
sw_update_testcase.validate_phase(build_phase, expected_results)
|
sw_update_testcase.validate_phase(build_phase, expected_results)
|
||||||
@ -1497,7 +1826,55 @@ class TestSwUpgradeStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
|
|||||||
expected_results = {
|
expected_results = {
|
||||||
'total_stages': 0,
|
'total_stages': 0,
|
||||||
'result': 'failed',
|
'result': 'failed',
|
||||||
'result_reason': 'all worker hosts must be unlocked-enabled-available'
|
'result_reason':
|
||||||
|
'all worker hosts must be unlocked-enabled-available'
|
||||||
}
|
}
|
||||||
|
|
||||||
sw_update_testcase.validate_phase(build_phase, expected_results)
|
sw_update_testcase.validate_phase(build_phase, expected_results)
|
||||||
|
|
||||||
|
@mock.patch('nfv_vim.strategy._strategy.get_local_host_name',
|
||||||
|
sw_update_testcase.fake_host_name_controller_1)
|
||||||
|
def test_sw_upgrade_strategy_controller_missing_strategy_fields(self):
|
||||||
|
"""
|
||||||
|
Test the sw_upgrade strategy add controller strategy stages:
|
||||||
|
- serial apply
|
||||||
|
Verify:
|
||||||
|
- controller-0 upgraded
|
||||||
|
- the missing fields do not cause deserialization failures
|
||||||
|
"""
|
||||||
|
self.create_host('controller-0')
|
||||||
|
self.create_host('controller-1')
|
||||||
|
|
||||||
|
controller_hosts = []
|
||||||
|
for host in self._host_table.values():
|
||||||
|
if (HOST_PERSONALITY.CONTROLLER in host.personality and
|
||||||
|
HOST_NAME.CONTROLLER_0 == host.name):
|
||||||
|
controller_hosts.append(host)
|
||||||
|
strategy = self.create_sw_upgrade_strategy()
|
||||||
|
strategy._add_controller_strategy_stages(controllers=controller_hosts,
|
||||||
|
reboot=True)
|
||||||
|
|
||||||
|
strategy_dict = strategy.as_dict()
|
||||||
|
# remove the fields that do not exist in the previous version
|
||||||
|
# - the retry fields in 'unlock'
|
||||||
|
# in this strategy the unlock hosts stage is located at:
|
||||||
|
# - first stage of apply is sw-upgrade-controllers for controller-0
|
||||||
|
# - 4th step (index 3) in that stage is the unlock-hosts step
|
||||||
|
|
||||||
|
# Ensure the field exists before we remove it
|
||||||
|
self.assertEqual(
|
||||||
|
120,
|
||||||
|
strategy_dict['apply_phase']['stages'][0]['steps'][3]['retry_delay'])
|
||||||
|
# remove the fields that would not exist in an older version
|
||||||
|
strategy_dict['apply_phase']['stages'][0]['steps'][3].pop('retry_delay')
|
||||||
|
strategy_dict['apply_phase']['stages'][0]['steps'][3].pop('retry_count')
|
||||||
|
|
||||||
|
# rebuild from the dictionary. If the new code is not robust, it would
|
||||||
|
# raise an exception
|
||||||
|
new_strategy = strategy_rebuild_from_dict(strategy_dict)
|
||||||
|
|
||||||
|
# the default value should be re-populated
|
||||||
|
strategy_dict = new_strategy.as_dict()
|
||||||
|
self.assertEqual(
|
||||||
|
120,
|
||||||
|
strategy_dict['apply_phase']['stages'][0]['steps'][3]['retry_delay'])
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2016-2020 Wind River Systems, Inc.
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -114,6 +114,41 @@ _alarm_templates = {
|
|||||||
"problem persists contact next level of support"),
|
"problem persists contact next level of support"),
|
||||||
'exclude_alarm_context': [alarm.ALARM_CONTEXT.TENANT],
|
'exclude_alarm_context': [alarm.ALARM_CONTEXT.TENANT],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
alarm.ALARM_TYPE.KUBE_UPGRADE_AUTO_APPLY_INPROGRESS: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': alarm.ALARM_EVENT_TYPE.EQUIPMENT_ALARM,
|
||||||
|
'severity': alarm.ALARM_SEVERITY.MAJOR,
|
||||||
|
'probable_cause': alarm.ALARM_PROBABLE_CAUSE.UNKNOWN,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply inprogress",
|
||||||
|
'repair_action': ("Wait for kubernetes upgrade auto-apply to complete; "
|
||||||
|
"if problem persists contact next level of support"),
|
||||||
|
'exclude_alarm_context': [alarm.ALARM_CONTEXT.TENANT],
|
||||||
|
},
|
||||||
|
alarm.ALARM_TYPE.KUBE_UPGRADE_AUTO_APPLY_ABORTING: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': alarm.ALARM_EVENT_TYPE.EQUIPMENT_ALARM,
|
||||||
|
'severity': alarm.ALARM_SEVERITY.MAJOR,
|
||||||
|
'probable_cause': alarm.ALARM_PROBABLE_CAUSE.UNKNOWN,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply aborting",
|
||||||
|
'repair_action': ("Wait for kubernetes upgrade auto-apply abort to "
|
||||||
|
"complete; if problem persists contact next "
|
||||||
|
"level of support"),
|
||||||
|
'exclude_alarm_context': [alarm.ALARM_CONTEXT.TENANT],
|
||||||
|
},
|
||||||
|
alarm.ALARM_TYPE.KUBE_UPGRADE_AUTO_APPLY_FAILED: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': alarm.ALARM_EVENT_TYPE.EQUIPMENT_ALARM,
|
||||||
|
'severity': alarm.ALARM_SEVERITY.CRITICAL,
|
||||||
|
'probable_cause': alarm.ALARM_PROBABLE_CAUSE.UNKNOWN,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply failed",
|
||||||
|
'repair_action': ("Attempt to apply kubernetes upgrade manually; if "
|
||||||
|
"problem persists contact next level of support"),
|
||||||
|
'exclude_alarm_context': [alarm.ALARM_CONTEXT.TENANT],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -11,6 +11,7 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
|
|
||||||
from nfv_vim.api._link import Link
|
from nfv_vim.api._link import Link
|
||||||
from nfv_vim.api.controllers.v1.orchestration.sw_update import FwUpdateAPI
|
from nfv_vim.api.controllers.v1.orchestration.sw_update import FwUpdateAPI
|
||||||
|
from nfv_vim.api.controllers.v1.orchestration.sw_update import KubeUpgradeAPI
|
||||||
from nfv_vim.api.controllers.v1.orchestration.sw_update import SwPatchAPI
|
from nfv_vim.api.controllers.v1.orchestration.sw_update import SwPatchAPI
|
||||||
from nfv_vim.api.controllers.v1.orchestration.sw_update import SwUpgradeAPI
|
from nfv_vim.api.controllers.v1.orchestration.sw_update import SwUpgradeAPI
|
||||||
|
|
||||||
@ -32,6 +33,8 @@ class OrchestrationDescription(wsme_types.Base):
|
|||||||
Link.make_link('self', url, 'orchestration'),
|
Link.make_link('self', url, 'orchestration'),
|
||||||
Link.make_link('sw-patch', url, 'orchestration/sw-patch', ''),
|
Link.make_link('sw-patch', url, 'orchestration/sw-patch', ''),
|
||||||
Link.make_link('sw-upgrade', url, 'orchestration/sw-upgrade', ''),
|
Link.make_link('sw-upgrade', url, 'orchestration/sw-upgrade', ''),
|
||||||
|
Link.make_link('kube-upgrade',
|
||||||
|
url, 'orchestration/kube-upgrade', ''),
|
||||||
Link.make_link('fw-update', url, 'orchestration/fw-update', '')]
|
Link.make_link('fw-update', url, 'orchestration/fw-update', '')]
|
||||||
return description
|
return description
|
||||||
|
|
||||||
@ -48,6 +51,8 @@ class OrchestrationAPI(rest.RestController):
|
|||||||
return SwUpgradeAPI(), remainder
|
return SwUpgradeAPI(), remainder
|
||||||
elif 'fw-update' == key:
|
elif 'fw-update' == key:
|
||||||
return FwUpdateAPI(), remainder
|
return FwUpdateAPI(), remainder
|
||||||
|
elif 'kube-upgrade' == key:
|
||||||
|
return KubeUpgradeAPI(), remainder
|
||||||
else:
|
else:
|
||||||
pecan.abort(httplib.NOT_FOUND)
|
pecan.abort(httplib.NOT_FOUND)
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
from nfv_vim.api.controllers.v1.orchestration.sw_update._fw_update import FwUpdateAPI # noqa: F401
|
from nfv_vim.api.controllers.v1.orchestration.sw_update._fw_update import FwUpdateAPI # noqa: F401
|
||||||
|
from nfv_vim.api.controllers.v1.orchestration.sw_update._kube_upgrade import KubeUpgradeAPI # noqa: F401
|
||||||
from nfv_vim.api.controllers.v1.orchestration.sw_update._sw_patch import SwPatchAPI # noqa: F401
|
from nfv_vim.api.controllers.v1.orchestration.sw_update._sw_patch import SwPatchAPI # noqa: F401
|
||||||
from nfv_vim.api.controllers.v1.orchestration.sw_update._sw_upgrade import SwUpgradeAPI # noqa: F401
|
from nfv_vim.api.controllers.v1.orchestration.sw_update._sw_upgrade import SwUpgradeAPI # noqa: F401
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2020-2021 Wind River Systems, Inc.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
import pecan
|
||||||
|
from pecan import rest
|
||||||
|
from six.moves import http_client as httplib
|
||||||
|
from wsme import types as wsme_types
|
||||||
|
import wsmeext.pecan as wsme_pecan
|
||||||
|
|
||||||
|
from nfv_common import debug
|
||||||
|
from nfv_vim.api._link import Link
|
||||||
|
from nfv_vim.api.controllers.v1.orchestration.sw_update._sw_update_strategy \
|
||||||
|
import KubeUpgradeStrategyAPI
|
||||||
|
|
||||||
|
DLOG = debug.debug_get_logger('nfv_vim.api.kube_upgrade')
|
||||||
|
|
||||||
|
|
||||||
|
class KubeUpgradeDescription(wsme_types.Base):
|
||||||
|
"""
|
||||||
|
Kubernetes Update Description
|
||||||
|
"""
|
||||||
|
id = wsme_types.text
|
||||||
|
links = wsme_types.wsattr([Link], name='links')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def convert(cls):
|
||||||
|
url = pecan.request.host_url
|
||||||
|
|
||||||
|
description = KubeUpgradeDescription()
|
||||||
|
description.id = "kube-upgrade"
|
||||||
|
description.links = [
|
||||||
|
Link.make_link('self',
|
||||||
|
url,
|
||||||
|
'orchestration/kube-upgrade'),
|
||||||
|
Link.make_link('strategy',
|
||||||
|
url,
|
||||||
|
'orchestration/kube-upgrade/strategy')]
|
||||||
|
return description
|
||||||
|
|
||||||
|
|
||||||
|
class KubeUpgradeAPI(rest.RestController):
|
||||||
|
"""
|
||||||
|
KubeUpgradeRest API
|
||||||
|
"""
|
||||||
|
@pecan.expose()
|
||||||
|
def _lookup(self, key, *remainder):
|
||||||
|
if 'strategy' == key:
|
||||||
|
return KubeUpgradeStrategyAPI(), remainder
|
||||||
|
else:
|
||||||
|
pecan.abort(httplib.NOT_FOUND)
|
||||||
|
|
||||||
|
@wsme_pecan.wsexpose(KubeUpgradeDescription)
|
||||||
|
def get(self):
|
||||||
|
# NOTE: The reason why convert() is being called for every
|
||||||
|
# request is because we need to get the host url from
|
||||||
|
# the request object to make the links.
|
||||||
|
return KubeUpgradeDescription.convert()
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -19,6 +19,7 @@ class SwUpdateNames(Constants):
|
|||||||
SW_PATCH = Constant('sw-patch')
|
SW_PATCH = Constant('sw-patch')
|
||||||
SW_UPGRADE = Constant('sw-upgrade')
|
SW_UPGRADE = Constant('sw-upgrade')
|
||||||
FW_UPDATE = Constant('fw-update')
|
FW_UPDATE = Constant('fw-update')
|
||||||
|
KUBE_UPGRADE = Constant('kube-upgrade')
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(Singleton)
|
@six.add_metaclass(Singleton)
|
||||||
@ -72,7 +73,8 @@ SW_UPDATE_ALARM_RESTRICTION_TYPES = SwUpdateAlarmRestrictionTypes()
|
|||||||
SwUpdateNames = wsme_types.Enum(str,
|
SwUpdateNames = wsme_types.Enum(str,
|
||||||
SW_UPDATE_NAME.SW_PATCH,
|
SW_UPDATE_NAME.SW_PATCH,
|
||||||
SW_UPDATE_NAME.SW_UPGRADE,
|
SW_UPDATE_NAME.SW_UPGRADE,
|
||||||
SW_UPDATE_NAME.FW_UPDATE)
|
SW_UPDATE_NAME.FW_UPDATE,
|
||||||
|
SW_UPDATE_NAME.KUBE_UPGRADE)
|
||||||
SwUpdateApplyTypes = wsme_types.Enum(str,
|
SwUpdateApplyTypes = wsme_types.Enum(str,
|
||||||
SW_UPDATE_APPLY_TYPE.SERIAL,
|
SW_UPDATE_APPLY_TYPE.SERIAL,
|
||||||
SW_UPDATE_APPLY_TYPE.PARALLEL,
|
SW_UPDATE_APPLY_TYPE.PARALLEL,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -33,6 +33,7 @@ MIN_PARALLEL_HOSTS = 2
|
|||||||
MAX_PARALLEL_PATCH_HOSTS = 100
|
MAX_PARALLEL_PATCH_HOSTS = 100
|
||||||
MAX_PARALLEL_UPGRADE_HOSTS = 10
|
MAX_PARALLEL_UPGRADE_HOSTS = 10
|
||||||
MAX_PARALLEL_FW_UPDATE_HOSTS = 5
|
MAX_PARALLEL_FW_UPDATE_HOSTS = 5
|
||||||
|
MAX_PARALLEL_KUBE_UPGRADE_HOSTS = 10
|
||||||
|
|
||||||
|
|
||||||
def _get_sw_update_type_from_path(path):
|
def _get_sw_update_type_from_path(path):
|
||||||
@ -43,6 +44,8 @@ def _get_sw_update_type_from_path(path):
|
|||||||
return SW_UPDATE_NAME.SW_UPGRADE
|
return SW_UPDATE_NAME.SW_UPGRADE
|
||||||
elif 'fw-update' in split_path:
|
elif 'fw-update' in split_path:
|
||||||
return SW_UPDATE_NAME.FW_UPDATE
|
return SW_UPDATE_NAME.FW_UPDATE
|
||||||
|
elif 'kube-upgrade' in split_path:
|
||||||
|
return SW_UPDATE_NAME.KUBE_UPGRADE
|
||||||
else:
|
else:
|
||||||
DLOG.error("Unknown sw_update_type in path: %s" % path)
|
DLOG.error("Unknown sw_update_type in path: %s" % path)
|
||||||
return 'unknown'
|
return 'unknown'
|
||||||
@ -201,6 +204,33 @@ class FwUpdateStrategyCreateData(wsme_types.Base):
|
|||||||
name='alarm-restrictions')
|
name='alarm-restrictions')
|
||||||
|
|
||||||
|
|
||||||
|
class KubeUpgradeStrategyCreateData(wsme_types.Base):
|
||||||
|
"""
|
||||||
|
Kubernetes Upgrade Strategy - Create Data
|
||||||
|
"""
|
||||||
|
to_version = wsme_types.wsattr(six.text_type,
|
||||||
|
mandatory=True,
|
||||||
|
name='to-version')
|
||||||
|
storage_apply_type = wsme_types.wsattr(SwUpdateApplyTypes,
|
||||||
|
mandatory=True,
|
||||||
|
name='storage-apply-type')
|
||||||
|
worker_apply_type = wsme_types.wsattr(SwUpdateApplyTypes,
|
||||||
|
mandatory=True,
|
||||||
|
name='worker-apply-type')
|
||||||
|
max_parallel_worker_hosts = wsme_types.wsattr(
|
||||||
|
int,
|
||||||
|
mandatory=False,
|
||||||
|
name='max-parallel-worker-hosts')
|
||||||
|
default_instance_action = wsme_types.wsattr(SwUpdateInstanceActionTypes,
|
||||||
|
mandatory=True,
|
||||||
|
name='default-instance-action')
|
||||||
|
alarm_restrictions = wsme_types.wsattr(
|
||||||
|
SwUpdateAlarmRestrictionTypes,
|
||||||
|
mandatory=False,
|
||||||
|
default=SW_UPDATE_ALARM_RESTRICTION_TYPES.STRICT,
|
||||||
|
name='alarm-restrictions')
|
||||||
|
|
||||||
|
|
||||||
class SwUpdateStrategyActionData(wsme_types.Base):
|
class SwUpdateStrategyActionData(wsme_types.Base):
|
||||||
"""
|
"""
|
||||||
Software Update Strategy - Action Data
|
Software Update Strategy - Action Data
|
||||||
@ -633,3 +663,62 @@ class FwUpdateStrategyAPI(SwUpdateStrategyAPI):
|
|||||||
|
|
||||||
DLOG.error("Unexpected result received, result=%s." % response.result)
|
DLOG.error("Unexpected result received, result=%s." % response.result)
|
||||||
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||||
|
|
||||||
|
|
||||||
|
class KubeUpgradeStrategyAPI(SwUpdateStrategyAPI):
|
||||||
|
"""
|
||||||
|
Kubernetes Upgrade Strategy Rest API
|
||||||
|
"""
|
||||||
|
@wsme_pecan.wsexpose(SwUpdateStrategyQueryData,
|
||||||
|
body=KubeUpgradeStrategyCreateData,
|
||||||
|
status_code=httplib.OK)
|
||||||
|
def post(self, request_data):
|
||||||
|
rpc_request = rpc.APIRequestCreateKubeUpgradeStrategy()
|
||||||
|
rpc_request.sw_update_type = _get_sw_update_type_from_path(
|
||||||
|
pecan.request.path)
|
||||||
|
rpc_request.to_version = request_data.to_version
|
||||||
|
rpc_request.controller_apply_type = SW_UPDATE_APPLY_TYPE.SERIAL
|
||||||
|
rpc_request.storage_apply_type = request_data.storage_apply_type
|
||||||
|
rpc_request.worker_apply_type = request_data.worker_apply_type
|
||||||
|
if wsme_types.Unset != request_data.max_parallel_worker_hosts:
|
||||||
|
if request_data.max_parallel_worker_hosts < MIN_PARALLEL_HOSTS:
|
||||||
|
return pecan.abort(
|
||||||
|
httplib.BAD_REQUEST,
|
||||||
|
"Invalid value for max-parallel-worker-hosts:(%s) < (%s)"
|
||||||
|
% (request_data.max_parallel_worker_hosts,
|
||||||
|
MIN_PARALLEL_HOSTS))
|
||||||
|
if (request_data.max_parallel_worker_hosts >
|
||||||
|
MAX_PARALLEL_KUBE_UPGRADE_HOSTS):
|
||||||
|
return pecan.abort(
|
||||||
|
httplib.BAD_REQUEST,
|
||||||
|
"Invalid value for max-parallel-worker-hosts:(%s) > (%s)"
|
||||||
|
% (request_data.max_parallel_worker_hosts,
|
||||||
|
MAX_PARALLEL_KUBE_UPGRADE_HOSTS))
|
||||||
|
rpc_request.max_parallel_worker_hosts = \
|
||||||
|
request_data.max_parallel_worker_hosts
|
||||||
|
rpc_request.default_instance_action = request_data.default_instance_action
|
||||||
|
rpc_request.alarm_restrictions = request_data.alarm_restrictions
|
||||||
|
vim_connection = pecan.request.vim.open_connection()
|
||||||
|
vim_connection.send(rpc_request.serialize())
|
||||||
|
msg = vim_connection.receive(timeout_in_secs=30)
|
||||||
|
if msg is None:
|
||||||
|
DLOG.error("No response received.")
|
||||||
|
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||||
|
|
||||||
|
response = rpc.RPCMessage.deserialize(msg)
|
||||||
|
if (rpc.RPC_MSG_TYPE.CREATE_SW_UPDATE_STRATEGY_RESPONSE !=
|
||||||
|
response.type):
|
||||||
|
DLOG.error("Unexpected message type received, msg_type=%s."
|
||||||
|
% response.type)
|
||||||
|
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||||
|
|
||||||
|
if rpc.RPC_MSG_RESULT.SUCCESS == response.result:
|
||||||
|
strategy = json.loads(response.strategy)
|
||||||
|
query_data = SwUpdateStrategyQueryData()
|
||||||
|
query_data.convert_strategy(strategy)
|
||||||
|
return query_data
|
||||||
|
elif rpc.RPC_MSG_RESULT.CONFLICT == response.result:
|
||||||
|
return pecan.abort(httplib.CONFLICT)
|
||||||
|
|
||||||
|
DLOG.error("Unexpected result received, result=%s." % response.result)
|
||||||
|
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2016,2020 Wind River Systems, Inc.
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -69,4 +69,8 @@ def database_sw_update_get_list():
|
|||||||
elif objects.SW_UPDATE_TYPE.FW_UPDATE == sw_update.sw_update_type:
|
elif objects.SW_UPDATE_TYPE.FW_UPDATE == sw_update.sw_update_type:
|
||||||
fw_update_obj = objects.FwUpdate(sw_update.uuid, strategy_data)
|
fw_update_obj = objects.FwUpdate(sw_update.uuid, strategy_data)
|
||||||
sw_update_objs.append(fw_update_obj)
|
sw_update_objs.append(fw_update_obj)
|
||||||
|
elif objects.SW_UPDATE_TYPE.KUBE_UPGRADE == sw_update.sw_update_type:
|
||||||
|
kube_upgrade_obj = objects.KubeUpgrade(sw_update.uuid,
|
||||||
|
strategy_data)
|
||||||
|
sw_update_objs.append(kube_upgrade_obj)
|
||||||
return sw_update_objs
|
return sw_update_objs
|
||||||
|
@ -85,6 +85,7 @@ nfv_common.histogram: debug.level.verbose
|
|||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
nfv_vim.nfvi.nfvi_block_storage_plugin: debug.level.verbose
|
nfv_vim.nfvi.nfvi_block_storage_plugin: debug.level.verbose
|
||||||
nfv_vim.nfvi.nfvi_compute_plugin: debug.level.verbose
|
nfv_vim.nfvi.nfvi_compute_plugin: debug.level.verbose
|
||||||
|
nfv_vim.nfvi.nfvi_fault_mgmt_plugin: debug.level.verbose
|
||||||
nfv_vim.nfvi.nfvi_guest_plugin: debug.level.verbose
|
nfv_vim.nfvi.nfvi_guest_plugin: debug.level.verbose
|
||||||
nfv_vim.nfvi.nfvi_identity_plugin: debug.level.verbose
|
nfv_vim.nfvi.nfvi_identity_plugin: debug.level.verbose
|
||||||
nfv_vim.nfvi.nfvi_image_plugin: debug.level.verbose
|
nfv_vim.nfvi.nfvi_image_plugin: debug.level.verbose
|
||||||
@ -94,6 +95,7 @@ nfv_vim.nfvi.nfvi_sw_mgmt_plugin: debug.level.verbose
|
|||||||
nfv_vim.nfvi.nfvi_plugin: debug.level.verbose
|
nfv_vim.nfvi.nfvi_plugin: debug.level.verbose
|
||||||
nfv_vim.nfvi.nfvi_block_storage_module: debug.level.verbose
|
nfv_vim.nfvi.nfvi_block_storage_module: debug.level.verbose
|
||||||
nfv_vim.nfvi.nfvi_compute_module: debug.level.verbose
|
nfv_vim.nfvi.nfvi_compute_module: debug.level.verbose
|
||||||
|
nfv_vim.nfvi.nfvi_fault_mgmt_module: debug.level.verbose
|
||||||
nfv_vim.nfvi.nfvi_guest_module: debug.level.verbose
|
nfv_vim.nfvi.nfvi_guest_module: debug.level.verbose
|
||||||
nfv_vim.nfvi.nfvi_identity_module: debug.level.verbose
|
nfv_vim.nfvi.nfvi_identity_module: debug.level.verbose
|
||||||
nfv_vim.nfvi.nfvi_image_module: debug.level.verbose
|
nfv_vim.nfvi.nfvi_image_module: debug.level.verbose
|
||||||
@ -123,9 +125,11 @@ nfv_vim.objects.guest_services: debug.level.verbose
|
|||||||
nfv_vim.objects.host_group: debug.level.verbose
|
nfv_vim.objects.host_group: debug.level.verbose
|
||||||
nfv_vim.objects.instance_group: debug.level.verbose
|
nfv_vim.objects.instance_group: debug.level.verbose
|
||||||
nfv_vim.objects.fw_update: debug.level.info
|
nfv_vim.objects.fw_update: debug.level.info
|
||||||
|
nfv_vim.objects.kube_upgrade: debug.level.info
|
||||||
nfv_vim.objects.sw_update: debug.level.verbose
|
nfv_vim.objects.sw_update: debug.level.verbose
|
||||||
nfv_vim.objects.sw_patch: debug.level.verbose
|
nfv_vim.objects.sw_patch: debug.level.verbose
|
||||||
nfv_vim.objects.sw_upgrade: debug.level.verbose
|
nfv_vim.objects.sw_upgrade: debug.level.verbose
|
||||||
|
nfv_vim.objects.volume_snapshot: debug.level.verbose
|
||||||
nfv_vim.vim_image_api_events: debug.level.verbose
|
nfv_vim.vim_image_api_events: debug.level.verbose
|
||||||
nfv_vim.vim_volume_api_events: debug.level.verbose
|
nfv_vim.vim_volume_api_events: debug.level.verbose
|
||||||
nfv_vim.vim_instance_api_events: debug.level.verbose
|
nfv_vim.vim_instance_api_events: debug.level.verbose
|
||||||
@ -139,6 +143,7 @@ nfv_vim.rpc.image: debug.level.verbose
|
|||||||
nfv_vim.rpc.volume: debug.level.verbose
|
nfv_vim.rpc.volume: debug.level.verbose
|
||||||
nfv_vim.rpc.instance: debug.level.verbose
|
nfv_vim.rpc.instance: debug.level.verbose
|
||||||
nfv_vim.rpc.network: debug.level.verbose
|
nfv_vim.rpc.network: debug.level.verbose
|
||||||
|
nfv_vim.rpc.subnet: debug.level.verbose
|
||||||
nfv_vim.rpc.sw_update: debug.level.verbose
|
nfv_vim.rpc.sw_update: debug.level.verbose
|
||||||
nfv_vim.host_director: debug.level.verbose
|
nfv_vim.host_director: debug.level.verbose
|
||||||
nfv_vim.image_director: debug.level.verbose
|
nfv_vim.image_director: debug.level.verbose
|
||||||
@ -154,8 +159,13 @@ nfv_vim.dor: debug.level.verbose
|
|||||||
nfv_vim.l3_rebalance: debug.level.info
|
nfv_vim.l3_rebalance: debug.level.info
|
||||||
nfv_vim.dhcp_rebalance: debug.level.info
|
nfv_vim.dhcp_rebalance: debug.level.info
|
||||||
nfv_vim: debug.level.verbose
|
nfv_vim: debug.level.verbose
|
||||||
|
nfv_vim.database: debug.level.verbose
|
||||||
|
nfv_vim.manage: debug.level.verbose
|
||||||
|
nfv_vim.vim_network_api_events: debug.level.verbose
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
nfv_vim.api.openstack: debug.level.verbose
|
nfv_vim.api.openstack: debug.level.verbose
|
||||||
|
nfv_vim.api.fw_update: debug.level.verbose
|
||||||
|
nfv_vim.api.kube_upgrade: debug.level.verbose
|
||||||
nfv_vim.api.sw_patch: debug.level.verbose
|
nfv_vim.api.sw_patch: debug.level.verbose
|
||||||
nfv_vim.api.sw_upgrade: debug.level.verbose
|
nfv_vim.api.sw_upgrade: debug.level.verbose
|
||||||
nfv_vim.api.sw_update.strategy: debug.level.verbose
|
nfv_vim.api.sw_update.strategy: debug.level.verbose
|
||||||
@ -175,6 +185,7 @@ nfv_plugins.event_log_handlers.fm: debug.level.info
|
|||||||
nfv_plugins.nfvi_plugins.clients: debug.level.info
|
nfv_plugins.nfvi_plugins.clients: debug.level.info
|
||||||
nfv_plugins.nfvi_plugins.clients.kubernetes_client: debug.level.info
|
nfv_plugins.nfvi_plugins.clients.kubernetes_client: debug.level.info
|
||||||
nfv_plugins.nfvi_plugins.openstack: debug.level.info
|
nfv_plugins.nfvi_plugins.openstack: debug.level.info
|
||||||
|
nfv_plugins.nfvi_plugins.openstack.fm: debug.level.info
|
||||||
nfv_plugins.nfvi_plugins.openstack.patching: debug.level.info
|
nfv_plugins.nfvi_plugins.openstack.patching: debug.level.info
|
||||||
nfv_plugins.nfvi_plugins.openstack.keystone: debug.level.info
|
nfv_plugins.nfvi_plugins.openstack.keystone: debug.level.info
|
||||||
nfv_plugins.nfvi_plugins.openstack.sysinv: debug.level.info
|
nfv_plugins.nfvi_plugins.openstack.sysinv: debug.level.info
|
||||||
@ -188,6 +199,7 @@ nfv_plugins.nfvi_plugins.openstack.ceilometer: debug.level.info
|
|||||||
nfv_plugins.nfvi_plugins.openstack.objects: debug.level.info
|
nfv_plugins.nfvi_plugins.openstack.objects: debug.level.info
|
||||||
nfv_plugins.nfvi_plugins.openstack.rest_api: debug.level.info
|
nfv_plugins.nfvi_plugins.openstack.rest_api: debug.level.info
|
||||||
nfv_plugins.nfvi_plugins.openstack.rpc: debug.level.info
|
nfv_plugins.nfvi_plugins.openstack.rpc: debug.level.info
|
||||||
|
nfv_plugins.nfvi_plugins.fault_mgmt_api: debug.level.debug
|
||||||
nfv_plugins.nfvi_plugins.identity_api: debug.level.debug
|
nfv_plugins.nfvi_plugins.identity_api: debug.level.debug
|
||||||
nfv_plugins.nfvi_plugins.image_api: debug.level.debug
|
nfv_plugins.nfvi_plugins.image_api: debug.level.debug
|
||||||
nfv_plugins.nfvi_plugins.block_storage_api: debug.level.debug
|
nfv_plugins.nfvi_plugins.block_storage_api: debug.level.debug
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -27,6 +27,7 @@ class OperationTypes(Constants):
|
|||||||
SWACT_HOSTS = Constant('swact-hosts')
|
SWACT_HOSTS = Constant('swact-hosts')
|
||||||
FW_UPDATE_HOSTS = Constant('fw-update-hosts')
|
FW_UPDATE_HOSTS = Constant('fw-update-hosts')
|
||||||
FW_UPDATE_ABORT_HOSTS = Constant('fw-update-abort-hosts')
|
FW_UPDATE_ABORT_HOSTS = Constant('fw-update-abort-hosts')
|
||||||
|
KUBE_UPGRADE_HOSTS = Constant('kube-upgrade-hosts')
|
||||||
START_INSTANCES = Constant('start-instances')
|
START_INSTANCES = Constant('start-instances')
|
||||||
START_INSTANCES_SERIAL = Constant('start-instances-serial')
|
START_INSTANCES_SERIAL = Constant('start-instances-serial')
|
||||||
STOP_INSTANCES = Constant('stop-instances')
|
STOP_INSTANCES = Constant('stop-instances')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -803,6 +803,161 @@ class HostDirector(object):
|
|||||||
|
|
||||||
return host_operation
|
return host_operation
|
||||||
|
|
||||||
|
@coroutine
|
||||||
|
def _nfvi_kube_host_upgrade_control_plane_callback(self):
|
||||||
|
"""
|
||||||
|
NFVI Kube Host Upgrade Control Plane Callback
|
||||||
|
"""
|
||||||
|
from nfv_vim import directors
|
||||||
|
|
||||||
|
response = (yield)
|
||||||
|
DLOG.verbose("NFVI Kube Host Upgrade Control Plane response=%s."
|
||||||
|
% response)
|
||||||
|
if not response['completed']:
|
||||||
|
DLOG.info("Kube Host Upgrade Control Plane failed. Host:%s, reason=%s."
|
||||||
|
% (response['host_name'], response['reason']))
|
||||||
|
|
||||||
|
host_table = tables.tables_get_host_table()
|
||||||
|
host = host_table.get(response['host_name'], None)
|
||||||
|
if host is None:
|
||||||
|
DLOG.verbose("Host %s does not exist." % response['host_name'])
|
||||||
|
return
|
||||||
|
|
||||||
|
if self._host_operation is None:
|
||||||
|
DLOG.verbose("No host %s operation inprogress." % host.name)
|
||||||
|
return
|
||||||
|
|
||||||
|
if OPERATION_TYPE.KUBE_UPGRADE_HOSTS != self._host_operation.operation_type:
|
||||||
|
DLOG.verbose("Unexpected host %s operation %s, ignoring."
|
||||||
|
% (host.name, self._host_operation.operation_type))
|
||||||
|
return
|
||||||
|
|
||||||
|
sw_mgmt_director = directors.get_sw_mgmt_director()
|
||||||
|
sw_mgmt_director.kube_host_upgrade_control_plane_failed(host)
|
||||||
|
|
||||||
|
def _nfvi_kube_host_upgrade_control_plane(self,
|
||||||
|
host_uuid,
|
||||||
|
host_name,
|
||||||
|
force):
|
||||||
|
"""
|
||||||
|
NFVI Kube Host Upgrade Control Plane
|
||||||
|
"""
|
||||||
|
nfvi.nfvi_kube_host_upgrade_control_plane(
|
||||||
|
host_uuid,
|
||||||
|
host_name,
|
||||||
|
force,
|
||||||
|
self._nfvi_kube_host_upgrade_control_plane_callback())
|
||||||
|
|
||||||
|
def kube_upgrade_hosts_control_plane(self, host_names, force):
|
||||||
|
"""
|
||||||
|
Kube Upgrade Hosts Control Plane for multiple hosts
|
||||||
|
"""
|
||||||
|
DLOG.info("Kube Host Upgrade control plane for hosts: %s" % host_names)
|
||||||
|
|
||||||
|
host_operation = \
|
||||||
|
Operation(OPERATION_TYPE.KUBE_UPGRADE_HOSTS)
|
||||||
|
|
||||||
|
if self._host_operation is not None:
|
||||||
|
DLOG.debug("Canceling previous host operation %s, before "
|
||||||
|
"continuing with host operation %s."
|
||||||
|
% (self._host_operation.operation_type,
|
||||||
|
host_operation.operation_type))
|
||||||
|
self._host_operation = None
|
||||||
|
|
||||||
|
host_table = tables.tables_get_host_table()
|
||||||
|
for host_name in host_names:
|
||||||
|
host = host_table.get(host_name, None)
|
||||||
|
if host is None:
|
||||||
|
reason = "Unknown host %s given." % host_name
|
||||||
|
DLOG.info(reason)
|
||||||
|
host_operation.set_failed(reason)
|
||||||
|
return host_operation
|
||||||
|
|
||||||
|
host_operation.add_host(host.name, OPERATION_STATE.INPROGRESS)
|
||||||
|
self._nfvi_kube_host_upgrade_control_plane(host.uuid,
|
||||||
|
host.name,
|
||||||
|
force)
|
||||||
|
|
||||||
|
if host_operation.is_inprogress():
|
||||||
|
self._host_operation = host_operation
|
||||||
|
|
||||||
|
return host_operation
|
||||||
|
|
||||||
|
@coroutine
|
||||||
|
def _nfvi_kube_host_upgrade_kubelet_callback(self):
|
||||||
|
"""
|
||||||
|
NFVI Kube Host Upgrade Kubelet Callback (for a single host)
|
||||||
|
"""
|
||||||
|
from nfv_vim import directors
|
||||||
|
|
||||||
|
response = (yield)
|
||||||
|
DLOG.verbose("NFVI Kube Host Upgrade Kubelet response=%s."
|
||||||
|
% response)
|
||||||
|
if not response['completed']:
|
||||||
|
DLOG.info("Kube Host Upgrade Kubelet failed. Host:%s, reason=%s."
|
||||||
|
% (response['host_name'], response['reason']))
|
||||||
|
|
||||||
|
host_table = tables.tables_get_host_table()
|
||||||
|
host = host_table.get(response['host_name'], None)
|
||||||
|
if host is None:
|
||||||
|
DLOG.verbose("Host %s does not exist." % response['host_name'])
|
||||||
|
return
|
||||||
|
|
||||||
|
if self._host_operation is None:
|
||||||
|
DLOG.verbose("No host %s operation inprogress." % host.name)
|
||||||
|
return
|
||||||
|
|
||||||
|
if OPERATION_TYPE.KUBE_UPGRADE_HOSTS != self._host_operation.operation_type:
|
||||||
|
DLOG.verbose("Unexpected host %s operation %s, ignoring."
|
||||||
|
% (host.name, self._host_operation.operation_type))
|
||||||
|
return
|
||||||
|
|
||||||
|
sw_mgmt_director = directors.get_sw_mgmt_director()
|
||||||
|
sw_mgmt_director.kube_host_upgrade_kubelet_failed(host)
|
||||||
|
|
||||||
|
def _nfvi_kube_host_upgrade_kubelet(self, host_uuid, host_name, force):
|
||||||
|
"""
|
||||||
|
NFVI Kube Host Upgrade Kubelet
|
||||||
|
"""
|
||||||
|
nfvi.nfvi_kube_host_upgrade_kubelet(
|
||||||
|
host_uuid,
|
||||||
|
host_name,
|
||||||
|
force,
|
||||||
|
self._nfvi_kube_host_upgrade_kubelet_callback())
|
||||||
|
|
||||||
|
def kube_upgrade_hosts_kubelet(self, host_names, force):
|
||||||
|
"""
|
||||||
|
Kube Upgrade Hosts Kubelet for multiple hosts
|
||||||
|
"""
|
||||||
|
DLOG.info("Kube Host Upgrade kubelet for hosts: %s" % host_names)
|
||||||
|
|
||||||
|
host_operation = \
|
||||||
|
Operation(OPERATION_TYPE.KUBE_UPGRADE_HOSTS)
|
||||||
|
|
||||||
|
if self._host_operation is not None:
|
||||||
|
DLOG.debug("Canceling previous host operation %s, before "
|
||||||
|
"continuing with host operation %s."
|
||||||
|
% (self._host_operation.operation_type,
|
||||||
|
host_operation.operation_type))
|
||||||
|
self._host_operation = None
|
||||||
|
|
||||||
|
host_table = tables.tables_get_host_table()
|
||||||
|
for host_name in host_names:
|
||||||
|
host = host_table.get(host_name, None)
|
||||||
|
if host is None:
|
||||||
|
reason = "Unknown host %s given." % host_name
|
||||||
|
DLOG.info(reason)
|
||||||
|
host_operation.set_failed(reason)
|
||||||
|
return host_operation
|
||||||
|
|
||||||
|
host_operation.add_host(host.name, OPERATION_STATE.INPROGRESS)
|
||||||
|
self._nfvi_kube_host_upgrade_kubelet(host.uuid, host.name, force)
|
||||||
|
|
||||||
|
if host_operation.is_inprogress():
|
||||||
|
self._host_operation = host_operation
|
||||||
|
|
||||||
|
return host_operation
|
||||||
|
|
||||||
def disable_host_services(self, host_names, service):
|
def disable_host_services(self, host_names, service):
|
||||||
"""
|
"""
|
||||||
Disable a host service on a list of hosts
|
Disable a host service on a list of hosts
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -95,7 +95,8 @@ class SwMgmtDirector(object):
|
|||||||
strategy_uuid, storage_apply_type,
|
strategy_uuid, storage_apply_type,
|
||||||
worker_apply_type, max_parallel_worker_hosts,
|
worker_apply_type, max_parallel_worker_hosts,
|
||||||
alarm_restrictions, start_upgrade,
|
alarm_restrictions, start_upgrade,
|
||||||
complete_upgrade, self._ignore_alarms)
|
complete_upgrade, self._ignore_alarms,
|
||||||
|
self._single_controller)
|
||||||
|
|
||||||
schedule.schedule_function_call(callback, success, reason,
|
schedule.schedule_function_call(callback, success, reason,
|
||||||
self._sw_update.strategy)
|
self._sw_update.strategy)
|
||||||
@ -133,6 +134,46 @@ class SwMgmtDirector(object):
|
|||||||
self._sw_update.strategy)
|
self._sw_update.strategy)
|
||||||
return strategy_uuid, ''
|
return strategy_uuid, ''
|
||||||
|
|
||||||
|
def create_kube_upgrade_strategy(self,
|
||||||
|
controller_apply_type,
|
||||||
|
storage_apply_type,
|
||||||
|
worker_apply_type,
|
||||||
|
max_parallel_worker_hosts,
|
||||||
|
default_instance_action,
|
||||||
|
alarm_restrictions,
|
||||||
|
to_version,
|
||||||
|
callback):
|
||||||
|
"""
|
||||||
|
Create Kubernetes Upgrade Strategy
|
||||||
|
"""
|
||||||
|
strategy_uuid = str(uuid.uuid4())
|
||||||
|
|
||||||
|
if self._sw_update is not None:
|
||||||
|
# Do not schedule the callback - if creation failed because a
|
||||||
|
# strategy already exists, the callback will attempt to operate
|
||||||
|
# on the old strategy, which is not what we want.
|
||||||
|
reason = "strategy already exists"
|
||||||
|
return None, reason
|
||||||
|
|
||||||
|
self._sw_update = objects.KubeUpgrade()
|
||||||
|
success, reason = self._sw_update.strategy_build(
|
||||||
|
strategy_uuid,
|
||||||
|
controller_apply_type,
|
||||||
|
storage_apply_type,
|
||||||
|
worker_apply_type,
|
||||||
|
max_parallel_worker_hosts,
|
||||||
|
default_instance_action,
|
||||||
|
alarm_restrictions,
|
||||||
|
self._ignore_alarms,
|
||||||
|
to_version,
|
||||||
|
self._single_controller)
|
||||||
|
|
||||||
|
schedule.schedule_function_call(callback,
|
||||||
|
success,
|
||||||
|
reason,
|
||||||
|
self._sw_update.strategy)
|
||||||
|
return strategy_uuid, ''
|
||||||
|
|
||||||
def apply_sw_update_strategy(self, strategy_uuid, stage_id, callback):
|
def apply_sw_update_strategy(self, strategy_uuid, stage_id, callback):
|
||||||
"""
|
"""
|
||||||
Apply Software Update Strategy
|
Apply Software Update Strategy
|
||||||
@ -244,6 +285,24 @@ class SwMgmtDirector(object):
|
|||||||
self._sw_update.handle_event(
|
self._sw_update.handle_event(
|
||||||
strategy.STRATEGY_EVENT.HOST_FW_UPDATE_FAILED, host)
|
strategy.STRATEGY_EVENT.HOST_FW_UPDATE_FAILED, host)
|
||||||
|
|
||||||
|
def kube_host_upgrade_control_plane_failed(self, host):
|
||||||
|
"""
|
||||||
|
Called when a kube host upgrade for control plane fails
|
||||||
|
"""
|
||||||
|
if self._sw_update is not None:
|
||||||
|
self._sw_update.handle_event(
|
||||||
|
strategy.STRATEGY_EVENT.KUBE_HOST_UPGRADE_CONTROL_PLANE_FAILED,
|
||||||
|
host)
|
||||||
|
|
||||||
|
def kube_host_upgrade_kubelet_failed(self, host):
|
||||||
|
"""
|
||||||
|
Called when a kube host upgrade for kubelet fails
|
||||||
|
"""
|
||||||
|
if self._sw_update is not None:
|
||||||
|
self._sw_update.handle_event(
|
||||||
|
strategy.STRATEGY_EVENT.KUBE_HOST_UPGRADE_KUBELET_FAILED,
|
||||||
|
host)
|
||||||
|
|
||||||
def host_audit(self, host):
|
def host_audit(self, host):
|
||||||
"""
|
"""
|
||||||
Called when a host audit is to be performed
|
Called when a host audit is to be performed
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -342,6 +342,172 @@ _event_templates = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_START: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': event_log.EVENT_TYPE.ACTION_EVENT,
|
||||||
|
'importance': event_log.EVENT_IMPORTANCE.HIGH,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply start",
|
||||||
|
'exclude_event_context': [],
|
||||||
|
'event_context_data': {
|
||||||
|
event_log.EVENT_CONTEXT.ADMIN: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply start",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_INPROGRESS: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': event_log.EVENT_TYPE.ACTION_EVENT,
|
||||||
|
'importance': event_log.EVENT_IMPORTANCE.HIGH,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply inprogress",
|
||||||
|
'exclude_event_context': [],
|
||||||
|
'event_context_data': {
|
||||||
|
event_log.EVENT_CONTEXT.ADMIN: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply inprogress",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_REJECTED: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': event_log.EVENT_TYPE.ACTION_EVENT,
|
||||||
|
'importance': event_log.EVENT_IMPORTANCE.HIGH,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply rejected",
|
||||||
|
'exclude_event_context': [],
|
||||||
|
'event_context_data': {
|
||||||
|
event_log.EVENT_CONTEXT.ADMIN: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply rejected%(reason)s",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_CANCELLED: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': event_log.EVENT_TYPE.ACTION_EVENT,
|
||||||
|
'importance': event_log.EVENT_IMPORTANCE.HIGH,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply cancelled",
|
||||||
|
'exclude_event_context': [],
|
||||||
|
'event_context_data': {
|
||||||
|
event_log.EVENT_CONTEXT.ADMIN: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply cancelled%(reason)s",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_FAILED: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': event_log.EVENT_TYPE.ACTION_EVENT,
|
||||||
|
'importance': event_log.EVENT_IMPORTANCE.HIGH,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply failed",
|
||||||
|
'exclude_event_context': [],
|
||||||
|
'event_context_data': {
|
||||||
|
event_log.EVENT_CONTEXT.ADMIN: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply failed%(reason)s",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_COMPLETED: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': event_log.EVENT_TYPE.ACTION_EVENT,
|
||||||
|
'importance': event_log.EVENT_IMPORTANCE.HIGH,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply completed",
|
||||||
|
'exclude_event_context': [],
|
||||||
|
'event_context_data': {
|
||||||
|
event_log.EVENT_CONTEXT.ADMIN: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply completed",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORT: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': event_log.EVENT_TYPE.ACTION_EVENT,
|
||||||
|
'importance': event_log.EVENT_IMPORTANCE.HIGH,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply abort",
|
||||||
|
'exclude_event_context': [],
|
||||||
|
'event_context_data': {
|
||||||
|
event_log.EVENT_CONTEXT.ADMIN: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply abort",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORTING: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': event_log.EVENT_TYPE.ACTION_EVENT,
|
||||||
|
'importance': event_log.EVENT_IMPORTANCE.HIGH,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply aborting",
|
||||||
|
'exclude_event_context': [],
|
||||||
|
'event_context_data': {
|
||||||
|
event_log.EVENT_CONTEXT.ADMIN: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply aborting",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORT_REJECTED: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': event_log.EVENT_TYPE.ACTION_EVENT,
|
||||||
|
'importance': event_log.EVENT_IMPORTANCE.HIGH,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply abort rejected",
|
||||||
|
'exclude_event_context': [],
|
||||||
|
'event_context_data': {
|
||||||
|
event_log.EVENT_CONTEXT.ADMIN: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply abort "
|
||||||
|
"rejected%(reason)s",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORT_FAILED: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': event_log.EVENT_TYPE.ACTION_EVENT,
|
||||||
|
'importance': event_log.EVENT_IMPORTANCE.HIGH,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply abort failed",
|
||||||
|
'exclude_event_context': [],
|
||||||
|
'event_context_data': {
|
||||||
|
event_log.EVENT_CONTEXT.ADMIN: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply abort failed%(reason)s",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORTED: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'event_type': event_log.EVENT_TYPE.ACTION_EVENT,
|
||||||
|
'importance': event_log.EVENT_IMPORTANCE.HIGH,
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply aborted",
|
||||||
|
'exclude_event_context': [],
|
||||||
|
'event_context_data': {
|
||||||
|
event_log.EVENT_CONTEXT.ADMIN: {
|
||||||
|
'entity_type': "orchestration",
|
||||||
|
'entity': "orchestration=kube-upgrade",
|
||||||
|
'reason_text': "Kubernetes upgrade auto-apply aborted",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -187,6 +187,9 @@ def _vim_api_message_handler(connection, msg):
|
|||||||
elif rpc.RPC_MSG_TYPE.CREATE_SW_UPDATE_STRATEGY_REQUEST == msg.type:
|
elif rpc.RPC_MSG_TYPE.CREATE_SW_UPDATE_STRATEGY_REQUEST == msg.type:
|
||||||
vim_sw_update_api_create_strategy(connection, msg)
|
vim_sw_update_api_create_strategy(connection, msg)
|
||||||
|
|
||||||
|
elif rpc.RPC_MSG_TYPE.CREATE_KUBE_UPGRADE_STRATEGY_REQUEST == msg.type:
|
||||||
|
vim_sw_update_api_create_strategy(connection, msg)
|
||||||
|
|
||||||
elif rpc.RPC_MSG_TYPE.CREATE_SW_UPGRADE_STRATEGY_REQUEST == msg.type:
|
elif rpc.RPC_MSG_TYPE.CREATE_SW_UPGRADE_STRATEGY_REQUEST == msg.type:
|
||||||
vim_sw_update_api_create_strategy(connection, msg)
|
vim_sw_update_api_create_strategy(connection, msg)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -124,6 +124,8 @@ def _nfvi_sw_update_get_callback():
|
|||||||
sw_update_type = 'sw-upgrade'
|
sw_update_type = 'sw-upgrade'
|
||||||
elif sw_update.sw_update_type == objects.SW_UPDATE_TYPE.FW_UPDATE:
|
elif sw_update.sw_update_type == objects.SW_UPDATE_TYPE.FW_UPDATE:
|
||||||
sw_update_type = 'fw-update'
|
sw_update_type = 'fw-update'
|
||||||
|
elif sw_update.sw_update_type == objects.SW_UPDATE_TYPE.KUBE_UPGRADE:
|
||||||
|
sw_update_type = 'kube-upgrade'
|
||||||
|
|
||||||
if sw_update.strategy.is_applying() or sw_update.strategy.is_aborting():
|
if sw_update.strategy.is_applying() or sw_update.strategy.is_aborting():
|
||||||
in_progress = True
|
in_progress = True
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -113,6 +113,17 @@ def vim_sw_update_api_create_strategy(connection, msg):
|
|||||||
default_instance_action,
|
default_instance_action,
|
||||||
alarm_restrictions,
|
alarm_restrictions,
|
||||||
_vim_sw_update_api_create_strategy_callback)
|
_vim_sw_update_api_create_strategy_callback)
|
||||||
|
elif 'kube-upgrade' == msg.sw_update_type:
|
||||||
|
to_version = msg.to_version
|
||||||
|
uuid, reason = sw_mgmt_director.create_kube_upgrade_strategy(
|
||||||
|
controller_apply_type,
|
||||||
|
storage_apply_type,
|
||||||
|
worker_apply_type,
|
||||||
|
max_parallel_worker_hosts,
|
||||||
|
default_instance_action,
|
||||||
|
alarm_restrictions,
|
||||||
|
to_version,
|
||||||
|
_vim_sw_update_api_create_strategy_callback)
|
||||||
else:
|
else:
|
||||||
DLOG.error("Invalid message name: %s" % msg.sw_update_type)
|
DLOG.error("Invalid message name: %s" % msg.sw_update_type)
|
||||||
response = rpc.APIResponseCreateSwUpdateStrategy()
|
response = rpc.APIResponseCreateSwUpdateStrategy()
|
||||||
@ -164,13 +175,15 @@ def vim_sw_update_api_apply_strategy(connection, msg):
|
|||||||
"""
|
"""
|
||||||
Handle Sw-Update Apply Strategy API request
|
Handle Sw-Update Apply Strategy API request
|
||||||
"""
|
"""
|
||||||
DLOG.info("Apply sw-update strategy.")
|
DLOG.info("Apply sw-update strategy: (%s) called." % msg.sw_update_type)
|
||||||
if 'sw-patch' == msg.sw_update_type:
|
if 'sw-patch' == msg.sw_update_type:
|
||||||
sw_update_type = objects.SW_UPDATE_TYPE.SW_PATCH
|
sw_update_type = objects.SW_UPDATE_TYPE.SW_PATCH
|
||||||
elif 'sw-upgrade' == msg.sw_update_type:
|
elif 'sw-upgrade' == msg.sw_update_type:
|
||||||
sw_update_type = objects.SW_UPDATE_TYPE.SW_UPGRADE
|
sw_update_type = objects.SW_UPDATE_TYPE.SW_UPGRADE
|
||||||
elif 'fw-update' == msg.sw_update_type:
|
elif 'fw-update' == msg.sw_update_type:
|
||||||
sw_update_type = objects.SW_UPDATE_TYPE.FW_UPDATE
|
sw_update_type = objects.SW_UPDATE_TYPE.FW_UPDATE
|
||||||
|
elif 'kube-upgrade' == msg.sw_update_type:
|
||||||
|
sw_update_type = objects.SW_UPDATE_TYPE.KUBE_UPGRADE
|
||||||
else:
|
else:
|
||||||
DLOG.error("Invalid message name: %s" % msg.sw_update_type)
|
DLOG.error("Invalid message name: %s" % msg.sw_update_type)
|
||||||
sw_update_type = 'unknown'
|
sw_update_type = 'unknown'
|
||||||
@ -226,6 +239,8 @@ def vim_sw_update_api_abort_strategy(connection, msg):
|
|||||||
sw_update_type = objects.SW_UPDATE_TYPE.SW_UPGRADE
|
sw_update_type = objects.SW_UPDATE_TYPE.SW_UPGRADE
|
||||||
elif 'fw-update' == msg.sw_update_type:
|
elif 'fw-update' == msg.sw_update_type:
|
||||||
sw_update_type = objects.SW_UPDATE_TYPE.FW_UPDATE
|
sw_update_type = objects.SW_UPDATE_TYPE.FW_UPDATE
|
||||||
|
elif 'kube-upgrade' == msg.sw_update_type:
|
||||||
|
sw_update_type = objects.SW_UPDATE_TYPE.KUBE_UPGRADE
|
||||||
else:
|
else:
|
||||||
DLOG.error("Invalid message name: %s" % msg.sw_update_type)
|
DLOG.error("Invalid message name: %s" % msg.sw_update_type)
|
||||||
sw_update_type = 'unknown'
|
sw_update_type = 'unknown'
|
||||||
@ -278,6 +293,8 @@ def vim_sw_update_api_delete_strategy(connection, msg):
|
|||||||
sw_update_type = objects.SW_UPDATE_TYPE.SW_UPGRADE
|
sw_update_type = objects.SW_UPDATE_TYPE.SW_UPGRADE
|
||||||
elif 'fw-update' == msg.sw_update_type:
|
elif 'fw-update' == msg.sw_update_type:
|
||||||
sw_update_type = objects.SW_UPDATE_TYPE.FW_UPDATE
|
sw_update_type = objects.SW_UPDATE_TYPE.FW_UPDATE
|
||||||
|
elif 'kube-upgrade' == msg.sw_update_type:
|
||||||
|
sw_update_type = objects.SW_UPDATE_TYPE.KUBE_UPGRADE
|
||||||
else:
|
else:
|
||||||
DLOG.error("Invalid message name: %s" % msg.sw_update_type)
|
DLOG.error("Invalid message name: %s" % msg.sw_update_type)
|
||||||
sw_update_type = 'unknown'
|
sw_update_type = 'unknown'
|
||||||
@ -309,6 +326,8 @@ def vim_sw_update_api_get_strategy(connection, msg):
|
|||||||
sw_update_type = objects.SW_UPDATE_TYPE.SW_UPGRADE
|
sw_update_type = objects.SW_UPDATE_TYPE.SW_UPGRADE
|
||||||
elif 'fw-update' == msg.sw_update_type:
|
elif 'fw-update' == msg.sw_update_type:
|
||||||
sw_update_type = objects.SW_UPDATE_TYPE.FW_UPDATE
|
sw_update_type = objects.SW_UPDATE_TYPE.FW_UPDATE
|
||||||
|
elif 'kube-upgrade' == msg.sw_update_type:
|
||||||
|
sw_update_type = objects.SW_UPDATE_TYPE.KUBE_UPGRADE
|
||||||
else:
|
else:
|
||||||
DLOG.error("Invalid message name: %s" % msg.sw_update_type)
|
DLOG.error("Invalid message name: %s" % msg.sw_update_type)
|
||||||
sw_update_type = 'unknown'
|
sw_update_type = 'unknown'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -100,6 +100,9 @@ from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_host # noqa: F401
|
|||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_host_device # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_host_device # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_host_devices # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_host_devices # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_hosts # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_hosts # noqa: F401
|
||||||
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_kube_host_upgrade_list # noqa: F401
|
||||||
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_kube_upgrade # noqa: F401
|
||||||
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_kube_version_list # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_logs # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_logs # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_system_info # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_system_info # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_system_state # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_system_state # noqa: F401
|
||||||
@ -107,6 +110,13 @@ from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_terminating_pods
|
|||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_upgrade # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_get_upgrade # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_host_device_image_update # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_host_device_image_update # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_host_device_image_update_abort # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_host_device_image_update_abort # noqa: F401
|
||||||
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_kube_host_upgrade_control_plane # noqa: F401
|
||||||
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_kube_host_upgrade_kubelet # noqa: F401
|
||||||
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_kube_upgrade_cleanup # noqa: F401
|
||||||
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_kube_upgrade_complete # noqa: F401
|
||||||
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_kube_upgrade_download_images # noqa: F401
|
||||||
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_kube_upgrade_networking # noqa: F401
|
||||||
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_kube_upgrade_start # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_lock_host # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_lock_host # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_notify_host_failed # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_notify_host_failed # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_notify_host_services_delete_failed # noqa: F401
|
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_notify_host_services_delete_failed # noqa: F401
|
||||||
@ -160,6 +170,7 @@ from nfv_vim.nfvi._nfvi_network_module import nfvi_remove_router_from_agent # n
|
|||||||
from nfv_vim.nfvi._nfvi_network_module import nfvi_update_network # noqa: F401
|
from nfv_vim.nfvi._nfvi_network_module import nfvi_update_network # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_network_module import nfvi_update_subnet # noqa: F401
|
from nfv_vim.nfvi._nfvi_network_module import nfvi_update_subnet # noqa: F401
|
||||||
|
|
||||||
|
from nfv_vim.nfvi._nfvi_sw_mgmt_module import nfvi_sw_mgmt_apply_updates # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_sw_mgmt_module import nfvi_sw_mgmt_query_hosts # noqa: F401
|
from nfv_vim.nfvi._nfvi_sw_mgmt_module import nfvi_sw_mgmt_query_hosts # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_sw_mgmt_module import nfvi_sw_mgmt_query_updates # noqa: F401
|
from nfv_vim.nfvi._nfvi_sw_mgmt_module import nfvi_sw_mgmt_query_updates # noqa: F401
|
||||||
from nfv_vim.nfvi._nfvi_sw_mgmt_module import nfvi_sw_mgmt_update_host # noqa: F401
|
from nfv_vim.nfvi._nfvi_sw_mgmt_module import nfvi_sw_mgmt_update_host # noqa: F401
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -100,6 +100,111 @@ def nfvi_host_device_image_update_abort(host_uuid, host_name, callback):
|
|||||||
return cmd_id
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
|
def nfvi_kube_host_upgrade_control_plane(host_uuid, host_name, force, callback):
|
||||||
|
"""
|
||||||
|
Kube Host Upgrade Control Plane
|
||||||
|
"""
|
||||||
|
cmd_id = _infrastructure_plugin.invoke_plugin(
|
||||||
|
'kube_host_upgrade_control_plane',
|
||||||
|
host_uuid,
|
||||||
|
host_name,
|
||||||
|
force,
|
||||||
|
callback=callback)
|
||||||
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
|
def nfvi_kube_host_upgrade_kubelet(host_uuid, host_name, force, callback):
|
||||||
|
"""
|
||||||
|
Kube Host Upgrade Kubelet
|
||||||
|
"""
|
||||||
|
cmd_id = _infrastructure_plugin.invoke_plugin(
|
||||||
|
'kube_host_upgrade_kubelet',
|
||||||
|
host_uuid,
|
||||||
|
host_name,
|
||||||
|
force,
|
||||||
|
callback=callback)
|
||||||
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
|
def nfvi_kube_upgrade_cleanup(callback):
|
||||||
|
"""
|
||||||
|
Kube Upgrade Cleanup
|
||||||
|
"""
|
||||||
|
cmd_id = _infrastructure_plugin.invoke_plugin(
|
||||||
|
'kube_upgrade_cleanup',
|
||||||
|
callback=callback)
|
||||||
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
|
def nfvi_kube_upgrade_complete(callback):
|
||||||
|
"""
|
||||||
|
Kube Upgrade Complete
|
||||||
|
"""
|
||||||
|
cmd_id = _infrastructure_plugin.invoke_plugin(
|
||||||
|
'kube_upgrade_complete',
|
||||||
|
callback=callback)
|
||||||
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
|
def nfvi_kube_upgrade_download_images(callback):
|
||||||
|
"""
|
||||||
|
Kube Upgrade Download Images
|
||||||
|
"""
|
||||||
|
cmd_id = _infrastructure_plugin.invoke_plugin(
|
||||||
|
'kube_upgrade_download_images',
|
||||||
|
callback=callback)
|
||||||
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
|
def nfvi_kube_upgrade_networking(callback):
|
||||||
|
"""
|
||||||
|
Kube Upgrade Networking
|
||||||
|
"""
|
||||||
|
cmd_id = _infrastructure_plugin.invoke_plugin('kube_upgrade_networking',
|
||||||
|
callback=callback)
|
||||||
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
|
def nfvi_kube_upgrade_start(to_version, force, alarm_ignore_list, callback):
|
||||||
|
"""
|
||||||
|
Kube Upgrade Start
|
||||||
|
"""
|
||||||
|
cmd_id = _infrastructure_plugin.invoke_plugin(
|
||||||
|
'kube_upgrade_start',
|
||||||
|
to_version=to_version,
|
||||||
|
force=force,
|
||||||
|
alarm_ignore_list=alarm_ignore_list,
|
||||||
|
callback=callback)
|
||||||
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
|
def nfvi_get_kube_host_upgrade_list(callback):
|
||||||
|
"""
|
||||||
|
Get kube host upgrade list
|
||||||
|
"""
|
||||||
|
cmd_id = _infrastructure_plugin.invoke_plugin('get_kube_host_upgrade_list',
|
||||||
|
callback=callback)
|
||||||
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
|
def nfvi_get_kube_upgrade(callback):
|
||||||
|
"""
|
||||||
|
Get kube upgrade
|
||||||
|
"""
|
||||||
|
cmd_id = _infrastructure_plugin.invoke_plugin('get_kube_upgrade',
|
||||||
|
callback=callback)
|
||||||
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
|
def nfvi_get_kube_version_list(callback):
|
||||||
|
"""
|
||||||
|
Get kube version list
|
||||||
|
"""
|
||||||
|
cmd_id = _infrastructure_plugin.invoke_plugin('get_kube_version_list',
|
||||||
|
callback=callback)
|
||||||
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
def nfvi_get_upgrade(callback):
|
def nfvi_get_upgrade(callback):
|
||||||
"""
|
"""
|
||||||
Get upgrade
|
Get upgrade
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2016 Wind River Systems, Inc.
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -37,6 +37,16 @@ def nfvi_sw_mgmt_update_host(host_name, callback):
|
|||||||
return cmd_id
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
|
def nfvi_sw_mgmt_apply_updates(patch_names, callback):
|
||||||
|
"""
|
||||||
|
Apply Software Patches
|
||||||
|
"""
|
||||||
|
cmd_id = _sw_mgmt_plugin.invoke_plugin('apply_patches',
|
||||||
|
patch_names,
|
||||||
|
callback=callback)
|
||||||
|
return cmd_id
|
||||||
|
|
||||||
|
|
||||||
def nfvi_sw_mgmt_update_hosts(host_names, callback):
|
def nfvi_sw_mgmt_update_hosts(host_names, callback):
|
||||||
"""
|
"""
|
||||||
Apply Software Patch to a list of hosts
|
Apply Software Patch to a list of hosts
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -48,6 +48,10 @@ from nfv_vim.nfvi.objects.v1._instance_group import InstanceGroup # noqa: F401
|
|||||||
from nfv_vim.nfvi.objects.v1._instance_type import INSTANCE_TYPE_EXTENSION # noqa: F401
|
from nfv_vim.nfvi.objects.v1._instance_type import INSTANCE_TYPE_EXTENSION # noqa: F401
|
||||||
from nfv_vim.nfvi.objects.v1._instance_type import InstanceType # noqa: F401
|
from nfv_vim.nfvi.objects.v1._instance_type import InstanceType # noqa: F401
|
||||||
from nfv_vim.nfvi.objects.v1._instance_type import InstanceTypeAttributes # noqa: F401
|
from nfv_vim.nfvi.objects.v1._instance_type import InstanceTypeAttributes # noqa: F401
|
||||||
|
from nfv_vim.nfvi.objects.v1._kube_upgrade import KUBE_UPGRADE_STATE # noqa: F401
|
||||||
|
from nfv_vim.nfvi.objects.v1._kube_upgrade import KubeHostUpgrade # noqa: F401
|
||||||
|
from nfv_vim.nfvi.objects.v1._kube_upgrade import KubeUpgrade # noqa: F401
|
||||||
|
from nfv_vim.nfvi.objects.v1._kube_upgrade import KubeVersion # noqa: F401
|
||||||
from nfv_vim.nfvi.objects.v1._network import Network # noqa: F401
|
from nfv_vim.nfvi.objects.v1._network import Network # noqa: F401
|
||||||
from nfv_vim.nfvi.objects.v1._network import NETWORK_ADMIN_STATE # noqa: F401
|
from nfv_vim.nfvi.objects.v1._network import NETWORK_ADMIN_STATE # noqa: F401
|
||||||
from nfv_vim.nfvi.objects.v1._network import NETWORK_AVAIL_STATUS # noqa: F401
|
from nfv_vim.nfvi.objects.v1._network import NETWORK_AVAIL_STATUS # noqa: F401
|
||||||
|
102
nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_kube_upgrade.py
Executable file
102
nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_kube_upgrade.py
Executable file
@ -0,0 +1,102 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
import six
|
||||||
|
|
||||||
|
from nfv_common.helpers import Constant
|
||||||
|
from nfv_common.helpers import Constants
|
||||||
|
from nfv_common.helpers import Singleton
|
||||||
|
|
||||||
|
from nfv_vim.nfvi.objects.v1._object import ObjectData
|
||||||
|
|
||||||
|
|
||||||
|
@six.add_metaclass(Singleton)
|
||||||
|
class KubeUpgradeState(Constants):
|
||||||
|
"""
|
||||||
|
Kube Upgrade State Constants
|
||||||
|
These values are copied from sysinv/common/kubernetes.py
|
||||||
|
"""
|
||||||
|
|
||||||
|
KUBE_UPGRADE_STARTED = Constant('upgrade-started')
|
||||||
|
KUBE_UPGRADE_DOWNLOADING_IMAGES = Constant('downloading-images')
|
||||||
|
KUBE_UPGRADE_DOWNLOADING_IMAGES_FAILED = Constant('downloading-images-failed')
|
||||||
|
KUBE_UPGRADE_DOWNLOADED_IMAGES = Constant('downloaded-images')
|
||||||
|
KUBE_UPGRADING_FIRST_MASTER = Constant('upgrading-first-master')
|
||||||
|
KUBE_UPGRADING_FIRST_MASTER_FAILED = Constant('upgrading-first-master-failed')
|
||||||
|
KUBE_UPGRADED_FIRST_MASTER = Constant('upgraded-first-master')
|
||||||
|
KUBE_UPGRADING_NETWORKING = Constant('upgrading-networking')
|
||||||
|
KUBE_UPGRADING_NETWORKING_FAILED = Constant('upgrading-networking-failed')
|
||||||
|
KUBE_UPGRADED_NETWORKING = Constant('upgraded-networking')
|
||||||
|
KUBE_UPGRADING_SECOND_MASTER = Constant('upgrading-second-master')
|
||||||
|
KUBE_UPGRADING_SECOND_MASTER_FAILED = Constant('upgrading-second-master-failed')
|
||||||
|
KUBE_UPGRADED_SECOND_MASTER = Constant('upgraded-second-master')
|
||||||
|
KUBE_UPGRADING_KUBELETS = Constant('upgrading-kubelets')
|
||||||
|
KUBE_UPGRADE_COMPLETE = Constant('upgrade-complete')
|
||||||
|
|
||||||
|
|
||||||
|
# Kube Upgrade Constant Instantiation
|
||||||
|
KUBE_UPGRADE_STATE = KubeUpgradeState()
|
||||||
|
|
||||||
|
|
||||||
|
class KubeHostUpgrade(ObjectData):
|
||||||
|
"""
|
||||||
|
NFVI Kube Host Upgrade Object
|
||||||
|
"""
|
||||||
|
def __init__(self,
|
||||||
|
host_id,
|
||||||
|
host_uuid,
|
||||||
|
target_version,
|
||||||
|
control_plane_version,
|
||||||
|
kubelet_version,
|
||||||
|
status):
|
||||||
|
super(KubeHostUpgrade, self).__init__('1.0.0')
|
||||||
|
self.update(
|
||||||
|
dict(host_id=host_id,
|
||||||
|
host_uuid=host_uuid,
|
||||||
|
target_version=target_version,
|
||||||
|
control_plane_version=control_plane_version,
|
||||||
|
kubelet_version=kubelet_version,
|
||||||
|
status=status
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class KubeUpgrade(ObjectData):
|
||||||
|
"""
|
||||||
|
NFVI Kube Upgrade Object
|
||||||
|
"""
|
||||||
|
def __init__(self, state, from_version, to_version):
|
||||||
|
super(KubeUpgrade, self).__init__('1.0.0')
|
||||||
|
self.update(
|
||||||
|
dict(state=state,
|
||||||
|
from_version=from_version,
|
||||||
|
to_version=to_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class KubeVersion(ObjectData):
|
||||||
|
"""
|
||||||
|
NFVI Kube Version Object
|
||||||
|
"""
|
||||||
|
def __init__(self,
|
||||||
|
kube_version,
|
||||||
|
state,
|
||||||
|
target,
|
||||||
|
upgrade_from,
|
||||||
|
downgrade_to,
|
||||||
|
applied_patches,
|
||||||
|
available_patches):
|
||||||
|
super(KubeVersion, self).__init__('1.0.0')
|
||||||
|
self.update(
|
||||||
|
dict(kube_version=kube_version,
|
||||||
|
state=state,
|
||||||
|
target=target,
|
||||||
|
upgrade_from=upgrade_from,
|
||||||
|
downgrade_to=downgrade_to,
|
||||||
|
applied_patches=applied_patches,
|
||||||
|
available_patches=available_patches
|
||||||
|
)
|
||||||
|
)
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -26,6 +26,7 @@ from nfv_vim.objects._instance_group import InstanceGroup # noqa: F401
|
|||||||
from nfv_vim.objects._instance_type import INSTANCE_TYPE_EXTENSION # noqa: F401
|
from nfv_vim.objects._instance_type import INSTANCE_TYPE_EXTENSION # noqa: F401
|
||||||
from nfv_vim.objects._instance_type import InstanceType # noqa: F401
|
from nfv_vim.objects._instance_type import InstanceType # noqa: F401
|
||||||
from nfv_vim.objects._instance_type import InstanceTypeAttributes # noqa: F401
|
from nfv_vim.objects._instance_type import InstanceTypeAttributes # noqa: F401
|
||||||
|
from nfv_vim.objects._kube_upgrade import KubeUpgrade # noqa: F401
|
||||||
from nfv_vim.objects._network import Network # noqa: F401
|
from nfv_vim.objects._network import Network # noqa: F401
|
||||||
from nfv_vim.objects._network import NetworkProviderData # noqa: F401
|
from nfv_vim.objects._network import NetworkProviderData # noqa: F401
|
||||||
from nfv_vim.objects._service_host import ServiceHost # noqa: F401
|
from nfv_vim.objects._service_host import ServiceHost # noqa: F401
|
||||||
|
193
nfv/nfv-vim/nfv_vim/objects/_kube_upgrade.py
Normal file
193
nfv/nfv-vim/nfv_vim/objects/_kube_upgrade.py
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2020-2021 Wind River Systems, Inc.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
from nfv_common import debug
|
||||||
|
|
||||||
|
from nfv_common.helpers import coroutine
|
||||||
|
|
||||||
|
from nfv_vim import alarm
|
||||||
|
from nfv_vim import event_log
|
||||||
|
from nfv_vim import nfvi
|
||||||
|
|
||||||
|
from nfv_vim.objects._sw_update import SW_UPDATE_ALARM_TYPES
|
||||||
|
from nfv_vim.objects._sw_update import SW_UPDATE_EVENT_IDS
|
||||||
|
from nfv_vim.objects._sw_update import SW_UPDATE_TYPE
|
||||||
|
from nfv_vim.objects._sw_update import SwUpdate
|
||||||
|
|
||||||
|
DLOG = debug.debug_get_logger('nfv_vim.objects.kube_upgrade')
|
||||||
|
|
||||||
|
|
||||||
|
class KubeUpgrade(SwUpdate):
|
||||||
|
"""
|
||||||
|
Kubernetes Upgrade Object
|
||||||
|
"""
|
||||||
|
def __init__(self, sw_update_uuid=None, strategy_data=None):
|
||||||
|
super(KubeUpgrade, self).__init__(
|
||||||
|
sw_update_type=SW_UPDATE_TYPE.KUBE_UPGRADE,
|
||||||
|
sw_update_uuid=sw_update_uuid,
|
||||||
|
strategy_data=strategy_data)
|
||||||
|
|
||||||
|
self._kube_upgrade_hosts = list()
|
||||||
|
|
||||||
|
def strategy_build(self,
|
||||||
|
strategy_uuid,
|
||||||
|
controller_apply_type,
|
||||||
|
storage_apply_type,
|
||||||
|
worker_apply_type,
|
||||||
|
max_parallel_worker_hosts,
|
||||||
|
default_instance_action,
|
||||||
|
alarm_restrictions,
|
||||||
|
ignore_alarms,
|
||||||
|
to_version,
|
||||||
|
single_controller):
|
||||||
|
"""
|
||||||
|
Create a kubernetes upgrade strategy
|
||||||
|
"""
|
||||||
|
from nfv_vim import strategy
|
||||||
|
|
||||||
|
if self._strategy:
|
||||||
|
reason = "strategy already exists"
|
||||||
|
return False, reason
|
||||||
|
|
||||||
|
self._strategy = \
|
||||||
|
strategy.KubeUpgradeStrategy(strategy_uuid,
|
||||||
|
controller_apply_type,
|
||||||
|
storage_apply_type,
|
||||||
|
worker_apply_type,
|
||||||
|
max_parallel_worker_hosts,
|
||||||
|
default_instance_action,
|
||||||
|
alarm_restrictions,
|
||||||
|
ignore_alarms,
|
||||||
|
to_version,
|
||||||
|
single_controller)
|
||||||
|
self._strategy.sw_update_obj = self
|
||||||
|
self._strategy.build()
|
||||||
|
self._persist()
|
||||||
|
return True, ''
|
||||||
|
|
||||||
|
def strategy_build_complete(self, success, reason):
|
||||||
|
"""
|
||||||
|
Creation of a kubernetes upgrade strategy complete
|
||||||
|
"""
|
||||||
|
DLOG.info("Kubernetes upgrade strategy build complete.")
|
||||||
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def alarm_type(alarm_type):
|
||||||
|
"""
|
||||||
|
Returns ALARM_TYPE corresponding to SW_UPDATE_ALARM_TYPES
|
||||||
|
"""
|
||||||
|
ALARM_TYPE_MAPPING = {
|
||||||
|
SW_UPDATE_ALARM_TYPES.APPLY_INPROGRESS:
|
||||||
|
alarm.ALARM_TYPE.KUBE_UPGRADE_AUTO_APPLY_INPROGRESS,
|
||||||
|
SW_UPDATE_ALARM_TYPES.APPLY_ABORTING:
|
||||||
|
alarm.ALARM_TYPE.KUBE_UPGRADE_AUTO_APPLY_ABORTING,
|
||||||
|
SW_UPDATE_ALARM_TYPES.APPLY_FAILED:
|
||||||
|
alarm.ALARM_TYPE.KUBE_UPGRADE_AUTO_APPLY_FAILED,
|
||||||
|
}
|
||||||
|
return ALARM_TYPE_MAPPING[alarm_type]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def event_id(event_id):
|
||||||
|
"""
|
||||||
|
Returns EVENT_ID corresponding to SW_UPDATE_EVENT_IDS
|
||||||
|
"""
|
||||||
|
EVENT_ID_MAPPING = {
|
||||||
|
SW_UPDATE_EVENT_IDS.APPLY_START:
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_START,
|
||||||
|
SW_UPDATE_EVENT_IDS.APPLY_INPROGRESS:
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_INPROGRESS,
|
||||||
|
SW_UPDATE_EVENT_IDS.APPLY_REJECTED:
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_REJECTED,
|
||||||
|
SW_UPDATE_EVENT_IDS.APPLY_CANCELLED:
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_CANCELLED,
|
||||||
|
SW_UPDATE_EVENT_IDS.APPLY_FAILED:
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_FAILED,
|
||||||
|
SW_UPDATE_EVENT_IDS.APPLY_COMPLETED:
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_COMPLETED,
|
||||||
|
SW_UPDATE_EVENT_IDS.APPLY_ABORT:
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORT,
|
||||||
|
SW_UPDATE_EVENT_IDS.APPLY_ABORTING:
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORTING,
|
||||||
|
SW_UPDATE_EVENT_IDS.APPLY_ABORT_REJECTED:
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORT_REJECTED,
|
||||||
|
SW_UPDATE_EVENT_IDS.APPLY_ABORT_FAILED:
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORT_FAILED,
|
||||||
|
SW_UPDATE_EVENT_IDS.APPLY_ABORTED:
|
||||||
|
event_log.EVENT_ID.KUBE_UPGRADE_AUTO_APPLY_ABORTED,
|
||||||
|
}
|
||||||
|
return EVENT_ID_MAPPING[event_id]
|
||||||
|
|
||||||
|
def nfvi_update(self):
|
||||||
|
"""
|
||||||
|
NFVI Update
|
||||||
|
"""
|
||||||
|
if self._strategy is None:
|
||||||
|
if self._alarms:
|
||||||
|
alarm.clear_sw_update_alarm(self._alarms)
|
||||||
|
return False
|
||||||
|
|
||||||
|
if self.strategy.is_applying():
|
||||||
|
if not self._alarms:
|
||||||
|
self._alarms = alarm.raise_sw_update_alarm(
|
||||||
|
self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_INPROGRESS))
|
||||||
|
event_log.sw_update_issue_log(
|
||||||
|
self.event_id(SW_UPDATE_EVENT_IDS.APPLY_INPROGRESS))
|
||||||
|
|
||||||
|
elif (self.strategy.is_apply_failed() or
|
||||||
|
self.strategy.is_apply_timed_out()):
|
||||||
|
for kube_upgrade_host in self._kube_upgrade_hosts:
|
||||||
|
if not self._alarms:
|
||||||
|
self._alarms = alarm.raise_sw_update_alarm(
|
||||||
|
self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_FAILED))
|
||||||
|
event_log.sw_update_issue_log(
|
||||||
|
self.event_id(SW_UPDATE_EVENT_IDS.APPLY_FAILED))
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
if self._alarms:
|
||||||
|
alarm.clear_sw_update_alarm(self._alarms)
|
||||||
|
return False
|
||||||
|
|
||||||
|
elif self.strategy.is_aborting():
|
||||||
|
if not self._alarms:
|
||||||
|
self._alarms = alarm.raise_sw_update_alarm(
|
||||||
|
self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_ABORTING))
|
||||||
|
event_log.sw_update_issue_log(
|
||||||
|
self.event_id(SW_UPDATE_EVENT_IDS.APPLY_ABORTING))
|
||||||
|
|
||||||
|
else:
|
||||||
|
if self._alarms:
|
||||||
|
alarm.clear_sw_update_alarm(self._alarms)
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
@coroutine
|
||||||
|
def nfvi_audit(self):
|
||||||
|
"""
|
||||||
|
Audit NFVI layer
|
||||||
|
"""
|
||||||
|
while True:
|
||||||
|
timer_id = (yield)
|
||||||
|
|
||||||
|
DLOG.debug("Audit alarms, timer_id=%s." % timer_id)
|
||||||
|
self.nfvi_alarms_clear()
|
||||||
|
nfvi.nfvi_get_alarms(self.nfvi_alarms_callback(timer_id))
|
||||||
|
if not nfvi.nfvi_fault_mgmt_plugin_disabled():
|
||||||
|
nfvi.nfvi_get_openstack_alarms(
|
||||||
|
self.nfvi_alarms_callback(timer_id))
|
||||||
|
self._nfvi_audit_inprogress = True
|
||||||
|
while self._nfvi_audit_inprogress:
|
||||||
|
timer_id = (yield)
|
||||||
|
|
||||||
|
if not self.nfvi_update():
|
||||||
|
DLOG.info("Audit no longer needed.")
|
||||||
|
break
|
||||||
|
|
||||||
|
DLOG.verbose("Audit kube upgrade still running, timer_id=%s." %
|
||||||
|
timer_id)
|
||||||
|
|
||||||
|
self._nfvi_timer_id = None
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2016-2020 Wind River Systems, Inc.
|
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -30,6 +30,7 @@ class SwUpdateTypes(Constants):
|
|||||||
SW_PATCH = Constant('sw-patch')
|
SW_PATCH = Constant('sw-patch')
|
||||||
SW_UPGRADE = Constant('sw-upgrade')
|
SW_UPGRADE = Constant('sw-upgrade')
|
||||||
FW_UPDATE = Constant('fw-update')
|
FW_UPDATE = Constant('fw-update')
|
||||||
|
KUBE_UPGRADE = Constant('kube-upgrade')
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(Singleton)
|
@six.add_metaclass(Singleton)
|
||||||
|
@ -30,7 +30,7 @@ class SwUpgrade(SwUpdate):
|
|||||||
def strategy_build(self, strategy_uuid, storage_apply_type,
|
def strategy_build(self, strategy_uuid, storage_apply_type,
|
||||||
worker_apply_type, max_parallel_worker_hosts,
|
worker_apply_type, max_parallel_worker_hosts,
|
||||||
alarm_restrictions, start_upgrade,
|
alarm_restrictions, start_upgrade,
|
||||||
complete_upgrade, ignore_alarms):
|
complete_upgrade, ignore_alarms, single_controller):
|
||||||
"""
|
"""
|
||||||
Create a software upgrade strategy
|
Create a software upgrade strategy
|
||||||
"""
|
"""
|
||||||
@ -43,7 +43,8 @@ class SwUpgrade(SwUpdate):
|
|||||||
self._strategy = strategy.SwUpgradeStrategy(
|
self._strategy = strategy.SwUpgradeStrategy(
|
||||||
strategy_uuid, storage_apply_type, worker_apply_type,
|
strategy_uuid, storage_apply_type, worker_apply_type,
|
||||||
max_parallel_worker_hosts,
|
max_parallel_worker_hosts,
|
||||||
alarm_restrictions, start_upgrade, complete_upgrade, ignore_alarms)
|
alarm_restrictions, start_upgrade, complete_upgrade,
|
||||||
|
ignore_alarms, single_controller)
|
||||||
|
|
||||||
self._strategy.sw_update_obj = self
|
self._strategy.sw_update_obj = self
|
||||||
self._strategy.build()
|
self._strategy.build()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -73,6 +73,7 @@ from nfv_vim.rpc._rpc_message_network import APIResponseUpdateNetwork # noqa: F
|
|||||||
|
|
||||||
from nfv_vim.rpc._rpc_message_sw_update import APIRequestAbortSwUpdateStrategy # noqa: F401
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestAbortSwUpdateStrategy # noqa: F401
|
||||||
from nfv_vim.rpc._rpc_message_sw_update import APIRequestApplySwUpdateStrategy # noqa: F401
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestApplySwUpdateStrategy # noqa: F401
|
||||||
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestCreateKubeUpgradeStrategy # noqa: F401
|
||||||
from nfv_vim.rpc._rpc_message_sw_update import APIRequestCreateSwUpdateStrategy # noqa: F401
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestCreateSwUpdateStrategy # noqa: F401
|
||||||
from nfv_vim.rpc._rpc_message_sw_update import APIRequestCreateSwUpgradeStrategy # noqa: F401
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestCreateSwUpgradeStrategy # noqa: F401
|
||||||
from nfv_vim.rpc._rpc_message_sw_update import APIRequestDeleteSwUpdateStrategy # noqa: F401
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestDeleteSwUpdateStrategy # noqa: F401
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -96,6 +96,7 @@ class _RPCMessageType(Constants):
|
|||||||
|
|
||||||
# Software Update Definitions
|
# Software Update Definitions
|
||||||
CREATE_SW_UPDATE_STRATEGY_REQUEST = Constant('create-sw-update-strategy-request')
|
CREATE_SW_UPDATE_STRATEGY_REQUEST = Constant('create-sw-update-strategy-request')
|
||||||
|
CREATE_KUBE_UPGRADE_STRATEGY_REQUEST = Constant('create-kube-upgrade-strategy-request')
|
||||||
CREATE_SW_UPGRADE_STRATEGY_REQUEST = Constant('create-sw-upgrade-strategy-request')
|
CREATE_SW_UPGRADE_STRATEGY_REQUEST = Constant('create-sw-upgrade-strategy-request')
|
||||||
CREATE_SW_UPDATE_STRATEGY_RESPONSE = Constant('create-sw-update-strategy-response')
|
CREATE_SW_UPDATE_STRATEGY_RESPONSE = Constant('create-sw-update-strategy-response')
|
||||||
APPLY_SW_UPDATE_STRATEGY_REQUEST = Constant('apply-sw-update-strategy-request')
|
APPLY_SW_UPDATE_STRATEGY_REQUEST = Constant('apply-sw-update-strategy-request')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -143,6 +143,7 @@ class RPCMessageFactory(object):
|
|||||||
|
|
||||||
from nfv_vim.rpc._rpc_message_sw_update import APIRequestAbortSwUpdateStrategy
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestAbortSwUpdateStrategy
|
||||||
from nfv_vim.rpc._rpc_message_sw_update import APIRequestApplySwUpdateStrategy
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestApplySwUpdateStrategy
|
||||||
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestCreateKubeUpgradeStrategy
|
||||||
from nfv_vim.rpc._rpc_message_sw_update import APIRequestCreateSwUpdateStrategy
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestCreateSwUpdateStrategy
|
||||||
from nfv_vim.rpc._rpc_message_sw_update import APIRequestCreateSwUpgradeStrategy
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestCreateSwUpgradeStrategy
|
||||||
from nfv_vim.rpc._rpc_message_sw_update import APIRequestDeleteSwUpdateStrategy
|
from nfv_vim.rpc._rpc_message_sw_update import APIRequestDeleteSwUpdateStrategy
|
||||||
@ -224,6 +225,7 @@ class RPCMessageFactory(object):
|
|||||||
|
|
||||||
# Software Update Mapping
|
# Software Update Mapping
|
||||||
RPC_MSG_TYPE.CREATE_SW_UPDATE_STRATEGY_REQUEST: APIRequestCreateSwUpdateStrategy,
|
RPC_MSG_TYPE.CREATE_SW_UPDATE_STRATEGY_REQUEST: APIRequestCreateSwUpdateStrategy,
|
||||||
|
RPC_MSG_TYPE.CREATE_KUBE_UPGRADE_STRATEGY_REQUEST: APIRequestCreateKubeUpgradeStrategy,
|
||||||
RPC_MSG_TYPE.CREATE_SW_UPGRADE_STRATEGY_REQUEST: APIRequestCreateSwUpgradeStrategy,
|
RPC_MSG_TYPE.CREATE_SW_UPGRADE_STRATEGY_REQUEST: APIRequestCreateSwUpgradeStrategy,
|
||||||
RPC_MSG_TYPE.CREATE_SW_UPDATE_STRATEGY_RESPONSE: APIResponseCreateSwUpdateStrategy,
|
RPC_MSG_TYPE.CREATE_SW_UPDATE_STRATEGY_RESPONSE: APIResponseCreateSwUpdateStrategy,
|
||||||
RPC_MSG_TYPE.APPLY_SW_UPDATE_STRATEGY_REQUEST: APIRequestApplySwUpdateStrategy,
|
RPC_MSG_TYPE.APPLY_SW_UPDATE_STRATEGY_REQUEST: APIRequestApplySwUpdateStrategy,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -84,6 +84,30 @@ class APIRequestCreateSwUpgradeStrategy(APIRequestCreateSwUpdateStrategy):
|
|||||||
return "create-sw-upgrade-strategy request: %s" % self.deserialize_payload
|
return "create-sw-upgrade-strategy request: %s" % self.deserialize_payload
|
||||||
|
|
||||||
|
|
||||||
|
class APIRequestCreateKubeUpgradeStrategy(APIRequestCreateSwUpdateStrategy):
|
||||||
|
"""
|
||||||
|
RPC API Request Message - Create Kube Upgrade Strategy
|
||||||
|
"""
|
||||||
|
to_version = None
|
||||||
|
|
||||||
|
def __init__(self, msg_version=RPC_MSG_VERSION.VERSION_1_0,
|
||||||
|
msg_type=RPC_MSG_TYPE.CREATE_KUBE_UPGRADE_STRATEGY_REQUEST,
|
||||||
|
msg_result=RPC_MSG_RESULT.SUCCESS):
|
||||||
|
super(APIRequestCreateKubeUpgradeStrategy, self).__init__(
|
||||||
|
msg_version, msg_type, msg_result)
|
||||||
|
|
||||||
|
def serialize_payload(self, msg):
|
||||||
|
super(APIRequestCreateKubeUpgradeStrategy, self).serialize_payload(msg)
|
||||||
|
msg['to_version'] = self.to_version
|
||||||
|
|
||||||
|
def deserialize_payload(self, msg):
|
||||||
|
super(APIRequestCreateKubeUpgradeStrategy, self).deserialize_payload(msg)
|
||||||
|
self.to_version = msg.get('to_version', None)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "create-kube-upgrade-strategy request: %s" % self.deserialize_payload
|
||||||
|
|
||||||
|
|
||||||
class APIResponseCreateSwUpdateStrategy(RPCMessage):
|
class APIResponseCreateSwUpdateStrategy(RPCMessage):
|
||||||
"""
|
"""
|
||||||
RPC API Response Message - Create Software Update Strategy
|
RPC API Response Message - Create Software Update Strategy
|
||||||
|
@ -1,22 +1,34 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
from nfv_common.strategy import * # noqa: F401,F403
|
from nfv_common.strategy import * # noqa: F401,F403
|
||||||
from nfv_vim.strategy._strategy import FwUpdateStrategy # noqa: F401
|
from nfv_vim.strategy._strategy import FwUpdateStrategy # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy import KubeUpgradeStrategy # noqa: F401
|
||||||
from nfv_vim.strategy._strategy import strategy_rebuild_from_dict # noqa: F401
|
from nfv_vim.strategy._strategy import strategy_rebuild_from_dict # noqa: F401
|
||||||
from nfv_vim.strategy._strategy import SwPatchStrategy # noqa: F401
|
from nfv_vim.strategy._strategy import SwPatchStrategy # noqa: F401
|
||||||
from nfv_vim.strategy._strategy import SwUpgradeStrategy # noqa: F401
|
from nfv_vim.strategy._strategy import SwUpgradeStrategy # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_defs import STRATEGY_EVENT # noqa: F401
|
from nfv_vim.strategy._strategy_defs import STRATEGY_EVENT # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_stages import STRATEGY_STAGE_NAME # noqa: F401
|
from nfv_vim.strategy._strategy_stages import STRATEGY_STAGE_NAME # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy_steps import ApplySwPatchesStep # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_steps import DisableHostServicesStep # noqa: F401
|
from nfv_vim.strategy._strategy_steps import DisableHostServicesStep # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_steps import FwUpdateAbortHostsStep # noqa: F401
|
from nfv_vim.strategy._strategy_steps import FwUpdateAbortHostsStep # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_steps import FwUpdateHostsStep # noqa: F401
|
from nfv_vim.strategy._strategy_steps import FwUpdateHostsStep # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy_steps import KubeHostUpgradeControlPlaneStep # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy_steps import KubeHostUpgradeKubeletStep # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy_steps import KubeUpgradeCleanupStep # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy_steps import KubeUpgradeCompleteStep # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy_steps import KubeUpgradeDownloadImagesStep # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy_steps import KubeUpgradeNetworkingStep # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy_steps import KubeUpgradeStartStep # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_steps import LockHostsStep # noqa: F401
|
from nfv_vim.strategy._strategy_steps import LockHostsStep # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_steps import MigrateInstancesStep # noqa: F401
|
from nfv_vim.strategy._strategy_steps import MigrateInstancesStep # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_steps import QueryAlarmsStep # noqa: F401
|
from nfv_vim.strategy._strategy_steps import QueryAlarmsStep # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_steps import QueryFwUpdateHostStep # noqa: F401
|
from nfv_vim.strategy._strategy_steps import QueryFwUpdateHostStep # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy_steps import QueryKubeHostUpgradeStep # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy_steps import QueryKubeUpgradeStep # noqa: F401
|
||||||
|
from nfv_vim.strategy._strategy_steps import QueryKubeVersionsStep # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_steps import QuerySwPatchesStep # noqa: F401
|
from nfv_vim.strategy._strategy_steps import QuerySwPatchesStep # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_steps import QuerySwPatchHostsStep # noqa: F401
|
from nfv_vim.strategy._strategy_steps import QuerySwPatchHostsStep # noqa: F401
|
||||||
from nfv_vim.strategy._strategy_steps import QueryUpgradeStep # noqa: F401
|
from nfv_vim.strategy._strategy_steps import QueryUpgradeStep # noqa: F401
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -28,6 +28,10 @@ class EventNames(object):
|
|||||||
DISABLE_HOST_SERVICES_FAILED = Constant('disable-host-services-failed')
|
DISABLE_HOST_SERVICES_FAILED = Constant('disable-host-services-failed')
|
||||||
ENABLE_HOST_SERVICES_FAILED = Constant('enable-host-services-failed')
|
ENABLE_HOST_SERVICES_FAILED = Constant('enable-host-services-failed')
|
||||||
MIGRATE_INSTANCES_FAILED = Constant('migrate-instances-failed')
|
MIGRATE_INSTANCES_FAILED = Constant('migrate-instances-failed')
|
||||||
|
KUBE_HOST_UPGRADE_CONTROL_PLANE_FAILED = \
|
||||||
|
Constant('kube-host-upgrade-control-plane-failed')
|
||||||
|
KUBE_HOST_UPGRADE_KUBELET_FAILED = \
|
||||||
|
Constant('kube-host-upgrade-kubelet-failed')
|
||||||
|
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Wind River Systems, Inc.
|
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -34,6 +34,20 @@ class StrategyStageNames(Constants):
|
|||||||
FW_UPDATE_HOSTS_QUERY = Constant('fw-update-hosts-query')
|
FW_UPDATE_HOSTS_QUERY = Constant('fw-update-hosts-query')
|
||||||
FW_UPDATE_HOST_QUERY = Constant('fw-update-host-query')
|
FW_UPDATE_HOST_QUERY = Constant('fw-update-host-query')
|
||||||
FW_UPDATE_WORKER_HOSTS = Constant('fw-update-worker-hosts')
|
FW_UPDATE_WORKER_HOSTS = Constant('fw-update-worker-hosts')
|
||||||
|
KUBE_UPGRADE_QUERY = Constant('kube-upgrade-query')
|
||||||
|
KUBE_UPGRADE_START = Constant('kube-upgrade-start')
|
||||||
|
KUBE_UPGRADE_DOWNLOAD_IMAGES = Constant('kube-upgrade-download-images')
|
||||||
|
KUBE_UPGRADE_FIRST_CONTROL_PLANE = \
|
||||||
|
Constant('kube-upgrade-first-control-plane')
|
||||||
|
KUBE_UPGRADE_NETWORKING = Constant('kube-upgrade-networking')
|
||||||
|
KUBE_UPGRADE_SECOND_CONTROL_PLANE = \
|
||||||
|
Constant('kube-upgrade-second-control-plane')
|
||||||
|
KUBE_UPGRADE_PATCH = Constant('kube-upgrade-patch')
|
||||||
|
KUBE_UPGRADE_KUBELETS_CONTROLLERS = \
|
||||||
|
Constant('kube-upgrade-kubelets-controllers')
|
||||||
|
KUBE_UPGRADE_KUBELETS_WORKERS = Constant('kube-upgrade-kubelets-workers')
|
||||||
|
KUBE_UPGRADE_COMPLETE = Constant('kube-upgrade-complete')
|
||||||
|
KUBE_UPGRADE_CLEANUP = Constant('kube-upgrade-cleanup')
|
||||||
|
|
||||||
|
|
||||||
# Constant Instantiation
|
# Constant Instantiation
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -63,7 +63,7 @@ output-format=text
|
|||||||
files-output=no
|
files-output=no
|
||||||
|
|
||||||
# Tells whether to display a full report or only the messages
|
# Tells whether to display a full report or only the messages
|
||||||
reports=no
|
reports=yes
|
||||||
|
|
||||||
# Python expression which should return a note less than 10 (10 is the highest
|
# Python expression which should return a note less than 10 (10 is the highest
|
||||||
# note). You have access to the variables errors warning, statement which
|
# note). You have access to the variables errors warning, statement which
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
SRC_DIR="$PKG_BASE/nova-api-proxy"
|
SRC_DIR="$PKG_BASE/nova-api-proxy"
|
||||||
TIS_PATCH_VER=10
|
TIS_PATCH_VER=PKG_GITREVCOUNT
|
||||||
|
Loading…
Reference in New Issue
Block a user