From 22fb89a6e165328c3ba23a7f53e5cbe7201d80e4 Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Thu, 24 Nov 2016 11:13:54 +0100 Subject: [PATCH] Make private network optional If a fixed_network and fixed_subnet is specified no private network is created by the templates and the specified network is used instead for VMs provisioning, like in the Ironic driver. Currently missing is the code to handle the use case where you specify a fixed_network but not a fixed_subnet, this will come in a following patch. Partially Implements: blueprint decouple-private-network Change-Id: I2003eb709b22b905063d846eb71570fc5e033618 --- .../environments/no_private_network.yaml | 8 ++++ .../environments/with_private_network.yaml | 8 ++++ .../fragments/network_switcher_existing.yaml | 27 +++++++++++ .../fragments/network_switcher_private.yaml | 27 +++++++++++ magnum/drivers/common/templates/network.yaml | 47 ++++++++++++------- .../drivers/heat/k8s_fedora_template_def.py | 19 ++------ magnum/drivers/heat/k8s_template_def.py | 4 ++ .../drivers/heat/swarm_fedora_template_def.py | 18 ++++--- magnum/drivers/heat/template_def.py | 28 +++++++++++ magnum/drivers/k8s_coreos_v1/template_def.py | 16 ++----- .../k8s_coreos_v1/templates/kubecluster.yaml | 16 ++++++- .../templates/kubecluster.yaml | 16 ++++++- .../drivers/mesos_ubuntu_v1/template_def.py | 14 ++++-- .../templates/mesoscluster.yaml | 14 +++++- .../templates/cluster.yaml | 14 +++++- .../handlers/test_k8s_cluster_conductor.py | 44 ++++++++++++----- .../handlers/test_mesos_cluster_conductor.py | 23 +++++++-- .../handlers/test_swarm_cluster_conductor.py | 27 ++++++++--- 18 files changed, 286 insertions(+), 84 deletions(-) create mode 100644 magnum/drivers/common/templates/environments/no_private_network.yaml create mode 100644 magnum/drivers/common/templates/environments/with_private_network.yaml create mode 100644 magnum/drivers/common/templates/fragments/network_switcher_existing.yaml create mode 100644 magnum/drivers/common/templates/fragments/network_switcher_private.yaml diff --git a/magnum/drivers/common/templates/environments/no_private_network.yaml b/magnum/drivers/common/templates/environments/no_private_network.yaml new file mode 100644 index 0000000000..59e0e62308 --- /dev/null +++ b/magnum/drivers/common/templates/environments/no_private_network.yaml @@ -0,0 +1,8 @@ +resource_registry: + "Magnum::NetworkSwitcher": ../fragments/network_switcher_existing.yaml + + # Cluster template + "Magnum::Optional::Neutron::Subnet": "OS::Heat::None" + "Magnum::Optional::Neutron::Net": "OS::Heat::None" + "Magnum::Optional::Neutron::Router": "OS::Heat::None" + "Magnum::Optional::Neutron::RouterInterface": "OS::Heat::None" diff --git a/magnum/drivers/common/templates/environments/with_private_network.yaml b/magnum/drivers/common/templates/environments/with_private_network.yaml new file mode 100644 index 0000000000..5a4b41558d --- /dev/null +++ b/magnum/drivers/common/templates/environments/with_private_network.yaml @@ -0,0 +1,8 @@ +resource_registry: + "Magnum::NetworkSwitcher": ../fragments/network_switcher_private.yaml + + # Cluster template + "Magnum::Optional::Neutron::Subnet": "OS::Neutron::Subnet" + "Magnum::Optional::Neutron::Net": "OS::Neutron::Net" + "Magnum::Optional::Neutron::Router": "OS::Neutron::Router" + "Magnum::Optional::Neutron::RouterInterface": "OS::Neutron::RouterInterface" diff --git a/magnum/drivers/common/templates/fragments/network_switcher_existing.yaml b/magnum/drivers/common/templates/fragments/network_switcher_existing.yaml new file mode 100644 index 0000000000..e3f14fadb6 --- /dev/null +++ b/magnum/drivers/common/templates/fragments/network_switcher_existing.yaml @@ -0,0 +1,27 @@ +heat_template_version: 2014-10-16 + +parameters: + + private_network: + type: string + default: "" + + existing_network: + type: string + default: "" + + private_subnet: + type: string + default: "" + + existing_subnet: + type: string + default: "" + +outputs: + + network: + value: {get_param: existing_network} + + subnet: + value: {get_param: existing_subnet} diff --git a/magnum/drivers/common/templates/fragments/network_switcher_private.yaml b/magnum/drivers/common/templates/fragments/network_switcher_private.yaml new file mode 100644 index 0000000000..107dd43d63 --- /dev/null +++ b/magnum/drivers/common/templates/fragments/network_switcher_private.yaml @@ -0,0 +1,27 @@ +heat_template_version: 2014-10-16 + +parameters: + + private_network: + type: string + default: "" + + existing_network: + type: string + default: "" + + private_subnet: + type: string + default: "" + + existing_subnet: + type: string + default: "" + +outputs: + + network: + value: {get_param: private_network} + + subnet: + value: {get_param: private_subnet} diff --git a/magnum/drivers/common/templates/network.yaml b/magnum/drivers/common/templates/network.yaml index a51a62ab4e..2399ff8308 100644 --- a/magnum/drivers/common/templates/network.yaml +++ b/magnum/drivers/common/templates/network.yaml @@ -5,12 +5,19 @@ description: > router for our server. parameters: + existing_network: + type: string + default: "" - fixed_network_cidr: + existing_subnet: + type: string + default: "" + + private_network_cidr: type: string description: network range for fixed ip network - fixed_network_name: + private_network_name: type: string description: fixed network name default: "" @@ -24,37 +31,45 @@ parameters: description: uuid/name of a network to use for floating ip addresses resources: - fixed_network: - type: OS::Neutron::Net + private_network: + type: Magnum::Optional::Neutron::Net properties: - name: {get_param: fixed_network_name} + name: {get_param: private_network_name} - fixed_subnet: - type: OS::Neutron::Subnet + private_subnet: + type: Magnum::Optional::Neutron::Subnet properties: - cidr: {get_param: fixed_network_cidr} - network: {get_resource: fixed_network} + cidr: {get_param: private_network_cidr} + network: {get_resource: private_network} dns_nameservers: - {get_param: dns_nameserver} extrouter: - type: OS::Neutron::Router + type: Magnum::Optional::Neutron::Router properties: external_gateway_info: network: {get_param: external_network} extrouter_inside: - type: OS::Neutron::RouterInterface + type: Magnum::Optional::Neutron::RouterInterface properties: router_id: {get_resource: extrouter} - subnet: {get_resource: fixed_subnet} + subnet: {get_resource: private_subnet} + + network_switch: + type: Magnum::NetworkSwitcher + properties: + private_network: {get_resource: private_network} + private_subnet: {get_resource: private_subnet} + existing_network: {get_param: existing_network} + existing_subnet: {get_param: existing_subnet} outputs: fixed_network: description: > - Created fixed network ID - value: {get_resource: fixed_network} + Network ID where to provision machines + value: {get_attr: [network_switch, network]} fixed_subnet: description: > - Created fixed subnet ID - value: {get_resource: fixed_subnet} + Subnet ID where to provision machines + value: {get_attr: [network_switch, subnet]} diff --git a/magnum/drivers/heat/k8s_fedora_template_def.py b/magnum/drivers/heat/k8s_fedora_template_def.py index 35e7e4d475..385ad6139b 100644 --- a/magnum/drivers/heat/k8s_fedora_template_def.py +++ b/magnum/drivers/heat/k8s_fedora_template_def.py @@ -81,18 +81,9 @@ class K8sFedoraTemplateDefinition(k8s_template_def.K8sTemplateDefinition): def get_env_files(self, cluster_template): env_files = [] - if cluster_template.docker_volume_size is None: - env_files.append('no_volume.yaml') - else: - env_files.append('with_volume.yaml') + template_def.add_priv_net_env_file(env_files, cluster_template) + template_def.add_volume_env_file(env_files, cluster_template) + template_def.add_lb_env_file(env_files, cluster_template) + template_def.add_fip_env_file(env_files, cluster_template) - if cluster_template.master_lb_enabled: - env_files.append('with_master_lb.yaml') - else: - env_files.append('no_master_lb.yaml') - if cluster_template.floating_ip_enabled: - env_files.append('enable_floating_ip.yaml') - else: - env_files.append('disable_floating_ip.yaml') - - return [template_def.COMMON_ENV_PATH + ef for ef in env_files] + return env_files diff --git a/magnum/drivers/heat/k8s_template_def.py b/magnum/drivers/heat/k8s_template_def.py index 852baf3f12..f08af20277 100644 --- a/magnum/drivers/heat/k8s_template_def.py +++ b/magnum/drivers/heat/k8s_template_def.py @@ -60,6 +60,10 @@ class K8sTemplateDefinition(template_def.BaseTemplateDefinition): self.add_parameter('external_network', cluster_template_attr='external_network_id', required=True) + self.add_parameter('fixed_network', + cluster_template_attr='fixed_network') + self.add_parameter('fixed_subnet', + cluster_template_attr='fixed_subnet') self.add_parameter('network_driver', cluster_template_attr='network_driver') self.add_parameter('volume_driver', diff --git a/magnum/drivers/heat/swarm_fedora_template_def.py b/magnum/drivers/heat/swarm_fedora_template_def.py index 0ac3325095..148cdcd274 100644 --- a/magnum/drivers/heat/swarm_fedora_template_def.py +++ b/magnum/drivers/heat/swarm_fedora_template_def.py @@ -58,6 +58,10 @@ class SwarmFedoraTemplateDefinition(template_def.BaseTemplateDefinition): self.add_parameter('external_network', cluster_template_attr='external_network_id', required=True) + self.add_parameter('fixed_network', + cluster_template_attr='fixed_network') + self.add_parameter('fixed_subnet', + cluster_template_attr='fixed_subnet') self.add_parameter('network_driver', cluster_template_attr='network_driver') self.add_parameter('tls_disabled', @@ -115,14 +119,8 @@ class SwarmFedoraTemplateDefinition(template_def.BaseTemplateDefinition): def get_env_files(self, cluster_template): env_files = [] - if cluster_template.docker_volume_size is None: - env_files.append('no_volume.yaml') - else: - env_files.append('with_volume.yaml') + template_def.add_priv_net_env_file(env_files, cluster_template) + template_def.add_volume_env_file(env_files, cluster_template) + template_def.add_lb_env_file(env_files, cluster_template) - if cluster_template.master_lb_enabled: - env_files.append('with_master_lb.yaml') - else: - env_files.append('no_master_lb.yaml') - - return [template_def.COMMON_ENV_PATH + ef for ef in env_files] + return env_files diff --git a/magnum/drivers/heat/template_def.py b/magnum/drivers/heat/template_def.py index 577c196f89..13ac63043b 100644 --- a/magnum/drivers/heat/template_def.py +++ b/magnum/drivers/heat/template_def.py @@ -313,3 +313,31 @@ class BaseTemplateDefinition(TemplateDefinition): else: cluster.discovery_url = discovery_url return discovery_url + + +def add_lb_env_file(env_files, cluster_template): + if cluster_template.master_lb_enabled: + env_files.append(COMMON_ENV_PATH + 'with_master_lb.yaml') + else: + env_files.append(COMMON_ENV_PATH + 'no_master_lb.yaml') + + +def add_volume_env_file(env_files, cluster_template): + if cluster_template.docker_volume_size is None: + env_files.append(COMMON_ENV_PATH + 'no_volume.yaml') + else: + env_files.append(COMMON_ENV_PATH + 'with_volume.yaml') + + +def add_fip_env_file(env_files, cluster_template): + if cluster_template.floating_ip_enabled: + env_files.append(COMMON_ENV_PATH + 'enable_floating_ip.yaml') + else: + env_files.append(COMMON_ENV_PATH + 'disable_floating_ip.yaml') + + +def add_priv_net_env_file(env_files, cluster_template): + if cluster_template.fixed_network: + env_files.append(COMMON_ENV_PATH + 'no_private_network.yaml') + else: + env_files.append(COMMON_ENV_PATH + 'with_private_network.yaml') diff --git a/magnum/drivers/k8s_coreos_v1/template_def.py b/magnum/drivers/k8s_coreos_v1/template_def.py index 05f81f1872..e9f5657d12 100644 --- a/magnum/drivers/k8s_coreos_v1/template_def.py +++ b/magnum/drivers/k8s_coreos_v1/template_def.py @@ -32,18 +32,10 @@ class CoreOSK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition): def get_env_files(self, cluster_template): env_files = [] - if cluster_template.master_lb_enabled: - env_files.append( - template_def.COMMON_ENV_PATH + 'with_master_lb.yaml') - else: - env_files.append( - template_def.COMMON_ENV_PATH + 'no_master_lb.yaml') - if cluster_template.floating_ip_enabled: - env_files.append( - template_def.COMMON_ENV_PATH + 'enable_floating_ip.yaml') - else: - env_files.append( - template_def.COMMON_ENV_PATH + 'disable_floating_ip.yaml') + + template_def.add_priv_net_env_file(env_files, cluster_template) + template_def.add_lb_env_file(env_files, cluster_template) + template_def.add_fip_env_file(env_files, cluster_template) return env_files diff --git a/magnum/drivers/k8s_coreos_v1/templates/kubecluster.yaml b/magnum/drivers/k8s_coreos_v1/templates/kubecluster.yaml index 64a1ae3176..9147a1e778 100644 --- a/magnum/drivers/k8s_coreos_v1/templates/kubecluster.yaml +++ b/magnum/drivers/k8s_coreos_v1/templates/kubecluster.yaml @@ -16,6 +16,16 @@ parameters: description: uuid/name of a network to use for floating ip addresses default: public + fixed_network: + type: string + description: uuid/name of an existing network to use to provision machines + default: "" + + fixed_subnet: + type: string + description: uuid/name of an existing subnet to use to provision machines + default: "" + server_image: type: string default: CoreOS @@ -212,10 +222,12 @@ resources: network: type: ../../common/templates/network.yaml properties: - fixed_network_cidr: {get_param: fixed_network_cidr} + existing_network: {get_param: fixed_network} + existing_subnet: {get_param: fixed_subnet} + private_network_cidr: {get_param: fixed_network_cidr} dns_nameserver: {get_param: dns_nameserver} external_network: {get_param: external_network} - fixed_network_name: private + private_network_name: private api_lb: type: ../../common/templates/lb.yaml diff --git a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml index fea34195b6..bb04f74eb0 100644 --- a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml +++ b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml @@ -16,6 +16,16 @@ parameters: description: uuid/name of a network to use for floating ip addresses default: public + fixed_network: + type: string + description: uuid/name of an existing network to use to provision machines + default: "" + + fixed_subnet: + type: string + description: uuid/name of an existing subnet to use to provision machines + default: "" + server_image: type: string description: glance image used to boot the server @@ -276,10 +286,12 @@ resources: network: type: ../../common/templates/network.yaml properties: - fixed_network_cidr: {get_param: fixed_network_cidr} + existing_network: {get_param: fixed_network} + existing_subnet: {get_param: fixed_subnet} + private_network_cidr: {get_param: fixed_network_cidr} dns_nameserver: {get_param: dns_nameserver} external_network: {get_param: external_network} - fixed_network_name: private + private_network_name: private api_lb: type: ../../common/templates/lb.yaml diff --git a/magnum/drivers/mesos_ubuntu_v1/template_def.py b/magnum/drivers/mesos_ubuntu_v1/template_def.py index c2f11cf242..e2bffc86b1 100644 --- a/magnum/drivers/mesos_ubuntu_v1/template_def.py +++ b/magnum/drivers/mesos_ubuntu_v1/template_def.py @@ -24,6 +24,10 @@ class UbuntuMesosTemplateDefinition(template_def.BaseTemplateDefinition): self.add_parameter('external_network', cluster_template_attr='external_network_id', required=True) + self.add_parameter('fixed_network', + cluster_template_attr='fixed_network') + self.add_parameter('fixed_subnet', + cluster_template_attr='fixed_subnet') self.add_parameter('number_of_slaves', cluster_attr='node_count') self.add_parameter('master_flavor', @@ -78,10 +82,12 @@ class UbuntuMesosTemplateDefinition(template_def.BaseTemplateDefinition): **kwargs) def get_env_files(self, cluster_template): - if cluster_template.master_lb_enabled: - return [template_def.COMMON_ENV_PATH + 'with_master_lb.yaml'] - else: - return [template_def.COMMON_ENV_PATH + 'no_master_lb.yaml'] + env_files = [] + + template_def.add_priv_net_env_file(env_files, cluster_template) + template_def.add_lb_env_file(env_files, cluster_template) + + return env_files @property def driver_module_path(self): diff --git a/magnum/drivers/mesos_ubuntu_v1/templates/mesoscluster.yaml b/magnum/drivers/mesos_ubuntu_v1/templates/mesoscluster.yaml index 1b9d00c369..789418f6b3 100644 --- a/magnum/drivers/mesos_ubuntu_v1/templates/mesoscluster.yaml +++ b/magnum/drivers/mesos_ubuntu_v1/templates/mesoscluster.yaml @@ -17,6 +17,16 @@ parameters: description: uuid/name of a network to use for floating ip addresses default: public + fixed_network: + type: string + description: uuid/name of an existing network to use to provision machines + default: "" + + fixed_subnet: + type: string + description: uuid/name of an existing subnet to use to provision machines + default: "" + server_image: type: string default: ubuntu-mesos @@ -207,7 +217,9 @@ resources: network: type: ../../common/templates/network.yaml properties: - fixed_network_cidr: {get_param: fixed_network_cidr} + existing_network: {get_param: fixed_network} + existing_subnet: {get_param: fixed_subnet} + private_network_cidr: {get_param: fixed_network_cidr} dns_nameserver: {get_param: dns_nameserver} external_network: {get_param: external_network} diff --git a/magnum/drivers/swarm_fedora_atomic_v1/templates/cluster.yaml b/magnum/drivers/swarm_fedora_atomic_v1/templates/cluster.yaml index ef535bfb99..402e1130be 100644 --- a/magnum/drivers/swarm_fedora_atomic_v1/templates/cluster.yaml +++ b/magnum/drivers/swarm_fedora_atomic_v1/templates/cluster.yaml @@ -21,6 +21,16 @@ parameters: type: string description: uuid/name of a network to use for floating ip addresses + fixed_network: + type: string + description: uuid/name of an existing network to use to provision machines + default: "" + + fixed_subnet: + type: string + description: uuid/name of an existing subnet to use to provision machines + default: "" + discovery_url: type: string description: url provided for node discovery @@ -246,7 +256,9 @@ resources: network: type: ../../common/templates/network.yaml properties: - fixed_network_cidr: {get_param: fixed_network_cidr} + existing_network: {get_param: fixed_network} + existing_subnet: {get_param: fixed_subnet} + private_network_cidr: {get_param: fixed_network_cidr} dns_nameserver: {get_param: dns_nameserver} external_network: {get_param: external_network} diff --git a/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py b/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py index 78ee9dab2c..5c03ab984d 100644 --- a/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py +++ b/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py @@ -34,6 +34,8 @@ class TestClusterConductorWithK8s(base.TestCase): 'keypair_id': 'keypair_id', 'dns_nameserver': 'dns_nameserver', 'external_network_id': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'network_driver': 'network_driver', 'volume_driver': 'volume_driver', 'docker_volume_size': 20, @@ -153,6 +155,8 @@ class TestClusterConductorWithK8s(base.TestCase): expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'network_driver': 'network_driver', 'volume_driver': 'volume_driver', 'dns_nameserver': 'dns_nameserver', @@ -191,9 +195,11 @@ class TestClusterConductorWithK8s(base.TestCase): self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/with_volume.yaml', + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/with_volume.yaml', '../../common/templates/environments/no_master_lb.yaml', - '../../common/templates/environments/disable_floating_ip.yaml'], + '../../common/templates/environments/disable_floating_ip.yaml', + ], env_files) @patch('requests.get') @@ -234,6 +240,8 @@ class TestClusterConductorWithK8s(base.TestCase): 'docker_storage_driver': 'devicemapper', 'docker_volume_size': 20, 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'flannel_backend': 'vxlan', 'flannel_network_cidr': '10.101.0.0/16', 'flannel_network_subnetlen': '26', @@ -267,9 +275,11 @@ class TestClusterConductorWithK8s(base.TestCase): self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/with_volume.yaml', + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/with_volume.yaml', '../../common/templates/environments/no_master_lb.yaml', - '../../common/templates/environments/disable_floating_ip.yaml'], + '../../common/templates/environments/disable_floating_ip.yaml', + ], env_files) @patch('requests.get') @@ -285,7 +295,7 @@ class TestClusterConductorWithK8s(base.TestCase): 'docker_volume_size', 'fixed_network', 'http_proxy', 'https_proxy', 'no_proxy', 'network_driver', 'master_flavor_id', 'docker_storage_driver', - 'volume_driver'] + 'volume_driver', 'fixed_subnet'] for key in not_required: self.cluster_template_dict[key] = None self.cluster_dict['discovery_url'] = 'https://discovery.etcd.io/test' @@ -334,9 +344,11 @@ class TestClusterConductorWithK8s(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/no_volume.yaml', + ['../../common/templates/environments/with_private_network.yaml', + '../../common/templates/environments/no_volume.yaml', '../../common/templates/environments/no_master_lb.yaml', - '../../common/templates/environments/disable_floating_ip.yaml'], + '../../common/templates/environments/disable_floating_ip.yaml', + ], env_files) @patch('requests.get') @@ -368,6 +380,8 @@ class TestClusterConductorWithK8s(base.TestCase): expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'minion_flavor': 'flavor_id', @@ -398,7 +412,8 @@ class TestClusterConductorWithK8s(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/no_master_lb.yaml', + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/no_master_lb.yaml', '../../common/templates/environments/disable_floating_ip.yaml'], env_files) @@ -429,6 +444,8 @@ class TestClusterConductorWithK8s(base.TestCase): expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'minion_flavor': 'flavor_id', @@ -459,7 +476,8 @@ class TestClusterConductorWithK8s(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/no_master_lb.yaml', + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/no_master_lb.yaml', '../../common/templates/environments/disable_floating_ip.yaml'], env_files) @@ -614,6 +632,8 @@ class TestClusterConductorWithK8s(base.TestCase): expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'master_flavor': 'master_flavor_id', @@ -649,9 +669,11 @@ class TestClusterConductorWithK8s(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/with_volume.yaml', + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/with_volume.yaml', '../../common/templates/environments/no_master_lb.yaml', - '../../common/templates/environments/disable_floating_ip.yaml'], + '../../common/templates/environments/disable_floating_ip.yaml', + ], env_files) reqget.assert_called_once_with('http://etcd/test?size=1') diff --git a/magnum/tests/unit/conductor/handlers/test_mesos_cluster_conductor.py b/magnum/tests/unit/conductor/handlers/test_mesos_cluster_conductor.py index f04b1d013d..ff14d92f7c 100644 --- a/magnum/tests/unit/conductor/handlers/test_mesos_cluster_conductor.py +++ b/magnum/tests/unit/conductor/handlers/test_mesos_cluster_conductor.py @@ -47,6 +47,8 @@ class TestClusterConductorWithMesos(base.TestCase): 'mesos_slave_work_dir': '/tmp/mesos/slave' }, 'master_lb_enabled': False, + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', } self.cluster_dict = { 'id': 1, @@ -99,6 +101,8 @@ class TestClusterConductorWithMesos(base.TestCase): expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'master_flavor': 'master_flavor_id', @@ -128,7 +132,8 @@ class TestClusterConductorWithMesos(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/no_master_lb.yaml'], + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/no_master_lb.yaml'], env_files) @patch('magnum.objects.ClusterTemplate.get_by_uuid') @@ -139,7 +144,8 @@ class TestClusterConductorWithMesos(base.TestCase): mock_objects_cluster_template_get_by_uuid): not_required = ['image_id', 'master_flavor_id', 'flavor_id', 'dns_nameserver', 'fixed_network', 'http_proxy', - 'https_proxy', 'no_proxy', 'volume_driver'] + 'https_proxy', 'no_proxy', 'volume_driver', + 'fixed_subnet'] for key in not_required: self.cluster_template_dict[key] = None @@ -179,7 +185,8 @@ class TestClusterConductorWithMesos(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/no_master_lb.yaml'], + ['../../common/templates/environments/with_private_network.yaml', + '../../common/templates/environments/no_master_lb.yaml'], env_files) @patch('magnum.objects.ClusterTemplate.get_by_uuid') @@ -204,6 +211,8 @@ class TestClusterConductorWithMesos(base.TestCase): expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'master_flavor': 'master_flavor_id', @@ -233,7 +242,8 @@ class TestClusterConductorWithMesos(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/with_master_lb.yaml'], + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/with_master_lb.yaml'], env_files) @patch('magnum.objects.ClusterTemplate.get_by_uuid') @@ -259,6 +269,8 @@ class TestClusterConductorWithMesos(base.TestCase): expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'master_flavor': 'master_flavor_id', @@ -288,7 +300,8 @@ class TestClusterConductorWithMesos(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/with_master_lb.yaml'], + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/with_master_lb.yaml'], env_files) @patch('magnum.conductor.utils.retrieve_cluster_template') diff --git a/magnum/tests/unit/conductor/handlers/test_swarm_cluster_conductor.py b/magnum/tests/unit/conductor/handlers/test_swarm_cluster_conductor.py index 65d79f4db2..6e531ad010 100644 --- a/magnum/tests/unit/conductor/handlers/test_swarm_cluster_conductor.py +++ b/magnum/tests/unit/conductor/handlers/test_swarm_cluster_conductor.py @@ -37,6 +37,8 @@ class TestClusterConductorWithSwarm(base.TestCase): 'docker_volume_size': 20, 'docker_storage_driver': 'devicemapper', 'external_network_id': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'cluster_distro': 'fedora-atomic', 'coe': 'swarm', 'http_proxy': 'http_proxy', @@ -111,6 +113,8 @@ class TestClusterConductorWithSwarm(base.TestCase): expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'master_flavor': 'master_flavor_id', @@ -144,7 +148,8 @@ class TestClusterConductorWithSwarm(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/with_volume.yaml', + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/with_volume.yaml', '../../common/templates/environments/no_master_lb.yaml'], env_files) @@ -181,6 +186,8 @@ class TestClusterConductorWithSwarm(base.TestCase): expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'master_flavor': 'master_flavor_id', @@ -216,7 +223,8 @@ class TestClusterConductorWithSwarm(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/with_volume.yaml', + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/with_volume.yaml', '../../common/templates/environments/no_master_lb.yaml'], env_files) @@ -233,7 +241,7 @@ class TestClusterConductorWithSwarm(base.TestCase): 'docker_volume_size', 'fixed_network', 'http_proxy', 'https_proxy', 'no_proxy', 'network_driver', 'master_flavor_id', 'docker_storage_driver', - 'volume_driver', 'rexray_preempt'] + 'volume_driver', 'rexray_preempt', 'fixed_subnet'] for key in not_required: self.cluster_template_dict[key] = None self.cluster_dict['discovery_url'] = 'https://discovery.etcd.io/test' @@ -280,7 +288,8 @@ class TestClusterConductorWithSwarm(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/no_volume.yaml', + ['../../common/templates/environments/with_private_network.yaml', + '../../common/templates/environments/no_volume.yaml', '../../common/templates/environments/no_master_lb.yaml'], env_files) @@ -313,6 +322,8 @@ class TestClusterConductorWithSwarm(base.TestCase): expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'master_flavor': 'master_flavor_id', @@ -346,7 +357,8 @@ class TestClusterConductorWithSwarm(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/with_volume.yaml', + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/with_volume.yaml', '../../common/templates/environments/with_master_lb.yaml'], env_files) @@ -380,6 +392,8 @@ class TestClusterConductorWithSwarm(base.TestCase): expected = { 'ssh_key_name': 'keypair_id', 'external_network': 'external_network_id', + 'fixed_network': 'fixed_network', + 'fixed_subnet': 'fixed_subnet', 'dns_nameserver': 'dns_nameserver', 'server_image': 'image_id', 'master_flavor': 'master_flavor_id', @@ -413,7 +427,8 @@ class TestClusterConductorWithSwarm(base.TestCase): } self.assertEqual(expected, definition) self.assertEqual( - ['../../common/templates/environments/with_volume.yaml', + ['../../common/templates/environments/no_private_network.yaml', + '../../common/templates/environments/with_volume.yaml', '../../common/templates/environments/with_master_lb.yaml'], env_files)