From 112dbb1075d8fba54fa64b8d39b6bd0daa87c845 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Tue, 15 Aug 2017 16:34:57 +0100 Subject: [PATCH] Add -n/--networks-data option This allows overriding the default network_data.yaml, similar to the existing interface for roles_data.yaml. Change-Id: I0a7fa4538702c61169a6760b10dbc4f5137bd9ec Partially-Implements: blueprint composable-networks --- ...networks_data_option-6c613c0d118ccfc8.yaml | 6 +++++ tripleoclient/constants.py | 1 + tripleoclient/v1/overcloud_deploy.py | 11 ++++++++-- tripleoclient/workflows/plan_management.py | 22 ++++++++++++++----- 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/networks_data_option-6c613c0d118ccfc8.yaml diff --git a/releasenotes/notes/networks_data_option-6c613c0d118ccfc8.yaml b/releasenotes/notes/networks_data_option-6c613c0d118ccfc8.yaml new file mode 100644 index 000000000..cac856525 --- /dev/null +++ b/releasenotes/notes/networks_data_option-6c613c0d118ccfc8.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + A new -n/--networks-data option has been added. This allows overriding the + default network_data.yaml, similar to the existing interface for + roles_data.yaml. diff --git a/tripleoclient/constants.py b/tripleoclient/constants.py index 338ce6770..f11f37775 100644 --- a/tripleoclient/constants.py +++ b/tripleoclient/constants.py @@ -34,6 +34,7 @@ SERVICE_LIST = { TRIPLEO_HEAT_TEMPLATES = "/usr/share/openstack-tripleo-heat-templates/" OVERCLOUD_YAML_NAME = "overcloud.yaml" OVERCLOUD_ROLES_FILE = "roles_data.yaml" +OVERCLOUD_NETWORKS_FILE = "network_data.yaml" RHEL_REGISTRATION_EXTRACONFIG_NAME = ( "extraconfig/pre_deploy/rhel-registration/") diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index d637b7316..634712e11 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -398,12 +398,14 @@ class DeployOvercloud(command.Command): plan_management.update_plan_from_templates( self.clients, parsed_args.stack, tht_root, parsed_args.roles_file, generate_passwords, - parsed_args.plan_environment_file) + parsed_args.plan_environment_file, + parsed_args.networks_file) else: plan_management.create_plan_from_templates( self.clients, parsed_args.stack, tht_root, parsed_args.roles_file, generate_passwords, - parsed_args.plan_environment_file) + parsed_args.plan_environment_file, + parsed_args.networks_file) # Get any missing (e.g j2 rendered) files from the plan to tht_root self._download_missing_files_from_plan( @@ -714,6 +716,11 @@ class DeployOvercloud(command.Command): help=_('Roles file, overrides the default %s in the --templates ' 'directory') % constants.OVERCLOUD_ROLES_FILE ) + parser.add_argument( + '--networks-file', '-n', dest='networks_file', + help=_('Networks file, overrides the default %s in the ' + '--templates directory') % constants.OVERCLOUD_NETWORKS_FILE + ) parser.add_argument( '--plan-environment-file', '-p', help=_('Plan Environment file, overrides the default %s in the ' diff --git a/tripleoclient/workflows/plan_management.py b/tripleoclient/workflows/plan_management.py index ee155668a..ea65ecd34 100644 --- a/tripleoclient/workflows/plan_management.py +++ b/tripleoclient/workflows/plan_management.py @@ -31,7 +31,7 @@ _WORKFLOW_TIMEOUT = 360 # 6 * 60 seconds def _upload_templates(swift_client, container_name, tht_root, roles_file=None, - plan_env_file=None): + plan_env_file=None, networks_file=None): """tarball up a given directory and upload it to Swift to be extracted""" with tempfile.NamedTemporaryFile() as tmp_tarball: @@ -45,6 +45,14 @@ def _upload_templates(swift_client, container_name, tht_root, roles_file=None, swift_client.put_object(container_name, constants.OVERCLOUD_ROLES_FILE, rf) + + # Allow optional override of the network_data.yaml file + if networks_file: + with open(networks_file) as rf: + swift_client.put_object(container_name, + constants.OVERCLOUD_NETWORKS_FILE, + rf) + # Optional override of the plan-environment.yaml file if plan_env_file: # TODO(jpalanis): Instead of overriding default file, @@ -140,7 +148,8 @@ def create_container(workflow_client, **input_): def create_plan_from_templates(clients, name, tht_root, roles_file=None, - generate_passwords=True, plan_env_file=None): + generate_passwords=True, plan_env_file=None, + networks_file=None): workflow_client = clients.workflow_engine swift_client = clients.tripleoclient.object_store @@ -153,7 +162,8 @@ def create_plan_from_templates(clients, name, tht_root, roles_file=None, "Unable to create plan. {}".format(result)) print("Creating plan from template files in: {}".format(tht_root)) - _upload_templates(swift_client, name, tht_root, roles_file, plan_env_file) + _upload_templates(swift_client, name, tht_root, roles_file, plan_env_file, + networks_file) try: create_deployment_plan(clients, container=name, @@ -165,7 +175,8 @@ def create_plan_from_templates(clients, name, tht_root, roles_file=None, def update_plan_from_templates(clients, name, tht_root, roles_file=None, - generate_passwords=True, plan_env_file=None): + generate_passwords=True, plan_env_file=None, + networks_file=None): swift_client = clients.tripleoclient.object_store # If the plan environment was migrated to Swift, save the generated @@ -196,7 +207,8 @@ def update_plan_from_templates(clients, name, tht_root, roles_file=None, # need to special-case plan-environment.yaml to avoid this. print("Uploading new plan files") - _upload_templates(swift_client, name, tht_root, roles_file, plan_env_file) + _upload_templates(swift_client, name, tht_root, roles_file, plan_env_file, + networks_file) _update_passwords(swift_client, name, passwords) update_deployment_plan(clients, container=name, queue_name=str(uuid.uuid4()),