sw-deploy-strategy backend overhaul
Roughed in sw-deploy by replacing sw-upgrade and adding things as needed. Flow is mostly working, however several parts need updating like how nfvi.objects.v1.Upgrade is constructed. I used None for parts. Also disabled alarm checking so speed things up. TEST PLAN NOT PASSING: sw-deploy-strategy on system controllers (AIO-DX) Change-Id: If1eb5b45089f4a67d6d88093d0e215e510fd8c55 Signed-off-by: Joshua Kraitberg <joshua.kraitberg@windriver.com>
This commit is contained in:
parent
3399c7fc54
commit
5c3bc10c7e
|
@ -299,13 +299,9 @@ def create_strategy(token_id,
|
|||
elif sw_update.STRATEGY_NAME_SYSTEM_CONFIG_UPDATE == strategy_name:
|
||||
api_cmd_payload['controller-apply-type'] = controller_apply_type
|
||||
api_cmd_payload['default-instance-action'] = default_instance_action
|
||||
# TODO(jkraitbe): Backend for sw-deploy will continue as old sw-upgrade for now
|
||||
elif sw_update.STRATEGY_NAME_SW_UPGRADE == strategy_name:
|
||||
# for upgrade: default-instance-action is hardcoded to MIGRATE
|
||||
if 'start_upgrade' in kwargs and kwargs['start_upgrade']:
|
||||
api_cmd_payload['start-upgrade'] = True
|
||||
if 'complete_upgrade' in kwargs and kwargs['complete_upgrade']:
|
||||
api_cmd_payload['complete-upgrade'] = True
|
||||
if 'release' in kwargs and kwargs['release']:
|
||||
api_cmd_payload['release'] = kwargs['release']
|
||||
api_cmd_payload['storage-apply-type'] = storage_apply_type
|
||||
api_cmd_payload['worker-apply-type'] = worker_apply_type
|
||||
if max_parallel_worker_hosts is not None:
|
||||
|
|
|
@ -51,9 +51,7 @@ def get_extra_create_args(cmd_area, args):
|
|||
# no additional kwargs for patch
|
||||
return {}
|
||||
elif sw_update.CMD_NAME_SW_DEPLOY == cmd_area:
|
||||
# TODO(jkraitbe): Args will be updated to use new release parameter
|
||||
# upgrade supports: complete_upgrade
|
||||
return {'complete_upgrade': args.complete_upgrade}
|
||||
return {'release': args.release}
|
||||
elif sw_update.CMD_NAME_FW_UPDATE == cmd_area:
|
||||
# no additional kwargs for firmware update
|
||||
return {}
|
||||
|
@ -465,14 +463,7 @@ def setup_sw_deploy_parser(commands):
|
|||
# add sw-deploy 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)
|
||||
|
||||
# TODO(jkraitbe): Args will be updated to use new release parameter
|
||||
create_strategy_cmd.add_argument('--complete-upgrade',
|
||||
action='store_true',
|
||||
create_strategy_cmd.add_argument('--release',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
# define the delete command
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2015-2023 Wind River Systems, Inc.
|
||||
# Copyright (c) 2015-2024 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -23,6 +23,7 @@ from nfv_plugins.nfvi_plugins.openstack import mtc
|
|||
from nfv_plugins.nfvi_plugins.openstack import openstack
|
||||
from nfv_plugins.nfvi_plugins.openstack import rest_api
|
||||
from nfv_plugins.nfvi_plugins.openstack import sysinv
|
||||
from nfv_plugins.nfvi_plugins.openstack import usm
|
||||
|
||||
from nfv_plugins.nfvi_plugins.openstack.objects import OPENSTACK_SERVICE
|
||||
|
||||
|
@ -2202,9 +2203,9 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
callback.send(response)
|
||||
callback.close()
|
||||
|
||||
def get_upgrade(self, future, callback):
|
||||
def get_upgrade(self, future, release, callback):
|
||||
"""
|
||||
Get information about the upgrade from the plugin
|
||||
Get information about the sw-deploy from the plugin
|
||||
"""
|
||||
response = dict()
|
||||
response['completed'] = False
|
||||
|
@ -2225,26 +2226,30 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
|
||||
self._platform_token = future.result.data
|
||||
|
||||
future.work(sysinv.get_upgrade, self._platform_token)
|
||||
future.work(usm.sw_deploy_get_release, self._platform_token, release)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
DLOG.error("SysInv get-upgrade did not complete.")
|
||||
DLOG.error("USM sw-deploy get release did not complete.")
|
||||
return
|
||||
|
||||
upgrade_data_list = future.result.data
|
||||
if 1 < len(upgrade_data_list):
|
||||
DLOG.critical("Too many upgrades retrieved, num_upgrades=%i"
|
||||
% len(upgrade_data_list))
|
||||
release_data = future.result.data
|
||||
release_info = release_data["metadata"][release]
|
||||
|
||||
upgrade_obj = None
|
||||
future.work(usm.sw_deploy_host_list, self._platform_token)
|
||||
future.result = (yield)
|
||||
|
||||
for upgrade_data in upgrade_data_list['upgrades']:
|
||||
upgrade_obj = nfvi.objects.v1.Upgrade(
|
||||
upgrade_data['state'],
|
||||
upgrade_data['from_release'],
|
||||
upgrade_data['to_release'])
|
||||
break
|
||||
if not future.result.is_complete():
|
||||
DLOG.error("USM sw-deploy host list did not complete.")
|
||||
return
|
||||
|
||||
hosts_states_data = future.result.data
|
||||
|
||||
upgrade_obj = nfvi.objects.v1.Upgrade(
|
||||
release,
|
||||
release_info["state"],
|
||||
release_info["reboot_required"] == "Y",
|
||||
hosts_states_data["data"])
|
||||
|
||||
response['result-data'] = upgrade_obj
|
||||
response['completed'] = True
|
||||
|
@ -2267,15 +2272,16 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
callback.send(response)
|
||||
callback.close()
|
||||
|
||||
def upgrade_start(self, future, callback):
|
||||
def upgrade_precheck(self, future, release, callback):
|
||||
"""
|
||||
Start an upgrade
|
||||
Precheck a USM stoftware deploy
|
||||
"""
|
||||
response = dict()
|
||||
response['completed'] = False
|
||||
response['reason'] = ''
|
||||
|
||||
try:
|
||||
upgrade_data = future.result.data
|
||||
future.set_timeouts(config.CONF.get('nfvi-timeouts', None))
|
||||
|
||||
if self._platform_token is None or \
|
||||
|
@ -2290,18 +2296,76 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
|
||||
self._platform_token = future.result.data
|
||||
|
||||
future.work(sysinv.upgrade_start, self._platform_token)
|
||||
future.work(usm.sw_deploy_precheck, self._platform_token, release)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
DLOG.error("SysInv upgrade-start did not complete.")
|
||||
DLOG.error("USM sw-deploy precheck did not complete.")
|
||||
return
|
||||
|
||||
upgrade_data = future.result.data
|
||||
upgrade_obj = nfvi.objects.v1.Upgrade(
|
||||
self._release,
|
||||
None,
|
||||
None,
|
||||
None)
|
||||
|
||||
response['result-data'] = 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 exception while trying to precheck "
|
||||
"USM sw-deploy, error=%s." % e)
|
||||
|
||||
except Exception as e:
|
||||
DLOG.exception("Caught exception while trying to precheck USM sw-deploy, "
|
||||
"error=%s." % e)
|
||||
|
||||
finally:
|
||||
callback.send(response)
|
||||
callback.close()
|
||||
|
||||
def upgrade_start(self, future, release, callback):
|
||||
"""
|
||||
Start a USM stoftware deploy
|
||||
"""
|
||||
response = dict()
|
||||
response['completed'] = False
|
||||
response['reason'] = ''
|
||||
|
||||
try:
|
||||
upgrade_data = future.result.data
|
||||
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(usm.sw_deploy_start, self._platform_token, release)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
DLOG.error("USM sw-deploy start did not complete.")
|
||||
return
|
||||
|
||||
upgrade_obj = nfvi.objects.v1.Upgrade(
|
||||
self._release,
|
||||
upgrade_data['state'],
|
||||
upgrade_data['from_release'],
|
||||
upgrade_data['to_release'])
|
||||
None,
|
||||
None)
|
||||
|
||||
response['result-data'] = upgrade_obj
|
||||
response['completed'] = True
|
||||
|
@ -2314,19 +2378,19 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
|
||||
else:
|
||||
DLOG.exception("Caught exception while trying to start "
|
||||
"upgrade, error=%s." % e)
|
||||
"USM sw-deploy, error=%s." % e)
|
||||
|
||||
except Exception as e:
|
||||
DLOG.exception("Caught exception while trying to start upgrade, "
|
||||
DLOG.exception("Caught exception while trying to start USM sw-deploy, "
|
||||
"error=%s." % e)
|
||||
|
||||
finally:
|
||||
callback.send(response)
|
||||
callback.close()
|
||||
|
||||
def upgrade_activate(self, future, callback):
|
||||
def upgrade_activate(self, future, release, callback):
|
||||
"""
|
||||
Activate an upgrade
|
||||
Activate a USM software deployement
|
||||
"""
|
||||
response = dict()
|
||||
response['completed'] = False
|
||||
|
@ -2347,18 +2411,19 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
|
||||
self._platform_token = future.result.data
|
||||
|
||||
future.work(sysinv.upgrade_activate, self._platform_token)
|
||||
future.work(usm.sw_deploy_activate, self._platform_token, release)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
DLOG.error("SysInv upgrade-activate did not complete.")
|
||||
DLOG.error("USM sw-deploy activate did not complete.")
|
||||
return
|
||||
|
||||
upgrade_data = future.result.data
|
||||
upgrade_obj = nfvi.objects.v1.Upgrade(
|
||||
self._release,
|
||||
upgrade_data['state'],
|
||||
upgrade_data['from_release'],
|
||||
upgrade_data['to_release'])
|
||||
None,
|
||||
None)
|
||||
|
||||
response['result-data'] = upgrade_obj
|
||||
response['completed'] = True
|
||||
|
@ -2371,19 +2436,19 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
|
||||
else:
|
||||
DLOG.exception("Caught exception while trying to activate "
|
||||
"upgrade, error=%s." % e)
|
||||
"USM sw-deploy, error=%s." % e)
|
||||
|
||||
except Exception as e:
|
||||
DLOG.exception("Caught exception while trying to activate upgrade, "
|
||||
DLOG.exception("Caught exception while trying to activate USM sw-deploy, "
|
||||
"error=%s." % e)
|
||||
|
||||
finally:
|
||||
callback.send(response)
|
||||
callback.close()
|
||||
|
||||
def upgrade_complete(self, future, callback):
|
||||
def upgrade_complete(self, future, release, callback):
|
||||
"""
|
||||
Complete an upgrade
|
||||
Complete a USM software deployement
|
||||
"""
|
||||
response = dict()
|
||||
response['completed'] = False
|
||||
|
@ -2404,18 +2469,19 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
|
||||
self._platform_token = future.result.data
|
||||
|
||||
future.work(sysinv.upgrade_complete, self._platform_token)
|
||||
future.work(usm.sw_deploy_complete, self._platform_token, release)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
DLOG.error("SysInv upgrade-complete did not complete.")
|
||||
DLOG.error("USM sw-deploy complete did not complete.")
|
||||
return
|
||||
|
||||
upgrade_data = future.result.data
|
||||
upgrade_obj = nfvi.objects.v1.Upgrade(
|
||||
self._release,
|
||||
upgrade_data['state'],
|
||||
upgrade_data['from_release'],
|
||||
upgrade_data['to_release'])
|
||||
None,
|
||||
None)
|
||||
|
||||
response['result-data'] = upgrade_obj
|
||||
response['completed'] = True
|
||||
|
@ -2428,10 +2494,10 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
|
||||
else:
|
||||
DLOG.exception("Caught exception while trying to complete "
|
||||
"upgrade, error=%s." % e)
|
||||
"USM sw-deploy, error=%s." % e)
|
||||
|
||||
except Exception as e:
|
||||
DLOG.exception("Caught exception while trying to complete upgrade, "
|
||||
DLOG.exception("Caught exception while trying to complete USM sw-deploy, "
|
||||
"error=%s." % e)
|
||||
|
||||
finally:
|
||||
|
@ -3594,7 +3660,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
|
||||
self._platform_token = future.result.data
|
||||
|
||||
future.work(sysinv.upgrade_host, self._platform_token, host_uuid)
|
||||
future.work(usm.sw_deploy_execute, self._platform_token, host_name)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
|
@ -4379,4 +4445,4 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
Finalize the plugin
|
||||
"""
|
||||
if self._host_listener is not None:
|
||||
self._host_listener.shutdown()
|
||||
self._host_listener.shutdown()
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2015-2018 Wind River Systems, Inc.
|
||||
# Copyright (c) 2015-2024 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -40,6 +40,7 @@ class PlatformServices(Constants):
|
|||
SYSINV = Constant('sysinv')
|
||||
PATCHING = Constant('patching')
|
||||
FM = Constant('fm')
|
||||
USM = Constant('usm')
|
||||
|
||||
|
||||
# Platform Services Constant
|
||||
|
|
|
@ -28,10 +28,10 @@ KUBE_UPGRADE_ENDPOINT = "/kube_upgrade"
|
|||
|
||||
|
||||
# todo(abailey): refactor _api_get, etc.. into rest_api.py
|
||||
def _api_cmd(token, endpoint):
|
||||
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
|
||||
def _api_cmd(token, endpoint, service=PLATFORM_SERVICE.SYSINV):
|
||||
url = token.get_service_url(service)
|
||||
if url is None:
|
||||
raise ValueError("OpenStack SysInv URL is invalid")
|
||||
raise ValueError(f"OpenStack {service} URL is invalid")
|
||||
api_cmd = url + endpoint
|
||||
return api_cmd
|
||||
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
#
|
||||
# Copyright (c) 2024 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from nfv_common import debug
|
||||
from nfv_plugins.nfvi_plugins.openstack.objects import PLATFORM_SERVICE
|
||||
from nfv_plugins.nfvi_plugins.openstack.rest_api import rest_api_request
|
||||
from nfv_plugins.nfvi_plugins import config
|
||||
|
||||
|
||||
REST_API_REQUEST_TIMEOUT = 60
|
||||
|
||||
# TODO: FIX LOG NAME
|
||||
# DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.usm')
|
||||
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.sysinv')
|
||||
|
||||
|
||||
def _usm_api_cmd(token, endpoint):
|
||||
base_url = token.get_service_url(PLATFORM_SERVICE.USM)
|
||||
if base_url is None:
|
||||
raise ValueError("PlatformService USM URL is invalid")
|
||||
|
||||
url = os.path.join(base_url, "v1/software", endpoint)
|
||||
return url
|
||||
|
||||
|
||||
def _api_cmd_headers():
|
||||
api_cmd_headers = dict()
|
||||
api_cmd_headers['Content-Type'] = "application/json"
|
||||
api_cmd_headers['User-Agent'] = "vim/1.0"
|
||||
return api_cmd_headers
|
||||
|
||||
|
||||
def _api_get(token, url):
|
||||
"""
|
||||
Perform a generic GET for a particular API endpoint
|
||||
"""
|
||||
response = rest_api_request(token,
|
||||
"GET",
|
||||
url,
|
||||
timeout_in_secs=REST_API_REQUEST_TIMEOUT)
|
||||
return response
|
||||
|
||||
|
||||
|
||||
def _api_post(token, url, payload, headers=_api_cmd_headers()):
|
||||
"""
|
||||
Generic POST to an endpoint with a payload
|
||||
"""
|
||||
response = rest_api_request(token,
|
||||
"POST",
|
||||
url,
|
||||
headers,
|
||||
json.dumps(payload),
|
||||
timeout_in_secs=REST_API_REQUEST_TIMEOUT)
|
||||
return response
|
||||
|
||||
|
||||
def sw_deploy_get_release(token, release):
|
||||
"""
|
||||
Query USM for information about a specific upgrade
|
||||
"""
|
||||
|
||||
uri = f"show/{release}"
|
||||
url = _usm_api_cmd(token, uri)
|
||||
response = _api_get(token, url)
|
||||
return response
|
||||
|
||||
|
||||
def sw_deploy_host_list(token):
|
||||
"""
|
||||
Query USM for information about a hosts during a deployment
|
||||
"""
|
||||
|
||||
# TODO(jkraitbe): This API will change in the future
|
||||
uri = "host_list"
|
||||
url = _usm_api_cmd(token, uri)
|
||||
response = _api_get(token, url)
|
||||
return response
|
||||
|
||||
|
||||
def sw_deploy_precheck(token, release, force=False):
|
||||
"""
|
||||
Ask USM to precheck before a deployment
|
||||
"""
|
||||
|
||||
uri = f"deploy_precheck/{release}/force" if force else f"deploy_precheck/{release}"
|
||||
url = _usm_api_cmd(token, uri)
|
||||
response = _api_post(token, url,{})
|
||||
return response
|
||||
|
||||
|
||||
def sw_deploy_start(token, release, force=False):
|
||||
"""
|
||||
Ask USM to start a deployment
|
||||
"""
|
||||
|
||||
uri = f"deploy_start/{release}/force" if force else f"deploy_start/{release}"
|
||||
url = _usm_api_cmd(token, uri)
|
||||
response = _api_post(token, url,{})
|
||||
return response
|
||||
|
||||
|
||||
|
||||
def sw_deploy_execute(token, host_name):
|
||||
"""
|
||||
Ask USM to execute a deployment on a host
|
||||
"""
|
||||
|
||||
uri = f"deploy_host/{host_name}"
|
||||
url = _usm_api_cmd(token, uri)
|
||||
response = _api_post(token, url,{})
|
||||
return response
|
||||
|
||||
|
||||
def sw_deploy_activate(token, release):
|
||||
"""
|
||||
Ask USM activate a deployment
|
||||
"""
|
||||
|
||||
uri = f"deploy_activate/{release}"
|
||||
url = _usm_api_cmd(token, uri)
|
||||
response = _api_post(token, url,{})
|
||||
return response
|
||||
|
||||
|
||||
def sw_deploy_activate(token, release):
|
||||
"""
|
||||
Ask USM complete a deployment
|
||||
"""
|
||||
|
||||
uri = f"deploy_complete/{release}"
|
||||
url = _usm_api_cmd(token, uri)
|
||||
response = _api_post(token, url,{})
|
||||
return response
|
|
@ -183,8 +183,10 @@ class SwUpgradeStrategyCreateData(wsme_types.Base):
|
|||
# Disable support for start-upgrade as it was not completed
|
||||
# start_upgrade = wsme_types.wsattr(
|
||||
# bool, mandatory=False, default=False, name='start-upgrade')
|
||||
complete_upgrade = wsme_types.wsattr(
|
||||
bool, mandatory=False, default=False, name='complete-upgrade')
|
||||
# complete_upgrade = wsme_types.wsattr(
|
||||
# bool, mandatory=False, default=False, name='complete-upgrade')
|
||||
release = wsme_types.wsattr(
|
||||
str, mandatory=True, default=None, name='release')
|
||||
alarm_restrictions = wsme_types.wsattr(
|
||||
SwUpdateAlarmRestrictionTypes, mandatory=False,
|
||||
default=SW_UPDATE_ALARM_RESTRICTION_TYPES.STRICT,
|
||||
|
@ -689,8 +691,9 @@ class SwUpgradeStrategyAPI(SwUpdateStrategyAPI):
|
|||
rpc_request.default_instance_action = SW_UPDATE_INSTANCE_ACTION.MIGRATE
|
||||
rpc_request.alarm_restrictions = request_data.alarm_restrictions
|
||||
# rpc_request.start_upgrade = request_data.start_upgrade
|
||||
rpc_request.start_upgrade = False
|
||||
rpc_request.complete_upgrade = request_data.complete_upgrade
|
||||
# rpc_request.start_upgrade = False
|
||||
# rpc_request.complete_upgrade = request_data.complete_upgrade
|
||||
rpc_request.release = request_data.release
|
||||
vim_connection = pecan.request.vim.open_connection()
|
||||
vim_connection.send(rpc_request.serialize())
|
||||
msg = vim_connection.receive(timeout_in_secs=30)
|
||||
|
|
|
@ -40,6 +40,7 @@ class PlatformServices(Constants):
|
|||
SYSINV = Constant('sysinv')
|
||||
PATCHING = Constant('patching')
|
||||
FM = Constant('fm')
|
||||
USM = Constant('usm')
|
||||
|
||||
|
||||
# Platform Services Constant
|
||||
|
|
|
@ -76,8 +76,7 @@ class SwMgmtDirector(object):
|
|||
|
||||
def create_sw_upgrade_strategy(self, storage_apply_type, worker_apply_type,
|
||||
max_parallel_worker_hosts,
|
||||
alarm_restrictions, start_upgrade,
|
||||
complete_upgrade, callback):
|
||||
alarm_restrictions, release, callback):
|
||||
"""
|
||||
Create Software Upgrade Strategy
|
||||
"""
|
||||
|
@ -94,9 +93,8 @@ class SwMgmtDirector(object):
|
|||
success, reason = self._sw_update.strategy_build(
|
||||
strategy_uuid, storage_apply_type,
|
||||
worker_apply_type, max_parallel_worker_hosts,
|
||||
alarm_restrictions, start_upgrade,
|
||||
complete_upgrade, self._ignore_alarms,
|
||||
self._single_controller)
|
||||
alarm_restrictions, release,
|
||||
self._ignore_alarms, self._single_controller)
|
||||
|
||||
schedule.schedule_function_call(callback, success, reason,
|
||||
self._sw_update.strategy)
|
||||
|
|
|
@ -99,13 +99,12 @@ def vim_sw_update_api_create_strategy(connection, msg):
|
|||
default_instance_action,
|
||||
alarm_restrictions, _vim_sw_update_api_create_strategy_callback)
|
||||
elif 'sw-upgrade' == msg.sw_update_type:
|
||||
start_upgrade = msg.start_upgrade
|
||||
complete_upgrade = msg.complete_upgrade
|
||||
release = msg.release
|
||||
# start_upgrade = msg.start_upgrade
|
||||
# complete_upgrade = msg.complete_upgrade
|
||||
uuid, reason = sw_mgmt_director.create_sw_upgrade_strategy(
|
||||
storage_apply_type, worker_apply_type, max_parallel_worker_hosts,
|
||||
alarm_restrictions,
|
||||
start_upgrade, complete_upgrade,
|
||||
_vim_sw_update_api_create_strategy_callback)
|
||||
alarm_restrictions, release, _vim_sw_update_api_create_strategy_callback)
|
||||
elif 'fw-update' == msg.sw_update_type:
|
||||
uuid, reason = sw_mgmt_director.create_fw_update_strategy(
|
||||
controller_apply_type, storage_apply_type,
|
||||
|
|
|
@ -150,6 +150,7 @@ from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_register_host_update_c
|
|||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_register_host_upgrade_callback # noqa: F401
|
||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_register_sw_update_get_callback # noqa: F401
|
||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_swact_from_host # noqa: F401
|
||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_sw_deploy_precheck # noqa: F401
|
||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_unlock_host # noqa: F401
|
||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_upgrade_activate # noqa: F401
|
||||
from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_upgrade_complete # noqa: F401
|
||||
|
|
|
@ -367,38 +367,51 @@ def nfvi_get_kube_version_list(callback):
|
|||
return cmd_id
|
||||
|
||||
|
||||
def nfvi_get_upgrade(callback):
|
||||
def nfvi_get_upgrade(release, callback):
|
||||
"""
|
||||
Get upgrade
|
||||
Get Software deploy
|
||||
"""
|
||||
cmd_id = _infrastructure_plugin.invoke_plugin('get_upgrade',
|
||||
release,
|
||||
callback=callback)
|
||||
return cmd_id
|
||||
|
||||
|
||||
def nfvi_upgrade_start(callback):
|
||||
def nfvi_sw_deploy_precheck(release, callback):
|
||||
"""
|
||||
Upgrade start
|
||||
"""
|
||||
cmd_id = _infrastructure_plugin.invoke_plugin('upgrade_start',
|
||||
cmd_id = _infrastructure_plugin.invoke_plugin('sw_deploy_precheck',
|
||||
release,
|
||||
callback=callback)
|
||||
return cmd_id
|
||||
|
||||
|
||||
def nfvi_upgrade_activate(callback):
|
||||
def nfvi_upgrade_start(release, callback):
|
||||
"""
|
||||
Upgrade activate
|
||||
Software deploy start
|
||||
"""
|
||||
cmd_id = _infrastructure_plugin.invoke_plugin('upgrade_activate',
|
||||
cmd_id = _infrastructure_plugin.invoke_plugin('sw_deploy_start',
|
||||
release,
|
||||
callback=callback)
|
||||
return cmd_id
|
||||
|
||||
|
||||
def nfvi_upgrade_complete(callback):
|
||||
def nfvi_upgrade_activate(release, callback):
|
||||
"""
|
||||
Upgrade complete
|
||||
Software deploy activate
|
||||
"""
|
||||
cmd_id = _infrastructure_plugin.invoke_plugin('upgrade_complete',
|
||||
cmd_id = _infrastructure_plugin.invoke_plugin('sw_deploy_activate',
|
||||
release,
|
||||
callback=callback)
|
||||
return cmd_id
|
||||
|
||||
|
||||
def nfvi_upgrade_complete(release, callback):
|
||||
"""
|
||||
Software deploy complete
|
||||
"""
|
||||
cmd_id = _infrastructure_plugin.invoke_plugin('sw_deploy_complete',
|
||||
release,
|
||||
callback=callback)
|
||||
return cmd_id
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2016 Wind River Systems, Inc.
|
||||
# Copyright (c) 2016-2024 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -18,11 +18,10 @@ class UpgradeState(Constants):
|
|||
Upgrade State Constants
|
||||
"""
|
||||
UNKNOWN = Constant('unknown')
|
||||
PRECHECKING = Constant('prechecking')
|
||||
PRECHECK_PASSED = Constant('precheck-passed')
|
||||
STARTING = Constant('starting')
|
||||
STARTED = Constant('started')
|
||||
DATA_MIGRATION = Constant('data-migration')
|
||||
DATA_MIGRATION_COMPLETE = Constant('data-migration-complete')
|
||||
DATA_MIGRATION_FAILED = Constant('data-migration-failed')
|
||||
UPGRADING_CONTROLLERS = Constant('upgrading-controllers')
|
||||
UPGRADING_HOSTS = Constant('upgrading-hosts')
|
||||
ACTIVATION_REQUESTED = Constant('activation-requested')
|
||||
|
@ -32,7 +31,7 @@ class UpgradeState(Constants):
|
|||
COMPLETED = Constant('completed')
|
||||
ABORTING = Constant('aborting')
|
||||
ABORT_COMPLETING = Constant('abort-completing')
|
||||
ABORTING_ROLLBACK = Constant('aborting-reinstall')
|
||||
ABORTING_ROLLBACK = Constant('aborting-redeploy')
|
||||
|
||||
|
||||
# Upgrade Constant Instantiation
|
||||
|
@ -43,8 +42,9 @@ class Upgrade(ObjectData):
|
|||
"""
|
||||
NFVI Upgrade Object
|
||||
"""
|
||||
def __init__(self, state, from_release, to_release):
|
||||
def __init__(self, release, state, reboot_required, hosts_states):
|
||||
super(Upgrade, self).__init__('1.0.0')
|
||||
self.update(dict(state=state,
|
||||
from_release=from_release,
|
||||
to_release=to_release))
|
||||
self.update(dict(release=release,
|
||||
state=state,
|
||||
reboot_required=reboot_required,
|
||||
hosts_states=hosts_states))
|
||||
|
|
|
@ -31,8 +31,8 @@ class SwUpgrade(SwUpdate):
|
|||
|
||||
def strategy_build(self, strategy_uuid, storage_apply_type,
|
||||
worker_apply_type, max_parallel_worker_hosts,
|
||||
alarm_restrictions, start_upgrade,
|
||||
complete_upgrade, ignore_alarms, single_controller):
|
||||
alarm_restrictions, release,
|
||||
ignore_alarms, single_controller):
|
||||
"""
|
||||
Create a software upgrade strategy
|
||||
"""
|
||||
|
@ -45,7 +45,7 @@ class SwUpgrade(SwUpdate):
|
|||
self._strategy = strategy.SwUpgradeStrategy(
|
||||
strategy_uuid, storage_apply_type, worker_apply_type,
|
||||
max_parallel_worker_hosts,
|
||||
alarm_restrictions, start_upgrade, complete_upgrade,
|
||||
alarm_restrictions, release,
|
||||
ignore_alarms, single_controller)
|
||||
|
||||
self._strategy.sw_update_obj = self
|
||||
|
|
|
@ -59,10 +59,11 @@ class APIRequestCreateSwUpdateStrategy(RPCMessage):
|
|||
|
||||
class APIRequestCreateSwUpgradeStrategy(APIRequestCreateSwUpdateStrategy):
|
||||
"""
|
||||
RPC API Request Message - Create Software Upgrade Strategy
|
||||
RPC API Request Message - Create Software Deploy Strategy
|
||||
"""
|
||||
start_upgrade = None
|
||||
complete_upgrade = None
|
||||
# start_upgrade = None
|
||||
# complete_upgrade = None
|
||||
release = None
|
||||
|
||||
def __init__(self, msg_version=RPC_MSG_VERSION.VERSION_1_0,
|
||||
msg_type=RPC_MSG_TYPE.CREATE_SW_UPGRADE_STRATEGY_REQUEST,
|
||||
|
@ -72,16 +73,18 @@ class APIRequestCreateSwUpgradeStrategy(APIRequestCreateSwUpdateStrategy):
|
|||
|
||||
def serialize_payload(self, msg):
|
||||
super(APIRequestCreateSwUpgradeStrategy, self).serialize_payload(msg)
|
||||
msg['start_upgrade'] = self.start_upgrade
|
||||
msg['complete_upgrade'] = self.complete_upgrade
|
||||
# msg['start_upgrade'] = self.start_upgrade
|
||||
# msg['complete_upgrade'] = self.complete_upgrade
|
||||
msg['release'] = self.release
|
||||
|
||||
def deserialize_payload(self, msg):
|
||||
super(APIRequestCreateSwUpgradeStrategy, self).deserialize_payload(msg)
|
||||
self.start_upgrade = msg.get('start_upgrade', None)
|
||||
self.complete_upgrade = msg.get('complete_upgrade', None)
|
||||
self.release = msg.get('release', None)
|
||||
# self.start_upgrade = msg.get('start_upgrade', None)
|
||||
# self.complete_upgrade = msg.get('complete_upgrade', None)
|
||||
|
||||
def __str__(self):
|
||||
return "create-sw-upgrade-strategy request: %s" % self.deserialize_payload
|
||||
return "create-sw-deploy-strategy request: %s" % self.deserialize_payload
|
||||
|
||||
|
||||
class APIRequestCreateKubeRootcaUpdateStrategy(APIRequestCreateSwUpdateStrategy):
|
||||
|
|
|
@ -56,6 +56,7 @@ from nfv_vim.strategy._strategy_steps import StartInstancesStep # noqa: F401
|
|||
from nfv_vim.strategy._strategy_steps import StopInstancesStep # noqa: F401
|
||||
from nfv_vim.strategy._strategy_steps import STRATEGY_STEP_NAME # noqa: F401
|
||||
from nfv_vim.strategy._strategy_steps import SwactHostsStep # noqa: F401
|
||||
from nfv_vim.strategy._strategy_steps import SwDeployPrecheckStep # noqa: F401
|
||||
from nfv_vim.strategy._strategy_steps import SwPatchHostsStep # noqa: F401
|
||||
from nfv_vim.strategy._strategy_steps import SystemConfigUpdateHostsStep # noqa: F401
|
||||
from nfv_vim.strategy._strategy_steps import SystemStabilizeStep # noqa: F401
|
||||
|
|
|
@ -1054,6 +1054,17 @@ class PatchControllerHostsMixin(UpdateControllerHostsMixin):
|
|||
strategy.SwPatchHostsStep)
|
||||
|
||||
|
||||
class SwDeployControllerHostsMixin(UpdateControllerHostsMixin):
|
||||
def _add_controller_strategy_stages(self, controllers, reboot, release):
|
||||
from nfv_vim import strategy
|
||||
return self._add_update_controller_strategy_stages(
|
||||
controllers,
|
||||
reboot,
|
||||
strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_CONTROLLERS,
|
||||
strategy.UpgradeHostsStep,
|
||||
extra_args=dict(release=release))
|
||||
|
||||
|
||||
class UpdateSystemConfigControllerHostsMixin(UpdateControllerHostsMixin):
|
||||
def _add_system_config_controller_strategy_stages(self, controllers):
|
||||
"""
|
||||
|
@ -1090,7 +1101,8 @@ class UpdateStorageHostsMixin(object):
|
|||
storage_hosts,
|
||||
reboot,
|
||||
strategy_stage_name,
|
||||
host_action_step):
|
||||
host_action_step,
|
||||
extra_args=None):
|
||||
"""
|
||||
Add storage update stages to a strategy
|
||||
The strategy_stage_name is the type of stage (patch, kube, etc..)
|
||||
|
@ -1108,8 +1120,15 @@ class UpdateStorageHostsMixin(object):
|
|||
True, ignore_alarms=self._ignore_alarms))
|
||||
if reboot:
|
||||
stage.add_step(strategy.LockHostsStep(host_list))
|
||||
|
||||
# Add the action step for these hosts (patch, etc..)
|
||||
stage.add_step(host_action_step(host_list))
|
||||
if extra_args is None:
|
||||
stage.add_step(host_action_step(host_list))
|
||||
elif isinstance(extra_args, dict):
|
||||
stage.add_step(host_action_step(host_list, **extra_args))
|
||||
else:
|
||||
stage.add_step(host_action_step(host_list, extra_args))
|
||||
|
||||
if reboot:
|
||||
# Cannot unlock right away after the host action
|
||||
stage.add_step(strategy.SystemStabilizeStep(
|
||||
|
@ -1141,6 +1160,20 @@ class PatchStorageHostsMixin(UpdateStorageHostsMixin):
|
|||
strategy.SwPatchHostsStep)
|
||||
|
||||
|
||||
class SwDeployStorageHostsMixin(UpdateStorageHostsMixin):
|
||||
def _add_storage_strategy_stages(self, storage_hosts, reboot, release):
|
||||
"""
|
||||
Add storage software patch stages to a strategy
|
||||
"""
|
||||
from nfv_vim import strategy
|
||||
return self._add_update_storage_strategy_stages(
|
||||
storage_hosts,
|
||||
reboot,
|
||||
strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_STORAGE_HOSTS,
|
||||
strategy.UpgradeHostsStep,
|
||||
extra_args=dict(release=release))
|
||||
|
||||
|
||||
class UpdateSystemConfigStorageHostsMixin(UpdateStorageHostsMixin):
|
||||
def _add_system_config_storage_strategy_stages(self, storage_hosts):
|
||||
"""
|
||||
|
@ -1270,6 +1303,8 @@ class UpdateWorkerHostsMixin(object):
|
|||
# Add the action step for these hosts (patch, etc..)
|
||||
if extra_args is None:
|
||||
stage.add_step(host_action_step(host_list))
|
||||
elif isinstance(extra_args, dict):
|
||||
stage.add_step(host_action_step(host_list, **extra_args))
|
||||
else:
|
||||
stage.add_step(host_action_step(host_list, extra_args))
|
||||
|
||||
|
@ -1327,6 +1362,16 @@ class PatchWorkerHostsMixin(UpdateWorkerHostsMixin):
|
|||
strategy.SwPatchHostsStep)
|
||||
|
||||
|
||||
class SwDeployWorkerHostsMixin(UpdateWorkerHostsMixin):
|
||||
def _add_worker_strategy_stages(self, worker_hosts, release, reboot):
|
||||
from nfv_vim import strategy
|
||||
return self._add_update_worker_strategy_stages(
|
||||
worker_hosts,
|
||||
reboot,
|
||||
strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_WORKER_HOSTS,
|
||||
strategy.UpgradeHostsStep,
|
||||
extra_args=dict(release=release))
|
||||
|
||||
class UpgradeKubeletWorkerHostsMixin(UpdateWorkerHostsMixin):
|
||||
def _add_kubelet_worker_strategy_stages(self, worker_hosts, to_version, reboot, stage_name):
|
||||
from nfv_vim import strategy
|
||||
|
@ -1703,13 +1748,18 @@ class SwPatchStrategy(SwUpdateStrategy,
|
|||
# The Software Upgrade Strategy
|
||||
#
|
||||
###################################################################
|
||||
class SwUpgradeStrategy(SwUpdateStrategy):
|
||||
class SwUpgradeStrategy(
|
||||
SwUpdateStrategy,
|
||||
SwDeployControllerHostsMixin,
|
||||
SwDeployStorageHostsMixin,
|
||||
SwDeployWorkerHostsMixin,
|
||||
):
|
||||
"""
|
||||
Software Upgrade - Strategy
|
||||
"""
|
||||
def __init__(self, uuid, storage_apply_type, worker_apply_type,
|
||||
max_parallel_worker_hosts,
|
||||
alarm_restrictions, start_upgrade, complete_upgrade,
|
||||
alarm_restrictions, release,
|
||||
ignore_alarms, single_controller):
|
||||
super(SwUpgradeStrategy, self).__init__(
|
||||
uuid,
|
||||
|
@ -1723,6 +1773,7 @@ class SwUpgradeStrategy(SwUpdateStrategy):
|
|||
alarm_restrictions,
|
||||
ignore_alarms)
|
||||
|
||||
self._release = release
|
||||
# Note: The support for start_upgrade was implemented and (mostly)
|
||||
# tested, but there is a problem. When the sw-upgrade-start stage
|
||||
# runs, it will start the upgrade, upgrade controller-1 and swact to
|
||||
|
@ -1733,10 +1784,10 @@ class SwUpgradeStrategy(SwUpdateStrategy):
|
|||
# progress) and the strategy apply will fail. Fixing this would be
|
||||
# complex, so we will not support the start_upgrade option for now,
|
||||
# which would only have been for lab use.
|
||||
if start_upgrade:
|
||||
raise Exception("No support for start_upgrade")
|
||||
self._start_upgrade = start_upgrade
|
||||
self._complete_upgrade = complete_upgrade
|
||||
# if start_upgrade:
|
||||
# raise Exception("No support for start_upgrade")
|
||||
# self._start_upgrade = start_upgrade
|
||||
# self._complete_upgrade = complete_upgrade
|
||||
# The following alarms will not prevent a software upgrade operation
|
||||
IGNORE_ALARMS = ['900.005', # Upgrade in progress
|
||||
'900.201', # Software upgrade auto apply in progress
|
||||
|
@ -1768,12 +1819,11 @@ class SwUpgradeStrategy(SwUpdateStrategy):
|
|||
"""
|
||||
from nfv_vim import strategy
|
||||
|
||||
stage = strategy.StrategyStage(
|
||||
strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_QUERY)
|
||||
stage.add_step(strategy.QueryAlarmsStep(
|
||||
ignore_alarms=self._ignore_alarms))
|
||||
stage.add_step(strategy.QueryUpgradeStep())
|
||||
stage = strategy.StrategyStage(strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_QUERY)
|
||||
# stage.add_step(strategy.QueryAlarmsStep(ignore_alarms=self._ignore_alarms))
|
||||
stage.add_step(strategy.QueryUpgradeStep(release=self._release))
|
||||
self.build_phase.add_stage(stage)
|
||||
|
||||
super(SwUpgradeStrategy, self).build()
|
||||
|
||||
def _add_upgrade_start_stage(self):
|
||||
|
@ -1781,23 +1831,11 @@ class SwUpgradeStrategy(SwUpdateStrategy):
|
|||
Add upgrade start strategy stage
|
||||
"""
|
||||
from nfv_vim import strategy
|
||||
from nfv_vim import tables
|
||||
|
||||
host_table = tables.tables_get_host_table()
|
||||
controller_1_host = None
|
||||
for host in host_table.get_by_personality(HOST_PERSONALITY.CONTROLLER):
|
||||
if HOST_NAME.CONTROLLER_1 == host.name:
|
||||
controller_1_host = host
|
||||
break
|
||||
host_list = [controller_1_host]
|
||||
|
||||
stage = strategy.StrategyStage(
|
||||
strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_START)
|
||||
# Do not ignore any alarms when starting an upgrade
|
||||
stage.add_step(strategy.QueryAlarmsStep(True))
|
||||
# Upgrade start can only be done from controller-0
|
||||
stage.add_step(strategy.SwactHostsStep(host_list))
|
||||
stage.add_step(strategy.UpgradeStartStep())
|
||||
stage = strategy.StrategyStage(strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_START)
|
||||
# stage.add_step(strategy.QueryAlarmsStep(ignore_alarms=self._ignore_alarms))
|
||||
# stage.add_step(strategy.SwDeployPrecheckStep(release=self._release))
|
||||
stage.add_step(strategy.UpgradeStartStep(release=self._release))
|
||||
stage.add_step(strategy.SystemStabilizeStep())
|
||||
self.apply_phase.add_stage(stage)
|
||||
|
||||
|
@ -1806,280 +1844,14 @@ class SwUpgradeStrategy(SwUpdateStrategy):
|
|||
Add upgrade complete strategy stage
|
||||
"""
|
||||
from nfv_vim import strategy
|
||||
from nfv_vim import tables
|
||||
|
||||
host_table = tables.tables_get_host_table()
|
||||
controller_1_host = None
|
||||
for host in host_table.get_by_personality(HOST_PERSONALITY.CONTROLLER):
|
||||
if HOST_NAME.CONTROLLER_1 == host.name:
|
||||
controller_1_host = host
|
||||
break
|
||||
host_list = [controller_1_host]
|
||||
|
||||
stage = strategy.StrategyStage(
|
||||
strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_COMPLETE)
|
||||
stage.add_step(strategy.QueryAlarmsStep(
|
||||
True, ignore_alarms=self._ignore_alarms))
|
||||
# Upgrade complete can only be done from controller-0
|
||||
stage.add_step(strategy.SwactHostsStep(host_list))
|
||||
stage.add_step(strategy.UpgradeActivateStep())
|
||||
stage.add_step(strategy.UpgradeCompleteStep())
|
||||
stage = strategy.StrategyStage(strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_COMPLETE)
|
||||
# stage.add_step(strategy.QueryAlarmsStep(ignore_alarms=self._ignore_alarms))
|
||||
stage.add_step(strategy.UpgradeActivateStep(release=self._release))
|
||||
stage.add_step(strategy.UpgradeCompleteStep(release=self._release))
|
||||
stage.add_step(strategy.SystemStabilizeStep())
|
||||
self.apply_phase.add_stage(stage)
|
||||
|
||||
def _add_controller_strategy_stages(self, controllers, reboot):
|
||||
"""
|
||||
Add controller software upgrade strategy stages
|
||||
"""
|
||||
from nfv_vim import strategy
|
||||
from nfv_vim import tables
|
||||
|
||||
host_table = tables.tables_get_host_table()
|
||||
|
||||
if 2 > host_table.total_by_personality(HOST_PERSONALITY.CONTROLLER):
|
||||
DLOG.warn("Not enough controllers to apply software upgrades.")
|
||||
reason = 'not enough controllers to apply software upgrades'
|
||||
return False, reason
|
||||
|
||||
controller_0_host = None
|
||||
controller_1_host = None
|
||||
|
||||
for host in controllers:
|
||||
if HOST_PERSONALITY.WORKER in host.personality:
|
||||
# Do nothing for AIO hosts. We let the worker code handle everything.
|
||||
# This is done to handle the case where stx-openstack is
|
||||
# installed and there could be instances running on the
|
||||
# AIO-DX controllers which need to be migrated.
|
||||
if self._single_controller:
|
||||
DLOG.warn("Cannot apply software upgrades to AIO-SX deployment.")
|
||||
reason = 'cannot apply software upgrades to AIO-SX deployment'
|
||||
return False, reason
|
||||
else:
|
||||
return True, ''
|
||||
elif HOST_NAME.CONTROLLER_1 == host.name:
|
||||
controller_1_host = host
|
||||
elif HOST_NAME.CONTROLLER_0 == host.name:
|
||||
controller_0_host = host
|
||||
|
||||
if controller_1_host is not None:
|
||||
host_list = [controller_1_host]
|
||||
stage = strategy.StrategyStage(
|
||||
strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_CONTROLLERS)
|
||||
stage.add_step(strategy.QueryAlarmsStep(
|
||||
True, ignore_alarms=self._ignore_alarms))
|
||||
stage.add_step(strategy.LockHostsStep(host_list))
|
||||
stage.add_step(strategy.UpgradeHostsStep(host_list))
|
||||
# During an upgrade, unlock may need to retry. Bug details:
|
||||
# https://bugs.launchpad.net/starlingx/+bug/1946255
|
||||
stage.add_step(strategy.UnlockHostsStep(
|
||||
host_list,
|
||||
retry_count=strategy.UnlockHostsStep.MAX_RETRIES))
|
||||
# Allow up to four hours for controller disks to synchronize
|
||||
stage.add_step(strategy.WaitDataSyncStep(
|
||||
timeout_in_secs=4 * 60 * 60,
|
||||
ignore_alarms=self._ignore_alarms))
|
||||
self.apply_phase.add_stage(stage)
|
||||
|
||||
if controller_0_host is not None:
|
||||
host_list = [controller_0_host]
|
||||
stage = strategy.StrategyStage(
|
||||
strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_CONTROLLERS)
|
||||
stage.add_step(strategy.QueryAlarmsStep(
|
||||
True, ignore_alarms=self._ignore_alarms))
|
||||
if controller_1_host is not None:
|
||||
# Only swact to controller-1 if it was upgraded. If we are only
|
||||
# upgrading controller-0, then controller-1 needs to be
|
||||
# active already.
|
||||
stage.add_step(strategy.SwactHostsStep(host_list))
|
||||
stage.add_step(strategy.LockHostsStep(host_list))
|
||||
stage.add_step(strategy.UpgradeHostsStep(host_list))
|
||||
# During an upgrade, unlock may need to retry. Bug details:
|
||||
# https://bugs.launchpad.net/starlingx/+bug/1946255
|
||||
stage.add_step(strategy.UnlockHostsStep(
|
||||
host_list,
|
||||
retry_count=strategy.UnlockHostsStep.MAX_RETRIES))
|
||||
# Allow up to four hours for controller disks to synchronize
|
||||
stage.add_step(strategy.WaitDataSyncStep(
|
||||
timeout_in_secs=4 * 60 * 60,
|
||||
ignore_alarms=self._ignore_alarms))
|
||||
self.apply_phase.add_stage(stage)
|
||||
|
||||
return True, ''
|
||||
|
||||
def _add_storage_strategy_stages(self, storage_hosts, reboot):
|
||||
"""
|
||||
Add storage software upgrade strategy stages
|
||||
"""
|
||||
from nfv_vim import strategy
|
||||
|
||||
storage_0_host_list = list()
|
||||
storage_0_host_lists = list()
|
||||
other_storage_host_list = list()
|
||||
|
||||
for host in storage_hosts:
|
||||
if HOST_NAME.STORAGE_0 == host.name:
|
||||
storage_0_host_list.append(host)
|
||||
else:
|
||||
other_storage_host_list.append(host)
|
||||
|
||||
if len(storage_0_host_list) == 1:
|
||||
storage_0_host_lists, reason = self._create_storage_host_lists(
|
||||
storage_0_host_list)
|
||||
if storage_0_host_lists is None:
|
||||
return False, reason
|
||||
|
||||
other_storage_host_lists, reason = self._create_storage_host_lists(
|
||||
other_storage_host_list)
|
||||
if other_storage_host_lists is None:
|
||||
return False, reason
|
||||
|
||||
# Upgrade storage-0 first and on its own since it has a ceph monitor
|
||||
if len(storage_0_host_lists) == 1:
|
||||
combined_host_lists = storage_0_host_lists + other_storage_host_lists
|
||||
else:
|
||||
combined_host_lists = other_storage_host_lists
|
||||
|
||||
for host_list in combined_host_lists:
|
||||
stage = strategy.StrategyStage(
|
||||
strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_STORAGE_HOSTS)
|
||||
stage.add_step(strategy.QueryAlarmsStep(
|
||||
True, ignore_alarms=self._ignore_alarms))
|
||||
stage.add_step(strategy.LockHostsStep(host_list))
|
||||
stage.add_step(strategy.UpgradeHostsStep(host_list))
|
||||
# During an upgrade, unlock may need to retry. Bug details:
|
||||
# https://bugs.launchpad.net/starlingx/+bug/1946255
|
||||
stage.add_step(strategy.UnlockHostsStep(
|
||||
host_list,
|
||||
retry_count=strategy.UnlockHostsStep.MAX_RETRIES))
|
||||
|
||||
# After storage node(s) are unlocked, we need extra time to
|
||||
# allow the OSDs to go back in sync and the storage related
|
||||
# alarms to clear. We no longer wipe the OSD disks when upgrading
|
||||
# a storage node, so they should only be syncing data that changed
|
||||
# while they were being upgraded.
|
||||
stage.add_step(strategy.WaitDataSyncStep(
|
||||
timeout_in_secs=2 * 60 * 60,
|
||||
ignore_alarms=self._ignore_alarms))
|
||||
self.apply_phase.add_stage(stage)
|
||||
|
||||
return True, ''
|
||||
|
||||
def _add_worker_strategy_stages(self, worker_hosts, reboot):
|
||||
"""
|
||||
Add worker software upgrade strategy stages
|
||||
"""
|
||||
from nfv_vim import strategy
|
||||
from nfv_vim import tables
|
||||
|
||||
host_lists, reason = self._create_worker_host_lists(worker_hosts, reboot)
|
||||
if host_lists is None:
|
||||
return False, reason
|
||||
|
||||
instance_table = tables.tables_get_instance_table()
|
||||
|
||||
for host_list in host_lists:
|
||||
instance_list = list()
|
||||
|
||||
for host in host_list:
|
||||
for instance in instance_table.on_host(host.name):
|
||||
if not instance.is_locked():
|
||||
instance_list.append(instance)
|
||||
else:
|
||||
DLOG.warn("Instance %s must not be shut down" %
|
||||
instance.name)
|
||||
reason = ('instance %s must not be shut down' %
|
||||
instance.name)
|
||||
return False, reason
|
||||
|
||||
# Computes with no instances
|
||||
if 0 == len(instance_list):
|
||||
stage = strategy.StrategyStage(
|
||||
strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_WORKER_HOSTS)
|
||||
stage.add_step(strategy.QueryAlarmsStep(
|
||||
True, ignore_alarms=self._ignore_alarms))
|
||||
if HOST_PERSONALITY.CONTROLLER in host_list[0].personality:
|
||||
stage.add_step(strategy.SwactHostsStep(host_list))
|
||||
stage.add_step(strategy.LockHostsStep(host_list))
|
||||
stage.add_step(strategy.UpgradeHostsStep(host_list))
|
||||
# During an upgrade, unlock may need to retry. Bug details:
|
||||
# https://bugs.launchpad.net/starlingx/+bug/1914836
|
||||
stage.add_step(strategy.UnlockHostsStep(
|
||||
host_list,
|
||||
retry_count=strategy.UnlockHostsStep.MAX_RETRIES))
|
||||
if HOST_PERSONALITY.CONTROLLER in host_list[0].personality:
|
||||
# AIO Controller hosts will undergo WaitDataSyncStep step
|
||||
# Allow up to four hours for controller disks to synchronize
|
||||
stage.add_step(strategy.WaitDataSyncStep(
|
||||
timeout_in_secs=4 * 60 * 60,
|
||||
ignore_alarms=self._ignore_alarms))
|
||||
else:
|
||||
# Worker hosts will undergo:
|
||||
# 1) WaitAlarmsClear step if openstack is installed.
|
||||
# 2) SystemStabilizeStep step if openstack is not installed.
|
||||
if any([host.openstack_control or host.openstack_compute
|
||||
for host in host_list]):
|
||||
# Hosts with openstack that just need to wait for services to start up:
|
||||
stage.add_step(strategy.WaitAlarmsClearStep(
|
||||
timeout_in_secs=10 * 60,
|
||||
ignore_alarms=self._ignore_alarms))
|
||||
else:
|
||||
stage.add_step(strategy.SystemStabilizeStep())
|
||||
self.apply_phase.add_stage(stage)
|
||||
continue
|
||||
|
||||
# Computes with instances
|
||||
stage = strategy.StrategyStage(
|
||||
strategy.STRATEGY_STAGE_NAME.SW_UPGRADE_WORKER_HOSTS)
|
||||
|
||||
stage.add_step(strategy.QueryAlarmsStep(
|
||||
True, ignore_alarms=self._ignore_alarms))
|
||||
|
||||
if SW_UPDATE_APPLY_TYPE.PARALLEL == self._worker_apply_type:
|
||||
# Disable host services before migrating to ensure
|
||||
# instances do not migrate to worker hosts in the
|
||||
# same set of hosts.
|
||||
if host_list[0].host_service_configured(
|
||||
HOST_SERVICES.COMPUTE):
|
||||
stage.add_step(strategy.DisableHostServicesStep(
|
||||
host_list, HOST_SERVICES.COMPUTE))
|
||||
# TODO(ksmith)
|
||||
# When support is added for orchestration on
|
||||
# non-OpenStack worker nodes, support for disabling
|
||||
# kubernetes services will have to be added.
|
||||
|
||||
stage.add_step(strategy.MigrateInstancesStep(instance_list))
|
||||
if HOST_PERSONALITY.CONTROLLER in host_list[0].personality:
|
||||
stage.add_step(strategy.SwactHostsStep(host_list))
|
||||
stage.add_step(strategy.LockHostsStep(host_list))
|
||||
stage.add_step(strategy.UpgradeHostsStep(host_list))
|
||||
# During an upgrade, unlock may need to retry. Bug details:
|
||||
# https://bugs.launchpad.net/starlingx/+bug/1914836
|
||||
stage.add_step(strategy.UnlockHostsStep(
|
||||
host_list,
|
||||
retry_count=strategy.UnlockHostsStep.MAX_RETRIES))
|
||||
if HOST_PERSONALITY.CONTROLLER in host_list[0].personality:
|
||||
# AIO Controller hosts will undergo WaitDataSyncStep step
|
||||
# Allow up to four hours for controller disks to synchronize
|
||||
stage.add_step(strategy.WaitDataSyncStep(
|
||||
timeout_in_secs=4 * 60 * 60,
|
||||
ignore_alarms=self._ignore_alarms))
|
||||
else:
|
||||
# Worker hosts will undergo:
|
||||
# 1) WaitAlarmsClear step if openstack is installed.
|
||||
# 2) SystemStabilizeStep step if openstack is not installed.
|
||||
if any([host.openstack_control or host.openstack_compute
|
||||
for host in host_list]):
|
||||
# Hosts with openstack that just need to wait for
|
||||
# services to start up:
|
||||
stage.add_step(strategy.WaitAlarmsClearStep(
|
||||
timeout_in_secs=10 * 60,
|
||||
ignore_alarms=self._ignore_alarms))
|
||||
else:
|
||||
stage.add_step(strategy.SystemStabilizeStep())
|
||||
self.apply_phase.add_stage(stage)
|
||||
|
||||
return True, ''
|
||||
|
||||
def build_complete(self, result, result_reason):
|
||||
"""
|
||||
Strategy Build Complete
|
||||
|
@ -2096,146 +1868,81 @@ class SwUpgradeStrategy(SwUpdateStrategy):
|
|||
if result in [strategy.STRATEGY_RESULT.SUCCESS,
|
||||
strategy.STRATEGY_RESULT.DEGRADED]:
|
||||
|
||||
# Check whether the upgrade is in a valid state for orchestration
|
||||
if self.nfvi_upgrade is None:
|
||||
if not self._start_upgrade:
|
||||
DLOG.warn("No upgrade in progress.")
|
||||
self._state = strategy.STRATEGY_STATE.BUILD_FAILED
|
||||
self.build_phase.result = strategy.STRATEGY_PHASE_RESULT.FAILED
|
||||
self.build_phase.result_reason = 'no upgrade in progress'
|
||||
self.sw_update_obj.strategy_build_complete(
|
||||
False, self.build_phase.result_reason)
|
||||
self.save()
|
||||
return
|
||||
else:
|
||||
if self._start_upgrade:
|
||||
valid_states = [UPGRADE_STATE.STARTED,
|
||||
UPGRADE_STATE.DATA_MIGRATION_COMPLETE,
|
||||
UPGRADE_STATE.UPGRADING_CONTROLLERS,
|
||||
UPGRADE_STATE.UPGRADING_HOSTS]
|
||||
else:
|
||||
valid_states = [UPGRADE_STATE.UPGRADING_CONTROLLERS,
|
||||
UPGRADE_STATE.UPGRADING_HOSTS]
|
||||
|
||||
if self.nfvi_upgrade.state not in valid_states:
|
||||
DLOG.warn("Invalid upgrade state for orchestration: %s." %
|
||||
self.nfvi_upgrade.state)
|
||||
self._state = strategy.STRATEGY_STATE.BUILD_FAILED
|
||||
self.build_phase.result = strategy.STRATEGY_PHASE_RESULT.FAILED
|
||||
self.build_phase.result_reason = (
|
||||
'invalid upgrade state for orchestration: %s' %
|
||||
self.nfvi_upgrade.state)
|
||||
self.sw_update_obj.strategy_build_complete(
|
||||
False, self.build_phase.result_reason)
|
||||
self.save()
|
||||
return
|
||||
|
||||
# If controller-1 has been upgraded and we have yet to upgrade
|
||||
# controller-0, then controller-1 must be active.
|
||||
if UPGRADE_STATE.UPGRADING_CONTROLLERS == self.nfvi_upgrade.state:
|
||||
if HOST_NAME.CONTROLLER_1 != get_local_host_name():
|
||||
DLOG.warn(
|
||||
"Controller-1 must be active for orchestration to "
|
||||
"upgrade controller-0.")
|
||||
self._state = strategy.STRATEGY_STATE.BUILD_FAILED
|
||||
self.build_phase.result = \
|
||||
strategy.STRATEGY_PHASE_RESULT.FAILED
|
||||
self.build_phase.result_reason = (
|
||||
'controller-1 must be active for orchestration to '
|
||||
'upgrade controller-0')
|
||||
self.sw_update_obj.strategy_build_complete(
|
||||
False, self.build_phase.result_reason)
|
||||
self.save()
|
||||
return
|
||||
|
||||
if self._nfvi_alarms:
|
||||
DLOG.warn(
|
||||
"Active alarms found, can't apply software upgrade.")
|
||||
alarm_id_list = ""
|
||||
for alarm_data in self._nfvi_alarms:
|
||||
if alarm_id_list:
|
||||
alarm_id_list += ', '
|
||||
alarm_id_list += alarm_data['alarm_id']
|
||||
DLOG.warn("... active alarms: %s" % alarm_id_list)
|
||||
self._state = strategy.STRATEGY_STATE.BUILD_FAILED
|
||||
self.build_phase.result = strategy.STRATEGY_PHASE_RESULT.FAILED
|
||||
self.build_phase.result_reason = 'active alarms present ; '
|
||||
self.build_phase.result_reason += alarm_id_list
|
||||
self.sw_update_obj.strategy_build_complete(
|
||||
False, self.build_phase.result_reason)
|
||||
self.save()
|
||||
return
|
||||
|
||||
host_table = tables.tables_get_host_table()
|
||||
for host in list(host_table.values()):
|
||||
# Only allow upgrade orchestration when all hosts are
|
||||
# available. It is not safe to automate upgrade application
|
||||
# when we do not have full redundancy.
|
||||
if not (host.is_unlocked() and host.is_enabled() and
|
||||
host.is_available()):
|
||||
DLOG.warn(
|
||||
"All %s hosts must be unlocked-enabled-available, "
|
||||
"can't apply software upgrades." % host.personality)
|
||||
self._state = strategy.STRATEGY_STATE.BUILD_FAILED
|
||||
self.build_phase.result = \
|
||||
strategy.STRATEGY_PHASE_RESULT.FAILED
|
||||
self.build_phase.result_reason = (
|
||||
'all %s hosts must be unlocked-enabled-available' %
|
||||
host.personality)
|
||||
self.sw_update_obj.strategy_build_complete(
|
||||
False, self.build_phase.result_reason)
|
||||
self.save()
|
||||
return
|
||||
|
||||
controller_hosts = list()
|
||||
# if self._nfvi_alarms:
|
||||
# DLOG.warn("Active alarms found, can't apply sw-deployment.")
|
||||
# self._state = strategy.STRATEGY_STATE.BUILD_FAILED
|
||||
# self.build_phase.result = strategy.STRATEGY_PHASE_RESULT.FAILED
|
||||
# self.build_phase.result_reason = 'active alarms present'
|
||||
# self.sw_update_obj.strategy_build_complete(
|
||||
# False, self.build_phase.result_reason)
|
||||
# self.save()
|
||||
# return
|
||||
|
||||
# for host in list(host_table.values()):
|
||||
# # All hosts must be unlock/enabled/online
|
||||
# if not (host.is_unlocked() and host.is_enabled() and host.is_available()):
|
||||
# DLOG.warn(
|
||||
# "All hosts must be unlocked-enabled-available, "
|
||||
# "can't apply sw-deployment: %s" % host.name)
|
||||
# self._state = strategy.STRATEGY_STATE.BUILD_FAILED
|
||||
# self.build_phase.result = \
|
||||
# strategy.STRATEGY_PHASE_RESULT.FAILED
|
||||
# self.build_phase.result_reason = (
|
||||
# 'all %s hosts must be unlocked-enabled-available' %
|
||||
# host.personality)
|
||||
# self.sw_update_obj.strategy_build_complete(
|
||||
# False, self.build_phase.result_reason)
|
||||
# self.save()
|
||||
# return
|
||||
|
||||
reboot_required = self.nfvi_upgrade.reboot_required
|
||||
controller_strategy = self._add_controller_strategy_stages
|
||||
controllers_hosts = list()
|
||||
storage_hosts = list()
|
||||
worker_hosts = list()
|
||||
|
||||
if self.nfvi_upgrade is None:
|
||||
# Start upgrade
|
||||
self._add_upgrade_start_stage()
|
||||
|
||||
# All hosts will be upgraded
|
||||
for host in list(host_table.values()):
|
||||
if HOST_PERSONALITY.CONTROLLER in host.personality:
|
||||
controller_hosts.append(host)
|
||||
|
||||
elif HOST_PERSONALITY.STORAGE in host.personality:
|
||||
storage_hosts.append(host)
|
||||
# TODO(jkraitbe): Exclude hosts that are already deployed.
|
||||
# The hosts states are found in self.nfvi_upgrade.hosts_states.
|
||||
# None means deployment hasn't started.
|
||||
self._add_upgrade_start_stage()
|
||||
|
||||
for host in host_table.values():
|
||||
if HOST_PERSONALITY.CONTROLLER in host.personality:
|
||||
controllers_hosts.append(host)
|
||||
if HOST_PERSONALITY.WORKER in host.personality:
|
||||
worker_hosts.append(host)
|
||||
else:
|
||||
# Only hosts not yet upgraded will be upgraded
|
||||
to_load = self.nfvi_upgrade.to_release
|
||||
for host in list(host_table.values()):
|
||||
if host.software_load == to_load:
|
||||
# No need to upgrade this host
|
||||
continue
|
||||
# We need to use this strategy on AIO type
|
||||
controller_strategy = self._add_worker_strategy_stages
|
||||
|
||||
if HOST_PERSONALITY.CONTROLLER in host.personality:
|
||||
controller_hosts.append(host)
|
||||
elif HOST_PERSONALITY.STORAGE in host.personality:
|
||||
storage_hosts.append(host)
|
||||
|
||||
elif HOST_PERSONALITY.STORAGE in host.personality:
|
||||
storage_hosts.append(host)
|
||||
elif HOST_PERSONALITY.WORKER in host.personality:
|
||||
worker_hosts.append(host)
|
||||
|
||||
if HOST_PERSONALITY.WORKER in host.personality:
|
||||
worker_hosts.append(host)
|
||||
else:
|
||||
DLOG.error(f"Unsupported personality for host {host.name}.")
|
||||
self._state = strategy.STRATEGY_STATE.BUILD_FAILED
|
||||
self.build_phase.result = \
|
||||
strategy.STRATEGY_PHASE_RESULT.FAILED
|
||||
self.build_phase.result_reason = \
|
||||
'Unsupported personality for host'
|
||||
self.sw_update_obj.strategy_build_complete(
|
||||
False, self.build_phase.result_reason)
|
||||
self.save()
|
||||
return
|
||||
|
||||
STRATEGY_CREATION_COMMANDS = [
|
||||
(self._add_controller_strategy_stages,
|
||||
controller_hosts, True),
|
||||
(self._add_storage_strategy_stages,
|
||||
storage_hosts, True),
|
||||
(self._add_worker_strategy_stages,
|
||||
worker_hosts, True)
|
||||
strategy_pairs = [
|
||||
(controller_strategy, controllers_hosts),
|
||||
(self._add_storage_strategy_stages, storage_hosts),
|
||||
(self._add_worker_strategy_stages, worker_hosts)
|
||||
]
|
||||
|
||||
for add_strategy_stages_function, host_list, reboot in \
|
||||
STRATEGY_CREATION_COMMANDS:
|
||||
for stage_func, host_list in strategy_pairs:
|
||||
if host_list:
|
||||
success, reason = add_strategy_stages_function(
|
||||
host_list, reboot)
|
||||
success, reason = stage_func(
|
||||
host_list, reboot_required, self._release)
|
||||
if not success:
|
||||
self._state = strategy.STRATEGY_STATE.BUILD_FAILED
|
||||
self.build_phase.result = \
|
||||
|
@ -2246,14 +1953,13 @@ class SwUpgradeStrategy(SwUpdateStrategy):
|
|||
self.save()
|
||||
return
|
||||
|
||||
if self._complete_upgrade:
|
||||
self._add_upgrade_complete_stage()
|
||||
self._add_upgrade_complete_stage()
|
||||
|
||||
if 0 == len(self.apply_phase.stages):
|
||||
DLOG.warn("No software upgrades need to be applied.")
|
||||
DLOG.warn("No sw-deployments need to be applied.")
|
||||
self._state = strategy.STRATEGY_STATE.BUILD_FAILED
|
||||
self.build_phase.result = strategy.STRATEGY_PHASE_RESULT.FAILED
|
||||
self.build_phase.result_reason = ('no software upgrades need to be '
|
||||
self.build_phase.result_reason = ('no sw-deployments patches need to be '
|
||||
'applied')
|
||||
self.sw_update_obj.strategy_build_complete(
|
||||
False, self.build_phase.result_reason)
|
||||
|
@ -2275,14 +1981,14 @@ class SwUpgradeStrategy(SwUpdateStrategy):
|
|||
super(SwUpgradeStrategy, self).from_dict(data, build_phase, apply_phase,
|
||||
abort_phase)
|
||||
self._single_controller = data['single_controller']
|
||||
self._start_upgrade = data['start_upgrade']
|
||||
self._complete_upgrade = data['complete_upgrade']
|
||||
self._release = data['release']
|
||||
nfvi_upgrade_data = data['nfvi_upgrade_data']
|
||||
if nfvi_upgrade_data:
|
||||
self._nfvi_upgrade = nfvi.objects.v1.Upgrade(
|
||||
nfvi_upgrade_data['release'],
|
||||
nfvi_upgrade_data['state'],
|
||||
nfvi_upgrade_data['from_release'],
|
||||
nfvi_upgrade_data['to_release'])
|
||||
nfvi_upgrade_data['reboot_required'],
|
||||
nfvi_upgrade_data['hosts_states'])
|
||||
else:
|
||||
self._nfvi_upgrade = None
|
||||
|
||||
|
@ -2294,8 +2000,7 @@ class SwUpgradeStrategy(SwUpdateStrategy):
|
|||
"""
|
||||
data = super(SwUpgradeStrategy, self).as_dict()
|
||||
data['single_controller'] = self._single_controller
|
||||
data['start_upgrade'] = self._start_upgrade
|
||||
data['complete_upgrade'] = self._complete_upgrade
|
||||
data['release'] = self._release
|
||||
if self._nfvi_upgrade:
|
||||
nfvi_upgrade_data = self._nfvi_upgrade.as_dict()
|
||||
else:
|
||||
|
|
|
@ -36,6 +36,7 @@ class StrategyStepNames(Constants):
|
|||
UNLOCK_HOSTS = Constant('unlock-hosts')
|
||||
REBOOT_HOSTS = Constant('reboot-hosts')
|
||||
UPGRADE_HOSTS = Constant('upgrade-hosts')
|
||||
SW_DEPLOY_PRECHECK = Constant('sw-deploy-precheck')
|
||||
START_UPGRADE = Constant('start-upgrade')
|
||||
ACTIVATE_UPGRADE = Constant('activate-upgrade')
|
||||
COMPLETE_UPGRADE = Constant('complete-upgrade')
|
||||
|
@ -919,7 +920,7 @@ class UpgradeHostsStep(strategy.StrategyStep):
|
|||
"""
|
||||
Upgrade Hosts - Strategy Step
|
||||
"""
|
||||
def __init__(self, hosts):
|
||||
def __init__(self, hosts, release):
|
||||
super(UpgradeHostsStep, self).__init__(
|
||||
STRATEGY_STEP_NAME.UPGRADE_HOSTS, timeout_in_secs=3600)
|
||||
self._hosts = hosts
|
||||
|
@ -929,6 +930,7 @@ class UpgradeHostsStep(strategy.StrategyStep):
|
|||
self._host_names.append(host.name)
|
||||
self._host_uuids.append(host.uuid)
|
||||
self._wait_time = 0
|
||||
self._release = release
|
||||
|
||||
def _total_hosts_upgraded(self):
|
||||
"""
|
||||
|
@ -942,8 +944,8 @@ class UpgradeHostsStep(strategy.StrategyStep):
|
|||
return -1
|
||||
|
||||
if (host.is_online() and
|
||||
host.target_load == self.strategy.nfvi_upgrade.to_release and
|
||||
host.software_load == self.strategy.nfvi_upgrade.to_release):
|
||||
host.target_load == self.strategy.nfvi_upgrade.release and
|
||||
host.software_load == self.strategy.nfvi_upgrade.release):
|
||||
total_hosts_upgraded += 1
|
||||
|
||||
return total_hosts_upgraded
|
||||
|
@ -1029,17 +1031,126 @@ class UpgradeHostsStep(strategy.StrategyStep):
|
|||
data['entity_uuids'] = self._host_uuids
|
||||
return data
|
||||
|
||||
class SwDeployPrecheckStep(strategy.StrategyStep):
|
||||
"""
|
||||
Software Deploy Precheck - Strategy Step
|
||||
"""
|
||||
def __init__(self, release):
|
||||
super(SwDeployPrecheckStep, self).__init__(
|
||||
STRATEGY_STEP_NAME.SW_DEPLOY_PRECHECK, timeout_in_secs=600)
|
||||
self._wait_time = 0
|
||||
self._query_inprogress = False
|
||||
self._release = release
|
||||
|
||||
@coroutine
|
||||
def _sw_deploy_precheck_callback(self):
|
||||
"""
|
||||
Software deploy precheck callback
|
||||
"""
|
||||
response = (yield)
|
||||
DLOG.debug("sw-deploy precheck callback response=%s." % response)
|
||||
|
||||
if response['completed']:
|
||||
if self.strategy is not None:
|
||||
self.strategy.nfvi_upgrade = response['result-data']
|
||||
else:
|
||||
result = strategy.STRATEGY_STEP_RESULT.FAILED
|
||||
self.stage.step_complete(result, "")
|
||||
|
||||
@coroutine
|
||||
def _get_sw_deploy_precheck_callback(self):
|
||||
"""
|
||||
Get sw-deploy precheck callback
|
||||
"""
|
||||
from nfv_vim import nfvi
|
||||
|
||||
response = (yield)
|
||||
DLOG.debug("Get-sw-deploy precheck callback response=%s." % response)
|
||||
|
||||
self._query_inprogress = False
|
||||
|
||||
if response['completed']:
|
||||
if self.strategy is not None:
|
||||
self.strategy.nfvi_upgrade = response['result-data']
|
||||
|
||||
if self.strategy.nfvi_upgrade.state != \
|
||||
nfvi.objects.v1.UPGRADE_STATE.STARTED:
|
||||
# Keep waiting for sw-deploy to start
|
||||
pass
|
||||
else:
|
||||
# Sw_deploy has started
|
||||
result = strategy.STRATEGY_STEP_RESULT.SUCCESS
|
||||
self.stage.step_complete(result, "")
|
||||
else:
|
||||
result = strategy.STRATEGY_STEP_RESULT.FAILED
|
||||
self.stage.step_complete(result, "")
|
||||
|
||||
def apply(self):
|
||||
"""
|
||||
Software deploy precheck
|
||||
"""
|
||||
from nfv_vim import nfvi
|
||||
|
||||
DLOG.info("Step (%s) apply." % self._name)
|
||||
nfvi.nfvi_sw_deploy_precheck(self._release, self._sw_deploy_precheck_callback())
|
||||
return strategy.STRATEGY_STEP_RESULT.WAIT, ""
|
||||
|
||||
def handle_event(self, event, event_data=None):
|
||||
"""
|
||||
Handle Host events
|
||||
"""
|
||||
from nfv_vim import nfvi
|
||||
|
||||
DLOG.debug("Step (%s) handle event (%s)." % (self._name, event))
|
||||
|
||||
if event == STRATEGY_EVENT.HOST_AUDIT:
|
||||
if 0 == self._wait_time:
|
||||
self._wait_time = timers.get_monotonic_timestamp_in_ms()
|
||||
|
||||
now_ms = timers.get_monotonic_timestamp_in_ms()
|
||||
secs_expired = (now_ms - self._wait_time) // 1000
|
||||
# Wait at least 60 seconds before checking sw_deploy for first time
|
||||
if 60 <= secs_expired and not self._query_inprogress:
|
||||
self._query_inprogress = True
|
||||
nfvi.nfvi_get_upgrade(self._get_sw_deploy_precheck_callback())
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def from_dict(self, data):
|
||||
"""
|
||||
Returns the sw-deploy precheck step object initialized using the given
|
||||
dictionary
|
||||
"""
|
||||
super(SwDeployPrecheckStep, self).from_dict(data)
|
||||
self._wait_time = 0
|
||||
self._query_inprogress = False
|
||||
self._release = data["release"]
|
||||
return self
|
||||
|
||||
def as_dict(self):
|
||||
"""
|
||||
Represent the sw-deploy precheck step as a dictionary
|
||||
"""
|
||||
data = super(SwDeployPrecheckStep, self).as_dict()
|
||||
data['entity_type'] = ''
|
||||
data['entity_names'] = list()
|
||||
data['entity_uuids'] = list()
|
||||
data['release'] = self._release
|
||||
return data
|
||||
|
||||
|
||||
class UpgradeStartStep(strategy.StrategyStep):
|
||||
"""
|
||||
Upgrade Start - Strategy Step
|
||||
"""
|
||||
def __init__(self):
|
||||
def __init__(self, release):
|
||||
super(UpgradeStartStep, self).__init__(
|
||||
STRATEGY_STEP_NAME.START_UPGRADE, timeout_in_secs=600)
|
||||
|
||||
self._wait_time = 0
|
||||
self._query_inprogress = False
|
||||
self._release = release
|
||||
|
||||
@coroutine
|
||||
def _start_upgrade_callback(self):
|
||||
|
@ -1091,7 +1202,7 @@ class UpgradeStartStep(strategy.StrategyStep):
|
|||
from nfv_vim import nfvi
|
||||
|
||||
DLOG.info("Step (%s) apply." % self._name)
|
||||
nfvi.nfvi_upgrade_start(self._start_upgrade_callback())
|
||||
nfvi.nfvi_upgrade_start(self._release, self._start_upgrade_callback())
|
||||
return strategy.STRATEGY_STEP_RESULT.WAIT, ""
|
||||
|
||||
def handle_event(self, event, event_data=None):
|
||||
|
@ -1124,6 +1235,7 @@ class UpgradeStartStep(strategy.StrategyStep):
|
|||
super(UpgradeStartStep, self).from_dict(data)
|
||||
self._wait_time = 0
|
||||
self._query_inprogress = False
|
||||
self._release = data["release"]
|
||||
return self
|
||||
|
||||
def as_dict(self):
|
||||
|
@ -1134,6 +1246,7 @@ class UpgradeStartStep(strategy.StrategyStep):
|
|||
data['entity_type'] = ''
|
||||
data['entity_names'] = list()
|
||||
data['entity_uuids'] = list()
|
||||
data['release'] = self._release
|
||||
return data
|
||||
|
||||
|
||||
|
@ -1142,12 +1255,13 @@ class UpgradeActivateStep(strategy.StrategyStep):
|
|||
Upgrade Activate - Strategy Step
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, release):
|
||||
super(UpgradeActivateStep, self).__init__(
|
||||
STRATEGY_STEP_NAME.ACTIVATE_UPGRADE, timeout_in_secs=900)
|
||||
|
||||
self._wait_time = 0
|
||||
self._query_inprogress = False
|
||||
self._release = release
|
||||
|
||||
@coroutine
|
||||
def _activate_upgrade_callback(self):
|
||||
|
@ -1199,7 +1313,7 @@ class UpgradeActivateStep(strategy.StrategyStep):
|
|||
from nfv_vim import nfvi
|
||||
|
||||
DLOG.info("Step (%s) apply." % self._name)
|
||||
nfvi.nfvi_upgrade_activate(self._activate_upgrade_callback())
|
||||
nfvi.nfvi_upgrade_activate(self._release, self._activate_upgrade_callback())
|
||||
return strategy.STRATEGY_STEP_RESULT.WAIT, ""
|
||||
|
||||
def handle_event(self, event, event_data=None):
|
||||
|
@ -1232,6 +1346,7 @@ class UpgradeActivateStep(strategy.StrategyStep):
|
|||
super(UpgradeActivateStep, self).from_dict(data)
|
||||
self._wait_time = 0
|
||||
self._query_inprogress = False
|
||||
self._release = data["release"]
|
||||
return self
|
||||
|
||||
def as_dict(self):
|
||||
|
@ -1242,6 +1357,7 @@ class UpgradeActivateStep(strategy.StrategyStep):
|
|||
data['entity_type'] = ''
|
||||
data['entity_names'] = list()
|
||||
data['entity_uuids'] = list()
|
||||
data['release'] = self._release
|
||||
return data
|
||||
|
||||
|
||||
|
@ -1250,12 +1366,13 @@ class UpgradeCompleteStep(strategy.StrategyStep):
|
|||
Upgrade Complete - Strategy Step
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, release):
|
||||
super(UpgradeCompleteStep, self).__init__(
|
||||
STRATEGY_STEP_NAME.COMPLETE_UPGRADE, timeout_in_secs=300)
|
||||
|
||||
self._wait_time = 0
|
||||
self._query_inprogress = False
|
||||
self._release = release
|
||||
|
||||
@coroutine
|
||||
def _complete_upgrade_callback(self):
|
||||
|
@ -1304,7 +1421,7 @@ class UpgradeCompleteStep(strategy.StrategyStep):
|
|||
from nfv_vim import nfvi
|
||||
|
||||
DLOG.info("Step (%s) apply." % self._name)
|
||||
nfvi.nfvi_upgrade_complete(self._complete_upgrade_callback())
|
||||
nfvi.nfvi_upgrade_complete(self._release, self._complete_upgrade_callback())
|
||||
return strategy.STRATEGY_STEP_RESULT.WAIT, ""
|
||||
|
||||
def handle_event(self, event, event_data=None):
|
||||
|
@ -1337,6 +1454,7 @@ class UpgradeCompleteStep(strategy.StrategyStep):
|
|||
super(UpgradeCompleteStep, self).from_dict(data)
|
||||
self._wait_time = 0
|
||||
self._query_inprogress = False
|
||||
self._release = data["release"]
|
||||
return self
|
||||
|
||||
def as_dict(self):
|
||||
|
@ -1347,6 +1465,7 @@ class UpgradeCompleteStep(strategy.StrategyStep):
|
|||
data['entity_type'] = ''
|
||||
data['entity_names'] = list()
|
||||
data['entity_uuids'] = list()
|
||||
data['release'] = self._release
|
||||
return data
|
||||
|
||||
|
||||
|
@ -2755,15 +2874,18 @@ class QueryUpgradeStep(strategy.StrategyStep):
|
|||
"""
|
||||
Query Upgrade - Strategy Step
|
||||
"""
|
||||
def __init__(self):
|
||||
def __init__(self, release):
|
||||
super(QueryUpgradeStep, self).__init__(
|
||||
STRATEGY_STEP_NAME.QUERY_UPGRADE, timeout_in_secs=60)
|
||||
|
||||
self._release = release
|
||||
|
||||
@coroutine
|
||||
def _get_upgrade_callback(self):
|
||||
"""
|
||||
Get Upgrade Callback
|
||||
"""
|
||||
|
||||
response = (yield)
|
||||
DLOG.debug("Query-Upgrade callback response=%s." % response)
|
||||
|
||||
|
@ -2784,7 +2906,7 @@ class QueryUpgradeStep(strategy.StrategyStep):
|
|||
from nfv_vim import nfvi
|
||||
|
||||
DLOG.info("Step (%s) apply." % self._name)
|
||||
nfvi.nfvi_get_upgrade(self._get_upgrade_callback())
|
||||
nfvi.nfvi_get_upgrade(self._release, self._get_upgrade_callback())
|
||||
return strategy.STRATEGY_STEP_RESULT.WAIT, ""
|
||||
|
||||
def as_dict(self):
|
||||
|
@ -2795,6 +2917,7 @@ class QueryUpgradeStep(strategy.StrategyStep):
|
|||
data['entity_type'] = ''
|
||||
data['entity_names'] = list()
|
||||
data['entity_uuids'] = list()
|
||||
data['release'] = None
|
||||
return data
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue