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
9 changes: 7 additions & 2 deletions SoftLayer/CLI/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,13 @@ def prettytable(self):
else:
msg = "Column (%s) doesn't exist to sort by" % self.sortby
raise exceptions.CLIAbort(msg)
for a_col, alignment in self.align.items():
table.align[a_col] = alignment

if isinstance(self.align, str):
table.align = self.align
else:
# Required because PrettyTable has a strict setter function for alignment
for a_col, alignment in self.align.items():
table.align[a_col] = alignment

if self.title:
table.title = self.title
Expand Down
72 changes: 21 additions & 51 deletions SoftLayer/CLI/hardware/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,56 +12,27 @@


@click.command(epilog="See 'slcli server create-options' for valid options.")
@click.option('--hostname', '-H',
help="Host portion of the FQDN",
required=True,
prompt=True)
@click.option('--domain', '-D',
help="Domain portion of the FQDN",
required=True,
prompt=True)
@click.option('--size', '-s',
help="Hardware size",
required=True,
prompt=True)
@click.option('--os', '-o', help="OS install code",
required=True,
prompt=True)
@click.option('--datacenter', '-d', help="Datacenter shortname",
required=True,
prompt=True)
@click.option('--port-speed',
type=click.INT,
help="Port speeds",
required=True,
prompt=True)
@click.option('--billing',
type=click.Choice(['hourly', 'monthly']),
default='hourly',
show_default=True,
@click.option('--hostname', '-H', required=True, prompt=True, help="Host portion of the FQDN")
@click.option('--domain', '-D', required=True, prompt=True, help="Domain portion of the FQDN")
@click.option('--size', '-s', required=True, prompt=True, help="Hardware size")
@click.option('--os', '-o', required=True, prompt=True, help="OS Key value")
@click.option('--datacenter', '-d', required=True, prompt=True, help="Datacenter shortname")
@click.option('--port-speed', type=click.INT, help="Port speeds. DEPRECATED, use --network")
@click.option('--no-public', is_flag=True, help="Private network only. DEPRECATED, use --network.")
@click.option('--network', help="Network Option Key. Use instead of port-speed option")
@click.option('--billing', default='hourly', show_default=True, type=click.Choice(['hourly', 'monthly']),
help="Billing rate")
@click.option('--postinstall', '-i', help="Post-install script to download")
@helpers.multi_option('--key', '-k',
help="SSH keys to add to the root user")
@click.option('--no-public',
is_flag=True,
help="Private network only")
@helpers.multi_option('--extra', '-e', help="Extra options")
@click.option('--test',
is_flag=True,
help="Do not actually create the server")
@click.option('--template', '-t',
is_eager=True,
@click.option('--postinstall', '-i', help="Post-install script. Should be a HTTPS URL.")
@click.option('--test', is_flag=True, help="Do not actually create the server")
@click.option('--template', '-t', is_eager=True, type=click.Path(exists=True, readable=True, resolve_path=True),
callback=template.TemplateCallback(list_args=['key']),
help="A template file that defaults the command-line options",
type=click.Path(exists=True, readable=True, resolve_path=True))
@click.option('--export',
type=click.Path(writable=True, resolve_path=True),
help="A template file that defaults the command-line options")
@click.option('--export', type=click.Path(writable=True, resolve_path=True),
help="Exports options to a template file")
@click.option('--wait',
type=click.INT,
help="Wait until the server is finished provisioning for up to "
"X seconds before returning")
@click.option('--wait', type=click.INT,
help="Wait until the server is finished provisioning for up to X seconds before returning")
@helpers.multi_option('--key', '-k', help="SSH keys to add to the root user")
@helpers.multi_option('--extra', '-e', help="Extra option Key Names")
@environment.pass_env
def cli(env, **args):
"""Order/create a dedicated server."""
Expand All @@ -86,6 +57,7 @@ def cli(env, **args):
'port_speed': args.get('port_speed'),
'no_public': args.get('no_public') or False,
'extras': args.get('extra'),
'network': args.get('network')
}

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

if args['export']:
export_file = args.pop('export')
template.export_to_template(export_file, args,
exclude=['wait', 'test'])
template.export_to_template(export_file, args, exclude=['wait', 'test'])
env.fout('Successfully exported options to a template file.')
return

if do_create:
if not (env.skip_confirmations or formatting.confirm(
"This action will incur charges on your account. "
"Continue?")):
"This action will incur charges on your account. Continue?")):
raise exceptions.CLIAbort('Aborting dedicated server order.')

result = mgr.place_order(**order)
Expand Down
28 changes: 17 additions & 11 deletions SoftLayer/CLI/hardware/create_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,42 @@ def cli(env):
tables = []

# Datacenters
dc_table = formatting.Table(['datacenter', 'value'])
dc_table.sortby = 'value'
dc_table = formatting.Table(['Datacenter', 'Value'], title="Datacenters")
dc_table.sortby = 'Value'
dc_table.align = 'l'
for location in options['locations']:
dc_table.add_row([location['name'], location['key']])
tables.append(dc_table)

# Presets
preset_table = formatting.Table(['size', 'value'])
preset_table.sortby = 'value'
preset_table = formatting.Table(['Size', 'Value'], title="Sizes")
preset_table.sortby = 'Value'
preset_table.align = 'l'
for size in options['sizes']:
preset_table.add_row([size['name'], size['key']])
tables.append(preset_table)

# Operating systems
os_table = formatting.Table(['operating_system', 'value', 'operatingSystemReferenceCode '])
os_table.sortby = 'value'
os_table = formatting.Table(['OS', 'Key', 'Reference Code'], title="Operating Systems")
os_table.sortby = 'Key'
os_table.align = 'l'
for operating_system in options['operating_systems']:
os_table.add_row([operating_system['name'], operating_system['key'], operating_system['referenceCode']])
tables.append(os_table)

# Port speed
port_speed_table = formatting.Table(['port_speed', 'value'])
port_speed_table.sortby = 'value'
port_speed_table = formatting.Table(['Network', 'Speed', 'Key'], title="Network Options")
port_speed_table.sortby = 'Speed'
port_speed_table.align = 'l'

for speed in options['port_speeds']:
port_speed_table.add_row([speed['name'], speed['key']])
port_speed_table.add_row([speed['name'], speed['speed'], speed['key']])
tables.append(port_speed_table)

# Extras
extras_table = formatting.Table(['extras', 'value'])
extras_table.sortby = 'value'
extras_table = formatting.Table(['Extra Option', 'Value'], title="Extras")
extras_table.sortby = 'Value'
extras_table.align = 'l'
for extra in options['extras']:
extras_table.add_row([extra['name'], extra['key']])
tables.append(extras_table)
Expand Down
Loading