Skip to content

Commit 83266f6

Browse files
#828 refactored hardware create to use the ordering manager primarily instead of doing price lookups on its own. Added option to specify a particular networking keyname instead of just a speed
1 parent 034a72f commit 83266f6

File tree

6 files changed

+193
-443
lines changed

6 files changed

+193
-443
lines changed

SoftLayer/CLI/formatting.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,13 @@ def prettytable(self):
301301
else:
302302
msg = "Column (%s) doesn't exist to sort by" % self.sortby
303303
raise exceptions.CLIAbort(msg)
304-
for a_col, alignment in self.align.items():
305-
table.align[a_col] = alignment
304+
305+
if isinstance(self.align, str):
306+
table.align = self.align
307+
else:
308+
# Required because PrettyTable has a strict setter function for alignment
309+
for a_col, alignment in self.align.items():
310+
table.align[a_col] = alignment
306311

307312
if self.title:
308313
table.title = self.title

SoftLayer/CLI/hardware/create.py

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,40 @@
1212

1313

1414
@click.command(epilog="See 'slcli server create-options' for valid options.")
15-
@click.option('--hostname', '-H',
16-
help="Host portion of the FQDN",
17-
required=True,
18-
prompt=True)
19-
@click.option('--domain', '-D',
20-
help="Domain portion of the FQDN",
21-
required=True,
22-
prompt=True)
23-
@click.option('--size', '-s',
24-
help="Hardware size",
25-
required=True,
26-
prompt=True)
27-
@click.option('--os', '-o', help="OS install code",
28-
required=True,
29-
prompt=True)
30-
@click.option('--datacenter', '-d', help="Datacenter shortname",
31-
required=True,
32-
prompt=True)
33-
@click.option('--port-speed',
34-
type=click.INT,
35-
help="Port speeds",
36-
required=True,
37-
prompt=True)
38-
@click.option('--billing',
15+
@click.option('--hostname', '-H', required=True, prompt=True,
16+
help="Host portion of the FQDN")
17+
@click.option('--domain', '-D', required=True, prompt=True,
18+
help="Domain portion of the FQDN")
19+
@click.option('--size', '-s', required=True, prompt=True,
20+
help="Hardware size")
21+
@click.option('--os', '-o', required=True, prompt=True,
22+
help="OS Key value")
23+
@click.option('--datacenter', '-d', required=True, prompt=True,
24+
help="Datacenter shortname")
25+
@click.option('--port-speed', type=click.INT, required=True, prompt=True,
26+
help="Port speeds. DEPRECATED, use --network")
27+
@click.option('--no-public', is_flag=True,
28+
help="Private network only. DEPRECATED, use --network.")
29+
@click.option('--network',
30+
help="Network Option Key.")
31+
@click.option('--billing', default='hourly', show_default=True,
3932
type=click.Choice(['hourly', 'monthly']),
40-
default='hourly',
41-
show_default=True,
4233
help="Billing rate")
43-
@click.option('--postinstall', '-i', help="Post-install script to download")
44-
@helpers.multi_option('--key', '-k',
45-
help="SSH keys to add to the root user")
46-
@click.option('--no-public',
47-
is_flag=True,
48-
help="Private network only")
49-
@helpers.multi_option('--extra', '-e', help="Extra options")
50-
@click.option('--test',
51-
is_flag=True,
34+
@click.option('--postinstall', '-i',
35+
help="Post-install script. Should be a HTTPS URL.")
36+
@click.option('--test', is_flag=True,
5237
help="Do not actually create the server")
53-
@click.option('--template', '-t',
54-
is_eager=True,
38+
@click.option('--template', '-t', is_eager=True,
5539
callback=template.TemplateCallback(list_args=['key']),
5640
help="A template file that defaults the command-line options",
5741
type=click.Path(exists=True, readable=True, resolve_path=True))
58-
@click.option('--export',
59-
type=click.Path(writable=True, resolve_path=True),
42+
@click.option('--export', type=click.Path(writable=True, resolve_path=True),
6043
help="Exports options to a template file")
61-
@click.option('--wait',
62-
type=click.INT,
44+
@click.option('--wait', type=click.INT,
6345
help="Wait until the server is finished provisioning for up to "
6446
"X seconds before returning")
47+
@helpers.multi_option('--key', '-k', help="SSH keys to add to the root user")
48+
@helpers.multi_option('--extra', '-e', help="Extra option Key Names")
6549
@environment.pass_env
6650
def cli(env, **args):
6751
"""Order/create a dedicated server."""
@@ -86,6 +70,7 @@ def cli(env, **args):
8670
'port_speed': args.get('port_speed'),
8771
'no_public': args.get('no_public') or False,
8872
'extras': args.get('extra'),
73+
'network': args.get('network')
8974
}
9075

9176
# Do not create hardware server with --test or --export

SoftLayer/CLI/hardware/create_options.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,42 @@ def cli(env):
1919
tables = []
2020

2121
# Datacenters
22-
dc_table = formatting.Table(['datacenter', 'value'])
23-
dc_table.sortby = 'value'
22+
dc_table = formatting.Table(['Datacenter', 'Value'], title="Datacenters")
23+
dc_table.sortby = 'Value'
24+
dc_table.align = 'l'
2425
for location in options['locations']:
2526
dc_table.add_row([location['name'], location['key']])
2627
tables.append(dc_table)
2728

2829
# Presets
29-
preset_table = formatting.Table(['size', 'value'])
30-
preset_table.sortby = 'value'
30+
preset_table = formatting.Table(['Size', 'Value'], title="Sizes")
31+
preset_table.sortby = 'Value'
32+
preset_table.align = 'l'
3133
for size in options['sizes']:
3234
preset_table.add_row([size['name'], size['key']])
3335
tables.append(preset_table)
3436

3537
# Operating systems
36-
os_table = formatting.Table(['operating_system', 'value', 'operatingSystemReferenceCode '])
37-
os_table.sortby = 'value'
38+
os_table = formatting.Table(['OS', 'Key', 'Reference Code'], title="Operating Systems")
39+
os_table.sortby = 'Key'
40+
os_table.align = 'l'
3841
for operating_system in options['operating_systems']:
3942
os_table.add_row([operating_system['name'], operating_system['key'], operating_system['referenceCode']])
4043
tables.append(os_table)
4144

4245
# Port speed
43-
port_speed_table = formatting.Table(['port_speed', 'value'])
44-
port_speed_table.sortby = 'value'
46+
port_speed_table = formatting.Table(['Network', 'Speed', 'Key'], title="Network Options")
47+
port_speed_table.sortby = 'Speed'
48+
port_speed_table.align = 'l'
49+
4550
for speed in options['port_speeds']:
46-
port_speed_table.add_row([speed['name'], speed['key']])
51+
port_speed_table.add_row([speed['name'], speed['speed'], speed['key']])
4752
tables.append(port_speed_table)
4853

4954
# Extras
50-
extras_table = formatting.Table(['extras', 'value'])
51-
extras_table.sortby = 'value'
55+
extras_table = formatting.Table(['Extra Option', 'Value'], title="Extras")
56+
extras_table.sortby = 'Value'
57+
extras_table.align = 'l'
5258
for extra in options['extras']:
5359
extras_table.add_row([extra['name'], extra['key']])
5460
tables.append(extras_table)

0 commit comments

Comments
 (0)