Do not error out when a network is ipv6 only

Currently with the following network definition in network-data:

- name: InternalApi
  name_lower: internal_api
  mtu: 1500
  vip: true
  ipv6: true
  subnets:
    internal_api_subnet:
      ipv6_subnet: fd00:fd00:fd00:1000::/64
      ipv6_allocation_pools:
        - start: fd00:fd00:fd00:1000::50
            end: fd00:fd00:fd00:1000::90

We fail as follows:
 Error rendering template /home/stack/overcloud-deploy/overcloud/tripleo-heat-templates/network/internal_api.yaml : 'dict object' has no attribute 'ip_subnet'
 Traceback (most recent call last):
   File "/usr/share/openstack-tripleo-heat-templates/tools/process-templates.py", line 97, in _j2_render_to_file
     r_template = template.render(**j2_data)
   File "/usr/lib/python3.9/site-packages/jinja2/environment.py", line 1304, in render
     self.environment.handle_exception()
   File "/usr/lib/python3.9/site-packages/jinja2/environment.py", line 925, in handle_exception
     raise rewrite_traceback_stack(source=source)
   File "<template>", line 1, in top-level template code
   File "/home/stack/overcloud-deploy/overcloud/tripleo-heat-templates/network/network.j2", line 98, in top-level template code
     {%-     if ":" in network.subnets[subnet]['ip_subnet'] or network.ipv6|default(false) or ipv6_override %}

We need to put the """if ":" in network.subnets[subnet]['ip_subnet']"""
check after the ipv6 test. After applying this patch I was able to
correctly deploy the overcloud.

Closes-Bug: #1948834
Change-Id: I7872f3ef926cdfd59ff19c9744052f3cc0157a1e
This commit is contained in:
Michele Baldessari 2021-10-26 18:11:58 +02:00
parent 187f87ad4b
commit 48ed6294c8
1 changed files with 4 additions and 4 deletions

View File

@ -95,7 +95,7 @@ parameters:
Cidr for the {{network.name_lower}} network's {{subnet}} subnet.
type: string
{{network.name}}AllocationPools_{{subnet}}:
{%- if ":" in network.subnets[subnet]['ip_subnet'] or network.ipv6|default(false) or ipv6_override %}
{%- if network.ipv6|default(false) or ipv6_override or ":" in network.subnets[subnet]['ip_subnet'] %}
default: {{network.subnets[subnet]['ipv6_allocation_pools']|default(network.subnets[subnet]['allocation_pools']|default([]))}}
{%- else %}
default: {{network.subnets[subnet]['allocation_pools']|default([])}}
@ -104,7 +104,7 @@ parameters:
Ip allocation pool range for the {{network.name_lower}} network's {{subnet}} subnet.
type: json
{{network.name}}InterfaceDefaultRoute_{{subnet}}:
{%- if ":" in network.subnets[subnet]['ip_subnet'] or network.ipv6|default(false) or ipv6_override %}
{%- if network.ipv6|default(false) or ipv6_override or ":" in network.subnets[subnet]['ip_subnet'] %}
default: "{{network.subnets[subnet]['gateway_ipv6']|default(network.subnets[subnet]['gateway_ip']|default([]))}}"
{%- else %}
default: "{{network.subnets[subnet]['gateway_ip']|default([])}}"
@ -208,7 +208,7 @@ resources:
# All networks have an implicit network segment when created, map this subnet to that segment.
segment: {get_attr: [{{network.name}}Network, segments, 0, id]}
ip_version: {if: [is_ipv6, 6, 4]}
{%- if ":" in network.ip_subnet|default("") or network.ipv6|default(false) or ipv6_override %}
{%- if network.ipv6|default(false) or ipv6_override or ":" in network.ip_subnet|default("") %}
ipv6_address_mode: {get_param: IPv6AddressMode}
ipv6_ra_mode: {get_param: IPv6RAMode}
{%- else %}
@ -256,7 +256,7 @@ resources:
host_routes: {get_param: {{network.name}}Routes_{{subnet}}}
segment: {get_resource: {{network.name}}Segment_{{subnet}}}
ip_version: {if: [is_ipv6, 6, 4]}
{%- if ":" in network.ip_subnet|default("") or network.ipv6|default(false) or ipv6_override %}
{%- if network.ipv6|default(false) or ipv6_override or ":" in network.ip_subnet|default("") %}
ipv6_address_mode: {get_param: IPv6AddressMode}
ipv6_ra_mode: {get_param: IPv6RAMode}
{%- else %}