Li Zhu 665fa12a79 Tech debt: move portions of dcorch.common.consts into dccommon.consts
Parts of dcorch.common.consts: such as ENDPOINT_TYPE_*,
ENDPOINT_TYPES_LIST, SYNC_STATUS_*, and so on, are shared by
dcmanager, so they should be moved into the dccommon.consts.

Test Plan:

PASSED:

All distributedcloud sanity tests.

Closes-Bug: 1978334
Change-Id: I13d7ec72e2863171138b39cd8f982d69e87d60b8
2022-06-16 12:28:44 -04:00

215 lines
5.7 KiB
Python

#
# Copyright (c) 2020-2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
import uuid
from dccommon import consts as dccommon_consts
from dcmanager.common import consts
PREVIOUS_PREVIOUS_VERSION = '01.23'
PREVIOUS_VERSION = '12.34'
UPGRADED_VERSION = '56.78'
PREVIOUS_KUBE_VERSION = 'v1.2.3'
UPGRADED_KUBE_VERSION = 'v1.2.4'
FAKE_VENDOR = '8086'
FAKE_DEVICE = '0b30'
class FakeController(object):
def __init__(self,
host_id=1,
hostname='controller-0',
administrative=consts.ADMIN_UNLOCKED,
operational=consts.OPERATIONAL_ENABLED,
availability=dccommon_consts.AVAILABILITY_ONLINE,
ihost_action=None,
target_load=UPGRADED_VERSION,
software_load=PREVIOUS_VERSION,
task=None,
capabilities={"Personality": "Controller-Active"}):
self.uuid = str(uuid.uuid4())
self.id = host_id
self.hostname = hostname
self.administrative = administrative
self.operational = operational
self.availability = availability
self.ihost_action = ihost_action
self.target_load = target_load
self.software_load = software_load
self.task = task
self.capabilities = capabilities
class FakeDevice(object):
def __init__(self,
obj_id,
pvendor_id=FAKE_VENDOR,
pdevice_id=FAKE_DEVICE,
enabled=True):
self.uuid = obj_id
self.pvendor_id = pvendor_id
self.pdevice_id = pdevice_id
self.enabled = enabled
class FakeDeviceImage(object):
def __init__(self,
obj_id,
pci_vendor=FAKE_VENDOR,
pci_device=FAKE_DEVICE,
bitstream_type='functional',
applied=False,
applied_labels=None):
self.uuid = obj_id
self.pci_vendor = pci_vendor
self.pci_device = pci_device
self.bitstream_type = bitstream_type
self.applied = applied
self.applied_labels = applied_labels
class FakeDeviceLabel(object):
def __init__(self,
label_key=None,
label_value=None,
pcidevice_uuid=None):
self.uuid = str(uuid.uuid4())
self.label_key = label_key
self.label_value = label_value
self.pcidevice_uuid = pcidevice_uuid
class FakeHostFilesystem(object):
def __init__(self,
name='scratch',
logical_volume='scratch-lv',
size=16):
self.name = name
self.logical_volume = logical_volume
self.size = size
self.uuid = str(uuid.uuid4())
class FakeKeystoneClient(object):
def __init__(self):
self.session = mock.MagicMock()
class FakeKubeRootCaUpdate(object):
def __init__(self,
obj_id=1,
state='update-started'):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.state = state
class FakeKubeUpgrade(object):
def __init__(self,
obj_id=1,
from_version=PREVIOUS_KUBE_VERSION,
to_version=UPGRADED_KUBE_VERSION,
state='upgrade-complete'):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.from_version = state
self.to_version = to_version
self.state = state
class FakeKubeVersion(object):
def __init__(self,
obj_id=1,
version=UPGRADED_KUBE_VERSION,
target=True,
state='active'):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.version = version
self.target = target
self.state = state
self.upgrade_from = []
self.applied_patches = []
self.available_patches = []
def to_dict(self):
return dict(self.__dict__)
class FakeLoad(object):
def __init__(self,
obj_id,
compatible_version='N/A',
required_patches='N/A',
software_version=PREVIOUS_VERSION,
state='active',
created_at=None,
updated_at=None):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.compatible_version = compatible_version
self.required_patches = required_patches
self.software_version = software_version
self.state = state
self.created_at = created_at
self.updated_at = updated_at
@staticmethod
def from_dict(load_data):
return FakeLoad(**load_data)
def to_dict(self):
return dict(self.__dict__)
class FakeSysinvClient(object):
def __init__(self):
pass
class FakePatchingClient(object):
def __init__(self):
pass
class FakeFmClient(object):
def __init__(self):
pass
class FakeSystem(object):
def __init__(self,
obj_id=1,
software_version=UPGRADED_VERSION):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.software_version = software_version
class FakeUpgrade(object):
def __init__(self,
obj_id=1,
state='completed',
from_release=PREVIOUS_VERSION,
to_release=UPGRADED_VERSION):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.state = state
self.from_release = from_release
self.to_release = to_release
self.links = []
class FakeAlarm(object):
def __init__(self,
alarm_id='12.34',
mgmt_affecting='False'):
self.alarm_id = alarm_id
self.mgmt_affecting = mgmt_affecting