
This commit updates subcloud's error_description with the error returned by the software API during VIM strategy create and apply. - Created two custom exceptions for handling these errors. - Clean up error_description in strategy creation. Note: This also updated the timeout values of software API. Test Plan: PASS - Apply a sw-deploy-strategy and force an error in the deploy precheck command. - Apply should fail in the `create VIM strategy` state - dcmanager subcloud errors should be updated PASS - Apply a sw-deploy-strategy and force an error in the deploy start command. - Apply should fail in `apply VIM strategy` state - dcmanager subcloud errors should be updated PASS - Create a dcmanager sw-deploy-strategy with subcloud errors. - Strategy created and subcloud errors should be `No errors present`. Story: 2010676 Task: 50644 Change-Id: Ib0b0b586d90093088a6af96e5d630e3fe04fd3f7 Signed-off-by: Hugo Brito <hugo.brito@windriver.com>
92 lines
3.2 KiB
Python
92 lines
3.2 KiB
Python
# Copyright (c) 2017-2021 Wind River Systems, Inc.
|
|
# 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.
|
|
#
|
|
import uuid
|
|
|
|
from oslo_utils import timeutils
|
|
|
|
# VIM constants for Strategy
|
|
APPLY_TYPE_SERIAL = 'serial'
|
|
INSTANCE_ACTION_STOP_START = 'stop-start'
|
|
ALARM_RESTRICTIONS_STRICT = 'strict'
|
|
|
|
|
|
class FakeVimClient(object):
|
|
def __init__(self):
|
|
pass
|
|
|
|
|
|
class FakeVimStrategy(object):
|
|
"""Represents a VIM Strategy object defined in:
|
|
|
|
starlingx/nfv/nfv-client/nfv_client/openstack/sw_update.py
|
|
"""
|
|
|
|
def __init__(self,
|
|
name="VIM Strategy",
|
|
controller_apply_type=APPLY_TYPE_SERIAL,
|
|
storage_apply_type=APPLY_TYPE_SERIAL,
|
|
swift_apply_type=APPLY_TYPE_SERIAL,
|
|
worker_apply_type=APPLY_TYPE_SERIAL,
|
|
max_parallel_worker_hosts=2,
|
|
default_instance_action=INSTANCE_ACTION_STOP_START,
|
|
alarm_restrictions=ALARM_RESTRICTIONS_STRICT,
|
|
current_phase=None,
|
|
current_phase_completion_percentage=0,
|
|
state=None,
|
|
build_phase=None,
|
|
apply_phase=None,
|
|
abort_phase=None):
|
|
self.uuid = str(uuid.uuid4())
|
|
self.name = name
|
|
self.controller_apply_type = controller_apply_type
|
|
self.storage_apply_type = storage_apply_type
|
|
self.swift_apply_type = swift_apply_type
|
|
self.worker_apply_type = worker_apply_type
|
|
self.max_parallel_worker_hosts = max_parallel_worker_hosts
|
|
self.default_instance_action = default_instance_action
|
|
self.alarm_restrictions = alarm_restrictions
|
|
self.current_phase = current_phase
|
|
self.current_phase_completion_percentage =\
|
|
current_phase_completion_percentage
|
|
self.state = state
|
|
self.build_phase = build_phase
|
|
self.apply_phase = apply_phase
|
|
self.abort_phase = abort_phase
|
|
|
|
|
|
class FakeVimStrategyPhase(object):
|
|
"""Represents a VIM StrategyPhase object defined in:
|
|
|
|
starlingx/nfv/nfv-client/nfv_client/openstack/sw_update.py
|
|
"""
|
|
|
|
def __init__(self, response=None, reason=None):
|
|
self.response = response
|
|
self.reason = reason
|
|
|
|
|
|
class SwUpdateStrategy(object):
|
|
def __init__(self, id, data):
|
|
self.id = id
|
|
self.type = data['type']
|
|
self.subcloud_apply_type = data['subcloud-apply-type']
|
|
self.max_parallel_subclouds = int(data['max-parallel-subclouds'])
|
|
if data['stop-on-failure'] == 'true':
|
|
self.stop_on_failure = True
|
|
else:
|
|
self.stop_on_failure = False
|
|
self.state = data['state']
|
|
self.created_at = timeutils.utcnow()
|
|
self.updated_at = timeutils.utcnow()
|