Skip to content

Commit 530bc56

Browse files
committed
Credential commands resolve the identifier now
Also re-adds the -h flag to show help for CLI commands.
1 parent 0cbcf3f commit 530bc56

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

SoftLayer/CLI/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ def get_command(self, ctx, name):
7070
epilog="""To use most commands your SoftLayer
7171
username and api_key need to be configured. The easiest way to do that is to
7272
use: 'sl config setup'""",
73-
cls=CommandLoader)
73+
cls=CommandLoader,
74+
context_settings={'help_option_names': ['-h', '--help']})
7475
@click.pass_context
7576
@click.option('--format',
7677
default=DEFAULT_FORMAT,
7778
help="Output format",
7879
type=click.Choice(VALID_FORMATS))
7980
@click.option('--config', '-C',
8081
required=False,
81-
default=click.get_app_dir('softlayer',
82-
force_posix=True),
82+
default=click.get_app_dir('softlayer', force_posix=True),
8383
help="Config file location",
8484
type=click.Path(resolve_path=True))
8585
@click.option('--debug',

SoftLayer/CLI/server/credentials.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import SoftLayer
44
from SoftLayer.CLI import environment
55
from SoftLayer.CLI import formatting
6+
from SoftLayer.CLI import helpers
67

78
import click
89

@@ -13,9 +14,13 @@
1314
def cli(env, identifier):
1415
"""List virtual server credentials."""
1516

16-
hardware = SoftLayer.HardwareManager(env.client)
17-
result = hardware.get_hardware(identifier)
17+
manager = SoftLayer.HardwareManager(env.client)
18+
hardware_id = helpers.resolve_id(manager.resolve_ids,
19+
identifier,
20+
'hardware')
21+
instance = manager.get_hardware(hardware_id)
22+
1823
table = formatting.Table(['username', 'password'])
19-
for item in result['operatingSystem']['passwords']:
24+
for item in instance['operatingSystem']['passwords']:
2025
table.add_row([item['username'], item['password']])
2126
return table

SoftLayer/CLI/virt/credentials.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import SoftLayer
44
from SoftLayer.CLI import environment
55
from SoftLayer.CLI import formatting
6+
from SoftLayer.CLI import helpers
67

78
import click
89

@@ -14,8 +15,10 @@ def cli(env, identifier):
1415
"""List virtual server credentials."""
1516

1617
vsi = SoftLayer.VSManager(env.client)
17-
result = vsi.get_instance(identifier)
18+
vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
19+
instance = vsi.get_instance(vs_id)
20+
1821
table = formatting.Table(['username', 'password'])
19-
for item in result['operatingSystem']['passwords']:
22+
for item in instance['operatingSystem']['passwords']:
2023
table.add_row([item['username'], item['password']])
2124
return table

0 commit comments

Comments
 (0)