Skip to content

Commit 04c0bec

Browse files
Merge pull request #1296 from allmightyspiff/issues828
`slcli hw create` updates
2 parents ce27773 + f4c2565 commit 04c0bec

File tree

7 files changed

+305
-498
lines changed

7 files changed

+305
-498
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: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,27 @@
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',
39-
type=click.Choice(['hourly', 'monthly']),
40-
default='hourly',
41-
show_default=True,
15+
@click.option('--hostname', '-H', required=True, prompt=True, help="Host portion of the FQDN")
16+
@click.option('--domain', '-D', required=True, prompt=True, help="Domain portion of the FQDN")
17+
@click.option('--size', '-s', required=True, prompt=True, help="Hardware size")
18+
@click.option('--os', '-o', required=True, prompt=True, help="OS Key value")
19+
@click.option('--datacenter', '-d', required=True, prompt=True, help="Datacenter shortname")
20+
@click.option('--port-speed', type=click.INT, help="Port speeds. DEPRECATED, use --network")
21+
@click.option('--no-public', is_flag=True, help="Private network only. DEPRECATED, use --network.")
22+
@click.option('--network', help="Network Option Key. Use instead of port-speed option")
23+
@click.option('--billing', default='hourly', show_default=True, type=click.Choice(['hourly', 'monthly']),
4224
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,
52-
help="Do not actually create the server")
53-
@click.option('--template', '-t',
54-
is_eager=True,
25+
@click.option('--postinstall', '-i', help="Post-install script. Should be a HTTPS URL.")
26+
@click.option('--test', is_flag=True, help="Do not actually create the server")
27+
@click.option('--template', '-t', is_eager=True, type=click.Path(exists=True, readable=True, resolve_path=True),
5528
callback=template.TemplateCallback(list_args=['key']),
56-
help="A template file that defaults the command-line options",
57-
type=click.Path(exists=True, readable=True, resolve_path=True))
58-
@click.option('--export',
59-
type=click.Path(writable=True, resolve_path=True),
29+
help="A template file that defaults the command-line options")
30+
@click.option('--export', type=click.Path(writable=True, resolve_path=True),
6031
help="Exports options to a template file")
61-
@click.option('--wait',
62-
type=click.INT,
63-
help="Wait until the server is finished provisioning for up to "
64-
"X seconds before returning")
32+
@click.option('--wait', type=click.INT,
33+
help="Wait until the server is finished provisioning for up to X seconds before returning")
34+
@helpers.multi_option('--key', '-k', help="SSH keys to add to the root user")
35+
@helpers.multi_option('--extra', '-e', help="Extra option Key Names")
6536
@environment.pass_env
6637
def cli(env, **args):
6738
"""Order/create a dedicated server."""
@@ -86,6 +57,7 @@ def cli(env, **args):
8657
'port_speed': args.get('port_speed'),
8758
'no_public': args.get('no_public') or False,
8859
'extras': args.get('extra'),
60+
'network': args.get('network')
8961
}
9062

9163
# Do not create hardware server with --test or --export
@@ -116,15 +88,13 @@ def cli(env, **args):
11688

11789
if args['export']:
11890
export_file = args.pop('export')
119-
template.export_to_template(export_file, args,
120-
exclude=['wait', 'test'])
91+
template.export_to_template(export_file, args, exclude=['wait', 'test'])
12192
env.fout('Successfully exported options to a template file.')
12293
return
12394

12495
if do_create:
12596
if not (env.skip_confirmations or formatting.confirm(
126-
"This action will incur charges on your account. "
127-
"Continue?")):
97+
"This action will incur charges on your account. Continue?")):
12898
raise exceptions.CLIAbort('Aborting dedicated server order.')
12999

130100
result = mgr.place_order(**order)

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)