Add a tag's containing subnet cidr to ctlplane network
Since the ctlplane network and it's subnets are created outside of the overcloud heat templates we cannot in an easy way create a list containing the cidr of each of the ctlplane subnets in THT. Prior to routed networks we only had one subnet and was able to create the NetCidrMapValue by reading the cidr value of one of the ControlVirtualIP resource. When we have multiple subnets on each network we should make NetCidrMapValue contain lists of cidrs for each network. By setting a tags on the ctlplane network, one per subnet, containing each individual subnets cidr the tags can be loaded via the ControlVirtualIP resource so that we can have NetCidrMapValue contain all the cidrs of the ctlplane network. Change-Id: I7d9a951d0c156c83430c1e326bc8edcb52b08537 Partial: blueprint tripleo-routed-networks-templates
This commit is contained in:
parent
fdba8a89e3
commit
00cecfe2f3
@ -185,7 +185,17 @@ def _get_segment(sdk, phy, network_id):
|
|||||||
return False if not segment else segment[0]
|
return False if not segment else segment[0]
|
||||||
|
|
||||||
|
|
||||||
def _local_neutron_segments_and_subnets(sdk, ctlplane_id):
|
def _set_network_tags(sdk, network, tags):
|
||||||
|
try:
|
||||||
|
sdk.network.set_tags(network, tags=tags)
|
||||||
|
print('INFO: Tags %s added to network %s.' % (tags, network.name))
|
||||||
|
except Exception:
|
||||||
|
print('ERROR: Setting tags %s on network %s failed.' %
|
||||||
|
(tags, network.name))
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def _local_neutron_segments_and_subnets(sdk, ctlplane_id, net_cidrs):
|
||||||
"""Create's and updates the ctlplane subnet on the segment that is local to
|
"""Create's and updates the ctlplane subnet on the segment that is local to
|
||||||
the underclud.
|
the underclud.
|
||||||
"""
|
"""
|
||||||
@ -219,9 +229,11 @@ def _local_neutron_segments_and_subnets(sdk, ctlplane_id):
|
|||||||
# advertisments are sent out for stateless IP addressing to work.
|
# advertisments are sent out for stateless IP addressing to work.
|
||||||
if netaddr.IPNetwork(s['NetworkCidr']).version == 6:
|
if netaddr.IPNetwork(s['NetworkCidr']).version == 6:
|
||||||
_ensure_neutron_router(sdk, name, subnet.id)
|
_ensure_neutron_router(sdk, name, subnet.id)
|
||||||
|
net_cidrs.append(s['NetworkCidr'])
|
||||||
|
|
||||||
|
return net_cidrs
|
||||||
|
|
||||||
def _remote_neutron_segments_and_subnets(sdk, ctlplane_id):
|
def _remote_neutron_segments_and_subnets(sdk, ctlplane_id, net_cidrs):
|
||||||
"""Create's and updates the ctlplane subnet(s) on segments that is
|
"""Create's and updates the ctlplane subnet(s) on segments that is
|
||||||
not local to the undercloud.
|
not local to the undercloud.
|
||||||
"""
|
"""
|
||||||
@ -255,7 +267,9 @@ def _remote_neutron_segments_and_subnets(sdk, ctlplane_id):
|
|||||||
# advertisments are sent out for stateless IP addressing to work.
|
# advertisments are sent out for stateless IP addressing to work.
|
||||||
if netaddr.IPNetwork(s['NetworkCidr']).version == 6:
|
if netaddr.IPNetwork(s['NetworkCidr']).version == 6:
|
||||||
_ensure_neutron_router(sdk, name, subnet.id)
|
_ensure_neutron_router(sdk, name, subnet.id)
|
||||||
|
net_cidrs.append(s['NetworkCidr'])
|
||||||
|
|
||||||
|
return net_cidrs
|
||||||
|
|
||||||
if 'true' not in _run_command(['hiera', 'neutron_api_enabled'],
|
if 'true' not in _run_command(['hiera', 'neutron_api_enabled'],
|
||||||
name='hiera').lower():
|
name='hiera').lower():
|
||||||
@ -265,9 +279,14 @@ else:
|
|||||||
sdk = openstack.connect(CONF['cloud_name'])
|
sdk = openstack.connect(CONF['cloud_name'])
|
||||||
|
|
||||||
network = _ensure_neutron_network(sdk)
|
network = _ensure_neutron_network(sdk)
|
||||||
|
net_cidrs = []
|
||||||
# Always create/update the local_subnet first to ensure it is can have the
|
# Always create/update the local_subnet first to ensure it is can have the
|
||||||
# subnet associated with a segment prior to creating the remote subnets if
|
# subnet associated with a segment prior to creating the remote subnets if
|
||||||
# the user enabled routed networks support on undercloud update.
|
# the user enabled routed networks support on undercloud update.
|
||||||
_local_neutron_segments_and_subnets(sdk, network.id)
|
net_cidrs = _local_neutron_segments_and_subnets(sdk, network.id, net_cidrs)
|
||||||
if CONF['enable_routed_networks']:
|
if CONF['enable_routed_networks']:
|
||||||
_remote_neutron_segments_and_subnets(sdk, network.id)
|
net_cidrs = _remote_neutron_segments_and_subnets(sdk, network.id,
|
||||||
|
net_cidrs)
|
||||||
|
# Set the cidrs for all ctlplane subnets as tags on the ctlplane network.
|
||||||
|
# These tags are used for the NetCidrMapValue in tripleo-heat-templates.
|
||||||
|
_set_network_tags(sdk, network, net_cidrs)
|
||||||
|
Loading…
Reference in New Issue
Block a user