Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Add attr of networks and subnets to Networks resource
Browse files Browse the repository at this point in the history
In the Networks resource tempaltes add the full resource
attributes to net_attributes_map.
Use the attributes to build per-role GroupVars.

Change-Id: I603521bd00dc100e03c765c25503b5e01f3383e4
  • Loading branch information
hjensas committed Sep 24, 2020
1 parent 0d8ecc4 commit 5b38785
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
10 changes: 10 additions & 0 deletions network/network.j2
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,14 @@ outputs:
{%- else %}
- "{{network.subnets[subnet]['ip_subnet']|default("")}}"
{%- endif %}
{%- endfor %}
network_attrs:
description: {{network.name}} network's attributes
value: {get_attr: [{{network.name}}Network]}
subnet_attrs:
description: Map of attributes for subnets in the {{network.name}} network
value:
{{network.name_lower}}_subnet: {get_attr: [{{network.name}}Subnet]}
{%- for subnet in network.subnets|default({}) if network.subnets[subnet].enabled|default(true) %}
{{subnet}}: {get_attr: [{{network.name}}Subnet_{{subnet}}]}
{%- endfor %}
10 changes: 9 additions & 1 deletion network/networks.j2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,13 @@ outputs:
value:
{%- for network in networks if network.enabled|default(true) %}
{%- set network_name = network.compat_name|default(network.name) %}
{{network.name_lower}}: {get_attr: [{{network_name}}Network, ip_version]}
{{network.name_lower}}: {get_attr: [{{network_name}}Network, ip_version]}
{%- endfor %}
net_attributes_map:
value:
{%- for network in networks if network.enabled|default(true) %}
{%- set network_name = network.compat_name|default(network.name) %}
{{network.name_lower}}:
network: {get_attr: [{{network_name}}Network, network_attrs]}
subnets: {get_attr: [{{network_name}}Network, subnet_attrs]}
{%- endfor %}
27 changes: 23 additions & 4 deletions overcloud.j2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -919,14 +919,33 @@ resources:
type: OS::Heat::Value
properties:
value:
{%- for network in networks if network.enabled|default(true) and network.name in role.networks|default([]) %}
{{network.name_lower}}_mtu: {get_attr: [Networks, net_attributes_map, {{network.name_lower}}, network, mtu]}
{%- if role.networks is mapping %}
{{network.name_lower}}_gateway_ip: {get_attr: [Networks, net_attributes_map, {{network.name_lower}}, subnets, {{role.networks[network.name]['subnet']}}, gateway_ip]}
{{network.name_lower}}_host_routes: {get_attr: [Networks, net_attributes_map, {{network.name_lower}}, subnets, {{role.networks[network.name]['subnet']}}, host_routes]}
{{network.name_lower}}_cidr: {str_split: ['/', {get_attr: [Networks, net_attributes_map, {{network.name_lower}}, subnets, {{role.networks[network.name]['subnet']}}, cidr]}, 1]}
{%- else %}
{{network.name_lower}}_gateway_ip: {get_attr: [Networks, net_attributes_map, {{network.name_lower}}, subnets, {{network.name_lower}}_subnet, gateway_ip]}
{{network.name_lower}}_host_routes: {get_attr: [Networks, net_attributes_map, {{network.name_lower}}, subnets, {{network.name_lower}}_subnet, host_routes]}
{{network.name_lower}}_cidr: {str_split: ['/', {get_attr: [Networks, net_attributes_map, {{network.name_lower}}, subnets, {{network.name_lower}}_subnet, cidr]}, 1]}
{%- endif %}
{%- endfor %}
network_cidrs:
{%- for network in networks if network.enabled|default(true) and network.name in role.networks|default([]) %}
{%- if role.networks is mapping %}
{{network.name}}_cidr: {str_split: ['/', {get_attr: [Networks, net_attributes_map, {{network.name_lower}}, subnets, {{role.networks[network.name]['subnet']}}, cidr]}, 1]}
{%- else %}
{{network.name}}_cidr: {str_split: ['/', {get_attr: [Networks, net_attributes_map, {{network.name_lower}}, subnets, {{network.name_lower}}_subnet, cidr]}, 1]}
{%- endif %}
{%- endfor %}
role_networks:
{%- for network in networks %}
{%- if network.enabled|default(true) and network.name in role.networks|default([]) %}
{%- for network in networks if network.enabled|default(true) and network.name in role.networks|default([]) %}
- {{network.name}}
{% endif %}
{% endfor %}
{%- endfor %}
service_metadata_settings: {get_attr: [{{role.name}}ServiceChainRoleData, value, service_metadata_settings]}


{% endfor %}

ControlVirtualIP:
Expand Down

0 comments on commit 5b38785

Please sign in to comment.