Skip to content

Commit 407a307

Browse files
committed
Adds new test, organizes options a bit better
1 parent eb9d3ea commit 407a307

3 files changed

Lines changed: 35 additions & 19 deletions

File tree

SoftLayer/CLI/server/create.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,11 @@
1717
@click.option('--size', '-s', help="Hardware size")
1818
@click.option('--os', '-o', help="OS install code")
1919
@click.option('--datacenter', '-d', help="Datacenter shortname")
20+
@click.option('--port-speed', type=click.INT, help="Port speeds")
2021
@click.option('--billing',
2122
type=click.Choice(['hourly', 'monthly']),
2223
default='hourly',
2324
help="Billing rate")
24-
@click.option('--port-speed', type=click.INT, help="Port speeds")
25-
@click.option('--test',
26-
is_flag=True,
27-
help="Do not actually create the virtual server")
28-
@click.option('--export',
29-
type=click.Path(writable=True, resolve_path=True),
30-
help="Exports options to a template file")
3125
@click.option('--postinstall', '-i', help="Post-install script to download")
3226
@helpers.multi_option('--key', '-k',
3327
help="SSH keys to add to the root user")
@@ -40,6 +34,12 @@
4034
"server placed",
4135
type=click.INT)
4236
@helpers.multi_option('--extra', '-e', help="Extra options")
37+
@click.option('--test',
38+
is_flag=True,
39+
help="Do not actually create the virtual server")
40+
@click.option('--export',
41+
type=click.Path(writable=True, resolve_path=True),
42+
help="Exports options to a template file")
4343
@click.option('--wait',
4444
type=click.INT,
4545
help="Wait until the server is finished provisioning for up to "

SoftLayer/managers/hardware.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -398,18 +398,6 @@ def _generate_create_dict(self,
398398

399399
extras = extras or []
400400

401-
hardware = {
402-
'hostname': hostname,
403-
'domain': domain,
404-
}
405-
406-
if public_vlan:
407-
hardware['primaryNetworkComponent'] = {
408-
"networkVlan": {"id": int(public_vlan)}}
409-
if private_vlan:
410-
hardware['primaryBackendNetworkComponent'] = {
411-
"networkVlan": {"id": int(private_vlan)}}
412-
413401
package = self._get_package()
414402

415403
prices = []
@@ -432,6 +420,18 @@ def _generate_create_dict(self,
432420
for extra in extras:
433421
prices.append(_get_extra_price_id(package['items'], extra, hourly))
434422

423+
hardware = {
424+
'hostname': hostname,
425+
'domain': domain,
426+
}
427+
428+
if public_vlan:
429+
hardware['primaryNetworkComponent'] = {
430+
"networkVlan": {"id": int(public_vlan)}}
431+
if private_vlan:
432+
hardware['primaryBackendNetworkComponent'] = {
433+
"networkVlan": {"id": int(private_vlan)}}
434+
435435
order = {
436436
'hardware': [hardware],
437437
'location': _get_location_key(package, location),

SoftLayer/tests/managers/hardware_tests.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,22 @@ def test_get_extra_price_id_no_items(self):
362362
self.assertEqual("Could not find valid price for extra option, 'test'",
363363
str(ex))
364364

365+
def test_get_default_price_id_item_not_first(self):
366+
items = [{
367+
'itemCategory': {'categoryCode': 'unknown', 'id': 325},
368+
'keyName': 'UNKNOWN',
369+
'prices': [{'accountRestrictions': [],
370+
'currentPriceFlag': '',
371+
'hourlyRecurringFee': '10.0',
372+
'id': 1245172,
373+
'recurringFee': '1.0'}],
374+
}]
375+
ex = self.assertRaises(SoftLayer.SoftLayerError,
376+
managers.hardware._get_default_price_id,
377+
items, 'unknown', True)
378+
self.assertEqual("Could not find valid price for 'unknown' option",
379+
str(ex))
380+
365381
def test_get_default_price_id_no_items(self):
366382
ex = self.assertRaises(SoftLayer.SoftLayerError,
367383
managers.hardware._get_default_price_id,

0 commit comments

Comments
 (0)