Skip to content

Commit b547dca

Browse files
caberoscaberos
authored andcommitted
fix the team code review comments
1 parent e68a14f commit b547dca

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

SoftLayer/CLI/hardware/create_credential.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@
55

66
import SoftLayer
77
from SoftLayer.CLI import environment
8+
from SoftLayer.CLI import exceptions
89
from SoftLayer.CLI import formatting
910

1011

1112
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1213
@click.argument('identifier')
13-
@click.option('--username', '-U', help="The username part of the username/password pair")
14-
@click.option('--password', '-P', help="The password part of the username/password pair.")
14+
@click.option('--username', '-U', required=True, help="The username part of the username/password pair")
15+
@click.option('--password', '-P', required=True, help="The password part of the username/password pair.")
1516
@click.option('--notes', '-n', help="A note string stored for this username/password pair.")
16-
@click.option('--system', help="The name of this specific piece of software.")
17+
@click.option('--system', required=True, help="The name of this specific piece of software.")
1718
@environment.pass_env
1819
def cli(env, identifier, username, password, notes, system):
1920
"""Create a password for a software component."""
2021

2122
mgr = SoftLayer.HardwareManager(env.client)
2223

2324
software = mgr.get_software_components(identifier)
24-
sw_id = None
25-
for sw_instance in software:
26-
if (sw_instance['softwareLicense']['softwareDescription']['name']).lower() == system:
27-
sw_id = sw_instance['id']
28-
break
29-
elif system:
30-
if (sw_instance['softwareLicense']['softwareDescription']['name']) == 'Passmark Suite':
25+
sw_id = ''
26+
try:
27+
for sw_instance in software:
28+
if (sw_instance['softwareLicense']['softwareDescription']['name']).lower() == system:
3129
sw_id = sw_instance['id']
30+
except KeyError as ex:
31+
raise exceptions.CLIAbort('System id not found') from ex
3232

3333
template = {
3434
"notes": notes,

SoftLayer/managers/hardware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ def add_notification(self, hardware_id, user_id):
11031103
return self.client.call('SoftLayer_User_Customer_Notification_Hardware', 'createObject', template)
11041104

11051105
def get_software_components(self, hardware_id):
1106-
"""Returns Hardware sensor data"""
1106+
"""Returns a piece of hardware’s installed software."""
11071107
return self.client.call('Hardware', 'getSoftwareComponents', id=hardware_id)
11081108

11091109
def create_credential(self, template):

0 commit comments

Comments
 (0)