Add subcloud enroll command
This commit introduces the enroll command for subclouds. Test Plan PASS: Deploy a system controller and run subcloud add enroll command with migrate command. Verify that an error is thrown informing that enroll and migrate cannot run together. PASS: Deploy a system controller and run subcloud add enroll command. Verify that the dcmanager API returns a success. Change-Id: Icbebdafa746b87cd8b906a9394f161991da9a123 Signed-off-by: Gustavo Pereira <gustavo.lyrapereira@windriver.com>
This commit is contained in:
parent
622b38f552
commit
f83fe08336
|
@ -79,3 +79,9 @@ class PhasedSubcloudDeployManager(base.ResourceManager):
|
||||||
files = kwargs.get("files")
|
files = kwargs.get("files")
|
||||||
url = BASE_URL + f"{subcloud_ref}/resume"
|
url = BASE_URL + f"{subcloud_ref}/resume"
|
||||||
return self._deploy_operation(url, files, data, method="patch")
|
return self._deploy_operation(url, files, data, method="patch")
|
||||||
|
|
||||||
|
def subcloud_deploy_enroll(self, subcloud_ref, **kwargs):
|
||||||
|
data = kwargs.get("data")
|
||||||
|
files = kwargs.get("files")
|
||||||
|
url = BASE_URL + f"{subcloud_ref}/enroll"
|
||||||
|
return self._deploy_operation(url, files, data, method="patch")
|
||||||
|
|
|
@ -537,3 +537,74 @@ class CompletePhasedSubcloudDeploy(base.DCManagerShowOne):
|
||||||
f"Unable to complete the deployment of subcloud {subcloud_ref}"
|
f"Unable to complete the deployment of subcloud {subcloud_ref}"
|
||||||
)
|
)
|
||||||
raise exceptions.DCManagerClientException(error_msg)
|
raise exceptions.DCManagerClientException(error_msg)
|
||||||
|
|
||||||
|
|
||||||
|
class EnrollPhasedSubcloudDeploy(base.DCManagerShowOne):
|
||||||
|
"""Enrolls a subcloud."""
|
||||||
|
|
||||||
|
def _get_format_function(self):
|
||||||
|
return utils.subcloud_detail_format
|
||||||
|
|
||||||
|
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(
|
||||||
|
"--bootstrap-address",
|
||||||
|
required=False,
|
||||||
|
help="IP address for initial subcloud controller.",
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--bootstrap-values",
|
||||||
|
required=False,
|
||||||
|
help="YAML file containing parameters required for the enrollment "
|
||||||
|
"of the subcloud.",
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--sysadmin-password",
|
||||||
|
required=False,
|
||||||
|
help="sysadmin password of the subcloud to be configured, "
|
||||||
|
"if not provided you will be prompted.",
|
||||||
|
)
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def _get_resources(self, parsed_args):
|
||||||
|
phased_subcloud_deploy_manager = (
|
||||||
|
self.app.client_manager.phased_subcloud_deploy_manager
|
||||||
|
)
|
||||||
|
files = {}
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
if parsed_args.bootstrap_address:
|
||||||
|
data["bootstrap-address"] = parsed_args.bootstrap_address
|
||||||
|
|
||||||
|
# Get the bootstrap values yaml file
|
||||||
|
if parsed_args.bootstrap_values:
|
||||||
|
if not os.path.isfile(parsed_args.bootstrap_values):
|
||||||
|
error_msg = (
|
||||||
|
"bootstrap-values does not exist: "
|
||||||
|
f"{parsed_args.bootstrap_values}"
|
||||||
|
)
|
||||||
|
raise exceptions.DCManagerClientException(error_msg)
|
||||||
|
files["bootstrap_values"] = parsed_args.bootstrap_values
|
||||||
|
|
||||||
|
# Prompt the user for the subcloud's password if it isn't provided
|
||||||
|
if parsed_args.sysadmin_password:
|
||||||
|
data["sysadmin_password"] = base64.b64encode(
|
||||||
|
parsed_args.sysadmin_password.encode("utf-8")
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
password = utils.prompt_for_password()
|
||||||
|
data["sysadmin_password"] = base64.b64encode(password.encode("utf-8"))
|
||||||
|
|
||||||
|
subcloud_ref = parsed_args.subcloud
|
||||||
|
|
||||||
|
return phased_subcloud_deploy_manager.subcloud_deploy_enroll(
|
||||||
|
subcloud_ref, files=files, data=data
|
||||||
|
)
|
||||||
|
|
|
@ -264,6 +264,13 @@ class AddSubcloud(base.DCManagerShowOne):
|
||||||
"release of the system controller will be used.",
|
"release of the system controller will be used.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--enroll",
|
||||||
|
required=False,
|
||||||
|
action="store_true",
|
||||||
|
help="Enroll a subcloud",
|
||||||
|
)
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def _get_resources(self, parsed_args):
|
def _get_resources(self, parsed_args):
|
||||||
|
@ -303,6 +310,10 @@ class AddSubcloud(base.DCManagerShowOne):
|
||||||
raise exceptions.DCManagerClientException(error_msg)
|
raise exceptions.DCManagerClientException(error_msg)
|
||||||
files["deploy_config"] = parsed_args.deploy_config
|
files["deploy_config"] = parsed_args.deploy_config
|
||||||
|
|
||||||
|
if parsed_args.migrate and parsed_args.enroll:
|
||||||
|
error_msg = "cannot run migrate and enroll commands together"
|
||||||
|
raise exceptions.DCManagerClientException(error_msg)
|
||||||
|
|
||||||
# Prompt the user for the subcloud's password if it isn't provided
|
# Prompt the user for the subcloud's password if it isn't provided
|
||||||
if parsed_args.sysadmin_password is not None:
|
if parsed_args.sysadmin_password is not None:
|
||||||
data["sysadmin_password"] = base64.b64encode(
|
data["sysadmin_password"] = base64.b64encode(
|
||||||
|
@ -327,6 +338,9 @@ class AddSubcloud(base.DCManagerShowOne):
|
||||||
if parsed_args.migrate:
|
if parsed_args.migrate:
|
||||||
data["migrate"] = "true"
|
data["migrate"] = "true"
|
||||||
|
|
||||||
|
if parsed_args.enroll:
|
||||||
|
data["enroll"] = "true"
|
||||||
|
|
||||||
if parsed_args.release is not None:
|
if parsed_args.release is not None:
|
||||||
data["release"] = parsed_args.release
|
data["release"] = parsed_args.release
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue