Distributed cloud: Fix Patch Orchestration

The dcmanager failed to create patch strategy for sub-clouds.
This problem is caused by keyword argument name mismatch in the
vim interfaces that used by the dcmanager.
The argument names that have compute reference have been
changed to worker on the vim side while the dcmanager
still uses the old names.

This update changes all compute references to worker in
dcmanager including the data model.

Closes-Bug:1821081

Change-Id: I8cb2dea286e7f91d9b34cc13c57d40de018f3a9f
Signed-off-by: Tao Liu <tao.liu@windriver.com>
This commit is contained in:
Tao Liu 2019-03-20 17:10:35 -04:00
parent 3ac45e3281
commit ae73fe3469
7 changed files with 99 additions and 57 deletions

View File

@ -136,8 +136,8 @@ class SwUpdateOptionsController(object):
sw_update_opts_ref = db_api.sw_update_opts_default_update(
context,
payload['storage-apply-type'],
payload['compute-apply-type'],
payload['max-parallel-computes'],
payload['worker-apply-type'],
payload['max-parallel-workers'],
payload['alarm-restriction-type'],
payload['default-instance-action'])
except Exception as e:
@ -149,8 +149,8 @@ class SwUpdateOptionsController(object):
sw_update_opts_ref = db_api.sw_update_opts_default_create(
context,
payload['storage-apply-type'],
payload['compute-apply-type'],
payload['max-parallel-computes'],
payload['worker-apply-type'],
payload['max-parallel-workers'],
payload['alarm-restriction-type'],
payload['default-instance-action'])
except Exception as e:
@ -186,8 +186,8 @@ class SwUpdateOptionsController(object):
context,
subcloud.id,
payload['storage-apply-type'],
payload['compute-apply-type'],
payload['max-parallel-computes'],
payload['worker-apply-type'],
payload['max-parallel-workers'],
payload['alarm-restriction-type'],
payload['default-instance-action'])
@ -197,8 +197,8 @@ class SwUpdateOptionsController(object):
context,
subcloud.id,
payload['storage-apply-type'],
payload['compute-apply-type'],
payload['max-parallel-computes'],
payload['worker-apply-type'],
payload['max-parallel-workers'],
payload['alarm-restriction-type'],
payload['default-instance-action'])

View File

@ -289,8 +289,8 @@ def sw_update_opts_w_name_db_model_to_dict(sw_update_opts, subcloud_name):
"name": subcloud_name,
"subcloud-id": sw_update_opts.subcloud_id,
"storage-apply-type": sw_update_opts.storage_apply_type,
"compute-apply-type": sw_update_opts.compute_apply_type,
"max-parallel-computes": sw_update_opts.max_parallel_computes,
"worker-apply-type": sw_update_opts.worker_apply_type,
"max-parallel-workers": sw_update_opts.max_parallel_workers,
"alarm-restriction-type": sw_update_opts.alarm_restriction_type,
"default-instance-action":
sw_update_opts.default_instance_action,
@ -300,13 +300,13 @@ def sw_update_opts_w_name_db_model_to_dict(sw_update_opts, subcloud_name):
def sw_update_opts_create(context, subcloud_id, storage_apply_type,
compute_apply_type, max_parallel_computes,
worker_apply_type, max_parallel_workers,
alarm_restriction_type, default_instance_action):
"""Create sw update options."""
return IMPL.sw_update_opts_create(context, subcloud_id,
storage_apply_type,
compute_apply_type,
max_parallel_computes,
worker_apply_type,
max_parallel_workers,
alarm_restriction_type,
default_instance_action)
@ -323,16 +323,16 @@ def sw_update_opts_get_all_plus_subcloud_info(context):
def sw_update_opts_update(context, subcloud_id,
storage_apply_type=None,
compute_apply_type=None,
max_parallel_computes=None,
worker_apply_type=None,
max_parallel_workers=None,
alarm_restriction_type=None,
default_instance_action=None):
"""Update sw update options or raise if it does not exist."""
return IMPL.sw_update_opts_update(context, subcloud_id,
storage_apply_type,
compute_apply_type,
max_parallel_computes,
worker_apply_type,
max_parallel_workers,
alarm_restriction_type,
default_instance_action)
@ -344,14 +344,14 @@ def sw_update_opts_destroy(context, subcloud_id):
###################
def sw_update_opts_default_create(context, storage_apply_type,
compute_apply_type, max_parallel_computes,
worker_apply_type, max_parallel_workers,
alarm_restriction_type,
default_instance_action):
"""Create default sw update options."""
return IMPL.sw_update_opts_default_create(context,
storage_apply_type,
compute_apply_type,
max_parallel_computes,
worker_apply_type,
max_parallel_workers,
alarm_restriction_type,
default_instance_action)
@ -363,16 +363,16 @@ def sw_update_opts_default_get(context):
def sw_update_opts_default_update(context,
storage_apply_type=None,
compute_apply_type=None,
max_parallel_computes=None,
worker_apply_type=None,
max_parallel_workers=None,
alarm_restriction_type=None,
default_instance_action=None):
"""Update default sw update options."""
return IMPL.sw_update_opts_default_update(context,
storage_apply_type,
compute_apply_type,
max_parallel_computes,
worker_apply_type,
max_parallel_workers,
alarm_restriction_type,
default_instance_action)

