From 9cd91775f249bd1e171b3f5c81585a64d01f9e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Jens=C3=A5s?= Date: Thu, 23 Apr 2020 10:52:44 +0200 Subject: [PATCH] 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 --- ...ort-physnet-cidr-map-463a1639aba45832.yaml | 6 +++++ .../tests/v1/undercloud/test_config.py | 22 +++++++++++++++++++ tripleoclient/v1/undercloud_config.py | 13 +++++++++++ 3 files changed, 41 insertions(+) create mode 100644 releasenotes/notes/port-physnet-cidr-map-463a1639aba45832.yaml diff --git a/releasenotes/notes/port-physnet-cidr-map-463a1639aba45832.yaml b/releasenotes/notes/port-physnet-cidr-map-463a1639aba45832.yaml new file mode 100644 index 000000000..77886d7de --- /dev/null +++ b/releasenotes/notes/port-physnet-cidr-map-463a1639aba45832.yaml @@ -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 `_. diff --git a/tripleoclient/tests/v1/undercloud/test_config.py b/tripleoclient/tests/v1/undercloud/test_config.py index a245215d3..e17b9f1ea 100644 --- a/tripleoclient/tests/v1/undercloud/test_config.py +++ b/tripleoclient/tests/v1/undercloud/test_config.py @@ -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': { diff --git a/tripleoclient/v1/undercloud_config.py b/tripleoclient/v1/undercloud_config.py index 135d961d1..255fef763 100644 --- a/tripleoclient/v1/undercloud_config.py +++ b/tripleoclient/v1/undercloud_config.py @@ -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']