Create a zuul job for black formatter
Create a Zuul job to check Black Formatter in the code. This commit also applies the Black formatter to the entire project. Test Plan Pass - Success on stx-distcloud-client-tox-black Pass - Success on tox command Story: 2011149 Task: 50393 Change-Id: I5d7b537e83931304ffd5f67ce51e8ebb44f7e65b Signed-off-by: Hugo Brito <hugo.brito@windriver.com>
This commit is contained in:
parent
c0183431c6
commit
b5cbd9480c
12
.zuul.yaml
12
.zuul.yaml
@ -10,12 +10,14 @@
|
||||
- stx-distcloud-client-tox-pep8
|
||||
- stx-distcloud-client-tox-py39
|
||||
- stx-distcloud-client-tox-pylint
|
||||
- stx-distcloud-client-tox-black
|
||||
gate:
|
||||
jobs:
|
||||
- openstack-tox-linters
|
||||
- stx-distcloud-client-tox-pep8
|
||||
- stx-distcloud-client-tox-py39
|
||||
- stx-distcloud-client-tox-pylint
|
||||
- stx-distcloud-client-tox-black
|
||||
post:
|
||||
jobs:
|
||||
- stx-distcloud-client-upload-git-mirror
|
||||
@ -50,6 +52,16 @@
|
||||
tox_envlist: pep8
|
||||
tox_extra_args: -c distributedcloud-client/tox.ini
|
||||
|
||||
- job:
|
||||
name: stx-distcloud-client-tox-black
|
||||
parent: tox
|
||||
description: Run black for distcloud-client
|
||||
nodeset: debian-bullseye
|
||||
vars:
|
||||
python_version: 3.9
|
||||
tox_envlist: black_check
|
||||
tox_extra_args: -c distributedcloud-client/tox.ini
|
||||
|
||||
- job:
|
||||
name: stx-distcloud-client-upload-git-mirror
|
||||
parent: upload-git-mirror
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Copyright (c) 2016 Ericsson AB
|
||||
# Copyright (c) 2017-2021 Wind River Systems, Inc.
|
||||
# Copyright (c) 2017-2021, 2024 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
|
||||
@ -17,5 +17,4 @@
|
||||
import pbr.version
|
||||
|
||||
|
||||
__version__ = pbr.version.VersionInfo(
|
||||
'distributedcloud_client').version_string()
|
||||
__version__ = pbr.version.VersionInfo("distributedcloud_client").version_string()
|
||||
|
@ -57,7 +57,7 @@ class Subcloud(Resource):
|
||||
"prestage-status": "prestage_status",
|
||||
"prestage-versions": "prestage_versions",
|
||||
"region-name": "region_name",
|
||||
"info_message": "info_message"
|
||||
"info_message": "info_message",
|
||||
}
|
||||
|
||||
def __init__(
|
||||
@ -90,7 +90,7 @@ class Subcloud(Resource):
|
||||
region_name=None,
|
||||
prestage_status=None,
|
||||
prestage_versions=None,
|
||||
info_message=None
|
||||
info_message=None,
|
||||
):
|
||||
if endpoint_sync_status is None:
|
||||
endpoint_sync_status = {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Copyright 2016 - Ericsson AB
|
||||
# Copyright (c) 2017, 2019, 2021 Wind River Systems, Inc.
|
||||
# Copyright (c) 2017, 2019, 2021, 2024 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.
|
||||
@ -19,14 +19,28 @@ import six
|
||||
from dcmanagerclient.api.v1 import client as client_v1
|
||||
|
||||
|
||||
def client(dcmanager_url=None, username=None, api_key=None,
|
||||
project_name=None, auth_url=None, project_id=None,
|
||||
endpoint_type='publicURL', service_type='dcmanager',
|
||||
auth_token=None, user_id=None, cacert=None, insecure=False,
|
||||
profile=None, auth_type='keystone', client_id=None,
|
||||
client_secret=None, session=None, **kwargs):
|
||||
def client(
|
||||
dcmanager_url=None,
|
||||
username=None,
|
||||
api_key=None,
|
||||
project_name=None,
|
||||
auth_url=None,
|
||||
project_id=None,
|
||||
endpoint_type="publicURL",
|
||||
service_type="dcmanager",
|
||||
auth_token=None,
|
||||
user_id=None,
|
||||
cacert=None,
|
||||
insecure=False,
|
||||
profile=None,
|
||||
auth_type="keystone",
|
||||
client_id=None,
|
||||
client_secret=None,
|
||||
session=None,
|
||||
**kwargs
|
||||
):
|
||||
if dcmanager_url and not isinstance(dcmanager_url, six.string_types):
|
||||
raise RuntimeError('DC Manager url should be a string.')
|
||||
raise RuntimeError("DC Manager url should be a string.")
|
||||
|
||||
return client_v1.Client(
|
||||
dcmanager_url=dcmanager_url,
|
||||
|
@ -43,7 +43,6 @@ def log_request(func):
|
||||
|
||||
|
||||
class HTTPClient:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
base_url,
|
||||
|
@ -26,17 +26,18 @@ from dcmanagerclient.api.v1.alarm_manager import AlarmManager
|
||||
from dcmanagerclient.api.v1.fw_update_manager import FwUpdateManager
|
||||
from dcmanagerclient.api.v1.kube_rootca_update_manager import KubeRootcaUpdateManager
|
||||
from dcmanagerclient.api.v1.kube_upgrade_manager import KubeUpgradeManager
|
||||
from dcmanagerclient.api.v1.peer_group_association_manager import \
|
||||
PeerGroupAssociationManager
|
||||
from dcmanagerclient.api.v1.phased_subcloud_deploy_manager import \
|
||||
PhasedSubcloudDeployManager
|
||||
from dcmanagerclient.api.v1.peer_group_association_manager import (
|
||||
PeerGroupAssociationManager,
|
||||
)
|
||||
from dcmanagerclient.api.v1.phased_subcloud_deploy_manager import (
|
||||
PhasedSubcloudDeployManager,
|
||||
)
|
||||
from dcmanagerclient.api.v1.strategy_step_manager import StrategyStepManager
|
||||
from dcmanagerclient.api.v1.subcloud_backup_manager import SubcloudBackupManager
|
||||
from dcmanagerclient.api.v1.subcloud_deploy_manager import SubcloudDeployManager
|
||||
from dcmanagerclient.api.v1.subcloud_group_manager import SubcloudGroupManager
|
||||
from dcmanagerclient.api.v1.subcloud_manager import SubcloudManager
|
||||
from dcmanagerclient.api.v1.subcloud_peer_group_manager import \
|
||||
SubcloudPeerGroupManager
|
||||
from dcmanagerclient.api.v1.subcloud_peer_group_manager import SubcloudPeerGroupManager
|
||||
from dcmanagerclient.api.v1.sw_deploy_manager import SwDeployManager
|
||||
from dcmanagerclient.api.v1.sw_patch_manager import SwPatchManager
|
||||
from dcmanagerclient.api.v1.sw_prestage_manager import SwPrestageManager
|
||||
|
@ -20,6 +20,5 @@ SW_UPDATE_TYPE_FIRMWARE = "firmware"
|
||||
|
||||
|
||||
class FwUpdateManager(SwUpdateManager):
|
||||
|
||||
def __init__(self, http_client):
|
||||
super().__init__(http_client, update_type=SW_UPDATE_TYPE_FIRMWARE)
|
||||
|
@ -9,7 +9,6 @@ SW_UPDATE_TYPE_KUBE_ROOTCA_UPDATE = "kube-rootca-update"
|
||||
|
||||
|
||||
class KubeRootcaUpdateManager(SwUpdateManager):
|
||||
|
||||
def __init__(self, http_client):
|
||||
super().__init__(http_client, update_type=SW_UPDATE_TYPE_KUBE_ROOTCA_UPDATE)
|
||||
self.extra_args = ["subject", "expiry-date", "cert-file"]
|
||||
|
@ -20,7 +20,6 @@ SW_UPDATE_TYPE_KUBERNETES = "kubernetes"
|
||||
|
||||
|
||||
class KubeUpgradeManager(SwUpdateManager):
|
||||
|
||||
def __init__(self, http_client):
|
||||
super().__init__(http_client, update_type=SW_UPDATE_TYPE_KUBERNETES)
|
||||
self.extra_args = ["to-version"]
|
||||
|
@ -47,9 +47,7 @@ class PeerGroupAssociationManager(base.ResourceManager):
|
||||
|
||||
def _json_to_resource(self, json_object):
|
||||
sync_message = (
|
||||
None
|
||||
if "sync-message" not in json_object
|
||||
else json_object["sync-message"]
|
||||
None if "sync-message" not in json_object else json_object["sync-message"]
|
||||
)
|
||||
return self.resource_class(
|
||||
self,
|
||||
|
@ -45,7 +45,6 @@ class StrategyStep(base.Resource):
|
||||
|
||||
|
||||
class StrategyStepManager(base.ResourceManager):
|
||||
|
||||
def __init__(self, http_client):
|
||||
super().__init__(http_client)
|
||||
self.resource_class = StrategyStep
|
||||
|
@ -13,7 +13,6 @@ from dcmanagerclient.api.base import get_json
|
||||
|
||||
|
||||
class SubcloudBackupManager(base.ResourceManager):
|
||||
|
||||
resource_class = base.Subcloud
|
||||
|
||||
def json_to_resource(self, json_object):
|
||||
|
@ -19,7 +19,6 @@ SW_UPDATE_TYPE_PRESTAGE = "prestage"
|
||||
|
||||
|
||||
class SwPrestageManager(SwUpdateManager):
|
||||
|
||||
def __init__(self, http_client):
|
||||
super().__init__(
|
||||
http_client,
|
||||
|
@ -20,6 +20,5 @@ SW_UPDATE_TYPE_UPGRADE = "upgrade"
|
||||
|
||||
|
||||
class SwUpgradeManager(SwUpdateManager):
|
||||
|
||||
def __init__(self, http_client):
|
||||
super().__init__(http_client, update_type=SW_UPDATE_TYPE_UPGRADE)
|
||||
|
@ -72,9 +72,7 @@ class SystemPeerManager(base.ResourceManager):
|
||||
heartbeat_interval=json_object["heartbeat-interval"],
|
||||
heartbeat_failure_threshold=json_object["heartbeat-failure-threshold"],
|
||||
heartbeat_failure_policy=json_object["heartbeat-failure-policy"],
|
||||
heartbeat_maintenance_timeout=json_object[
|
||||
"heartbeat-maintenance-timeout"
|
||||
],
|
||||
heartbeat_maintenance_timeout=json_object["heartbeat-maintenance-timeout"],
|
||||
availability_state=json_object["availability-state"],
|
||||
created_at=json_object["created-at"],
|
||||
updated_at=json_object["updated-at"],
|
||||
|
@ -85,7 +85,6 @@ class DCManagerShowOne(command.ShowOne):
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class DCManagerShow(DCManagerLister, DCManagerShowOne):
|
||||
|
||||
@abc.abstractmethod
|
||||
def should_list(self, parsed_args):
|
||||
"""Uses Lister behaviour if True, ShowOne otherwise."""
|
||||
@ -102,7 +101,5 @@ class DCManagerShow(DCManagerLister, DCManagerShowOne):
|
||||
"""Overrides method from cliff.Lister/cliff.ShowOne."""
|
||||
|
||||
if self.should_list(parsed_args):
|
||||
return DCManagerLister.produce_output(
|
||||
self, parsed_args, column_names, data
|
||||
)
|
||||
return DCManagerLister.produce_output(self, parsed_args, column_names, data)
|
||||
return DCManagerShowOne.produce_output(self, parsed_args, column_names, data)
|
||||
|
@ -82,9 +82,7 @@ class AddPeerGroupAssociation(base.DCManagerShowOne):
|
||||
"--peer-group-id", required=True, help="Subcloud peer group ID."
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--system-peer-id", required=True, help="System Peer ID."
|
||||
)
|
||||
parser.add_argument("--system-peer-id", required=True, help="System Peer ID.")
|
||||
|
||||
parser.add_argument(
|
||||
"--peer-group-priority",
|
||||
@ -186,9 +184,7 @@ class DeletePeerGroupAssociation(command.Command):
|
||||
self.app.client_manager.peer_group_association_manager
|
||||
)
|
||||
try:
|
||||
peer_group_association_manager.delete_peer_group_association(
|
||||
parsed_args.id
|
||||
)
|
||||
peer_group_association_manager.delete_peer_group_association(parsed_args.id)
|
||||
except Exception as exc:
|
||||
print(exc)
|
||||
msg = f"Unable to delete peer group association {parsed_args.id}"
|
||||
|
@ -140,9 +140,7 @@ class PhasedSubcloudDeployResume(base.DCManagerShowOne):
|
||||
# Get the deploy config yaml file
|
||||
if parsed_args.deploy_config:
|
||||
if not os.path.isfile(parsed_args.deploy_config):
|
||||
error_msg = (
|
||||
f"deploy-config does not exist: {parsed_args.deploy_config}"
|
||||
)
|
||||
error_msg = f"deploy-config does not exist: {parsed_args.deploy_config}"
|
||||
raise exceptions.DCManagerClientException(error_msg)
|
||||
files["deploy_config"] = parsed_args.deploy_config
|
||||
|
||||
@ -243,9 +241,7 @@ class CreatePhasedSubcloudDeploy(base.DCManagerShowOne):
|
||||
# Get the deploy config yaml file
|
||||
if parsed_args.deploy_config:
|
||||
if not os.path.isfile(parsed_args.deploy_config):
|
||||
error_msg = (
|
||||
f"deploy-config does not exist: {parsed_args.deploy_config}"
|
||||
)
|
||||
error_msg = f"deploy-config does not exist: {parsed_args.deploy_config}"
|
||||
raise exceptions.DCManagerClientException(error_msg)
|
||||
files["deploy_config"] = parsed_args.deploy_config
|
||||
|
||||
@ -286,9 +282,7 @@ class InstallPhasedSubcloudDeploy(base.DCManagerShowOne):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
"subcloud", help="Name or ID of the subcloud to install."
|
||||
)
|
||||
parser.add_argument("subcloud", help="Name or ID of the subcloud to install.")
|
||||
|
||||
parser.add_argument(
|
||||
"--install-values",
|
||||
@ -369,9 +363,7 @@ class BootstrapPhasedSubcloudDeploy(base.DCManagerShowOne):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
"subcloud", help="Name or ID of the subcloud to bootstrap."
|
||||
)
|
||||
parser.add_argument("subcloud", help="Name or ID of the subcloud to bootstrap.")
|
||||
|
||||
parser.add_argument(
|
||||
"--bootstrap-address",
|
||||
@ -504,14 +496,10 @@ class CompletePhasedSubcloudDeploy(base.DCManagerShowOne):
|
||||
)
|
||||
|
||||
try:
|
||||
return phased_subcloud_deploy_manager.subcloud_deploy_complete(
|
||||
subcloud_ref
|
||||
)
|
||||
return phased_subcloud_deploy_manager.subcloud_deploy_complete(subcloud_ref)
|
||||
except Exception as exc:
|
||||
print(exc)
|
||||
error_msg = (
|
||||
f"Unable to complete the deployment of subcloud {subcloud_ref}"
|
||||
)
|
||||
error_msg = f"Unable to complete the deployment of subcloud {subcloud_ref}"
|
||||
raise exceptions.DCManagerClientException(error_msg)
|
||||
|
||||
|
||||
@ -524,22 +512,20 @@ class EnrollPhasedSubcloudDeploy(base.DCManagerShowOne):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
"subcloud", help="Name or ID of the subcloud to enroll."
|
||||
)
|
||||
parser.add_argument("subcloud", help="Name or ID of the subcloud to enroll.")
|
||||
|
||||
parser.add_argument(
|
||||
"--install-values",
|
||||
required=False,
|
||||
help="YAML file containing parameters required for the "
|
||||
"enrollment of the subcloud.",
|
||||
"enrollment of the subcloud.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--deploy-config",
|
||||
required=False,
|
||||
help="YAML file containing parameters required for the initial "
|
||||
"configuration and unlock of the subcloud.",
|
||||
"configuration and unlock of the subcloud.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
@ -552,7 +538,7 @@ class EnrollPhasedSubcloudDeploy(base.DCManagerShowOne):
|
||||
"--bootstrap-values",
|
||||
required=False,
|
||||
help="YAML file containing the parameters required for the "
|
||||
"subcloud enrollment.",
|
||||
"subcloud enrollment.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
|
@ -372,7 +372,6 @@ class RestoreSubcloudBackup(base.DCManagerShow):
|
||||
return parser
|
||||
|
||||
def _get_resources(self, parsed_args):
|
||||
|
||||
subcloud_backup_manager = self.app.client_manager.subcloud_backup_manager
|
||||
data = {}
|
||||
files = {}
|
||||
@ -402,9 +401,7 @@ class RestoreSubcloudBackup(base.DCManagerShow):
|
||||
raise exceptions.DCManagerClientException(error_msg)
|
||||
|
||||
if not parsed_args.with_install and parsed_args.release:
|
||||
error_msg = (
|
||||
"Option --release cannot be used without --with-install option."
|
||||
)
|
||||
error_msg = "Option --release cannot be used without --with-install option."
|
||||
raise exceptions.DCManagerClientException(error_msg)
|
||||
|
||||
if parsed_args.with_install:
|
||||
|
@ -68,34 +68,32 @@ class SubcloudDeployUpload(base.DCManagerShowOne):
|
||||
parser.add_argument(
|
||||
"--deploy-playbook",
|
||||
required=False,
|
||||
help="An ansible playbook to be run after the subcloud "
|
||||
"has been successfully bootstrapped. It will be run with the "
|
||||
"subcloud as the target and authentication is "
|
||||
"handled automatically. "
|
||||
"Must be a local file path",
|
||||
help=(
|
||||
"An ansible playbook to be run after the subcloud has been "
|
||||
"successfully bootstrapped. It will be run with the subcloud as the "
|
||||
"target and authentication is handled automatically. Must be a local "
|
||||
"file path."
|
||||
),
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--deploy-overrides",
|
||||
required=False,
|
||||
help="YAML file containing subcloud variables to be passed to the "
|
||||
"deploy playbook."
|
||||
"Must be a local file path",
|
||||
"deploy playbook. Must be a local file path",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--deploy-chart",
|
||||
required=False,
|
||||
help="Deployment Manager helm chart to be passed to the "
|
||||
"deploy playbook."
|
||||
"Must be a local file path",
|
||||
"deploy playbook. Must be a local file path",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--prestage-images",
|
||||
required=False,
|
||||
help="Container image list to be passed to "
|
||||
"prestage_images playbook. "
|
||||
help="Container image list to be passed to prestage_images playbook. "
|
||||
"Must be a local file path",
|
||||
)
|
||||
|
||||
@ -164,14 +162,13 @@ class SubcloudDeployShow(base.DCManagerShowOne):
|
||||
|
||||
|
||||
class DeprecatedSubcloudDeployShow(SubcloudDeployShow):
|
||||
DEPRECATION_MESSAGE = ("This command has been deprecated. Please use "
|
||||
"subcloud deploy show instead.")
|
||||
DEPRECATION_MESSAGE = (
|
||||
"This command has been deprecated. Please use subcloud deploy show instead."
|
||||
)
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument_group(
|
||||
title="Notice", description=self.DEPRECATION_MESSAGE
|
||||
)
|
||||
parser.add_argument_group(title="Notice", description=self.DEPRECATION_MESSAGE)
|
||||
return parser
|
||||
|
||||
def _get_resources(self, _):
|
||||
@ -179,14 +176,13 @@ class DeprecatedSubcloudDeployShow(SubcloudDeployShow):
|
||||
|
||||
|
||||
class DeprecatedSubcloudDeployUpload(SubcloudDeployUpload):
|
||||
DEPRECATION_MESSAGE = ("This command has been deprecated. Please use "
|
||||
"subcloud deploy upload instead.")
|
||||
DEPRECATION_MESSAGE = (
|
||||
"This command has been deprecated. Please use subcloud deploy upload instead."
|
||||
)
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument_group(
|
||||
title="Notice", description=self.DEPRECATION_MESSAGE
|
||||
)
|
||||
parser.add_argument_group(title="Notice", description=self.DEPRECATION_MESSAGE)
|
||||
return parser
|
||||
|
||||
def _get_resources(self, _):
|
||||
|
@ -192,9 +192,7 @@ class DeleteSubcloudGroup(command.Command):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
"group", help="Name or ID of the subcloud group to delete."
|
||||
)
|
||||
parser.add_argument("group", help="Name or ID of the subcloud group to delete.")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -217,9 +215,7 @@ class UpdateSubcloudGroup(base.DCManagerShowOne):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
"group", help="Name or ID of the subcloud group to update."
|
||||
)
|
||||
parser.add_argument("group", help="Name or ID of the subcloud group to update.")
|
||||
|
||||
parser.add_argument("--name", required=False, help="Name of subcloud group.")
|
||||
|
||||
|
@ -24,10 +24,7 @@ from dcmanagerclient import exceptions
|
||||
from dcmanagerclient import utils
|
||||
from dcmanagerclient.commands.v1 import base
|
||||
|
||||
SET_FIELD_VALUE_DICT = {
|
||||
"region_name": None,
|
||||
"info_message": None
|
||||
}
|
||||
SET_FIELD_VALUE_DICT = {"region_name": None, "info_message": None}
|
||||
|
||||
|
||||
def basic_format(subcloud=None):
|
||||
@ -304,9 +301,7 @@ class AddSubcloud(base.DCManagerShowOne):
|
||||
raise exceptions.DCManagerClientException(error_msg)
|
||||
|
||||
if not os.path.isfile(parsed_args.deploy_config):
|
||||
error_msg = (
|
||||
f"deploy-config does not exist: {parsed_args.deploy_config}"
|
||||
)
|
||||
error_msg = f"deploy-config does not exist: {parsed_args.deploy_config}"
|
||||
raise exceptions.DCManagerClientException(error_msg)
|
||||
files["deploy_config"] = parsed_args.deploy_config
|
||||
|
||||
@ -488,9 +483,7 @@ class UnmanageSubcloud(base.DCManagerShowOne):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
"subcloud", help="Name or ID of the subcloud to unmanage."
|
||||
)
|
||||
parser.add_argument("subcloud", help="Name or ID of the subcloud to unmanage.")
|
||||
|
||||
parser.add_argument(
|
||||
"--migrate",
|
||||
@ -564,6 +557,7 @@ class ManageSubcloud(base.DCManagerShowOne):
|
||||
|
||||
class UpdateSubcloud(base.DCManagerShowOne):
|
||||
"""Update attributes of a subcloud."""
|
||||
|
||||
_info_message = None
|
||||
|
||||
def produce_output(self, parsed_args, column_names, data):
|
||||
@ -590,9 +584,7 @@ class UpdateSubcloud(base.DCManagerShowOne):
|
||||
"--description", required=False, help="Description of subcloud."
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--location", required=False, help="Location of subcloud."
|
||||
)
|
||||
parser.add_argument("--location", required=False, help="Location of subcloud.")
|
||||
|
||||
parser.add_argument(
|
||||
"--group", required=False, help="Name or ID of subcloud group."
|
||||
@ -702,9 +694,7 @@ class UpdateSubcloud(base.DCManagerShowOne):
|
||||
)
|
||||
else:
|
||||
password = utils.prompt_for_password()
|
||||
data["sysadmin_password"] = base64.b64encode(
|
||||
password.encode("utf-8")
|
||||
)
|
||||
data["sysadmin_password"] = base64.b64encode(password.encode("utf-8"))
|
||||
# For subcloud network reconfiguration
|
||||
# If any management_* presents, need all
|
||||
# management_subnet/management_gateway_ip/
|
||||
@ -756,7 +746,7 @@ class UpdateSubcloud(base.DCManagerShowOne):
|
||||
result = subcloud_manager.update_subcloud(
|
||||
subcloud_ref, files=files, data=data
|
||||
)
|
||||
self._info_message = getattr(result[0], 'info_message')
|
||||
self._info_message = getattr(result[0], "info_message")
|
||||
update_fields_values(result)
|
||||
return result
|
||||
except Exception as exc:
|
||||
@ -768,17 +758,16 @@ class UpdateSubcloud(base.DCManagerShowOne):
|
||||
class ReconfigSubcloud(base.DCManagerShowOne):
|
||||
"""Reconfigure a subcloud."""
|
||||
|
||||
DEPRECATION_MESSAGE = ("This command has been deprecated. Please use "
|
||||
"'subcloud deploy config' instead.")
|
||||
DEPRECATION_MESSAGE = (
|
||||
"This command has been deprecated. Please use 'subcloud deploy config' instead."
|
||||
)
|
||||
|
||||
def _get_format_function(self):
|
||||
return detail_format
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument_group(
|
||||
title="Notice", description=self.DEPRECATION_MESSAGE
|
||||
)
|
||||
parser.add_argument_group(title="Notice", description=self.DEPRECATION_MESSAGE)
|
||||
return parser
|
||||
|
||||
def _get_resources(self, parsed_args):
|
||||
@ -788,17 +777,16 @@ class ReconfigSubcloud(base.DCManagerShowOne):
|
||||
class ReinstallSubcloud(base.DCManagerShowOne):
|
||||
"""Reinstall a subcloud."""
|
||||
|
||||
DEPRECATION_MESSAGE = ("This command has been deprecated. Please use "
|
||||
"'subcloud redeploy' instead.")
|
||||
DEPRECATION_MESSAGE = (
|
||||
"This command has been deprecated. Please use 'subcloud redeploy' instead."
|
||||
)
|
||||
|
||||
def _get_format_function(self):
|
||||
return detail_format
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument_group(
|
||||
title="Notice", description=self.DEPRECATION_MESSAGE
|
||||
)
|
||||
parser.add_argument_group(title="Notice", description=self.DEPRECATION_MESSAGE)
|
||||
return parser
|
||||
|
||||
def _get_resources(self, parsed_args):
|
||||
@ -814,9 +802,7 @@ class RedeploySubcloud(base.DCManagerShowOne):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
"subcloud", help="Name or ID of the subcloud to redeploy."
|
||||
)
|
||||
parser.add_argument("subcloud", help="Name or ID of the subcloud to redeploy.")
|
||||
|
||||
parser.add_argument(
|
||||
"--install-values",
|
||||
@ -891,9 +877,7 @@ class RedeploySubcloud(base.DCManagerShowOne):
|
||||
# Get the deploy config yaml file
|
||||
if parsed_args.deploy_config is not None:
|
||||
if not os.path.isfile(parsed_args.deploy_config):
|
||||
error_msg = (
|
||||
f"deploy-config does not exist: {parsed_args.deploy_config}"
|
||||
)
|
||||
error_msg = f"deploy-config does not exist: {parsed_args.deploy_config}"
|
||||
raise exceptions.DCManagerClientException(error_msg)
|
||||
files["deploy_config"] = parsed_args.deploy_config
|
||||
|
||||
@ -923,9 +907,7 @@ class RedeploySubcloud(base.DCManagerShowOne):
|
||||
"WARNING: This will redeploy the subcloud. "
|
||||
"All applications and data on the subcloud will be lost."
|
||||
)
|
||||
confirm = (
|
||||
six.moves.input('Please type "redeploy" to confirm: ').strip().lower()
|
||||
)
|
||||
confirm = six.moves.input('Please type "redeploy" to confirm: ').strip().lower()
|
||||
if confirm == "redeploy":
|
||||
try:
|
||||
return subcloud_manager.redeploy_subcloud(
|
||||
@ -943,17 +925,17 @@ class RedeploySubcloud(base.DCManagerShowOne):
|
||||
class RestoreSubcloud(base.DCManagerShowOne):
|
||||
"""Restore a subcloud."""
|
||||
|
||||
DEPRECATION_MESSAGE = ("This command has been deprecated. Please use "
|
||||
"subcloud-backup restore instead.")
|
||||
DEPRECATION_MESSAGE = (
|
||||
"This command has been deprecated. Please use "
|
||||
"subcloud-backup restore instead."
|
||||
)
|
||||
|
||||
def _get_format_function(self):
|
||||
return detail_format
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument_group(
|
||||
title="Notice", description=self.DEPRECATION_MESSAGE
|
||||
)
|
||||
parser.add_argument_group(title="Notice", description=self.DEPRECATION_MESSAGE)
|
||||
return parser
|
||||
|
||||
def _get_resources(self, parsed_args):
|
||||
@ -976,9 +958,7 @@ class PrestageSubcloud(base.DCManagerShowOne):
|
||||
"if not provided you will be prompted.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"subcloud", help="Name or ID of the subcloud to prestage."
|
||||
)
|
||||
parser.add_argument("subcloud", help="Name or ID of the subcloud to prestage.")
|
||||
|
||||
parser.add_argument(
|
||||
"--force",
|
||||
@ -1000,9 +980,7 @@ class PrestageSubcloud(base.DCManagerShowOne):
|
||||
"--for-install",
|
||||
required=False,
|
||||
action="store_true",
|
||||
help=(
|
||||
"Prestage for installation. This is the default prestaging option."
|
||||
),
|
||||
help=("Prestage for installation. This is the default prestaging option."),
|
||||
)
|
||||
# Prestaging for deployment means prestaging for upgrade
|
||||
# With USM there is no install phase for upgrades. This operation
|
||||
|
@ -218,8 +218,7 @@ class ListSubcloudPeerGroupSubclouds(base.DCManagerLister):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
"group",
|
||||
help="Name or ID of subcloud peer group to list "
|
||||
"associated subclouds.",
|
||||
help="Name or ID of subcloud peer group to list " "associated subclouds.",
|
||||
)
|
||||
return parser
|
||||
|
||||
|
@ -38,9 +38,7 @@ class SwPrestageManagerMixin:
|
||||
if prestage_software_version:
|
||||
# Insert the 'software version' field before the 'state',
|
||||
# 'created_at' and 'updated_at' fields if it's present
|
||||
columns = (
|
||||
columns[:-3] + ("prestage software version",) + columns[-3:]
|
||||
)
|
||||
columns = columns[:-3] + ("prestage software version",) + columns[-3:]
|
||||
data = data[:-3] + (prestage_software_version,) + data[-3:]
|
||||
|
||||
return columns, data
|
||||
@ -83,9 +81,7 @@ class CreateSwPrestageStrategy(
|
||||
"--for-install",
|
||||
required=False,
|
||||
action="store_true",
|
||||
help=(
|
||||
"Prestage for installation. This is the default prestaging option."
|
||||
),
|
||||
help=("Prestage for installation. This is the default prestaging option."),
|
||||
)
|
||||
# Prestaging for deployment means prestaging for upgrade
|
||||
# For this operation, there is NO INSTALL phase anymore with USM
|
||||
|
@ -180,9 +180,7 @@ class CreateSwUpdateStrategy(base.DCManagerShowOne):
|
||||
"""When specifying a group, other inputs are considered invalid"""
|
||||
if parsed_args.group:
|
||||
if parsed_args.cloud_name:
|
||||
error_msg = (
|
||||
"The cloud_name and group options are mutually exclusive."
|
||||
)
|
||||
error_msg = "The cloud_name and group options are mutually exclusive."
|
||||
raise exceptions.DCManagerClientException(error_msg)
|
||||
if parsed_args.subcloud_apply_type:
|
||||
error_msg = (
|
||||
|
@ -23,7 +23,6 @@ DEFAULT_REGION_NAME = "RegionOne"
|
||||
|
||||
|
||||
def options_detail_format(sw_update_options=None):
|
||||
|
||||
columns = (
|
||||
"cloud",
|
||||
"storage apply type",
|
||||
|
@ -162,16 +162,14 @@ class AddSystemPeer(base.DCManagerShowOne):
|
||||
"--heartbeat-interval",
|
||||
required=False,
|
||||
default=60,
|
||||
help="Interval between heartbeat messages (in seconds) (default \
|
||||
60).",
|
||||
help="Interval between heartbeat messages (in seconds) (default 60).",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--heartbeat-failure-threshold",
|
||||
required=False,
|
||||
default=3,
|
||||
help="Consecutive heartbeat failures before failure declared \
|
||||
(default 3).",
|
||||
help="Consecutive heartbeat failures before failure declared (default 3).",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
@ -186,8 +184,10 @@ class AddSystemPeer(base.DCManagerShowOne):
|
||||
"--heartbeat-maintenance-timeout",
|
||||
required=False,
|
||||
default=600,
|
||||
help="Overall failure timeout during maintenance state (in \
|
||||
seconds) (default 600).",
|
||||
help=(
|
||||
"Overall failure timeout during maintenance state (in seconds) "
|
||||
"(default 600)."
|
||||
),
|
||||
)
|
||||
return parser
|
||||
|
||||
@ -272,8 +272,8 @@ class ListSystemPeerSubcloudPeerGroups(base.DCManagerLister):
|
||||
parser.add_argument(
|
||||
"peer",
|
||||
help=(
|
||||
"Name or ID or UUID of system peer to list "
|
||||
"associated subcloud peer groups."
|
||||
"Name or ID or UUID of system peer to list associated subcloud peer "
|
||||
"groups."
|
||||
),
|
||||
)
|
||||
return parser
|
||||
@ -380,16 +380,13 @@ class UpdateSystemPeer(base.DCManagerShowOne):
|
||||
parser.add_argument(
|
||||
"--heartbeat-interval",
|
||||
required=False,
|
||||
help=("Interval between heartbeat messages (in seconds) (default 60)."),
|
||||
help="Interval between heartbeat messages (in seconds) (default 60).",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--heartbeat-failure-threshold",
|
||||
required=False,
|
||||
help=(
|
||||
"Consecutive heartbeat failures before failure declared "
|
||||
"(default 3)."
|
||||
),
|
||||
help="Consecutive heartbeat failures before failure declared (default 3).",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2017, 2019, 2021 Wind River Systems, Inc.
|
||||
# Copyright (c) 2017, 2019, 2021, 2024 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.
|
||||
@ -21,31 +21,26 @@ from osc_lib import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_DCMANAGER_API_VERSION = '1'
|
||||
API_VERSION_OPTION = 'os_dcmanager_api_version'
|
||||
API_NAME = 'dcmanager'
|
||||
DEFAULT_DCMANAGER_API_VERSION = "1"
|
||||
API_VERSION_OPTION = "os_dcmanager_api_version"
|
||||
API_NAME = "dcmanager"
|
||||
API_VERSIONS = {
|
||||
'1': 'dcmanagerclient.api.v1.client.Client',
|
||||
"1": "dcmanagerclient.api.v1.client.Client",
|
||||
}
|
||||
|
||||
|
||||
def make_client(instance):
|
||||
"""Return a dcmanager client."""
|
||||
version = instance._api_version[API_NAME]
|
||||
dcmanager_client = utils.get_client_class(
|
||||
API_NAME,
|
||||
version,
|
||||
API_VERSIONS)
|
||||
dcmanager_client = utils.get_client_class(API_NAME, version, API_VERSIONS)
|
||||
|
||||
LOG.debug('Instantiating dcmanager client: %s', dcmanager_client)
|
||||
LOG.debug("Instantiating dcmanager client: %s", dcmanager_client)
|
||||
|
||||
dcmanager_url = instance.get_endpoint_for_service_type(
|
||||
'dcmanager',
|
||||
interface='publicURL'
|
||||
"dcmanager", interface="publicURL"
|
||||
)
|
||||
|
||||
client = dcmanager_client(dcmanager_url=dcmanager_url,
|
||||
session=instance.session)
|
||||
client = dcmanager_client(dcmanager_url=dcmanager_url, session=instance.session)
|
||||
|
||||
return client
|
||||
|
||||
@ -53,13 +48,14 @@ def make_client(instance):
|
||||
def build_option_parser(parser):
|
||||
"""Hook to add global options."""
|
||||
parser.add_argument(
|
||||
'--os-dcmanager-api-version',
|
||||
metavar='<dcmanager-api-version>',
|
||||
"--os-dcmanager-api-version",
|
||||
metavar="<dcmanager-api-version>",
|
||||
default=utils.env(
|
||||
'OS_DCMANAGER_API_VERSION',
|
||||
default=DEFAULT_DCMANAGER_API_VERSION),
|
||||
help='DCMANAGER API version, default=' +
|
||||
DEFAULT_DCMANAGER_API_VERSION +
|
||||
' (Env: OS_DCMANAGER_API_VERSION)')
|
||||
"OS_DCMANAGER_API_VERSION", default=DEFAULT_DCMANAGER_API_VERSION
|
||||
),
|
||||
help="DCMANAGER API version, default="
|
||||
+ DEFAULT_DCMANAGER_API_VERSION
|
||||
+ " (Env: OS_DCMANAGER_API_VERSION)",
|
||||
)
|
||||
|
||||
return parser
|
||||
|
@ -23,7 +23,8 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from cliff import app, commandmanager
|
||||
from cliff import app
|
||||
from cliff import commandmanager
|
||||
from cliff import help as cliff_help
|
||||
from osc_lib.command import command
|
||||
|
||||
@ -146,7 +147,6 @@ class BashCompletionCommand(command.Command):
|
||||
|
||||
|
||||
class DCManagerShell(app.App):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
description=__doc__.strip(),
|
||||
|
@ -201,12 +201,10 @@ DEPLOY_STATUS_IDX = SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID.index(DEPLOY_STATUS)
|
||||
SUBCLOUD_ALL_FIELDS_RESULT_LIST = (
|
||||
SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID[: DEPLOY_STATUS_IDX + 1]
|
||||
+ (SYNC,)
|
||||
+ SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID[DEPLOY_STATUS_IDX + 1:]
|
||||
+ SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID[DEPLOY_STATUS_IDX + 1 :]
|
||||
)
|
||||
|
||||
EMPTY_SUBCLOUD_ALL_FIELDS_RESULT = (
|
||||
("<none>",) * len(SUBCLOUD_ALL_FIELDS_RESULT_LIST),
|
||||
)
|
||||
EMPTY_SUBCLOUD_ALL_FIELDS_RESULT = (("<none>",) * len(SUBCLOUD_ALL_FIELDS_RESULT_LIST),)
|
||||
|
||||
# Subcloud result values returned from subcloud list command
|
||||
SUBCLOUD_LIST_RESULT = (
|
||||
|
@ -25,7 +25,6 @@ from dcmanagerclient import shell
|
||||
|
||||
|
||||
class BaseShellTests(testtools.TestCase):
|
||||
|
||||
def shell(self, argstr):
|
||||
orig = (sys.stdout, sys.stderr)
|
||||
clean_env = {}
|
||||
|
@ -48,9 +48,7 @@ class BaseClientTests(testtools.TestCase):
|
||||
project_id = keystone_session_instance.get_project_id.return_value = str(
|
||||
uuid.uuid4()
|
||||
)
|
||||
user_id = keystone_session_instance.get_user_id.return_value = str(
|
||||
uuid.uuid4()
|
||||
)
|
||||
user_id = keystone_session_instance.get_user_id.return_value = str(uuid.uuid4())
|
||||
keystone_session_instance.get_endpoint.return_value = DCMANAGER_HTTP_URL
|
||||
|
||||
expected_args = (DCMANAGER_HTTP_URL, token, project_id, user_id)
|
||||
@ -78,9 +76,7 @@ class BaseClientTests(testtools.TestCase):
|
||||
project_id = keystone_session_instance.get_project_id.return_value = str(
|
||||
uuid.uuid4()
|
||||
)
|
||||
user_id = keystone_session_instance.get_user_id.return_value = str(
|
||||
uuid.uuid4()
|
||||
)
|
||||
user_id = keystone_session_instance.get_user_id.return_value = str(uuid.uuid4())
|
||||
keystone_session_instance.get_endpoint.return_value = DCMANAGER_HTTP_URL
|
||||
|
||||
expected_args = (DCMANAGER_HTTPS_URL, token, project_id, user_id)
|
||||
@ -104,18 +100,14 @@ class BaseClientTests(testtools.TestCase):
|
||||
|
||||
@mock.patch("keystoneauth1.session.Session")
|
||||
@mock.patch("dcmanagerclient.api.httpclient.HTTPClient")
|
||||
def test_dcmanager_url_https_secure(
|
||||
self, mock_client, mock_keystone_auth_session
|
||||
):
|
||||
def test_dcmanager_url_https_secure(self, mock_client, mock_keystone_auth_session):
|
||||
fd, path = tempfile.mkstemp(suffix=".pem")
|
||||
keystone_session_instance = mock_keystone_auth_session.return_value
|
||||
token = keystone_session_instance.get_token.return_value = str(uuid.uuid4())
|
||||
project_id = keystone_session_instance.get_project_id.return_value = str(
|
||||
uuid.uuid4()
|
||||
)
|
||||
user_id = keystone_session_instance.get_user_id.return_value = str(
|
||||
uuid.uuid4()
|
||||
)
|
||||
user_id = keystone_session_instance.get_user_id.return_value = str(uuid.uuid4())
|
||||
keystone_session_instance.get_endpoint.return_value = DCMANAGER_HTTPS_URL
|
||||
|
||||
expected_args = (DCMANAGER_HTTPS_URL, token, project_id, user_id)
|
||||
@ -182,17 +174,13 @@ class BaseClientTests(testtools.TestCase):
|
||||
|
||||
@mock.patch("keystoneauth1.session.Session")
|
||||
@mock.patch("dcmanagerclient.api.httpclient.HTTPClient")
|
||||
def test_dcmanager_profile_enabled(
|
||||
self, mock_client, mock_keystone_auth_session
|
||||
):
|
||||
def test_dcmanager_profile_enabled(self, mock_client, mock_keystone_auth_session):
|
||||
keystone_session_instance = mock_keystone_auth_session.return_value
|
||||
token = keystone_session_instance.get_token.return_value = str(uuid.uuid4())
|
||||
project_id = keystone_session_instance.get_project_id.return_value = str(
|
||||
uuid.uuid4()
|
||||
)
|
||||
user_id = keystone_session_instance.get_user_id.return_value = str(
|
||||
uuid.uuid4()
|
||||
)
|
||||
user_id = keystone_session_instance.get_user_id.return_value = str(uuid.uuid4())
|
||||
keystone_session_instance.get_endpoint.return_value = DCMANAGER_HTTP_URL
|
||||
|
||||
expected_args = (DCMANAGER_HTTP_URL, token, project_id, user_id)
|
||||
|
@ -19,7 +19,6 @@ from dcmanagerclient.tests import base_shell_test as base
|
||||
|
||||
|
||||
class TestShell(base.BaseShellTests):
|
||||
|
||||
@mock.patch("dcmanagerclient.api.client.determine_client_version")
|
||||
def test_dcmanager_version(self, mock_client_version):
|
||||
self.shell("--os-dcmanager-version=v1 quota-defaults")
|
||||
|
@ -27,7 +27,6 @@ ENV_YAML = yaml.safe_dump(ENV_DICT, default_flow_style=False)
|
||||
|
||||
|
||||
class UtilityTest(testtools.TestCase):
|
||||
|
||||
def test_load_empty(self):
|
||||
self.assertDictEqual({}, utils.load_content(None))
|
||||
self.assertDictEqual({}, utils.load_content(""))
|
||||
|
@ -28,7 +28,6 @@ ALARM_SUMMARY = AlarmSummary(
|
||||
|
||||
|
||||
class TestCLIAlarmSummaryV1(base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
# The client is the alarm_manager
|
||||
|
@ -10,7 +10,6 @@ from dcmanagerclient.tests.v1.mixins import UpdateStrategyMixin
|
||||
|
||||
|
||||
class TestFwUpdateStrategy(UpdateStrategyMixin, base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.sw_update_manager = self.app.client_manager.fw_update_manager
|
||||
|
@ -10,7 +10,6 @@ from dcmanagerclient.tests.v1.mixins import UpdateStrategyMixin
|
||||
|
||||
|
||||
class TestKubeRootcaUpdateStrategy(UpdateStrategyMixin, base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.sw_update_manager = self.app.client_manager.kube_rootca_update_manager
|
||||
|
@ -10,7 +10,6 @@ from dcmanagerclient.tests.v1.mixins import UpdateStrategyMixin
|
||||
|
||||
|
||||
class TestKubeUpgradeStrategy(UpdateStrategyMixin, base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.sw_update_manager = self.app.client_manager.kube_upgrade_manager
|
||||
|
@ -12,7 +12,6 @@ from dcmanagerclient.tests.v1.mixins import UpdateStrategyMixin
|
||||
|
||||
|
||||
class TestPatchUpdateStrategy(UpdateStrategyMixin, base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@ -35,9 +34,7 @@ class TestPatchUpdateStrategy(UpdateStrategyMixin, base.BaseCommandTest):
|
||||
|
||||
# mock the result of the API call
|
||||
strategy = utils.make_strategy(
|
||||
strategy_type=self.expected_strategy_type, extra_args={
|
||||
"upload-only": True
|
||||
}
|
||||
strategy_type=self.expected_strategy_type, extra_args={"upload-only": True}
|
||||
)
|
||||
|
||||
# mock that there is no pre-existing strategy
|
||||
|
@ -77,9 +77,7 @@ class TestCLIPeerGroupAssociationV1(base.BaseCommandTest):
|
||||
self.client = self.app.client_manager.peer_group_association_manager
|
||||
|
||||
def test_list_peer_group_association(self):
|
||||
self.client.list_peer_group_associations.return_value = [
|
||||
PEER_GROUP_ASSOCIATION
|
||||
]
|
||||
self.client.list_peer_group_associations.return_value = [PEER_GROUP_ASSOCIATION]
|
||||
actual_call = self.call(peer_group_association_cmd.ListPeerGroupAssociation)
|
||||
self.assertEqual([PEER_GROUP_ASSOCIATION_TUPLE], actual_call[1])
|
||||
|
||||
@ -92,9 +90,7 @@ class TestCLIPeerGroupAssociationV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
def test_add_peer_group_association(self):
|
||||
self.client.add_peer_group_association.return_value = [
|
||||
PEER_GROUP_ASSOCIATION
|
||||
]
|
||||
self.client.add_peer_group_association.return_value = [PEER_GROUP_ASSOCIATION]
|
||||
actual_call = self.call(
|
||||
peer_group_association_cmd.AddPeerGroupAssociation,
|
||||
app_args=[
|
||||
@ -159,9 +155,7 @@ class TestCLIPeerGroupAssociationV1(base.BaseCommandTest):
|
||||
|
||||
def test_update_peer_group_association(self):
|
||||
updated_peed_group_association = copy.copy(PEER_GROUP_ASSOCIATION)
|
||||
updated_peed_group_association.peer_group_priority = (
|
||||
PG_GROUP_PRIORITY_UPDATED
|
||||
)
|
||||
updated_peed_group_association.peer_group_priority = PG_GROUP_PRIORITY_UPDATED
|
||||
self.client.update_peer_group_association.return_value = [
|
||||
updated_peed_group_association
|
||||
]
|
||||
@ -187,9 +181,7 @@ class TestCLIPeerGroupAssociationV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
def test_sync_peer_group_association(self):
|
||||
self.client.sync_peer_group_association.return_value = [
|
||||
PEER_GROUP_ASSOCIATION
|
||||
]
|
||||
self.client.sync_peer_group_association.return_value = [PEER_GROUP_ASSOCIATION]
|
||||
actual_call = self.call(
|
||||
peer_group_association_cmd.SyncPeerGroupAssociation,
|
||||
app_args=[PEER_GROUP_ASSOCIATION_ID],
|
||||
|
@ -17,7 +17,6 @@ from dcmanagerclient.tests import base
|
||||
|
||||
@mock.patch("getpass.getpass", new=mock.Mock(return_value="testpassword"))
|
||||
class TestCLIPhasedSubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
# The client is the subcloud_deploy_manager
|
||||
@ -33,7 +32,6 @@ class TestCLIPhasedSubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
) as config_file, tempfile.NamedTemporaryFile(
|
||||
mode="w"
|
||||
) as install_file:
|
||||
|
||||
bootstrap_file_path = os.path.abspath(bootstrap_file.name)
|
||||
config_file_path = os.path.abspath(config_file.name)
|
||||
install_file_path = os.path.abspath(install_file.name)
|
||||
@ -110,9 +108,7 @@ class TestCLIPhasedSubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
def test_install_subcloud_without_install_values(self):
|
||||
self.client.subcloud_deploy_install.return_value = [base.SUBCLOUD_RESOURCE]
|
||||
|
||||
actual_call = self.call(
|
||||
cmd.InstallPhasedSubcloudDeploy, app_args=[base.NAME]
|
||||
)
|
||||
actual_call = self.call(cmd.InstallPhasedSubcloudDeploy, app_args=[base.NAME])
|
||||
|
||||
self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID, actual_call[1])
|
||||
|
||||
@ -156,9 +152,7 @@ class TestCLIPhasedSubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
|
||||
def test_complete_subcloud_deployment(self):
|
||||
self.client.subcloud_deploy_complete.return_value = [base.SUBCLOUD_RESOURCE]
|
||||
actual_call = self.call(
|
||||
cmd.CompletePhasedSubcloudDeploy, app_args=[base.NAME]
|
||||
)
|
||||
actual_call = self.call(cmd.CompletePhasedSubcloudDeploy, app_args=[base.NAME])
|
||||
self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID, actual_call[1])
|
||||
|
||||
def test_abort_subcloud(self):
|
||||
@ -176,7 +170,6 @@ class TestCLIPhasedSubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
) as config_file, tempfile.NamedTemporaryFile(
|
||||
mode="w"
|
||||
) as install_file:
|
||||
|
||||
bootstrap_file_path = os.path.abspath(bootstrap_file.name)
|
||||
config_file_path = os.path.abspath(config_file.name)
|
||||
install_file_path = os.path.abspath(install_file.name)
|
||||
@ -209,7 +202,6 @@ class TestCLIPhasedSubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
) as config_file, tempfile.NamedTemporaryFile(
|
||||
mode="w"
|
||||
) as install_file:
|
||||
|
||||
bootstrap_file_path = os.path.abspath(bootstrap_file.name)
|
||||
config_file_path = os.path.abspath(config_file.name)
|
||||
install_file_path = os.path.abspath(install_file.name)
|
||||
@ -276,7 +268,7 @@ class TestCLIPhasedSubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
self.client.subcloud_deploy_enroll.return_value = [base.SUBCLOUD_RESOURCE]
|
||||
|
||||
with tempfile.NamedTemporaryFile(
|
||||
mode="w"
|
||||
mode="w"
|
||||
) as bootstrap_file, tempfile.NamedTemporaryFile(
|
||||
mode="w"
|
||||
) as config_file, tempfile.NamedTemporaryFile(
|
||||
@ -297,7 +289,7 @@ class TestCLIPhasedSubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
"--install-values",
|
||||
install_file_path,
|
||||
"--deploy-config",
|
||||
config_file_path
|
||||
config_file_path,
|
||||
],
|
||||
)
|
||||
self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID, actual_call[1])
|
||||
@ -307,9 +299,7 @@ class TestCLIPhasedSubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
|
||||
actual_call = self.call(
|
||||
cmd.EnrollPhasedSubcloudDeploy,
|
||||
app_args=[
|
||||
base.NAME
|
||||
],
|
||||
app_args=[base.NAME],
|
||||
)
|
||||
self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID, actual_call[1])
|
||||
|
||||
@ -318,10 +308,7 @@ class TestCLIPhasedSubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
|
||||
self.assertRaises(
|
||||
DCManagerClientException,
|
||||
self.call, cmd.EnrollPhasedSubcloudDeploy,
|
||||
app_args=[
|
||||
base.ID,
|
||||
"--bootstrap-values",
|
||||
"missing_path"
|
||||
]
|
||||
self.call,
|
||||
cmd.EnrollPhasedSubcloudDeploy,
|
||||
app_args=[base.ID, "--bootstrap-values", "missing_path"],
|
||||
)
|
||||
|
@ -33,7 +33,6 @@ TEST_UPDATED_AT = TIME_NOW
|
||||
|
||||
|
||||
class TestCLI(base.BaseCommandTest):
|
||||
|
||||
def test_list_strategy_steps(self):
|
||||
sample_step = StrategyStep(
|
||||
mock,
|
||||
|
@ -23,13 +23,11 @@ OVERRIDE_VALUES = """---
|
||||
|
||||
|
||||
class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.client = self.app.client_manager.subcloud_backup_manager
|
||||
|
||||
def test_backup_create_subcloud(self):
|
||||
|
||||
self.client.backup_subcloud_create.return_value = [base.SUBCLOUD_RESOURCE]
|
||||
|
||||
backup_path = os.path.normpath(os.path.join(os.getcwd(), "test.yaml"))
|
||||
@ -52,7 +50,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST, actual_call[1])
|
||||
|
||||
def test_backup_create_group(self):
|
||||
|
||||
self.client.backup_subcloud_create.return_value = [base.SUBCLOUD_RESOURCE]
|
||||
|
||||
backup_path = os.path.normpath(os.path.join(os.getcwd(), "test.yaml"))
|
||||
@ -97,8 +94,8 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
self.assertTrue(
|
||||
(
|
||||
"The command only applies to a single subcloud or a"
|
||||
" subcloud group, not both."
|
||||
"The command only applies to a single subcloud or a subcloud group, "
|
||||
"not both."
|
||||
)
|
||||
in str(e)
|
||||
)
|
||||
@ -124,8 +121,7 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
self.assertTrue(
|
||||
("Please provide the subcloud or subcloud group name" " or id.")
|
||||
in str(e)
|
||||
("Please provide the subcloud or subcloud group name or id.") in str(e)
|
||||
)
|
||||
|
||||
def test_backup_create_backup_value_not_a_file(self):
|
||||
@ -150,7 +146,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
|
||||
@mock.patch("getpass.getpass", return_value="testpassword")
|
||||
def test_backup_create_prompt_ask_for_password(self, _mock_getpass):
|
||||
|
||||
self.client.backup_subcloud_create.return_value = [base.SUBCLOUD_RESOURCE]
|
||||
|
||||
backup_path = os.path.normpath(os.path.join(os.getcwd(), "test.yaml"))
|
||||
@ -170,7 +165,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
self.assertEqual([base.SUBCLOUD_FIELD_RESULT_LIST], actual_call[1])
|
||||
|
||||
def test_backup_create_local_only_registry_images(self):
|
||||
|
||||
self.client.subcloud_backup_manager.backup_subcloud_create.return_value = []
|
||||
|
||||
e = self.assertRaises(
|
||||
@ -189,10 +183,7 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
self.assertTrue(
|
||||
(
|
||||
"Option --registry-images can not be used without "
|
||||
"--local-only option."
|
||||
)
|
||||
("Option --registry-images can not be used without --local-only option.")
|
||||
in str(e)
|
||||
)
|
||||
|
||||
@ -212,8 +203,7 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
self.assertTrue(
|
||||
("Please provide the subcloud or subcloud group" " name or id.")
|
||||
in str(e)
|
||||
("Please provide the subcloud or subcloud group name or id.") in str(e)
|
||||
)
|
||||
|
||||
def test_backup_delete_group_subcloud(self):
|
||||
@ -237,14 +227,13 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
|
||||
self.assertTrue(
|
||||
(
|
||||
"This command only applies to a single subcloud "
|
||||
"or a subcloud group, not both."
|
||||
"This command only applies to a single subcloud or a subcloud group, "
|
||||
"not both."
|
||||
)
|
||||
in str(e)
|
||||
)
|
||||
|
||||
def test_backup_delete_group(self):
|
||||
|
||||
group_name = "test_group_1"
|
||||
release_version = "release_version_2"
|
||||
password = "testpassword"
|
||||
@ -273,7 +262,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
def test_backup_delete_subcloud(self):
|
||||
|
||||
subcloud_name = "subcloud1"
|
||||
release_version = "release_version_2"
|
||||
password = "testpassword"
|
||||
@ -302,7 +290,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
def test_backup_delete_no_local_only(self):
|
||||
|
||||
group_name = "test_group_1"
|
||||
release_version = "release_version_2"
|
||||
password = "testpassword"
|
||||
@ -331,7 +318,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
|
||||
@mock.patch("getpass.getpass", return_value="testpassword")
|
||||
def test_backup_delete_prompt_ask_for_password(self, _mock_getpass):
|
||||
|
||||
group_name = "test_group_1"
|
||||
release_version = "release_version_2"
|
||||
password = "testpassword"
|
||||
@ -353,7 +339,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
def test_backup_delete_subcloud_no_release_version(self):
|
||||
|
||||
subcloud_name = "subcloud1"
|
||||
password = "testpassword"
|
||||
|
||||
@ -373,7 +358,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
def test_backup_restore(self):
|
||||
|
||||
self.client.backup_subcloud_restore.return_value = [base.SUBCLOUD_RESOURCE]
|
||||
|
||||
backup_path = os.path.normpath(os.path.join(os.getcwd(), "test.yaml"))
|
||||
@ -397,7 +381,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST, actual_call[1])
|
||||
|
||||
def test_backup_restore_no_restore_values(self):
|
||||
|
||||
self.client.backup_subcloud_restore.return_value = [base.SUBCLOUD_RESOURCE]
|
||||
|
||||
actual_call = self.call(
|
||||
@ -414,7 +397,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST, actual_call[1])
|
||||
|
||||
def test_backup_restore_with_group(self):
|
||||
|
||||
self.client.backup_subcloud_restore.return_value = [base.SUBCLOUD_RESOURCE]
|
||||
|
||||
backup_path = os.path.normpath(os.path.join(os.getcwd(), "test.yaml"))
|
||||
@ -461,8 +443,8 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
self.assertTrue(
|
||||
(
|
||||
"The command only applies to a single subcloud or a"
|
||||
" subcloud group, not both."
|
||||
"The command only applies to a single subcloud or a subcloud group, "
|
||||
"not both."
|
||||
)
|
||||
in str(e)
|
||||
)
|
||||
@ -489,8 +471,7 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
self.assertTrue(
|
||||
("Please provide the subcloud or subcloud group name" " or id.")
|
||||
in str(e)
|
||||
("Please provide the subcloud or subcloud group name or id.") in str(e)
|
||||
)
|
||||
|
||||
def test_backup_restore_backup_value_not_a_file(self):
|
||||
@ -515,7 +496,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
|
||||
@mock.patch("getpass.getpass", return_value="testpassword")
|
||||
def test_backup_restore_prompt_ask_for_password(self, _mock_getpass):
|
||||
|
||||
self.client.backup_subcloud_restore.return_value = [base.SUBCLOUD_RESOURCE]
|
||||
|
||||
backup_path = os.path.normpath(os.path.join(os.getcwd(), "test.yaml"))
|
||||
@ -536,7 +516,6 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
self.assertEqual([base.SUBCLOUD_FIELD_RESULT_LIST], actual_call[1])
|
||||
|
||||
def test_backup_restore_local_only_registry_images(self):
|
||||
|
||||
e = self.assertRaises(
|
||||
DCManagerClientException,
|
||||
self.call,
|
||||
@ -553,10 +532,7 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
self.assertTrue(
|
||||
(
|
||||
"Option --registry-images cannot be used without "
|
||||
"--local-only option."
|
||||
)
|
||||
("Option --registry-images cannot be used without --local-only option.")
|
||||
in str(e)
|
||||
)
|
||||
|
||||
@ -636,6 +612,5 @@ class TestCLISubcloudBackUpManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
self.assertTrue(
|
||||
("Option --release cannot be used without " "--with-install option.")
|
||||
in str(e)
|
||||
("Option --release cannot be used without --with-install option.") in str(e)
|
||||
)
|
||||
|
@ -76,7 +76,6 @@ SUBCLOUD_DEPLOY_NO_OVERRIDES_CHART = sdm.SubcloudDeploy(
|
||||
|
||||
|
||||
class TestCLISubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
# The client is the subcloud_deploy_manager
|
||||
@ -155,9 +154,7 @@ class TestCLISubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
def test_subcloud_deploy_upload_no_prestage(self):
|
||||
self.client.subcloud_deploy_upload.return_value = [
|
||||
SUBCLOUD_DEPLOY_NO_PRESTAGE
|
||||
]
|
||||
self.client.subcloud_deploy_upload.return_value = [SUBCLOUD_DEPLOY_NO_PRESTAGE]
|
||||
|
||||
f1 = tempfile.NamedTemporaryFile()
|
||||
f2 = tempfile.NamedTemporaryFile()
|
||||
@ -205,9 +202,7 @@ class TestCLISubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
def test_subcloud_deploy_upload_no_playbook(self):
|
||||
self.client.subcloud_deploy_upload.return_value = [
|
||||
SUBCLOUD_DEPLOY_NO_PLAYBOOK
|
||||
]
|
||||
self.client.subcloud_deploy_upload.return_value = [SUBCLOUD_DEPLOY_NO_PLAYBOOK]
|
||||
|
||||
f1 = tempfile.NamedTemporaryFile()
|
||||
f2 = tempfile.NamedTemporaryFile()
|
||||
@ -305,9 +300,7 @@ class TestCLISubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
|
||||
@mock.patch("builtins.print")
|
||||
def test_subcloud_deploy_upload_invalid_path(self, mock_print):
|
||||
self.client.subcloud_deploy_upload.return_value = [
|
||||
SUBCLOUD_DEPLOY_NO_PRESTAGE
|
||||
]
|
||||
self.client.subcloud_deploy_upload.return_value = [SUBCLOUD_DEPLOY_NO_PRESTAGE]
|
||||
mock_print.return_value = mock.ANY
|
||||
file_path_1 = "not_a_valid_path"
|
||||
|
||||
@ -337,7 +330,6 @@ class TestCLISubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
def test_subcloud_deploy_delete_with_release(self):
|
||||
|
||||
release_version = base.SOFTWARE_VERSION
|
||||
data = {"prestage_images": "False", "deployment_files": "False"}
|
||||
app_args = ["--release", release_version]
|
||||
@ -349,7 +341,6 @@ class TestCLISubcloudDeployManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
def test_subcloud_deploy_delete_without_release(self):
|
||||
|
||||
self.call(subcloud_deploy_manager.SubcloudDeployDelete)
|
||||
data = {"prestage_images": "False", "deployment_files": "False"}
|
||||
self.client.subcloud_deploy_delete.assert_called_once_with(None, data=data)
|
||||
|
@ -54,7 +54,6 @@ SUBCLOUD_GROUP = zm.SubcloudGroup(
|
||||
|
||||
|
||||
class TestCLISubcloudGroupManagerV1(base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
# The client is the subcloud_group_manager
|
||||
@ -78,9 +77,7 @@ class TestCLISubcloudGroupManagerV1(base.BaseCommandTest):
|
||||
subcloud_group_cmd.ListSubcloudGroupSubclouds, app_args=[ID]
|
||||
)
|
||||
self.client.subcloud_group_list_subclouds.assert_called_once_with(ID)
|
||||
self.assertEqual(
|
||||
[base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID], actual_call[1]
|
||||
)
|
||||
self.assertEqual([base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID], actual_call[1])
|
||||
|
||||
def test_delete_subcloud_group_by_id(self):
|
||||
self.call(subcloud_group_cmd.DeleteSubcloudGroup, app_args=[ID])
|
||||
|
@ -27,7 +27,6 @@ from dcmanagerclient.tests import base
|
||||
|
||||
|
||||
class TestCLISubcloudManagerV1(base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.subcloud_resource = copy.copy(base.SUBCLOUD_RESOURCE)
|
||||
@ -159,12 +158,8 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest):
|
||||
base.SOFTWARE_VERSION,
|
||||
],
|
||||
)
|
||||
self.assertEqual(
|
||||
base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID, actual_call1[1]
|
||||
)
|
||||
self.assertEqual(
|
||||
base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID, actual_call2[1]
|
||||
)
|
||||
self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID, actual_call1[1])
|
||||
self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID, actual_call2[1])
|
||||
|
||||
@mock.patch("getpass.getpass", return_value="testpassword")
|
||||
def test_add_migrate_subcloud(self, _mock_getpass):
|
||||
@ -281,16 +276,14 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest):
|
||||
"--bootstrap-values",
|
||||
file_path,
|
||||
"--enroll",
|
||||
"--migrate"
|
||||
]
|
||||
"--migrate",
|
||||
],
|
||||
)
|
||||
|
||||
def test_rename_subcloud(self):
|
||||
subcloud_renamed = copy.copy(base.SUBCLOUD_RESOURCE_WITH_PEERID)
|
||||
subcloud_renamed.name = base.NAME_SC2
|
||||
self.client.subcloud_manager.update_subcloud.return_value = [
|
||||
subcloud_renamed
|
||||
]
|
||||
self.client.subcloud_manager.update_subcloud.return_value = [subcloud_renamed]
|
||||
|
||||
# Rename by id
|
||||
actual_call1 = self.call(
|
||||
@ -407,7 +400,6 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest):
|
||||
) as config_file, tempfile.NamedTemporaryFile(
|
||||
mode="w"
|
||||
) as install_file:
|
||||
|
||||
bootstrap_file_path = os.path.abspath(bootstrap_file.name)
|
||||
config_file_path = os.path.abspath(config_file.name)
|
||||
install_file_path = os.path.abspath(install_file.name)
|
||||
@ -439,9 +431,7 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest):
|
||||
|
||||
@mock.patch("getpass.getpass", return_value="testpassword")
|
||||
@mock.patch("six.moves.input", return_value="redeploy")
|
||||
def test_redeploy_bootstrap_files_does_not_exists(
|
||||
self, _mock_input, _mock_getpass
|
||||
):
|
||||
def test_redeploy_bootstrap_files_does_not_exists(self, _mock_input, _mock_getpass):
|
||||
self.client.subcloud_manager.redeploy_subcloud.return_value = [
|
||||
self.subcloud_resource
|
||||
]
|
||||
|
@ -77,9 +77,7 @@ class TestCLISubcloudPeerGroupManager(base.BaseCommandTest):
|
||||
subcloud_peer_group_cmd.ListSubcloudPeerGroupSubclouds,
|
||||
app_args=[base.ID],
|
||||
)
|
||||
self.assertEqual(
|
||||
[base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID], actual_call[1]
|
||||
)
|
||||
self.assertEqual([base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID], actual_call[1])
|
||||
|
||||
def test_add_subcloud_peer_group(self):
|
||||
self.client.add_subcloud_peer_group.return_value = [SubcloudPeerGroup]
|
||||
|
@ -11,7 +11,6 @@ from dcmanagerclient.tests.v1 import utils
|
||||
|
||||
|
||||
class TestSwDeployStrategy(UpdateStrategyMixin, base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@ -43,9 +42,7 @@ class TestSwDeployStrategy(UpdateStrategyMixin, base.BaseCommandTest):
|
||||
|
||||
# invoke the backend method for the CLI.
|
||||
# Returns a tuple of field descriptions, and a second tuple of values
|
||||
fields, results = self.call(
|
||||
self.create_command, ["stx-24.09.1"]
|
||||
)
|
||||
fields, results = self.call(self.create_command, ["stx-24.09.1"])
|
||||
|
||||
# results is a tuple of expected length
|
||||
self.assertEqual(len(results), self.results_length)
|
||||
|
@ -17,7 +17,6 @@ FAKE_RELEASE = "21.12"
|
||||
|
||||
|
||||
class TestSwPrestageStrategy(UpdateStrategyMixin, base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.sw_update_manager = self.app.client_manager.sw_prestage_manager
|
||||
|
@ -47,7 +47,6 @@ UPDATED_SW_UPDATE_OPTION = SwUpdateOptions(
|
||||
|
||||
|
||||
class TestCLISWUpdateOptionsManagerV1(base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
# The client is the subcloud_group_manager
|
||||
@ -115,9 +114,7 @@ class TestCLISWUpdateOptionsManagerV1(base.BaseCommandTest):
|
||||
)
|
||||
|
||||
def test_update_sw_update_options(self):
|
||||
self.client.sw_update_options_update.return_value = [
|
||||
UPDATED_SW_UPDATE_OPTION
|
||||
]
|
||||
self.client.sw_update_options_update.return_value = [UPDATED_SW_UPDATE_OPTION]
|
||||
actual_call = self.call(
|
||||
sw_update_options_cmd.UpdateSwUpdateOptions,
|
||||
app_args=[
|
||||
|
@ -10,7 +10,6 @@ from dcmanagerclient.tests.v1.mixins import UpdateStrategyMixin
|
||||
|
||||
|
||||
class TestSwUpgradeStrategy(UpdateStrategyMixin, base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.sw_update_manager = self.app.client_manager.sw_upgrade_manager
|
||||
|
@ -105,7 +105,6 @@ PG_TUPLE = (
|
||||
|
||||
|
||||
class TestCLISystemPeerManagerV1(base.BaseCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
# The client is the system_peer_manager
|
||||
@ -228,9 +227,7 @@ class TestCLISystemPeerManagerV1(base.BaseCommandTest):
|
||||
|
||||
def test_update_system_peer(self):
|
||||
updated_system_peer = copy.copy(SYSTEM_PEER)
|
||||
updated_system_peer.peer_controller_gateway_ip = (
|
||||
NEW_PEER_CONTROLLER_GATEWAY_IP
|
||||
)
|
||||
updated_system_peer.peer_controller_gateway_ip = NEW_PEER_CONTROLLER_GATEWAY_IP
|
||||
self.client.update_system_peer.return_value = [updated_system_peer]
|
||||
actual_call = self.call(
|
||||
system_peer_cmd.UpdateSystemPeer,
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2020-2023 Wind River Systems, Inc.
|
||||
# Copyright (c) 2020-2024 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -11,29 +11,33 @@ from oslo_utils import timeutils
|
||||
from dcmanagerclient.api.v1.sw_update_manager import SwUpdateStrategy
|
||||
|
||||
TIME_NOW = timeutils.utcnow().isoformat()
|
||||
DEFAULT_APPLY_TYPE = 'serial'
|
||||
DEFAULT_APPLY_TYPE = "serial"
|
||||
DEFAULT_MAX_PARALLEL = 2
|
||||
DEFAULT_STATE = 'initial'
|
||||
DEFAULT_STRATEGY_TYPE = 'patch'
|
||||
DEFAULT_STATE = "initial"
|
||||
DEFAULT_STRATEGY_TYPE = "patch"
|
||||
|
||||
|
||||
def make_strategy(manager=None,
|
||||
strategy_type=DEFAULT_STRATEGY_TYPE,
|
||||
subcloud_apply_type=DEFAULT_APPLY_TYPE,
|
||||
max_parallel_subclouds=DEFAULT_MAX_PARALLEL,
|
||||
stop_on_failure=False,
|
||||
state=DEFAULT_STATE,
|
||||
created_at=TIME_NOW,
|
||||
updated_at=None,
|
||||
extra_args=None):
|
||||
def make_strategy(
|
||||
manager=None,
|
||||
strategy_type=DEFAULT_STRATEGY_TYPE,
|
||||
subcloud_apply_type=DEFAULT_APPLY_TYPE,
|
||||
max_parallel_subclouds=DEFAULT_MAX_PARALLEL,
|
||||
stop_on_failure=False,
|
||||
state=DEFAULT_STATE,
|
||||
created_at=TIME_NOW,
|
||||
updated_at=None,
|
||||
extra_args=None,
|
||||
):
|
||||
if manager is None:
|
||||
manager = mock.MagicMock()
|
||||
return SwUpdateStrategy(manager,
|
||||
strategy_type,
|
||||
subcloud_apply_type,
|
||||
max_parallel_subclouds,
|
||||
stop_on_failure,
|
||||
state,
|
||||
created_at,
|
||||
updated_at,
|
||||
extra_args)
|
||||
return SwUpdateStrategy(
|
||||
manager,
|
||||
strategy_type,
|
||||
subcloud_apply_type,
|
||||
max_parallel_subclouds,
|
||||
stop_on_failure,
|
||||
state,
|
||||
created_at,
|
||||
updated_at,
|
||||
extra_args,
|
||||
)
|
||||
|
@ -90,9 +90,7 @@ def prompt_for_password(password_type="sysadmin", item_type="subcloud"):
|
||||
print("Password cannot be empty")
|
||||
continue
|
||||
|
||||
confirm = getpass.getpass(
|
||||
f"Re-enter {password_type} password to confirm: "
|
||||
)
|
||||
confirm = getpass.getpass(f"Re-enter {password_type} password to confirm: ")
|
||||
if password != confirm:
|
||||
print("Passwords did not match")
|
||||
continue
|
||||
@ -170,7 +168,6 @@ def subcloud_detail_format(subcloud=None):
|
||||
|
||||
|
||||
def set_sysadmin_password(parsed_args, data):
|
||||
|
||||
if parsed_args.sysadmin_password:
|
||||
data["sysadmin_password"] = base64.b64encode(
|
||||
parsed_args.sysadmin_password.encode("utf-8")
|
||||
|
@ -1,4 +1,5 @@
|
||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
||||
# Copyright (c) 2024 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.
|
||||
@ -25,6 +26,4 @@ except ImportError:
|
||||
pass
|
||||
|
||||
# Danger - pbr requirement >= 2.0.0 not satisfied...
|
||||
setuptools.setup(
|
||||
setup_requires=['pbr>=1.8.0'],
|
||||
pbr=True)
|
||||
setuptools.setup(setup_requires=["pbr>=1.8.0"], pbr=True)
|
||||
|
@ -6,6 +6,5 @@ coverage!=4.4,>=4.0 # Apache-2.0
|
||||
flake8 # MIT
|
||||
mock>=2.0 # BSD
|
||||
pylint==2.14.1 # GPLv2
|
||||
python-dev-tools # Apache-2.0
|
||||
tempest>=14.0.0 # Apache-2.0
|
||||
testtools>=1.4.0 # MIT
|
||||
|
@ -1,8 +1,7 @@
|
||||
[tox]
|
||||
envlist = py39,pep8,pylint
|
||||
minversion = 2.3
|
||||
envlist = py39,pep8,pylint,black_check
|
||||
minversion = 4.4.0
|
||||
skipsdist = True
|
||||
|
||||
toxworkdir = /tmp/{env:USER}_dc_client_tox
|
||||
|
||||
[dcclient]
|
||||
@ -10,17 +9,16 @@ client_base_dir = .
|
||||
|
||||
[testenv]
|
||||
basepython = python3.9
|
||||
install_command = pip install \
|
||||
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
|
||||
{opts} {packages}
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
OS_STDOUT_CAPTURE=1
|
||||
OS_STDERR_CAPTURE=1
|
||||
OS_TEST_TIMEOUT=60
|
||||
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
-r{toxinidir}/requirements.txt
|
||||
deps =
|
||||
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt}
|
||||
-r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
|
||||
allowlist_externals =
|
||||
rm
|
||||
@ -51,6 +49,22 @@ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||
commands =
|
||||
pylint {posargs} dcmanagerclient --rcfile=./.pylintrc
|
||||
|
||||
[testenv:black]
|
||||
# This environment automatically applies the Black formatter to all Python files in
|
||||
# the project.
|
||||
deps =
|
||||
black>=23.11.0 # MIT
|
||||
commands =
|
||||
black {posargs} .
|
||||
|
||||
[testenv:black_check]
|
||||
# This environment checks and displays the recommended changes by Black for formatting
|
||||
# Python files.
|
||||
deps =
|
||||
black>=23.11.0 # MIT
|
||||
commands =
|
||||
black --check --diff .
|
||||
|
||||
[testenv:cover]
|
||||
setenv =
|
||||
PYTHON=coverage run --parallel-mode
|
||||
|
6
tox.ini
6
tox.ini
@ -27,6 +27,12 @@ description = Dummy environment to allow pep8 to be run in subdir tox
|
||||
[testenv:pylint]
|
||||
description = Dummy environment to allow pylint to be run in subdir tox
|
||||
|
||||
[testenv:black]
|
||||
description = Dummy environment to allow black to be run in subdir tox
|
||||
|
||||
[testenv:black_check]
|
||||
description = Dummy environment to allow black_check to be run in subdir tox
|
||||
|
||||
[testenv:docs]
|
||||
deps = -r{toxinidir}/doc/requirements.txt
|
||||
commands =
|
||||
|
Loading…
Reference in New Issue
Block a user