Merge "Fix label fixed_network_cidr"

This commit is contained in:
Zuul 2020-06-11 11:20:37 +00:00 committed by Gerrit Code Review
commit 52690900a7
13 changed files with 113 additions and 37 deletions

View File

@ -66,7 +66,7 @@ parameters:
description: uuid/name of an existing subnet to use to provision machines
default: ""
fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@ -347,7 +347,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}

View File

@ -45,7 +45,7 @@ parameters:
description: how many kubernetes minions to spawn
default: 1
fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@ -328,7 +328,7 @@ resources:
fixed_subnet:
type: OS::Neutron::Subnet
properties:
cidr: {get_param: fixed_network_cidr}
cidr: {get_param: fixed_subnet_cidr}
network: {get_resource: fixed_network}
dns_nameservers:
- {get_param: dns_nameserver}

View File

@ -483,6 +483,8 @@ the table are linked to more details elsewhere in the user guide.
+---------------------------------------+--------------------+---------------+
| `calico_ipv4pool_ipip`_ | see below | Off |
+---------------------------------------+--------------------+---------------+
| `fixed_subnet_cidr`_ | see below | "" |
+---------------------------------------+--------------------+---------------+
.. _cluster:
@ -1630,6 +1632,11 @@ _`metrics_scraper_tag`
The version of metrics-scraper used by kubernetes dashboard.
Ussuri default: v1.0.4
_`fixed_subnet_cidr`
CIDR of the fixed subnet created by Magnum when a user has not
specified an existing fixed_subnet during cluster creation.
Ussuri default: 10.0.0.0/24
External load balancer for services
-----------------------------------

View File

@ -188,6 +188,10 @@ class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
else:
extra_params['fixed_network_name'] = cluster.name
if cluster.labels.get('fixed_subnet_cidr'):
extra_params['fixed_subnet_cidr'] = cluster.labels.get(
'fixed_subnet_cidr')
# NOTE(brtknr): Convert fixed subnet name to UUID. If fixed_subnet
# is not specified in cluster template use 'private' as the default
# value, which is the same as the heat template default value.
@ -195,6 +199,12 @@ class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
subnet_id = neutron.get_fixed_subnet_id(context, fixed_subnet)
if subnet_id:
extra_params['fixed_subnet'] = subnet_id
# NOTE(flwang): If a fixed subnet is given, then the label
# fixed_subnet_cidr should be updated to reflect the correct
# setting.
extra_params['fixed_subnet_cidr'] = neutron.get_subnet(
context, subnet_id, "id", "cidr")
return extra_params
def get_params(self, context, cluster_template, cluster, **kwargs):
@ -272,7 +282,7 @@ class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
def _set_master_lb_allowed_cidrs(self, context, cluster, extra_params):
if extra_params.get("master_lb_allowed_cidrs"):
subnet_cidr = (cluster.labels.get("fixed_network_cidr") or
subnet_cidr = (cluster.labels.get("fixed_subnet_cidr") or
"10.0.0.0/24")
if extra_params.get("fixed_subnet"):
subnet_cidr = neutron.get_subnet(context,

View File

@ -104,7 +104,7 @@ parameters:
description: how many kubernetes minions to spawn
default: 1
fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@ -540,7 +540,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}
private_network_name: private

View File

@ -170,7 +170,7 @@ parameters:
description: how many kubernetes minions to spawn
default: 1
fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@ -936,7 +936,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}
private_network_name: {get_param: fixed_network_name}

View File

@ -170,7 +170,7 @@ parameters:
description: how many kubernetes minions to spawn
default: 1
fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@ -959,7 +959,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}
private_network_name: {get_param: fixed_network_name}

View File

@ -67,7 +67,7 @@ parameters:
description: how many mesos slaves to spawn initially
default: 1
fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@ -251,7 +251,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}

View File

@ -103,7 +103,7 @@ parameters:
description: how many swarm nodes to spawn
default: 1
fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: "10.0.0.0/24"
@ -291,7 +291,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}
@ -328,7 +328,7 @@ resources:
port_range_min: 2376
port_range_max: 2376
- protocol: tcp
remote_ip_prefix: {get_param: fixed_network_cidr}
remote_ip_prefix: {get_param: fixed_subnet_cidr}
port_range_min: 1
port_range_max: 65535
- protocol: udp

View File

