Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion SoftLayer/CLI/virt/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def _parse_create_args(client, args):
"disks": args['disk'],
"cpus": args.get('cpu', None),
"memory": args.get('memory', None),
"flavor": args.get('flavor', None)
"flavor": args.get('flavor', None),
"boot_mode": args.get('boot_mode', None)
}

# The primary disk is included in the flavor and the local_disk flag is not needed
Expand Down Expand Up @@ -175,6 +176,9 @@ def _parse_create_args(client, args):
help="OS install code. Tip: you can specify <OS>_LATEST")
@click.option('--image',
help="Image ID. See: 'slcli image list' for reference")
@click.option('--boot-mode',
help="Specify the mode to boot the OS in. Supported modes are HVM and PV.",
type=click.STRING)
@click.option('--billing',
type=click.Choice(['hourly', 'monthly']),
default='hourly',
Expand Down
9 changes: 6 additions & 3 deletions SoftLayer/managers/vs.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def _generate_create_dict(
dedicated=False, public_vlan=None, private_vlan=None,
userdata=None, nic_speed=None, disks=None, post_uri=None,
private=False, ssh_keys=None, public_security_groups=None,
private_security_groups=None, **kwargs):
private_security_groups=None, boot_mode=None, **kwargs):
"""Returns a dict appropriate to pass into Virtual_Guest::createObject

See :func:`create_instance` for a list of available options.
Expand Down Expand Up @@ -339,11 +339,14 @@ def _generate_create_dict(
"hostname": hostname,
"domain": domain,
"localDiskFlag": local_disk,
"hourlyBillingFlag": hourly
"hourlyBillingFlag": hourly,
"supplementalCreateObjectOptions": {
"bootMode": boot_mode
}
}

if flavor:
data["supplementalCreateObjectOptions"] = {"flavorKeyName": flavor}
data["supplementalCreateObjectOptions"]["flavorKeyName"] = flavor

if dedicated and not host_id:
data["dedicatedAccountHostOnlyFlag"] = dedicated
Expand Down
20 changes: 14 additions & 6 deletions tests/CLI/modules/vs_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ def test_create(self, confirm_mock):
'hostname': 'host',
'startCpus': 2,
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
'networkComponents': [{'maxSpeed': '100'}]},)
'networkComponents': [{'maxSpeed': '100'}],
'supplementalCreateObjectOptions': {'bootMode': None}},)
self.assert_called_with('SoftLayer_Virtual_Guest', 'createObject',
args=args)

Expand Down Expand Up @@ -195,7 +196,8 @@ def test_create_with_integer_image_id(self, confirm_mock):
'blockDeviceTemplateGroup': {
'globalIdentifier': '0B5DEAF4-643D-46CA-A695-CECBE8832C9D',
},
'networkComponents': [{'maxSpeed': '100'}]
'networkComponents': [{'maxSpeed': '100'}],
'supplementalCreateObjectOptions': {'bootMode': None}
},)
self.assert_called_with('SoftLayer_Virtual_Guest', 'createObject',
args=args)
Expand Down Expand Up @@ -225,7 +227,9 @@ def test_create_with_flavor(self, confirm_mock):
'startCpus': None,
'maxMemory': None,
'localDiskFlag': None,
'supplementalCreateObjectOptions': {'flavorKeyName': 'B1_1X2X25'},
'supplementalCreateObjectOptions': {
'bootMode': None,
'flavorKeyName': 'B1_1X2X25'},
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
'networkComponents': [{'maxSpeed': '100'}]},)
self.assert_called_with('SoftLayer_Virtual_Guest', 'createObject',
Expand Down Expand Up @@ -261,7 +265,8 @@ def test_create_with_host_id(self, confirm_mock):
'startCpus': 2,
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
'networkComponents': [{'maxSpeed': '100'}],
'dedicatedHost': {'id': 123}},)
'dedicatedHost': {'id': 123},
'supplementalCreateObjectOptions': {'bootMode': None}},)
self.assert_called_with('SoftLayer_Virtual_Guest', 'createObject',
args=args)

Expand Down Expand Up @@ -306,7 +311,8 @@ def test_create_like(self, confirm_mock):
'maxMemory': 1024,
'localDiskFlag': False,
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
'networkComponents': [{'maxSpeed': 100}]},)
'networkComponents': [{'maxSpeed': 100}],
'supplementalCreateObjectOptions': {'bootMode': None}},)
self.assert_called_with('SoftLayer_Virtual_Guest', 'createObject',
args=args)

Expand Down Expand Up @@ -347,7 +353,9 @@ def test_create_like_flavor(self, confirm_mock):
'startCpus': None,
'maxMemory': None,
'localDiskFlag': None,
'supplementalCreateObjectOptions': {'flavorKeyName': 'B1_1X2X25'},
'supplementalCreateObjectOptions': {
'bootMode': None,
'flavorKeyName': 'B1_1X2X25'},
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
'networkComponents': [{'maxSpeed': 100}]},)
self.assert_called_with('SoftLayer_Virtual_Guest', 'createObject',
Expand Down
38 changes: 37 additions & 1 deletion tests/managers/vs_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ def test_create_instances(self):
'localDiskFlag': True,
'maxMemory': 1024,
'hostname': 'server',
'startCpus': 1}],)
'startCpus': 1,
'supplementalCreateObjectOptions': {'bootMode': None}}],)
self.assert_called_with('SoftLayer_Virtual_Guest', 'createObjects',
args=args)
self.assert_called_with('SoftLayer_Virtual_Guest', 'setTags',
Expand Down Expand Up @@ -232,6 +233,7 @@ def test_generate_basic(self):
'localDiskFlag': True,
'operatingSystemReferenceCode': "STRING",
'hourlyBillingFlag': True,
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand All @@ -254,6 +256,7 @@ def test_generate_monthly(self):
'domain': 'example.com',
'localDiskFlag': True,
'operatingSystemReferenceCode': "STRING",
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand All @@ -275,6 +278,7 @@ def test_generate_image_id(self):
'localDiskFlag': True,
'blockDeviceTemplateGroup': {"globalIdentifier": "45"},
'hourlyBillingFlag': True,
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand All @@ -298,6 +302,7 @@ def test_generate_dedicated(self):
'operatingSystemReferenceCode': "STRING",
'hourlyBillingFlag': True,
'dedicatedAccountHostOnlyFlag': True,
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand All @@ -321,6 +326,7 @@ def test_generate_datacenter(self):
'operatingSystemReferenceCode': "STRING",
'hourlyBillingFlag': True,
'datacenter': {"name": 'sng01'},
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand All @@ -344,6 +350,7 @@ def test_generate_public_vlan(self):
'operatingSystemReferenceCode': "STRING",
'hourlyBillingFlag': True,
'primaryNetworkComponent': {"networkVlan": {"id": 1}},
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand All @@ -367,6 +374,7 @@ def test_generate_private_vlan(self):
'operatingSystemReferenceCode': "STRING",
'hourlyBillingFlag': True,
'primaryBackendNetworkComponent': {"networkVlan": {"id": 1}},
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand All @@ -390,6 +398,7 @@ def test_generate_userdata(self):
'operatingSystemReferenceCode': "STRING",
'hourlyBillingFlag': True,
'userData': [{'value': "ICANHAZVSI"}],
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand All @@ -413,6 +422,7 @@ def test_generate_network(self):
'operatingSystemReferenceCode': "STRING",
'hourlyBillingFlag': True,
'networkComponents': [{'maxSpeed': 9001}],
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand All @@ -438,6 +448,7 @@ def test_generate_private_network_only(self):
'privateNetworkOnlyFlag': True,
'hourlyBillingFlag': True,
'networkComponents': [{'maxSpeed': 9001}],
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand All @@ -461,6 +472,7 @@ def test_generate_post_uri(self):
'operatingSystemReferenceCode': "STRING",
'hourlyBillingFlag': True,
'postInstallScriptUri': 'https://example.com/boostrap.sh',
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand All @@ -484,6 +496,7 @@ def test_generate_sshkey(self):
'operatingSystemReferenceCode': "STRING",
'hourlyBillingFlag': True,
'sshKeys': [{'id': 543}],
'supplementalCreateObjectOptions': {'bootMode': None},
}

self.assertEqual(data, assert_data)
Expand Down Expand Up @@ -537,6 +550,29 @@ def test_generate_multi_disk(self):
self.assertTrue(data.get('blockDevices'))
self.assertEqual(data['blockDevices'], assert_data['blockDevices'])

def test_generate_boot_mode(self):
data = self.vs._generate_create_dict(
cpus=1,
memory=1,
hostname='test',
domain='example.com',
os_code="STRING",
boot_mode="HVM"
)

assert_data = {
'startCpus': 1,
'maxMemory': 1,
'hostname': 'test',
'domain': 'example.com',
'localDiskFlag': True,
'operatingSystemReferenceCode': "STRING",
'hourlyBillingFlag': True,
'supplementalCreateObjectOptions': {'bootMode': 'HVM'},
}

self.assertEqual(data, assert_data)

def test_change_port_speed_public(self):
result = self.vs.change_port_speed(1, True, 100)

Expand Down