diff --git a/network/network.j2 b/network/network.j2 index 92c303105f..0c8136267d 100644 --- a/network/network.j2 +++ b/network/network.j2 @@ -131,6 +131,9 @@ parameters: resources: {{network.name}}Network: type: OS::Neutron::Net +{%- if network.external_resource_network_id|default('') %} + external_id: {{ network.external_resource_network_id }} +{%- endif %} properties: admin_state_up: {get_param: {{network.name}}NetAdminStateUp} name: {get_param: {{network.name}}NetName} @@ -142,6 +145,9 @@ resources: {{network.name}}Subnet: type: OS::Neutron::Subnet +{%- if network.external_resource_subnet_id|default('') %} + external_id: {{ network.external_resource_subnet_id }} +{%- endif %} properties: {%- if ":" in network.ip_subnet or network.ipv6 or ipv6_override %} ip_version: 6 @@ -160,20 +166,29 @@ 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]} {%- endif %} + {% for subnet in network.subnets|default({}) if network.subnets[subnet].enabled|default(true) %} {{network.name}}Segment_{{subnet}}: type: OS::Neutron::Segment # NOTE(hjensas): Depends-On here to ensure we always create the base subnet # first. We can only set the segment for existing subnet if there is only # one segment and only one existing subnet on the network. +{%- if subnet.external_resource_segment_id|default('') %} + external_id: {{ subnet.external_resource_segment_id }} +{%- else %} depends_on: {{network.name}}Subnet +{%- endif %} properties: name: {{network.name_lower}}_{{subnet}} network: {get_resource: {{network.name}}Network} network_type: flat physical_network: {{network.name_lower}}_{{subnet}} + {{network.name}}Subnet_{{subnet}}: type: OS::Neutron::Subnet +{%- if subnet.external_resource_subnet_id|default('') %} + external_id: {{ subnet.external_resource_subnet_id }} +{%- endif %} properties: {%- if ":" in network.ip_subnet or network.ipv6 or ipv6_override %} ip_version: 6 diff --git a/network_data.yaml b/network_data.yaml index 158ff8339f..a40598c0e6 100644 --- a/network_data.yaml +++ b/network_data.yaml @@ -9,6 +9,15 @@ # to original default (optional). This field is only necessary when # changing the default network names, not when adding a new custom network. # enabled: Is the network enabled (optional, defaults to true) +# external_resource_network_id: Optional. If set, it should be the UUID of an existing already +# created Neutron network that will be used in place of creating a +# new network. +# external_resource_subnet_id: Optional. If set, it should be the UUID of an existing already +# created Neutron subnet that will be used in place of creating a +# new subnet for the network. +# external_resource_segment_id: Optional. If set, it should be the UUID of an existing already +# created Neutron segment that will be used in place of creating a +# new segment for the network. # NOTE: False will use noop.yaml for unused legacy networks to support upgrades. # vlan: vlan for the network (optional) # vip: Enable creation of a virtual IP on this network @@ -46,7 +55,9 @@ # 'ipv6_subnet': '', # 'ipv6_allocation_pools': '', # 'gateway_ipv6': '', -# 'routes_ipv6': ''}} +# 'routes_ipv6': '', +# 'external_resource_subnet_id': ''}} +# 'external_resource_segment_id': ''}} # # Example: # - name Example