Skip to content

Commit

Permalink
Merge pull request #462 from sudorandom/cred-fix
Browse files Browse the repository at this point in the history
Credential commands resolve the identifier now
  • Loading branch information
sudorandom committed Jan 13, 2015
2 parents f764db2 + 530bc56 commit d14a960
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions SoftLayer/CLI/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ def get_command(self, ctx, name):
epilog="""To use most commands your SoftLayer
username and api_key need to be configured. The easiest way to do that is to
use: 'sl config setup'""",
cls=CommandLoader)
cls=CommandLoader,
context_settings={'help_option_names': ['-h', '--help']})
@click.pass_context
@click.option('--format',
default=DEFAULT_FORMAT,
help="Output format",
type=click.Choice(VALID_FORMATS))
@click.option('--config', '-C',
required=False,
default=click.get_app_dir('softlayer',
force_posix=True),
default=click.get_app_dir('softlayer', force_posix=True),
help="Config file location",
type=click.Path(resolve_path=True))
@click.option('--debug',
Expand Down
11 changes: 8 additions & 3 deletions SoftLayer/CLI/server/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting
from SoftLayer.CLI import helpers

import click

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

hardware = SoftLayer.HardwareManager(env.client)
result = hardware.get_hardware(identifier)
manager = SoftLayer.HardwareManager(env.client)
hardware_id = helpers.resolve_id(manager.resolve_ids,
identifier,
'hardware')
instance = manager.get_hardware(hardware_id)

table = formatting.Table(['username', 'password'])
for item in result['operatingSystem']['passwords']:
for item in instance['operatingSystem']['passwords']:
table.add_row([item['username'], item['password']])
return table
7 changes: 5 additions & 2 deletions SoftLayer/CLI/virt/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting
from SoftLayer.CLI import helpers

import click

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

vsi = SoftLayer.VSManager(env.client)
result = vsi.get_instance(identifier)
vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
instance = vsi.get_instance(vs_id)

table = formatting.Table(['username', 'password'])
for item in result['operatingSystem']['passwords']:
for item in instance['operatingSystem']['passwords']:
table.add_row([item['username'], item['password']])
return table

0 comments on commit d14a960

Please sign in to comment.