Inspector set baremetal port physical_network

When deploying routed networks the physical_network
attribute of ironic ports must be set, this has been
a manual task.

With this change we add configuration for the
physnet_cidr_map processing hook in ironic inspector
so that the physical_network field of ironic ports
is set automatically when introspecting nodes.

Depends-On: https://review.opendev.org/722088
Closes-Bug: #1870529
Change-Id: I7f31b9f0143507ec3c9c26efd086f0bd95ef2ce7
This commit is contained in:
Harald Jensås 2020-04-23 10:52:44 +02:00
parent 93952566d6
commit 9cd91775f2
3 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
fixes:
- |
The undercloud install now configures ironic inspector to automatically
populate the physical_network field on baremetal provisioning ports. See
bug `1870529 <https://launchpad.net/bugs/1870529>`_.

View File

@ -184,6 +184,7 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'tag': 'ctlplane-subnet',
'mtu': 1500}],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'192.168.24.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
'ctlplane-subnet': {
'AllocationPools': [
@ -230,6 +231,7 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'tag': 'ctlplane-subnet',
'mtu': 1500}],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'fd12:3456:789a:1::/64': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
'ctlplane-subnet': {
'AllocationPools': [
@ -279,6 +281,7 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'tag': 'ctlplane-subnet',
'mtu': 1500}],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'fd12:3456:789a:1::/64': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
'ctlplane-subnet': {
'AllocationPools': [
@ -356,6 +359,7 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'tag': 'ctlplane-subnet',
'mtu': 1500}],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'192.168.24.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
'ctlplane-subnet': {
'AllocationPools': [
@ -386,6 +390,7 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'tag': 'ctlplane-subnet',
'mtu': 1500}],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'192.168.10.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
'ctlplane-subnet': {
'AllocationPools': [
@ -418,6 +423,7 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'tag': 'ctlplane-subnet',
'mtu': 1500}],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'192.168.10.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
'ctlplane-subnet': {
'AllocationPools': [
@ -449,6 +455,7 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'tag': 'ctlplane-subnet',
'mtu': 1500}],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'192.168.24.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
'ctlplane-subnet': {
'AllocationPools': [
@ -478,6 +485,7 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'tag': 'ctlplane-subnet',
'mtu': 1500}],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'192.168.24.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
'ctlplane-subnet': {
'AllocationPools': [
@ -508,6 +516,7 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'tag': 'ctlplane-subnet',
'mtu': 1500}],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'192.168.24.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
'ctlplane-subnet': {
'AllocationPools': [
@ -585,6 +594,9 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'192.168.24.0/24': ['192.168.24.0/24',
'192.168.10.0/24',
'192.168.20.0/24']},
'PortPhysnetCidrMap': {'192.168.10.0/24': 'subnet1',
'192.168.20.0/24': 'subnet2',
'192.168.24.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
# The ctlplane-subnet subnet have defaults
'ctlplane-subnet': {
@ -662,6 +674,9 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'mtu': 1500}
],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'192.168.10.0/24': 'subnet1',
'192.168.20.0/24': 'subnet2',
'192.168.24.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
# The ctlplane-subnet subnet have defaults
'ctlplane-subnet': {
@ -721,6 +736,8 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'mtu': 1500},
],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'192.168.10.0/24': 'subnet1',
'192.168.24.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
# The ctlplane-subnet subnet have defaults
'ctlplane-subnet': {
@ -773,6 +790,8 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'mtu': 1500},
],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'192.168.10.0/24': 'subnet1',
'192.168.24.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
# The ctlplane-subnet subnet have defaults
'ctlplane-subnet': {
@ -854,6 +873,9 @@ class TestNetworkSettings(TestBaseNetworkSettings):
'mtu': 1500}
],
'MasqueradeNetworks': {},
'PortPhysnetCidrMap': {'192.168.10.0/24': 'subnet1',
'192.168.20.0/24': 'subnet2',
'192.168.24.0/24': 'ctlplane'},
'UndercloudCtlplaneSubnets': {
# The ctlplane-subnet subnet have defaults
'ctlplane-subnet': {

View File

@ -354,10 +354,23 @@ def _calculate_allocation_pools(subnet):
for ip_range in list(ip_set.iter_ipranges())]
def _generate_inspection_physnet_cidr_map():
cidr_map = {}
for subnet in CONF.subnets:
s = CONF.get(subnet)
if subnet == str(CONF.local_subnet):
cidr_map[s.cidr] = 'ctlplane'
else:
cidr_map[s.cidr] = subnet
return cidr_map
def _process_network_args(env):
"""Populate the environment with network configuration."""
env['IronicInspectorSubnets'] = _generate_inspection_subnets()
env['PortPhysnetCidrMap'] = _generate_inspection_physnet_cidr_map()
env['ControlPlaneStaticRoutes'] = _generate_subnets_static_routes()
env['UndercloudCtlplaneSubnets'] = {}
env['UndercloudCtlplaneIPv6AddressMode'] = CONF['ipv6_address_mode']