From 75249892253dcde7642c0fad5e28bde1071137b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Jens=C3=A5s?= Date: Tue, 8 Sep 2020 13:20:39 +0200 Subject: [PATCH] Add tags to THT network resources This combines several changes that added tags to network resources into one commit. Add tripleo_vip and tripleo_service_net_map_replace tags. These tags are used by the tool that extracts network information from the stack and generates a network-v2 yaml definition Add an index tag on neutron network resources When using the multiple nic-config templates in THT and in tripleo-ansible the ordering of networks in the network_data file matters. Add a a tag 'tripleo_net_idx' to neutron resources to keep track of the ordering. Add tripleo_network_name tag hint to networks The ansible module to manage networks sets the name upper as a tag hint on the neutron network resources. tripleo_ansible/ansible_plugins/modules/tripleo_composable_network.py#L124 Depends-On: https://review.opendev.org/778816 Depends-On: https://review.opendev.org/792197 (cherry picked from commit 2aace23d2386bcc777d4f6984553a4a5a5cb8483) (cherry picked from commit 2d0125ed4023eb7c524d09a0e5865e8d3e22a492) (cherry picked from commit 70dc61cc0a5f99ce3d1368dc226ba4292866f22f) Change-Id: I08b98e9daa625c7c81e50a8ba67bcfc91af37cf0 --- network/network.j2 | 22 ++++++++++++++++++++-- tools/process-templates.py | 5 +++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/network/network.j2 b/network/network.j2 index 9dc37f8af4..78c58a24cc 100644 --- a/network/network.j2 +++ b/network/network.j2 @@ -63,12 +63,10 @@ parameters: {%- endif %} description: default route for the {{network.name_lower}} network type: string -{%- if network.vlan %} {{network.name}}NetworkVlanID: default: {{network.vlan|default(1)}} description: Vlan ID for the {{network.name_lower}} network traffic. type: number -{%- endif %} {{network.name}}Routes: default: {{network.routes|default([])}} description: > @@ -170,6 +168,16 @@ resources: map_merge: - {get_param: {{network.name}}NetValueSpecs} - {'mtu': {get_param: {{network.name}}Mtu}} + tags: + - tripleo_net_idx={{network.idx}} + - tripleo_network_name={{network.name}} + - tripleo_vip={{network.vip|default(false)}} +{%- if network.service_net_map_replace|default('') %} + - tripleo_service_net_map_replace={{network.service_net_map_replace}} +{%- endif %} +{%- if network.ipv6 or ipv6_override %} + - tripleo_ipv6=true +{%- endif %} {{network.name}}Subnet: type: OS::Neutron::Subnet @@ -193,6 +201,11 @@ resources: {%- else %} enable_dhcp: {get_param: {{network.name}}NetEnableDHCP} {%- endif %} + tags: + - str_replace: + template: tripleo_vlan_id=$vlan_id + params: + $vlan_id: {get_param: {{network.name}}NetworkVlanID} {% for subnet in network.subnets|default({}) if network.subnets[subnet].enabled|default(true) %} @@ -234,6 +247,11 @@ resources: {%- else %} enable_dhcp: {get_param: {{network.name}}NetEnableDHCP} {%- endif %} + tags: + - str_replace: + template: tripleo_vlan_id=$vlan_id + params: + $vlan_id: {get_param: {{network.name}}NetworkVlanID_{{subnet}}} {% endfor %} diff --git a/tools/process-templates.py b/tools/process-templates.py index 0bb8780259..f117f6d104 100755 --- a/tools/process-templates.py +++ b/tools/process-templates.py @@ -117,6 +117,11 @@ def process_templates(template_path, role_data_path, output_dir, if network_data is None: network_data = [] + # Set internal network index key for each network, network resources + # are created with a tag tripleo_net_idx + for idx, net in enumerate(network_data): + network_data[idx].update({'idx': idx}) + j2_excludes = {} j2_excludes_path = os.path.join(template_path, 'j2_excludes.yaml') if os.path.exists(j2_excludes_path):