sw-patch strategy orchestration removal.
sw-patch strategy orchestration CLI removal and corresponding API clean up. sw-patch strategy is no longer supported in stx-10 as the patch release deploy is handled by sw-deploy strategy. Test Plan: PASSED: sw-manager sw-patch-strategy absent from CLI. PASSED: sw-patch absent from REST API. PASSED: sw-deploy strategy tested. PASSED: sw-deploy strategy has no impacts. Story: 2011045 Task: 50535 Depends-on : https://review.opendev.org/c/starlingx/distcloud/+/924452 Change-Id: I6e1f363f607cae6cc3ace380e5d66196abdc9489 Signed-off-by: Vanathi.Selvaraju <vanathi.selvaraju@windriver.com>
This commit is contained in:
parent
b352f41251
commit
269d0d6511
File diff suppressed because it is too large
Load Diff
@ -275,11 +275,7 @@ def create_strategy(token_id,
|
||||
api_cmd_headers['X-Auth-Token'] = token_id
|
||||
|
||||
api_cmd_payload = dict()
|
||||
if sw_update.STRATEGY_NAME_SW_PATCH == strategy_name:
|
||||
api_cmd_payload['controller-apply-type'] = controller_apply_type
|
||||
api_cmd_payload['swift-apply-type'] = swift_apply_type
|
||||
api_cmd_payload['default-instance-action'] = default_instance_action
|
||||
elif sw_update.STRATEGY_NAME_FW_UPDATE == strategy_name:
|
||||
if sw_update.STRATEGY_NAME_FW_UPDATE == strategy_name:
|
||||
api_cmd_payload['controller-apply-type'] = controller_apply_type
|
||||
api_cmd_payload['default-instance-action'] = default_instance_action
|
||||
elif sw_update.STRATEGY_NAME_KUBE_ROOTCA_UPDATE == strategy_name:
|
||||
|
@ -52,10 +52,7 @@ def get_extra_create_args(cmd_area, args):
|
||||
:returns: a dictionary of additional kwargs for the create_strategy command
|
||||
:raises: ValueError if a strategy has been registered but not update here
|
||||
"""
|
||||
if sw_update.CMD_NAME_SW_PATCH == cmd_area:
|
||||
# no additional kwargs for patch
|
||||
return {}
|
||||
elif sw_update.CMD_NAME_SW_DEPLOY == cmd_area:
|
||||
if sw_update.CMD_NAME_SW_DEPLOY == cmd_area:
|
||||
# We can't use mutual exclusion for release and rollback because
|
||||
# release is a positional arg.
|
||||
if args.release is None and not args.rollback:
|
||||
@ -107,7 +104,7 @@ def setup_abort_cmd(parser):
|
||||
"""
|
||||
Sets up an 'abort' command for a strategy command parser.
|
||||
|
||||
ex: sw-manager patch-strategy abort <some args>
|
||||
ex: sw-manager sw-deploy-strategy abort <some args>
|
||||
|
||||
:param parser: the strategy parser to add the create command to.
|
||||
"""
|
||||
@ -123,7 +120,7 @@ def setup_apply_cmd(parser):
|
||||
"""
|
||||
Sets up an 'apply' command for a strategy command parser.
|
||||
|
||||
ex: sw-manager patch-strategy apply <some args>
|
||||
ex: sw-manager sw-deploy-strategy apply <some args>
|
||||
|
||||
:param parser: the strategy parser to register the command under
|
||||
"""
|
||||
@ -147,7 +144,7 @@ def setup_create_cmd(parser,
|
||||
"""
|
||||
Sets up a 'create' command for a strategy command parser.
|
||||
|
||||
ex: sw-manager patch-strategy create <some args>
|
||||
ex: sw-manager sw-deploy-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
|
||||
@ -180,7 +177,7 @@ def setup_delete_cmd(parser):
|
||||
"""
|
||||
Sets up a 'delete' command for a strategy command parser.
|
||||
|
||||
ex: sw-manager patch-strategy delete <some args>
|
||||
ex: sw-manager sw-deploy-strategy delete <some args>
|
||||
|
||||
:param parser: the strategy parser to register the command under
|
||||
"""
|
||||
@ -196,7 +193,7 @@ def setup_show_cmd(parser):
|
||||
"""
|
||||
Sets up a 'show' command for a strategy command parser.
|
||||
|
||||
ex: sw-manager patch-strategy show <some args>
|
||||
ex: sw-manager sw-deploy-strategy show <some args>
|
||||
|
||||
:param parser: the strategy parser to register the command under
|
||||
"""
|
||||
@ -360,49 +357,6 @@ def setup_kube_upgrade_parser(commands):
|
||||
_ = setup_show_cmd(sub_cmds)
|
||||
|
||||
|
||||
def setup_patch_parser(commands):
|
||||
"""Patch Strategy Commands"""
|
||||
|
||||
cmd_area = sw_update.CMD_NAME_SW_PATCH
|
||||
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
|
||||
_ = 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
|
||||
_ = setup_delete_cmd(sub_cmds)
|
||||
# define the apply command
|
||||
_ = setup_apply_cmd(sub_cmds)
|
||||
# define the abort command
|
||||
_ = setup_abort_cmd(sub_cmds)
|
||||
# define the show command
|
||||
_ = setup_show_cmd(sub_cmds)
|
||||
|
||||
|
||||
def setup_system_config_update_parser(commands):
|
||||
"""System config update Strategy Commands"""
|
||||
|
||||
@ -537,9 +491,6 @@ def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value
|
||||
# Add kubernetes upgrade strategy commands
|
||||
setup_kube_upgrade_parser(commands)
|
||||
|
||||
# Add software patch strategy commands
|
||||
setup_patch_parser(commands)
|
||||
|
||||
# Add system config update strategy commands
|
||||
setup_system_config_update_parser(commands)
|
||||
|
||||
|
@ -13,7 +13,6 @@ from nfv_client.sw_update._sw_update import CMD_NAME_FW_UPDATE # noqa: F401
|
||||
from nfv_client.sw_update._sw_update import CMD_NAME_KUBE_ROOTCA_UPDATE # noqa: F401
|
||||
from nfv_client.sw_update._sw_update import CMD_NAME_KUBE_UPGRADE # noqa: F401
|
||||
from nfv_client.sw_update._sw_update import CMD_NAME_SW_DEPLOY # noqa: F401
|
||||
from nfv_client.sw_update._sw_update import CMD_NAME_SW_PATCH # noqa: F401
|
||||
from nfv_client.sw_update._sw_update import CMD_NAME_SYSTEM_CONFIG_UPDATE # noqa: F401
|
||||
from nfv_client.sw_update._sw_update import create_strategy # noqa: F401
|
||||
from nfv_client.sw_update._sw_update import delete_strategy # noqa: F401
|
||||
@ -23,6 +22,5 @@ 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_KUBE_ROOTCA_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_UPGRADE # noqa: F401
|
||||
from nfv_client.sw_update._sw_update import STRATEGY_NAME_SYSTEM_CONFIG_UPDATE # noqa: F401
|
||||
|
@ -7,14 +7,12 @@ from nfv_client.openstack import openstack
|
||||
from nfv_client.openstack import sw_update
|
||||
import textwrap
|
||||
|
||||
STRATEGY_NAME_SW_PATCH = 'sw-patch'
|
||||
STRATEGY_NAME_SW_UPGRADE = 'sw-upgrade'
|
||||
STRATEGY_NAME_FW_UPDATE = 'fw-update'
|
||||
STRATEGY_NAME_KUBE_ROOTCA_UPDATE = 'kube-rootca-update'
|
||||
STRATEGY_NAME_KUBE_UPGRADE = 'kube-upgrade'
|
||||
STRATEGY_NAME_SYSTEM_CONFIG_UPDATE = 'system-config-update'
|
||||
|
||||
CMD_NAME_SW_PATCH = 'patch-strategy'
|
||||
CMD_NAME_SW_DEPLOY = 'sw-deploy-strategy'
|
||||
CMD_NAME_FW_UPDATE = 'fw-update-strategy'
|
||||
CMD_NAME_KUBE_ROOTCA_UPDATE = 'kube-rootca-update-strategy'
|
||||
@ -141,10 +139,8 @@ def _display_strategy(strategy, details=False, active=False, error_details=False
|
||||
"""
|
||||
Software Update - Display Strategy Information
|
||||
"""
|
||||
if strategy.name == STRATEGY_NAME_SW_PATCH:
|
||||
print("Strategy Patch Strategy:")
|
||||
# TODO(jkraitbe): Backend for sw-deploy will continue as old sw-upgrade for now
|
||||
elif strategy.name == STRATEGY_NAME_SW_UPGRADE:
|
||||
if strategy.name == STRATEGY_NAME_SW_UPGRADE:
|
||||
print("Strategy Software Deploy Strategy:")
|
||||
elif strategy.name == STRATEGY_NAME_FW_UPDATE:
|
||||
print("Strategy Firmware Update Strategy:")
|
||||
|
@ -19,7 +19,6 @@ function _swmanager()
|
||||
# The available sw-manager subcommands
|
||||
#
|
||||
local subcommands="
|
||||
patch-strategy
|
||||
sw-deploy-strategy
|
||||
fw-update-strategy
|
||||
kube-rootca-update-strategy
|
||||
@ -32,83 +31,6 @@ function _swmanager()
|
||||
# Complete the arguments to the subcommands
|
||||
#
|
||||
case "$subcommand" in
|
||||
patch-strategy)
|
||||
local actions="
|
||||
create
|
||||
delete
|
||||
apply
|
||||
abort
|
||||
show
|
||||
"
|
||||
if [ $COMP_CWORD -gt 2 ]; then
|
||||
local action=${COMP_WORDS[2]}
|
||||
#
|
||||
# Complete the arguments for each action
|
||||
#
|
||||
case "$action" in
|
||||
create)
|
||||
local createopts="
|
||||
--controller-apply-type
|
||||
--storage-apply-type
|
||||
--worker-apply-type
|
||||
--max-parallel-worker-hosts
|
||||
--instance-action
|
||||
--alarm-restrictions
|
||||
"
|
||||
local createopt=${prev}
|
||||
case "$createopt" in
|
||||
--controller-apply-type)
|
||||
COMPREPLY=($(compgen -W "serial ignore" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--storage-apply-type|--worker-apply-type)
|
||||
COMPREPLY=($(compgen -W "serial parallel ignore" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--max-parallel-worker-hosts)
|
||||
COMPREPLY=( $(compgen -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--instance-action)
|
||||
COMPREPLY=($(compgen -W "migrate stop-start" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--alarm-restrictions)
|
||||
COMPREPLY=($(compgen -W "strict relaxed" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=($(compgen -W "${createopts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
apply|abort)
|
||||
if [ "${prev}" = "${action}" ]; then
|
||||
COMPREPLY=($(compgen -W "--stage-id" -- ${cur}))
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
show)
|
||||
if [ "${prev}" = "${action}" ]; then
|
||||
COMPREPLY=($(compgen -W "--details --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
|
||||
;;
|
||||
sw-deploy-strategy)
|
||||
local actions="
|
||||
create
|
||||
|
@ -279,13 +279,6 @@ class TestCLISwDeployStrategy(TestNFVClientShell,
|
||||
assert str(e) == 'Cannot set both release and rollback', e
|
||||
|
||||
|
||||
class TestCLIPatchStrategy(TestNFVClientShell,
|
||||
StrategyMixin):
|
||||
def setUp(self):
|
||||
super(TestCLIPatchStrategy, self).setUp()
|
||||
self.set_strategy('patch-strategy')
|
||||
|
||||
|
||||
class TestCLIFwUpdateStrategy(TestNFVClientShell,
|
||||
StrategyMixin):
|
||||
def setUp(self):
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015-2021 Wind River Systems, Inc.
|
||||
# Copyright (c) 2015-2024 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -14,7 +14,6 @@ from nfv_vim.api.controllers.v1.orchestration.sw_update import FwUpdateAPI
|
||||
from nfv_vim.api.controllers.v1.orchestration.sw_update import KubeRootcaUpdateAPI
|
||||
from nfv_vim.api.controllers.v1.orchestration.sw_update import KubeUpgradeAPI
|
||||
from nfv_vim.api.controllers.v1.orchestration.sw_update import StrategyAPI
|
||||
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 SystemConfigUpdateAPI
|
||||
|
||||
@ -34,7 +33,6 @@ class OrchestrationDescription(wsme_types.Base):
|
||||
description.id = "orchestration"
|
||||
description.links = [
|
||||
Link.make_link('self', url, 'orchestration'),
|
||||
Link.make_link('sw-patch', url, 'orchestration/sw-patch', ''),
|
||||
Link.make_link('sw-upgrade', url, 'orchestration/sw-upgrade', ''),
|
||||
Link.make_link('system-config-update',
|
||||
url, 'orchestration/system-config-update', ''),
|
||||
@ -53,9 +51,7 @@ class OrchestrationAPI(rest.RestController):
|
||||
"""
|
||||
@pecan.expose()
|
||||
def _lookup(self, key, *remainder):
|
||||
if 'sw-patch' == key:
|
||||
return SwPatchAPI(), remainder
|
||||
elif 'sw-upgrade' == key:
|
||||
if 'sw-upgrade' == key:
|
||||
return SwUpgradeAPI(), remainder
|
||||
elif 'system-config-update' == key:
|
||||
return SystemConfigUpdateAPI(), remainder
|
||||
|
@ -7,6 +7,5 @@ from nfv_vim.api.controllers.v1.orchestration.sw_update._current_strategy import
|
||||
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_rootca_update import KubeRootcaUpdateAPI # 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_upgrade import SwUpgradeAPI # noqa: F401
|
||||
from nfv_vim.api.controllers.v1.orchestration.sw_update._system_config_update import SystemConfigUpdateAPI # noqa: F401
|
||||
|
@ -1,54 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2016 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 SwPatchStrategyAPI
|
||||
|
||||
DLOG = debug.debug_get_logger('nfv_vim.api.sw_patch')
|
||||
|
||||
|
||||
class SwPatchDescription(wsme_types.Base):
|
||||
"""
|
||||
Software Patch Description
|
||||
"""
|
||||
id = wsme_types.text
|
||||
links = wsme_types.wsattr([Link], name='links')
|
||||
|
||||
@classmethod
|
||||
def convert(cls):
|
||||
url = pecan.request.host_url
|
||||
|
||||
description = SwPatchDescription()
|
||||
description.id = "sw-patch"
|
||||
description.links = [
|
||||
Link.make_link('self', url, 'orchestration/sw-patch'),
|
||||
Link.make_link('strategy', url, 'orchestration/sw-patch/strategy')]
|
||||
return description
|
||||
|
||||
|
||||
class SwPatchAPI(rest.RestController):
|
||||
"""
|
||||
Software Patch Rest API
|
||||
"""
|
||||
@pecan.expose()
|
||||
def _lookup(self, key, *remainder):
|
||||
if 'strategy' == key:
|
||||
return SwPatchStrategyAPI(), remainder
|
||||
else:
|
||||
pecan.abort(httplib.NOT_FOUND)
|
||||
|
||||
@wsme_pecan.wsexpose(SwPatchDescription)
|
||||
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 SwPatchDescription.convert()
|
@ -19,7 +19,6 @@ class SwUpdateNames(Constants):
|
||||
FW_UPDATE = Constant('fw-update')
|
||||
KUBE_ROOTCA_UPDATE = Constant('kube-rootca-update')
|
||||
KUBE_UPGRADE = Constant('kube-upgrade')
|
||||
SW_PATCH = Constant('sw-patch')
|
||||
SW_UPGRADE = Constant('sw-upgrade')
|
||||
SYSTEM_CONFIG_UPDATE = Constant('system-config-update')
|
||||
CURRENT_STRATEGY = Constant('current-strategy')
|
||||
@ -77,7 +76,6 @@ SwUpdateNames = wsme_types.Enum(str,
|
||||
SW_UPDATE_NAME.FW_UPDATE,
|
||||
SW_UPDATE_NAME.KUBE_ROOTCA_UPDATE,
|
||||
SW_UPDATE_NAME.KUBE_UPGRADE,
|
||||
SW_UPDATE_NAME.SW_PATCH,
|
||||
SW_UPDATE_NAME.SW_UPGRADE,
|
||||
SW_UPDATE_NAME.SYSTEM_CONFIG_UPDATE,
|
||||
SW_UPDATE_NAME.CURRENT_STRATEGY)
|
||||
|
@ -16,7 +16,6 @@ from nfv_common import validate
|
||||
from nfv_vim.api.acl.policies import fw_update_strategy_policy
|
||||
from nfv_vim.api.acl.policies import kube_rootca_update_strategy_policy
|
||||
from nfv_vim.api.acl.policies import kube_upgrade_strategy_policy
|
||||
from nfv_vim.api.acl.policies import sw_patch_strategy_policy
|
||||
from nfv_vim.api.acl.policies import sw_update_strategy_policy
|
||||
from nfv_vim.api.acl.policies import sw_upgrade_strategy_policy
|
||||
from nfv_vim.api.acl.policies import system_config_update_strategy_policy
|
||||
@ -47,9 +46,7 @@ MAX_PARALLEL_UPGRADE_HOSTS = 10
|
||||
|
||||
def _get_sw_update_type_from_path(path):
|
||||
split_path = path.split('/')
|
||||
if 'sw-patch' in split_path:
|
||||
return SW_UPDATE_NAME.SW_PATCH
|
||||
elif 'sw-upgrade' in split_path:
|
||||
if 'sw-upgrade' in split_path:
|
||||
return SW_UPDATE_NAME.SW_UPGRADE
|
||||
elif 'system-config-update' in split_path:
|
||||
return SW_UPDATE_NAME.SYSTEM_CONFIG_UPDATE
|
||||
@ -147,29 +144,6 @@ class SwUpdateStrategyData(wsme_types.Base):
|
||||
abort_phase = wsme_types.wsattr(SwUpdateStrategyPhaseData, name='abort-phase')
|
||||
|
||||
|
||||
class SwPatchStrategyCreateData(wsme_types.Base):
|
||||
"""
|
||||
Software Patch Strategy - Create Data
|
||||
"""
|
||||
controller_apply_type = wsme_types.wsattr(SwUpdateApplyTypes, mandatory=True,
|
||||
name='controller-apply-type')
|
||||
storage_apply_type = wsme_types.wsattr(SwUpdateApplyTypes, mandatory=True,
|
||||
name='storage-apply-type')
|
||||
swift_apply_type = wsme_types.wsattr(SwUpdateApplyTypes, mandatory=False,
|
||||
name='swift-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 SwUpgradeStrategyCreateData(wsme_types.Base):
|
||||
"""
|
||||
Software Upgrade Strategy - Create Data
|
||||
@ -599,74 +573,6 @@ class SwUpdateStrategyAPI(rest.RestController):
|
||||
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||
|
||||
|
||||
class SwPatchStrategyAPI(SwUpdateStrategyAPI):
|
||||
"""
|
||||
Software Patch Strategy Rest API
|
||||
"""
|
||||
@wsme_pecan.wsexpose(SwUpdateStrategyQueryData,
|
||||
body=SwPatchStrategyCreateData,
|
||||
status_code=httplib.OK)
|
||||
def post(self, request_data):
|
||||
rpc_request = rpc.APIRequestCreateSwUpdateStrategy()
|
||||
rpc_request.sw_update_type = _get_sw_update_type_from_path(
|
||||
pecan.request.path)
|
||||
rpc_request.controller_apply_type = request_data.controller_apply_type
|
||||
rpc_request.storage_apply_type = request_data.storage_apply_type
|
||||
if wsme_types.Unset == request_data.swift_apply_type:
|
||||
rpc_request.swift_apply_type = SW_UPDATE_APPLY_TYPE.IGNORE
|
||||
else:
|
||||
rpc_request.swift_apply_type = request_data.swift_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 \
|
||||
or request_data.max_parallel_worker_hosts > \
|
||||
MAX_PARALLEL_PATCH_HOSTS:
|
||||
return pecan.abort(
|
||||
httplib.BAD_REQUEST,
|
||||
"Invalid value for max-parallel-worker-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, response.error_string)
|
||||
|
||||
DLOG.error("Unexpected result received, result=%s." % response.result)
|
||||
return pecan.abort(httplib.INTERNAL_SERVER_ERROR)
|
||||
|
||||
def enforce_policy(self, method_name, auth_context_dict):
|
||||
"""Check policy rules for each action of this controller."""
|
||||
if method_name == "delete":
|
||||
policy.check(sw_patch_strategy_policy.POLICY_ROOT % "delete", {},
|
||||
auth_context_dict, exc=policy.PolicyForbidden)
|
||||
elif method_name in ["get_all", "get_one"]:
|
||||
policy.check(sw_patch_strategy_policy.POLICY_ROOT % "get", {},
|
||||
auth_context_dict, exc=policy.PolicyForbidden)
|
||||
elif method_name == "post":
|
||||
policy.check(sw_patch_strategy_policy.POLICY_ROOT % "add", {},
|
||||
auth_context_dict, exc=policy.PolicyForbidden)
|
||||
else:
|
||||
policy.check('admin_in_system_projects', {}, auth_context_dict)
|
||||
|
||||
|
||||
class SwUpgradeStrategyAPI(SwUpdateStrategyAPI):
|
||||
"""
|
||||
Software Upgrade Strategy Rest API
|
||||
|
Loading…
Reference in New Issue
Block a user