View File

@ -398,16 +398,16 @@ def sw_update_opts_get_all_plus_subcloud_info(context):
@require_admin_context
def sw_update_opts_create(context, subcloud_id, storage_apply_type,
compute_apply_type,
max_parallel_computes,
worker_apply_type,
max_parallel_workers,
alarm_restriction_type,
default_instance_action):
with write_session() as session:
sw_update_opts_ref = models.SwUpdateOpts()
sw_update_opts_ref.subcloud_id = subcloud_id
sw_update_opts_ref.storage_apply_type = storage_apply_type
sw_update_opts_ref.compute_apply_type = compute_apply_type
sw_update_opts_ref.max_parallel_computes = max_parallel_computes
sw_update_opts_ref.worker_apply_type = worker_apply_type
sw_update_opts_ref.max_parallel_workers = max_parallel_workers
sw_update_opts_ref.alarm_restriction_type = alarm_restriction_type
sw_update_opts_ref.default_instance_action = default_instance_action
session.add(sw_update_opts_ref)
@ -416,17 +416,17 @@ def sw_update_opts_create(context, subcloud_id, storage_apply_type,
@require_admin_context
def sw_update_opts_update(context, subcloud_id, storage_apply_type=None,
compute_apply_type=None, max_parallel_computes=None,
worker_apply_type=None, max_parallel_workers=None,
alarm_restriction_type=None,
default_instance_action=None):
with write_session() as session:
sw_update_opts_ref = sw_update_opts_get(context, subcloud_id)
if storage_apply_type is not None:
sw_update_opts_ref.storage_apply_type = storage_apply_type
if compute_apply_type is not None:
sw_update_opts_ref.compute_apply_type = compute_apply_type
if max_parallel_computes is not None:
sw_update_opts_ref.max_parallel_computes = max_parallel_computes
if worker_apply_type is not None:
sw_update_opts_ref.worker_apply_type = worker_apply_type
if max_parallel_workers is not None:
sw_update_opts_ref.max_parallel_workers = max_parallel_workers
if alarm_restriction_type is not None:
sw_update_opts_ref.alarm_restriction_type = alarm_restriction_type
if default_instance_action is not None:
@ -458,17 +458,17 @@ def sw_update_opts_default_get(context):
@require_admin_context
def sw_update_opts_default_create(context, storage_apply_type,
compute_apply_type,
max_parallel_computes,
worker_apply_type,
max_parallel_workers,
alarm_restriction_type,
default_instance_action):
with write_session() as session:
sw_update_opts_default_ref = models.SwUpdateOptsDefault()
sw_update_opts_default_ref.subcloud_id = 0
sw_update_opts_default_ref.storage_apply_type = storage_apply_type
sw_update_opts_default_ref.compute_apply_type = compute_apply_type
sw_update_opts_default_ref.max_parallel_computes = \
max_parallel_computes
sw_update_opts_default_ref.worker_apply_type = worker_apply_type
sw_update_opts_default_ref.max_parallel_workers = \
max_parallel_workers
sw_update_opts_default_ref.alarm_restriction_type = \
alarm_restriction_type
sw_update_opts_default_ref.default_instance_action = \
@ -479,19 +479,19 @@ def sw_update_opts_default_create(context, storage_apply_type,
@require_admin_context
def sw_update_opts_default_update(context, storage_apply_type=None,
compute_apply_type=None,
max_parallel_computes=None,
worker_apply_type=None,
max_parallel_workers=None,
alarm_restriction_type=None,
default_instance_action=None):
with write_session() as session:
sw_update_opts_default_ref = sw_update_opts_default_get(context)
if storage_apply_type is not None:
sw_update_opts_default_ref.storage_apply_type = storage_apply_type
if compute_apply_type is not None:
sw_update_opts_default_ref.compute_apply_type = compute_apply_type
if max_parallel_computes is not None:
sw_update_opts_default_ref.max_parallel_computes = \
max_parallel_computes
if worker_apply_type is not None:
sw_update_opts_default_ref.worker_apply_type = worker_apply_type
if max_parallel_workers is not None:
sw_update_opts_default_ref.max_parallel_workers = \
max_parallel_workers
if alarm_restriction_type is not None:
sw_update_opts_default_ref.alarm_restriction_type = \
alarm_restriction_type

View File

@ -0,0 +1,42 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Copyright (c) 2019 Wind River Systems, Inc.
#
# The right to copy, distribute, modify, or otherwise make use
# of this software may be licensed only pursuant to the terms
# of an applicable Wind River license agreement.
#
from sqlalchemy import MetaData
from sqlalchemy import Table
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
sw_update_opts_default = Table('sw_update_opts_default', meta,
autoload=True)
sw_update_opts = Table('sw_update_opts', meta, autoload=True)
columns_to_rename = {'compute_apply_type': 'worker_apply_type',
'max_parallel_computes': 'max_parallel_workers'}
for k, v in columns_to_rename.items():
getattr(sw_update_opts_default.c, k).alter(name=v)
getattr(sw_update_opts.c, k).alter(name=v)
return True
def downgrade(migrate_engine):
raise NotImplementedError('Database downgrade is unsupported.')

View File

@ -130,8 +130,8 @@ class SwUpdateOpts(BASE, DCManagerBase):
ForeignKey('subclouds.id', ondelete='CASCADE'))
storage_apply_type = Column(String(255))
compute_apply_type = Column(String(255))
max_parallel_computes = Column(Integer)
worker_apply_type = Column(String(255))
max_parallel_workers = Column(Integer)
alarm_restriction_type = Column(String(255))
default_instance_action = Column(String(255))
@ -145,8 +145,8 @@ class SwUpdateOptsDefault(BASE, DCManagerBase):
subcloud_id = Column(Integer)
storage_apply_type = Column(String(255))
compute_apply_type = Column(String(255))
max_parallel_computes = Column(Integer)
worker_apply_type = Column(String(255))
max_parallel_workers = Column(Integer)
alarm_restriction_type = Column(String(255))
default_instance_action = Column(String(255))

View File

@ -45,8 +45,8 @@ ALARM_RESTRICTIONS_RELAXED = 'relaxed'
SW_UPDATE_OPTS_CONST_DEFAULT = {
"name": consts.SW_UPDATE_DEFAULT_TITLE,
"storage-apply-type": APPLY_TYPE_PARALLEL,
"compute-apply-type": APPLY_TYPE_PARALLEL,
"max-parallel-computes": 10,
"worker-apply-type": APPLY_TYPE_PARALLEL,
"max-parallel-workers": 10,
"default-instance-action": INSTANCE_ACTION_MIGRATE,
"alarm-restriction-type": ALARM_RESTRICTIONS_RELAXED,
"created-at": None,
@ -83,7 +83,7 @@ class VimClient(base.DriverBase):
raise
def create_strategy(self, strategy_name, storage_apply_type,
compute_apply_type, max_parallel_compute_hosts,
worker_apply_type, max_parallel_worker_hosts,
default_instance_action, alarm_restrictions):
"""Create orchestration strategy"""
@ -94,8 +94,8 @@ class VimClient(base.DriverBase):
controller_apply_type=APPLY_TYPE_SERIAL,
storage_apply_type=storage_apply_type,
swift_apply_type=APPLY_TYPE_IGNORE,
compute_apply_type=compute_apply_type,
max_parallel_compute_hosts=max_parallel_compute_hosts,
worker_apply_type=worker_apply_type,
max_parallel_worker_hosts=max_parallel_worker_hosts,
default_instance_action=default_instance_action,
alarm_restrictions=alarm_restrictions)
if not strategy:

View File

@ -963,9 +963,9 @@ class PatchOrchThread(threading.Thread):
subcloud_strategy = vim_client.create_strategy(
strategy_name=vim.STRATEGY_NAME_SW_PATCH,
storage_apply_type=opts_dict['storage-apply-type'],
compute_apply_type=opts_dict['compute-apply-type'],
max_parallel_compute_hosts=opts_dict[
'max-parallel-computes'],
worker_apply_type=opts_dict['worker-apply-type'],
max_parallel_worker_hosts=opts_dict[
'max-parallel-workers'],
default_instance_action=opts_dict[
'default-instance-action'],
alarm_restrictions=opts_dict['alarm-restriction-type'])