From 0a8fc376cdbd7973cb84290cd7a4fa670e12e4d6 Mon Sep 17 00:00:00 2001 From: "Chandan Kumar (raukadah)" Date: Tue, 11 Jun 2019 18:49:20 +0530 Subject: [PATCH] Added for support for generating overcloud clouds.yaml https://review.opendev.org/#/c/664568/ adds mistral actions for generating overcloud clouds.yaml file. This patch enables the same to call the above mistral action and reuse The clouds_yaml.py script is also moved from tht to here in order to reuse the script. Added proper constants and method for creating clouds yaml directory. Added a mock_clouds_yaml.py function to mock the tripleo-common.utils.clouds_yaml script in order to integrate with Tripleo. Depends-On: https://review.opendev.org/#/c/664568/ Change-Id: I243ec370f9de0f2a0e34163962f1a1f228c3a9a1 Signed-off-by: Chandan Kumar (raukadah) --- ...d-cloud-yaml-support-fae7585c46eda8e8.yaml | 8 +++++++ tripleoclient/constants.py | 4 ++++ tripleoclient/v1/mock_clouds_yaml.py | 3 +++ tripleoclient/v1/overcloud_deploy.py | 20 +++++++++++++++++ tripleoclient/workflows/deployment.py | 22 +++++++++++++++++++ 5 files changed, 57 insertions(+) create mode 100644 releasenotes/notes/overcloud-cloud-yaml-support-fae7585c46eda8e8.yaml create mode 100644 tripleoclient/v1/mock_clouds_yaml.py diff --git a/releasenotes/notes/overcloud-cloud-yaml-support-fae7585c46eda8e8.yaml b/releasenotes/notes/overcloud-cloud-yaml-support-fae7585c46eda8e8.yaml new file mode 100644 index 000000000..54c541e86 --- /dev/null +++ b/releasenotes/notes/overcloud-cloud-yaml-support-fae7585c46eda8e8.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + OpenStack overcloud services cli and api is currently accessed through + overcloudrc and clouds.yaml. + This adds support for overcloud clouds.yaml file generation after + deployment. The file can be found at ~/.config/openstack/clouds.yaml + and /etc/openstack/clouds.yaml. diff --git a/tripleoclient/constants.py b/tripleoclient/constants.py index d5a32f156..9f023cbb0 100644 --- a/tripleoclient/constants.py +++ b/tripleoclient/constants.py @@ -123,3 +123,7 @@ DEPRECATED_SERVICES = {"OS::TripleO::Services::OpenDaylightApi": "OpenDaylight to another networking backend. We " "recommend you understand other networking " "alternatives such as OVS or OVN. "} + +# clouds_yaml related constants +CLOUD_HOME_DIR = os.path.expanduser("~") +CLOUDS_YAML_DIR = os.path.join('.config', 'openstack') diff --git a/tripleoclient/v1/mock_clouds_yaml.py b/tripleoclient/v1/mock_clouds_yaml.py new file mode 100644 index 000000000..e1e704d27 --- /dev/null +++ b/tripleoclient/v1/mock_clouds_yaml.py @@ -0,0 +1,3 @@ +def create_clouds_yaml(cloud=None, cloud_yaml_dir=None, + user_id=None, group_id=None): + pass diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index ec4bae7a6..5ae838515 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -33,6 +33,14 @@ from osc_lib.i18n import _ from swiftclient.exceptions import ClientException from tripleo_common import update +# FIXME(chkumar246): Once https://review.opendev.org/664568 gets merged +# and new version of tripleo-common gots released, It requires a version +# bump in requirements.txt. +try: + from tripleo_common.utils import clouds_yaml +except ImportError: + from tripleoclient.v1 import mock_clouds_yaml as clouds_yaml + from tripleoclient import command from tripleoclient import constants from tripleoclient import exceptions @@ -1000,6 +1008,18 @@ class DeployOvercloud(command.Command): self.clients, container=stack.stack_name, no_proxy=parsed_args.no_proxy) + # Create overcloud clouds.yaml + cloud_data = deployment.create_cloudsyaml( + self.clients, container=stack.stack_name) + cloud_yaml_dir = os.path.join(constants.CLOUD_HOME_DIR, + constants.CLOUDS_YAML_DIR) + cloud_user_id = os.stat(constants.CLOUD_HOME_DIR).st_uid + cloud_group_id = os.stat(constants.CLOUD_HOME_DIR).st_gid + clouds_yaml.create_clouds_yaml( + cloud=cloud_data, + cloud_yaml_dir=cloud_yaml_dir, + user_id=cloud_user_id, + group_id=cloud_group_id) rcpath = utils.write_overcloudrc(stack.stack_name, overcloudrcs) utils.create_tempest_deployer_input() diff --git a/tripleoclient/workflows/deployment.py b/tripleoclient/workflows/deployment.py index 5519dfb4b..a21039184 100644 --- a/tripleoclient/workflows/deployment.py +++ b/tripleoclient/workflows/deployment.py @@ -132,6 +132,28 @@ def create_overcloudrc(clients, **workflow_input): payload.get('message'))) +def create_cloudsyaml(clients, **workflow_input): + workflow_client = clients.workflow_engine + tripleoclients = clients.tripleoclient + + with tripleoclients.messaging_websocket() as ws: + execution = base.start_workflow( + workflow_client, + 'tripleo.deployment.v1.createcloudsyaml', + workflow_input=workflow_input + ) + + for payload in base.wait_for_messages(workflow_client, ws, execution): + # the workflow will return the overcloud cloud yaml data, an error + # message or blank. + if payload.get('status') == 'SUCCESS': + return payload.get('message') + else: + raise exceptions.WorkflowServiceError( + 'Exception creating overcloud clouds.yaml file: {}'.format( + payload.get('message'))) + + def get_overcloud_hosts(stack, ssh_network): ips = [] role_net_ip_map = utils.get_role_net_ip_map(stack)