From efd2449f730610a6a787c325c8745b396c2feb93 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Mon, 16 Dec 2019 08:17:01 -0500 Subject: [PATCH] Revert "Added support of overcloud os_cloud" This reverts commit 3c4cb58d8162fadded40076a2e3b40a510a6e9d7. Change-Id: If7e58619cc43090f766db89c9abf477b683177cd Depends-On: https://review.opendev.org/706855 (cherry picked from commit fd7b5f2e1e35260fbe9a2ee42fcabf574fde5b53) --- setup.cfg | 3 +- tripleo_common/actions/deployment.py | 40 --------------- tripleo_common/constants.py | 4 -- tripleo_common/utils/clouds_yaml.py | 74 ---------------------------- workbooks/deployment.yaml | 34 ------------- 5 files changed, 1 insertion(+), 154 deletions(-) delete mode 100644 tripleo_common/utils/clouds_yaml.py diff --git a/setup.cfg b/setup.cfg index 7642fb4f6..27bdccdcd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -97,7 +97,6 @@ mistral.actions = tripleo.deployment.get_deployment_status = tripleo_common.actions.deployment:DeploymentStatusAction tripleo.deployment.convert_status = tripleo_common.actions.deployment:ConvertStatusAction tripleo.deployment.overcloudrc = tripleo_common.actions.deployment:OvercloudRcAction - tripleo.deployment.createcloudsyaml = tripleo_common.actions.deployment:CreateCloudsYamlAction tripleo.derive_params.convert_number_to_range_list = tripleo_common.actions.derive_params:ConvertNumberToRangeListAction tripleo.derive_params.convert_range_to_number_list = tripleo_common.actions.derive_params:ConvertRangeToNumberListAction tripleo.derive_params.get_dpdk_nics_numa_info = tripleo_common.actions.derive_params:GetDpdkNicsNumaInfoAction @@ -171,4 +170,4 @@ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,releasenotes builtins = _ [pycodestyle] -exclude = .eggs,.tox +exclude = .eggs,.tox \ No newline at end of file diff --git a/tripleo_common/actions/deployment.py b/tripleo_common/actions/deployment.py index 2ca847c1d..1e6a3ad0c 100644 --- a/tripleo_common/actions/deployment.py +++ b/tripleo_common/actions/deployment.py @@ -12,7 +12,6 @@ # 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 json import logging import os @@ -323,45 +322,6 @@ class OvercloudRcAction(base.TripleOAction): region_name) -class CreateCloudsYamlAction(base.TripleOAction): - """Generate the overcloud clouds.yaml contents for a plan - - Given the name of a container, generate the overcloud clouds.yaml - contents needed to access the overcloud via the CLI. - """ - - def __init__(self, container): - super(CreateCloudsYamlAction, self).__init__() - self.container = container - - def run(self, context): - orchestration_client = self.get_orchestration_client(context) - swift = self.get_object_client(context) - stack = orchestration_client.stacks.get(self.container) - env = plan_utils.get_env(swift, self.container) - parameter_defaults = env['parameter_defaults'] - passwords = env['passwords'] - # Retrive values for cloud from a stack - admin_pass = parameter_defaults.get('AdminPassword', - passwords['AdminPassword']) - region_name = parameter_defaults.get('KeystoneRegion', 'regionOne') - cloud_name = stack.stack_name - auth_url = overcloudrc.get_overcloud_endpoint(stack).replace('/v2.0', - '') - - # Create a dict needed for creating clouds.yaml - cloud = {cloud_name: {'auth': {'auth_url': auth_url, - 'project_name': 'admin', - 'project_domain_name': 'Default', - 'username': 'admin', - 'user_domain_name': 'Default', - 'password': admin_pass}, - 'region_name': region_name, - 'identity_api_version': 3}} - - return cloud - - class DeploymentFailuresAction(base.TripleOAction): """Return all of the failures (if any) from deploying the plan diff --git a/tripleo_common/constants.py b/tripleo_common/constants.py index 3b76aeadc..4d38671e6 100644 --- a/tripleo_common/constants.py +++ b/tripleo_common/constants.py @@ -215,7 +215,3 @@ EXCLUSIVE_NEUTRON_DRIVERS = ['ovn', 'openvswitch'] DEFAULT_STEPS_MAX = 6 PER_STEP_TASKS = ['upgrade_tasks', 'deploy_steps_tasks'] - -# Global Directories for clouds.yaml -GLOBAL_OS_DIR = '/etc/openstack' -CLOUDS_YAML_FILE = 'clouds.yaml' diff --git a/tripleo_common/utils/clouds_yaml.py b/tripleo_common/utils/clouds_yaml.py deleted file mode 100644 index 1749830c6..000000000 --- a/tripleo_common/utils/clouds_yaml.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2018, 2019 Red Hat, Inc. -# All Rights Reserved. -# -# 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 os -import yaml - -from tripleo_common import constants - - -def _create_clouds_yaml(clouds_yaml): - if not os.path.isfile(clouds_yaml): - with open(clouds_yaml, "w") as f: - yaml.safe_dump({"clouds": {}}, f, default_flow_style=False) - os.chmod(clouds_yaml, 0o600) - - -def _create_clouds_yaml_dir(dir_path, user_id, group_id): - if not os.path.isdir(dir_path): - os.makedirs(dir_path) - os.chown(dir_path, user_id, group_id) - - -def _read_clouds_yaml(clouds_yaml): - with open(clouds_yaml, "r") as f: - clouds = yaml.safe_load(f) - if "clouds" not in clouds: - clouds.update({"clouds": {}}) - - return clouds - - -def _write_clouds_yaml(clouds_yaml, clouds): - with open(clouds_yaml, "w") as f: - yaml.safe_dump(clouds, f, default_flow_style=False) - - -def create_clouds_yaml(**kwargs): - """Generates clouds.yaml file - - :param cloud: dict containing cloud data - :param clouds_yaml_dir: Directory to create clouds.yaml file - :param user_id: User id of the user owning the file - :param group_id: Group id of the user owning the file - """ - - cloud = kwargs.get("cloud", None) - dir_path = kwargs.get("cloud_yaml_dir", constants.GLOBAL_OS_DIR) - clouds_yaml = os.path.join(dir_path, constants.CLOUDS_YAML_FILE) - user_id = kwargs.get("user_id", 0) - group_id = kwargs.get("group_id", 0) - - try: - _create_clouds_yaml_dir(dir_path, user_id, group_id) - _create_clouds_yaml(clouds_yaml) - user_clouds = _read_clouds_yaml(clouds_yaml) - user_clouds["clouds"].update(cloud) - _write_clouds_yaml(clouds_yaml, user_clouds) - os.chown(clouds_yaml, user_id, group_id) - print("The clouds.yaml file is at {0}".format(clouds_yaml)) - - except Exception as e: - print("Create clouds.yaml failed: {}".format(e)) diff --git a/workbooks/deployment.yaml b/workbooks/deployment.yaml index e05a9ecc6..a08529852 100644 --- a/workbooks/deployment.yaml +++ b/workbooks/deployment.yaml @@ -744,40 +744,6 @@ workflows: execution: <% execution() %> message: <% $.get('message', '') %> - createcloudsyaml: - description: > - Generates the overcloud clouds.yaml - It requires container and queue name as a input. - - tags: - - tripleo-common-managed - - input: - - container: overcloud - - queue_name: tripleo - - tasks: - generate_cloudyaml: - action: tripleo.deployment.createcloudsyaml - input: - container: <% $.container %> - on-complete: send_message - publish-on-error: - status: FAILED - message: <% task().result %> - publish: - status: SUCCESS - message: <% task().result %> - - send_message: - workflow: tripleo.messaging.v1.send - input: - queue_name: <% $.queue_name %> - type: <% execution().name %> - status: <% $.status %> - execution: <% execution() %> - message: <% $.get('message', '') %> - get_deployment_status: description: > Get deployment status and update it if needed based on stack and