From 5672b1f869fdf6adc5ea1acef8d634d70aa957d9 Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Thu, 5 Jul 2018 16:30:30 -0400 Subject: [PATCH 1/8] Fixed vlan subnet issue. --- SoftLayer/CLI/virt/create.py | 12 ++++++++++++ SoftLayer/managers/vs.py | 26 ++++++++++++++++++++------ tests/CLI/modules/vs_tests.py | 25 +++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/SoftLayer/CLI/virt/create.py b/SoftLayer/CLI/virt/create.py index 4bb3427f0..69e9d3ea4 100644 --- a/SoftLayer/CLI/virt/create.py +++ b/SoftLayer/CLI/virt/create.py @@ -133,6 +133,12 @@ def _parse_create_args(client, args): if args.get('vlan_private'): data['private_vlan'] = args['vlan_private'] + if args.get('subnet_public'): + data['public_subnet'] = args['subnet_public'] + + if args.get('subnet_private'): + data['private_subnet'] = args['subnet_private'] + if args.get('public_security_group'): pub_groups = args.get('public_security_group') data['public_security_groups'] = [group for group in pub_groups] @@ -231,6 +237,12 @@ def _parse_create_args(client, args): help="The ID of the private VLAN on which you want the virtual " "server placed", type=click.INT) +@click.option('--subnet-public', + help="The ID of the public SUBNET on which you want the virtual server placed", + type=click.INT) +@click.option('--subnet-private', + help="The ID of the private SUBNET on which you want the virtual server placed", + type=click.INT) @helpers.multi_option('--public-security-group', '-S', help=('Security group ID to associate with ' diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index 7f9e56abe..d250627ac 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -305,6 +305,7 @@ def _generate_create_dict( hostname=None, domain=None, local_disk=True, datacenter=None, os_code=None, image_id=None, dedicated=False, public_vlan=None, private_vlan=None, + private_subnet=None, public_subnet=None, userdata=None, nic_speed=None, disks=None, post_uri=None, private=False, ssh_keys=None, public_security_groups=None, private_security_groups=None, boot_mode=None, **kwargs): @@ -366,13 +367,26 @@ def _generate_create_dict( data["datacenter"] = {"name": datacenter} if public_vlan: - data.update({ - 'primaryNetworkComponent': { - "networkVlan": {"id": int(public_vlan)}}}) + if public_subnet: + data.update({ + 'primaryNetworkComponent': { + "networkVlan": {"id": int(public_vlan), + "primarySubnet": {"id": int(public_subnet)}}}}) + else: + data.update({ + 'primaryNetworkComponent': { + "networkVlan": {"id": int(public_vlan)}}}) + if private_vlan: - data.update({ - "primaryBackendNetworkComponent": { - "networkVlan": {"id": int(private_vlan)}}}) + if private_subnet: + data.update({ + 'primaryBackendNetworkComponent': { + "networkVlan": {"id": int(private_vlan), + "primarySubnet": {"id": int(private_subnet)}}}}) + else: + data.update({ + "primaryBackendNetworkComponent": { + "networkVlan": {"id": int(private_vlan)}}}) if public_security_groups: secgroups = [{'securityGroup': {'id': int(sg)}} diff --git a/tests/CLI/modules/vs_tests.py b/tests/CLI/modules/vs_tests.py index c7ce60be8..ae643c834 100644 --- a/tests/CLI/modules/vs_tests.py +++ b/tests/CLI/modules/vs_tests.py @@ -337,6 +337,31 @@ def test_create(self, confirm_mock): self.assert_called_with('SoftLayer_Virtual_Guest', 'createObject', args=args) + @mock.patch('SoftLayer.CLI.formatting.confirm') + def test_create_vlan_subnet(self, confirm_mock): + confirm_mock.return_value = True + + result = self.run_command(['vs', 'create', + '--cpu=2', + '--domain=example.com', + '--hostname=host', + '--os=UBUNTU_LATEST', + '--memory=1', + '--billing=hourly', + '--datacenter=dal05', + '--vlan-private=577940', + '--subnet-private=478700', + '--vlan-public=1639255', + '--subnet-public=297614', + '--tag=dev', + '--tag=green']) + + self.assert_no_fail(result) + self.assertEqual(json.loads(result.output), + {'guid': '1a2b3c-1701', + 'id': 100, + 'created': '2013-08-01 15:23:45'}) + @mock.patch('SoftLayer.CLI.formatting.confirm') def test_create_with_wait_ready(self, confirm_mock): mock = self.set_mock('SoftLayer_Virtual_Guest', 'getObject') From 22f892c551da78a1a54bdeb65e8d6dee049464fb Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Fri, 6 Jul 2018 18:36:32 -0400 Subject: [PATCH 2/8] Fixed vlan subnet issue. --- SoftLayer/CLI/virt/create.py | 15 ++++---- SoftLayer/managers/vs.py | 68 ++++++++++++++++++++++++------------ 2 files changed, 55 insertions(+), 28 deletions(-) diff --git a/SoftLayer/CLI/virt/create.py b/SoftLayer/CLI/virt/create.py index 69e9d3ea4..4010a6e59 100644 --- a/SoftLayer/CLI/virt/create.py +++ b/SoftLayer/CLI/virt/create.py @@ -65,7 +65,6 @@ def _update_with_like_args(ctx, _, value): ctx.default_map = {} ctx.default_map.update(like_args) - def _parse_create_args(client, args): """Converts CLI arguments to args for VSManager.create_instance. @@ -121,10 +120,7 @@ def _parse_create_args(client, args): # Get the SSH keys if args.get('key'): keys = [] - for key in args.get('key'): - resolver = SoftLayer.SshKeyManager(client).resolve_ids - key_id = helpers.resolve_id(resolver, key, 'SshKey') - keys.append(key_id) + _add_keys(args, client, keys) data['ssh_keys'] = keys if args.get('vlan_public'): @@ -156,6 +152,13 @@ def _parse_create_args(client, args): return data +def _add_keys(args, client, keys): + for key in args.get('key'): + resolver = SoftLayer.SshKeyManager(client).resolve_ids + key_id = helpers.resolve_id(resolver, key, 'SshKey') + keys.append(key_id) + + @click.command(epilog="See 'slcli vs create-options' for valid options") @click.option('--hostname', '-H', help="Host portion of the FQDN", @@ -231,7 +234,7 @@ def _parse_create_args(client, args): type=click.Path(exists=True, readable=True, resolve_path=True)) @click.option('--vlan-public', help="The ID of the public VLAN on which you want the virtual " - "server placed", + "server placed", type=click.INT) @click.option('--vlan-private', help="The ID of the private VLAN on which you want the virtual " diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index d250627ac..97e0771bd 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -16,8 +16,9 @@ from SoftLayer.managers import ordering from SoftLayer import utils - LOGGER = logging.getLogger(__name__) + + # pylint: disable=no-self-use @@ -366,27 +367,10 @@ def _generate_create_dict( if datacenter: data["datacenter"] = {"name": datacenter} - if public_vlan: - if public_subnet: - data.update({ - 'primaryNetworkComponent': { - "networkVlan": {"id": int(public_vlan), - "primarySubnet": {"id": int(public_subnet)}}}}) - else: - data.update({ - 'primaryNetworkComponent': { - "networkVlan": {"id": int(public_vlan)}}}) - - if private_vlan: - if private_subnet: - data.update({ - 'primaryBackendNetworkComponent': { - "networkVlan": {"id": int(private_vlan), - "primarySubnet": {"id": int(private_subnet)}}}}) - else: - data.update({ - "primaryBackendNetworkComponent": { - "networkVlan": {"id": int(private_vlan)}}}) + if private_vlan and public_vlan: + network_components = self._create_network_components(public_vlan, private_vlan, + private_subnet, public_subnet) + data.update(network_components) if public_security_groups: secgroups = [{'securityGroup': {'id': int(sg)}} @@ -429,6 +413,46 @@ def _generate_create_dict( return data + def _create_network_components( + self, public_vlan=None, private_vlan=None, + private_subnet=None, public_subnet=None, **kwargs): + + if private_vlan and public_vlan: + if private_subnet and public_subnet: + parameters = { + 'primaryNetworkComponent': { + "networkVlan": {"primarySubnet": {"id": int(public_subnet)}}}, + 'primaryBackendNetworkComponent': { + "networkVlan": {"primarySubnet": {"id": int(private_subnet)}}}} + else: + if private_subnet: + parameters = { + 'primaryNetworkComponent': { + "networkVlan": {"id": int(public_vlan)}}, + 'primaryBackendNetworkComponent': { + "networkVlan": {"primarySubnet": {"id": int(private_subnet)}}} + } + else: + parameters = { + 'primaryNetworkComponent': { + "networkVlan": {"primarySubnet": {"id": int(public_subnet)}}}, + 'primaryBackendNetworkComponent': { + "networkVlan": {"id": int(private_vlan)}} + } + else: + if private_vlan: + parameters = { + 'primaryBackendNetworkComponent': { + "networkVlan": {"id": int(private_vlan)}} + } + else: + parameters = { + 'primaryNetworkComponent': { + "networkVlan": {"id": int(public_vlan)}} + } + + return parameters + @retry(logger=LOGGER) def wait_for_transaction(self, instance_id, limit, delay=10): """Waits on a VS transaction for the specified amount of time. From 4418057fc0e3632aba2d89b6e42494c79cadd16a Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Fri, 6 Jul 2018 19:03:30 -0400 Subject: [PATCH 3/8] Fixed vlan subnet issue. --- SoftLayer/managers/vs.py | 2 +- tests/managers/vs_tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index 97e0771bd..cd3f74ffe 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -367,7 +367,7 @@ def _generate_create_dict( if datacenter: data["datacenter"] = {"name": datacenter} - if private_vlan and public_vlan: + if private_vlan or public_vlan: network_components = self._create_network_components(public_vlan, private_vlan, private_subnet, public_subnet) data.update(network_components) diff --git a/tests/managers/vs_tests.py b/tests/managers/vs_tests.py index 7f4592ea1..4ec579005 100644 --- a/tests/managers/vs_tests.py +++ b/tests/managers/vs_tests.py @@ -373,7 +373,7 @@ def test_generate_private_vlan(self): 'localDiskFlag': True, 'operatingSystemReferenceCode': "STRING", 'hourlyBillingFlag': True, - 'primaryBackendNetworkComponent': {"networkVlan": {"id": 1}}, + 'primaryBackendNetworkComponent': {'networkVlan': {'id': 1}}, 'supplementalCreateObjectOptions': {'bootMode': None}, } From 0fdd8ddfc7d24b4b362cdf5afa6e4a51c256fb5d Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Fri, 6 Jul 2018 19:12:07 -0400 Subject: [PATCH 4/8] Fixed vlan subnet issue. --- SoftLayer/CLI/virt/create.py | 1 + 1 file changed, 1 insertion(+) diff --git a/SoftLayer/CLI/virt/create.py b/SoftLayer/CLI/virt/create.py index 4010a6e59..4843b46ff 100644 --- a/SoftLayer/CLI/virt/create.py +++ b/SoftLayer/CLI/virt/create.py @@ -65,6 +65,7 @@ def _update_with_like_args(ctx, _, value): ctx.default_map = {} ctx.default_map.update(like_args) + def _parse_create_args(client, args): """Converts CLI arguments to args for VSManager.create_instance. From 86bf981800b497fccdec5ab6c22661a5cd1b008a Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Mon, 9 Jul 2018 11:47:23 -0400 Subject: [PATCH 5/8] Fixed vlan subnet issue. --- SoftLayer/managers/vs.py | 2 +- tests/managers/vs_tests.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index cd3f74ffe..ae8361684 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -415,7 +415,7 @@ def _generate_create_dict( def _create_network_components( self, public_vlan=None, private_vlan=None, - private_subnet=None, public_subnet=None, **kwargs): + private_subnet=None, public_subnet=None): if private_vlan and public_vlan: if private_subnet and public_subnet: diff --git a/tests/managers/vs_tests.py b/tests/managers/vs_tests.py index 4ec579005..d9fed606d 100644 --- a/tests/managers/vs_tests.py +++ b/tests/managers/vs_tests.py @@ -621,10 +621,10 @@ def test_edit_full(self): self.assertEqual(result, True) args = ({ - 'hostname': 'new-host', - 'domain': 'new.sftlyr.ws', - 'notes': 'random notes', - },) + 'hostname': 'new-host', + 'domain': 'new.sftlyr.ws', + 'notes': 'random notes', + },) self.assert_called_with('SoftLayer_Virtual_Guest', 'editObject', identifier=100, args=args) From f338c143c7082eecb69003903e8c0542f4a19e5e Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Tue, 10 Jul 2018 12:59:15 -0400 Subject: [PATCH 6/8] Fixed the new feature vlan subnet --- SoftLayer/CLI/virt/create.py | 12 +-- SoftLayer/managers/vs.py | 46 +++------- tests/managers/vs_tests.py | 171 +++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+), 40 deletions(-) diff --git a/SoftLayer/CLI/virt/create.py b/SoftLayer/CLI/virt/create.py index 4843b46ff..efdad1140 100644 --- a/SoftLayer/CLI/virt/create.py +++ b/SoftLayer/CLI/virt/create.py @@ -121,7 +121,10 @@ def _parse_create_args(client, args): # Get the SSH keys if args.get('key'): keys = [] - _add_keys(args, client, keys) + for key in args.get('key'): + resolver = SoftLayer.SshKeyManager(client).resolve_ids + key_id = helpers.resolve_id(resolver, key, 'SshKey') + keys.append(key_id) data['ssh_keys'] = keys if args.get('vlan_public'): @@ -153,13 +156,6 @@ def _parse_create_args(client, args): return data -def _add_keys(args, client, keys): - for key in args.get('key'): - resolver = SoftLayer.SshKeyManager(client).resolve_ids - key_id = helpers.resolve_id(resolver, key, 'SshKey') - keys.append(key_id) - - @click.command(epilog="See 'slcli vs create-options' for valid options") @click.option('--hostname', '-H', help="Host portion of the FQDN", diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index ae8361684..f4a34d7b4 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -367,7 +367,7 @@ def _generate_create_dict( if datacenter: data["datacenter"] = {"name": datacenter} - if private_vlan or public_vlan: + if private_vlan or public_vlan or private_subnet or public_subnet: network_components = self._create_network_components(public_vlan, private_vlan, private_subnet, public_subnet) data.update(network_components) @@ -417,39 +417,21 @@ def _create_network_components( self, public_vlan=None, private_vlan=None, private_subnet=None, public_subnet=None): - if private_vlan and public_vlan: - if private_subnet and public_subnet: - parameters = { - 'primaryNetworkComponent': { - "networkVlan": {"primarySubnet": {"id": int(public_subnet)}}}, - 'primaryBackendNetworkComponent': { - "networkVlan": {"primarySubnet": {"id": int(private_subnet)}}}} + parameters = {} + if private_vlan: + parameters['primaryBackendNetworkComponent'] = {"networkVlan": {"id": int(private_vlan)}} + if public_vlan: + parameters['primaryNetworkComponent'] = {"networkVlan": {"id": int(public_vlan)}} + if public_subnet: + if public_vlan is None: + raise exceptions.SoftLayerError("You need to specify a public_vlan with public_subnet") else: - if private_subnet: - parameters = { - 'primaryNetworkComponent': { - "networkVlan": {"id": int(public_vlan)}}, - 'primaryBackendNetworkComponent': { - "networkVlan": {"primarySubnet": {"id": int(private_subnet)}}} - } - else: - parameters = { - 'primaryNetworkComponent': { - "networkVlan": {"primarySubnet": {"id": int(public_subnet)}}}, - 'primaryBackendNetworkComponent': { - "networkVlan": {"id": int(private_vlan)}} - } - else: - if private_vlan: - parameters = { - 'primaryBackendNetworkComponent': { - "networkVlan": {"id": int(private_vlan)}} - } + parameters['primaryNetworkComponent']['networkVlan']['primarySubnet'] = {'id':int(public_subnet)} + if private_subnet: + if private_vlan is None: + raise exceptions.SoftLayerError("You need to specify a private_vlan with private_subnet") else: - parameters = { - 'primaryNetworkComponent': { - "networkVlan": {"id": int(public_vlan)}} - } + parameters['primaryBackendNetworkComponent']['networkVlan']['primarySubnet'] = {"id": int(private_subnet)} return parameters diff --git a/tests/managers/vs_tests.py b/tests/managers/vs_tests.py index d9fed606d..ca3594667 100644 --- a/tests/managers/vs_tests.py +++ b/tests/managers/vs_tests.py @@ -355,6 +355,116 @@ def test_generate_public_vlan(self): self.assertEqual(data, assert_data) + def test_generate_public_vlan_with_public_subnet(self): + data = self.vs._generate_create_dict( + cpus=1, + memory=1, + hostname='test', + domain='example.com', + os_code="STRING", + public_vlan=1, + public_subnet=1 + ) + + assert_data = { + 'startCpus': 1, + 'maxMemory': 1, + 'hostname': 'test', + 'domain': 'example.com', + 'localDiskFlag': True, + 'operatingSystemReferenceCode': "STRING", + 'hourlyBillingFlag': True, + 'primaryNetworkComponent': {'networkVlan': {'id': 1, + 'primarySubnet': {'id': 1}}}, + 'supplementalCreateObjectOptions': {'bootMode': None}, + } + + self.assertEqual(data, assert_data) + + def test_generate_private_vlan_with_private_subnet(self): + data = self.vs._generate_create_dict( + cpus=1, + memory=1, + hostname='test', + domain='example.com', + os_code="STRING", + private_vlan=1, + private_subnet=1 + ) + + assert_data = { + 'startCpus': 1, + 'maxMemory': 1, + 'hostname': 'test', + 'domain': 'example.com', + 'localDiskFlag': True, + 'operatingSystemReferenceCode': "STRING", + 'hourlyBillingFlag': True, + 'primaryBackendNetworkComponent': {'networkVlan': {'id': 1, + 'primarySubnet': {'id': 1}}}, + 'supplementalCreateObjectOptions': {'bootMode': None}, + } + + self.assertEqual(data, assert_data) + + def test_generate_private_vlan_subnet_public_vlan_subnet(self): + data = self.vs._generate_create_dict( + cpus=1, + memory=1, + hostname='test', + domain='example.com', + os_code="STRING", + private_vlan=1, + private_subnet=1, + public_vlan=1, + public_subnet=1, + ) + + assert_data = { + 'startCpus': 1, + 'maxMemory': 1, + 'hostname': 'test', + 'domain': 'example.com', + 'localDiskFlag': True, + 'operatingSystemReferenceCode': "STRING", + 'hourlyBillingFlag': True, + 'primaryBackendNetworkComponent': {'networkVlan': {'id': 1, + 'primarySubnet': {'id': 1}}}, + 'primaryNetworkComponent': {'networkVlan': {'id': 1, + 'primarySubnet': {'id': 1}}}, + 'supplementalCreateObjectOptions': {'bootMode': None}, + } + + self.assertEqual(data, assert_data) + + def test_generate_private_subnet(self): + actual = self.assertRaises( + exceptions.SoftLayerError, + self.vs._generate_create_dict, + cpus=1, + memory=1, + hostname='test', + domain='example.com', + os_code="STRING", + private_subnet=1, + ) + + self.assertEquals(str(actual), "You need to specify a private_vlan with private_subnet") + + def test_generate_public_subnet(self): + actual = self.assertRaises( + exceptions.SoftLayerError, + self.vs._generate_create_dict, + cpus=1, + memory=1, + hostname='test', + domain='example.com', + os_code="STRING", + public_subnet=1, + ) + + self.assertEquals(str(actual), "You need to specify a public_vlan with public_subnet") + def test_generate_private_vlan(self): data = self.vs._generate_create_dict( cpus=1, @@ -379,6 +489,67 @@ def test_generate_private_vlan(self): self.assertEqual(data, assert_data) + def test_create_network_components_vlan_subnet_private_vlan_subnet_public(self): + data = self.vs._create_network_components( + private_vlan=1, + private_subnet=1, + public_vlan=1, + public_subnet=1, + ) + + assert_data = { + 'primaryBackendNetworkComponent': {'networkVlan': {'id': 1, + 'primarySubnet': {'id': 1}}}, + 'primaryNetworkComponent': {'networkVlan': {'id': 1, + 'primarySubnet': {'id': 1}}}, + } + + self.assertEqual(data, assert_data) + + def test_create_network_components_vlan_subnet_private(self): + data = self.vs._create_network_components( + private_vlan=1, + private_subnet=1, + ) + + assert_data = { + 'primaryBackendNetworkComponent': {'networkVlan': {'id': 1, + 'primarySubnet': {'id': 1}}}, + } + + self.assertEqual(data, assert_data) + + def test_create_network_components_vlan_subnet_public(self): + data = self.vs._create_network_components( + public_vlan=1, + public_subnet=1, + ) + + assert_data = { + 'primaryNetworkComponent': {'networkVlan': {'id': 1, + 'primarySubnet': {'id': 1}}}, + } + + self.assertEqual(data, assert_data) + + def test_create_network_components_private_subnet(self): + actual = self.assertRaises( + exceptions.SoftLayerError, + self.vs._create_network_components, + private_subnet=1, + ) + + self.assertEquals(str(actual), "You need to specify a private_vlan with private_subnet") + + def test_create_network_components_public_subnet(self): + actual = self.assertRaises( + exceptions.SoftLayerError, + self.vs._create_network_components, + public_subnet=1, + ) + + self.assertEquals(str(actual), "You need to specify a public_vlan with public_subnet") + def test_generate_userdata(self): data = self.vs._generate_create_dict( cpus=1, From 49d196d5cfddade87647fe213e8d3f779c75f03a Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Tue, 10 Jul 2018 19:38:07 -0400 Subject: [PATCH 7/8] Fixed the new feature vlan subnet --- SoftLayer/managers/vs.py | 5 +++-- tests/managers/vs_tests.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index f4a34d7b4..eed533a02 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -426,12 +426,13 @@ def _create_network_components( if public_vlan is None: raise exceptions.SoftLayerError("You need to specify a public_vlan with public_subnet") else: - parameters['primaryNetworkComponent']['networkVlan']['primarySubnet'] = {'id':int(public_subnet)} + parameters['primaryNetworkComponent']['networkVlan']['primarySubnet'] = {'id': int(public_subnet)} if private_subnet: if private_vlan is None: raise exceptions.SoftLayerError("You need to specify a private_vlan with private_subnet") else: - parameters['primaryBackendNetworkComponent']['networkVlan']['primarySubnet'] = {"id": int(private_subnet)} + parameters['primaryBackendNetworkComponent']['networkVlan']['primarySubnet'] = { + "id": int(private_subnet)} return parameters diff --git a/tests/managers/vs_tests.py b/tests/managers/vs_tests.py index ca3594667..456b5cbc3 100644 --- a/tests/managers/vs_tests.py +++ b/tests/managers/vs_tests.py @@ -449,7 +449,7 @@ def test_generate_private_subnet(self): private_subnet=1, ) - self.assertEquals(str(actual), "You need to specify a private_vlan with private_subnet") + self.assertEqual(str(actual), "You need to specify a private_vlan with private_subnet") def test_generate_public_subnet(self): actual = self.assertRaises( @@ -463,7 +463,7 @@ def test_generate_public_subnet(self): public_subnet=1, ) - self.assertEquals(str(actual), "You need to specify a public_vlan with public_subnet") + self.assertEqual(str(actual), "You need to specify a public_vlan with public_subnet") def test_generate_private_vlan(self): data = self.vs._generate_create_dict( @@ -539,7 +539,7 @@ def test_create_network_components_private_subnet(self): private_subnet=1, ) - self.assertEquals(str(actual), "You need to specify a private_vlan with private_subnet") + self.assertEqual(str(actual), "You need to specify a private_vlan with private_subnet") def test_create_network_components_public_subnet(self): actual = self.assertRaises( @@ -548,7 +548,7 @@ def test_create_network_components_public_subnet(self): public_subnet=1, ) - self.assertEquals(str(actual), "You need to specify a public_vlan with public_subnet") + self.assertEqual(str(actual), "You need to specify a public_vlan with public_subnet") def test_generate_userdata(self): data = self.vs._generate_create_dict( From 488979b324eeb63b30e0c35c5b62921c68e613cb Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Thu, 12 Jul 2018 17:52:35 -0400 Subject: [PATCH 8/8] Refactored the vlan subnet issue. --- SoftLayer/CLI/virt/create.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/SoftLayer/CLI/virt/create.py b/SoftLayer/CLI/virt/create.py index efdad1140..a0997704e 100644 --- a/SoftLayer/CLI/virt/create.py +++ b/SoftLayer/CLI/virt/create.py @@ -133,11 +133,9 @@ def _parse_create_args(client, args): if args.get('vlan_private'): data['private_vlan'] = args['vlan_private'] - if args.get('subnet_public'): - data['public_subnet'] = args['subnet_public'] + data['public_subnet'] = args.get('subnet_public', None) - if args.get('subnet_private'): - data['private_subnet'] = args['subnet_private'] + data['private_subnet'] = args.get('subnet_private', None) if args.get('public_security_group'): pub_groups = args.get('public_security_group')