@ -102,7 +102,7 @@ parameters:
type: number
description: how many secondary masters to spawn
fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: "10.0.0.0/24"
@ -228,7 +228,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}
@ -261,7 +261,7 @@ resources:
port_range_min: 2377
port_range_max: 2377
- protocol: tcp
remote_ip_prefix: {get_param: fixed_network_cidr}
remote_ip_prefix: {get_param: fixed_subnet_cidr}
port_range_min: 1
port_range_max: 65535
- protocol: udp

View File

@ -186,7 +186,9 @@ class TestClusterConductorWithK8s(base.TestCase):
'lvmdriver-1', group='cinder')
CONF.set_override('default_etcd_volume_type',
'lvmdriver-1', group='cinder')
self.fixed_subnet_cidr = '20.200.0.0/16'
@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@ -201,11 +203,12 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
self._test_extract_template_definition(
mock_generate_csr_and_key, mock_sign_node_certificate,
mock_driver, mock_objects_cluster_template_get_by_uuid, mock_get,
mock_objects_nodegroup_list)
mock_objects_nodegroup_list, mock_get_subnet)
def _test_extract_template_definition(
self,
@ -215,6 +218,7 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_cluster_template_get_by_uuid,
mock_get,
mock_objects_nodegroup_list,
mock_get_subnet,
missing_attr=None):
if missing_attr in self.cluster_template_dict:
self.cluster_template_dict[missing_attr] = None
@ -243,6 +247,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_nodegroup_list.return_value = [master_ng, worker_ng]
mock_driver.return_value = k8s_dr.Driver()
mock_get_subnet.return_value = self.fixed_subnet_cidr
(template_path,
definition,
env_files) = mock_driver()._extract_template_definition(self.context,
@ -374,6 +380,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'worker_nodegroup_name': 'worker_ng',
'post_install_manifest_url': '',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr,
}
if missing_attr is not None:
@ -397,6 +404,7 @@ class TestClusterConductorWithK8s(base.TestCase):
],
env_files)
@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@ -411,7 +419,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
self.cluster_template_dict['registry_enabled'] = True
cluster_template = objects.ClusterTemplate(
self.context, **self.cluster_template_dict)
@ -431,6 +440,7 @@ class TestClusterConductorWithK8s(base.TestCase):
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
mock_objects_nodegroup_list.return_value = [master_ng, worker_ng]
mock_driver.return_value = k8s_dr.Driver()
mock_get_subnet.return_value = self.fixed_subnet_cidr
CONF.set_override('swift_region',
'RegionOne',
@ -527,6 +537,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'worker_nodegroup_name': 'worker_ng',
'post_install_manifest_url': '',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr
}
self.assertEqual(expected, definition)
@ -540,6 +551,7 @@ class TestClusterConductorWithK8s(base.TestCase):
],
env_files)
@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@ -554,7 +566,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
not_required = ['image_id', 'flavor_id', 'dns_nameserver',
'docker_volume_size', 'http_proxy',
@ -586,6 +599,7 @@ class TestClusterConductorWithK8s(base.TestCase):
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
master_ng.image_id = None
mock_objects_nodegroup_list.return_value = [master_ng, worker_ng]
mock_get_subnet.return_value = self.fixed_subnet_cidr
(template_path,
definition,
@ -661,6 +675,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'worker_nodegroup_name': 'worker_ng',
'post_install_manifest_url': '',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr
}
self.assertEqual(expected, definition)
self.assertEqual(
@ -673,6 +688,7 @@ class TestClusterConductorWithK8s(base.TestCase):
],
env_files)
@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@ -682,7 +698,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
self.cluster_template_dict['cluster_distro'] = 'coreos'
cluster_template = objects.ClusterTemplate(
self.context, **self.cluster_template_dict)
@ -699,6 +716,7 @@ class TestClusterConductorWithK8s(base.TestCase):
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
mock_objects_nodegroup_list.return_value = [master_ng, worker_ng]
mock_driver.return_value = k8s_coreos_dr.Driver()
mock_get_subnet.return_value = self.fixed_subnet_cidr
(template_path,
definition,
@ -774,6 +792,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'master_nodegroup_name': 'master_ng',
'worker_nodegroup_name': 'worker_ng',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr,
}
self.assertEqual(expected, definition)
self.assertEqual(
@ -786,6 +805,7 @@ class TestClusterConductorWithK8s(base.TestCase):
],
env_files)
@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@ -795,7 +815,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
reqget):
reqget,
mock_get_subnet):
self.cluster_template_dict['cluster_distro'] = 'coreos'
self.cluster_dict['discovery_url'] = None
mock_req = mock.MagicMock(text='http://tokentest/h1/h2/h3',
@ -810,6 +831,7 @@ class TestClusterConductorWithK8s(base.TestCase):
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
mock_objects_nodegroup_list.return_value = [master_ng, worker_ng]
mock_driver.return_value = k8s_coreos_dr.Driver()
mock_get_subnet.return_value = self.fixed_subnet_cidr
(template_path,
definition,
@ -885,6 +907,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'master_nodegroup_name': 'master_ng',
'worker_nodegroup_name': 'worker_ng',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr,
}
self.assertEqual(expected, definition)
self.assertEqual(
@ -897,6 +920,7 @@ class TestClusterConductorWithK8s(base.TestCase):
],
env_files)
@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@ -911,7 +935,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
mock_driver.return_value = k8s_dr.Driver()
self._test_extract_template_definition(
mock_generate_csr_and_key,
@ -920,8 +945,10 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_cluster_template_get_by_uuid,
mock_get,
mock_objects_nodegroup_list,
mock_get_subnet,
missing_attr='dns_nameserver')
@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@ -936,7 +963,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
mock_driver.return_value = k8s_dr.Driver()
self._test_extract_template_definition(
mock_generate_csr_and_key,
@ -945,8 +973,10 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_cluster_template_get_by_uuid,
mock_get,
mock_objects_nodegroup_list,
mock_get_subnet,
missing_attr='image_id')
@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@ -961,7 +991,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
mock_driver.return_value = k8s_dr.Driver()
self._test_extract_template_definition(
mock_generate_csr_and_key,
@ -970,8 +1001,10 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_cluster_template_get_by_uuid,
mock_get,
mock_objects_nodegroup_list,
mock_get_subnet,
missing_attr='docker_storage_driver')
@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@ -986,7 +1019,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
mock_driver.return_value = k8s_dr.Driver()
self._test_extract_template_definition(
mock_generate_csr_and_key,
@ -995,8 +1029,10 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_cluster_template_get_by_uuid,
mock_get,
mock_objects_nodegroup_list,
mock_get_subnet,
missing_attr='apiserver_port')
@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@ -1011,7 +1047,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
reqget):
reqget,
mock_get_subnet):
cluster_template = objects.ClusterTemplate(
self.context, **self.cluster_template_dict)
mock_generate_csr_and_key.return_value = {'csr': 'csr',
@ -1034,6 +1071,7 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_req = mock.MagicMock(text='https://address/token',
status_code=200)
reqget.return_value = mock_req
mock_get_subnet.return_value = self.fixed_subnet_cidr
(template_path,
definition,
@ -1120,6 +1158,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'worker_nodegroup_name': 'worker_ng',
'post_install_manifest_url': '',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr,
}
self.assertEqual(expected, definition)
self.assertEqual(

View File

@ -427,6 +427,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
}
self.assertEqual(scale_params, expected_scale_params)
@mock.patch('magnum.common.neutron.get_subnet')
@mock.patch('magnum.drivers.heat.k8s_template_def.K8sTemplateDefinition'
'._set_master_lb_allowed_cidrs')
@mock.patch('magnum.common.neutron.get_fixed_network_name')
@ -447,7 +448,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_get_discovery_url, mock_osc_class,
mock_enable_octavia,
mock_get_fixed_network_name,
mock_set_master_lb_allowed_cidrs):
mock_set_master_lb_allowed_cidrs,
mock_get_subnet):
mock_generate_csr_and_key.return_value = {'csr': 'csr',
'private_key': 'private_key',
'public_key': 'public_key'}
@ -479,6 +481,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_context.auth_url = 'http://192.168.10.10:5000/v3'
mock_context.user_name = 'fake_user'
mock_get_subnet.return_value = '20.200.0.0/16'
flannel_cidr = mock_cluster.labels.get('flannel_network_cidr')
flannel_subnet = mock_cluster.labels.get(
@ -755,6 +758,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
'post_install_manifest_url': '',
'metrics_scraper_tag': metrics_scraper_tag,
'master_lb_allowed_cidrs': master_lb_allowed_cidrs,
'fixed_subnet_cidr': '20.200.0.0/16',
}}
mock_get_params.assert_called_once_with(mock_context,
mock_cluster_template,
@ -781,6 +785,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_cluster.fixed_network
)
@mock.patch('magnum.common.neutron.get_subnet')
@mock.patch('magnum.common.neutron.get_external_network_id')
@mock.patch('magnum.common.keystone.is_octavia_enabled')
@mock.patch('magnum.common.clients.OpenStackClients')
@ -798,7 +803,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_get_discovery_url,
mock_osc_class,
mock_enable_octavia,
mock_get_external_network_id):
mock_get_external_network_id,
mock_get_subnet):
mock_generate_csr_and_key.return_value = {'csr': 'csr',
'private_key': 'private_key',
'public_key': 'public_key'}
@ -842,6 +848,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_cluster_template.external_network_id
)
@mock.patch('magnum.common.neutron.get_subnet')
@mock.patch('magnum.common.keystone.is_octavia_enabled')
@mock.patch('magnum.common.clients.OpenStackClients')
@mock.patch('magnum.drivers.k8s_fedora_atomic_v1.template_def'
@ -857,7 +864,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_get_params,
mock_get_discovery_url,
mock_osc_class,
mock_enable_octavia):
mock_enable_octavia,
mock_get_subnet):
mock_generate_csr_and_key.return_value = {'csr': 'csr',
'private_key': 'private_key',
'public_key': 'public_key'}
@ -897,6 +905,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_cluster,
)
@mock.patch('magnum.common.neutron.get_subnet')
@mock.patch('magnum.common.keystone.is_octavia_enabled')
@mock.patch('magnum.common.clients.OpenStackClients')
@mock.patch('magnum.drivers.k8s_fedora_atomic_v1.template_def'
@ -912,7 +921,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_get_params,
mock_get_discovery_url,
mock_osc_class,
mock_enable_octavia):
mock_enable_octavia,
mock_get_subnet):
mock_generate_csr_and_key.return_value = {'csr': 'csr',
'private_key': 'private_key',
'public_key': 'public_key'}
@ -951,6 +961,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
actual_params.get("ingress_controller")
)
@mock.patch('magnum.common.neutron.get_subnet')
@mock.patch('magnum.drivers.heat.k8s_template_def.K8sTemplateDefinition'
'._set_master_lb_allowed_cidrs')
@mock.patch('magnum.common.keystone.is_octavia_enabled')
@ -969,7 +980,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_get_output, mock_get_params,
mock_get_discovery_url, mock_osc_class,
mock_enable_octavia,
mock_set_master_lb_allowed_cidrs):
mock_set_master_lb_allowed_cidrs,
mock_get_subnet):
mock_generate_csr_and_key.return_value = {'csr': 'csr',
'private_key': 'private_key',
'public_key': 'public_key'}
@ -999,6 +1011,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_context.auth_url = 'http://192.168.10.10:5000/v3'
mock_context.user_name = 'fake_user'
mock_get_subnet.return_value = "20.200.0.0/16"
flannel_cidr = mock_cluster.labels.get('flannel_network_cidr')
flannel_subnet = mock_cluster.labels.get(
@ -1278,6 +1291,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
'post_install_manifest_url': '',
'metrics_scraper_tag': metrics_scraper_tag,
'master_lb_allowed_cidrs': master_lb_allowed_cidrs,
'fixed_subnet_cidr': '20.200.0.0/16',
}}
mock_get_params.assert_called_once_with(mock_context,
mock_cluster_template,
@ -1554,12 +1568,12 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
self.assertEqual(extra_params["master_lb_allowed_cidrs"],
"192.168.0.0/16,10.0.0.0/24")
def test_set_master_lb_allowed_cidrs_fixed_network_cidr(self):
def test_set_master_lb_allowed_cidrs_fixed_subnet_cidr(self):
definition = self.get_definition()
extra_params = {"master_lb_allowed_cidrs": "192.168.0.0/16"}
mock_cluster = mock.MagicMock()
mock_context = mock.MagicMock()
mock_cluster.labels = {"fixed_network_cidr": "100.0.0.0/24"}
mock_cluster.labels = {"fixed_subnet_cidr": "100.0.0.0/24"}
definition._set_master_lb_allowed_cidrs(mock_context,
mock_cluster, extra_params)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Now the label `fixed_network_cidr` have been renamed with
`fixed_subnet_cidr`. And it can be passed in and set
correctly.