Skip to content

Commit 4db35de

Browse files
Merge pull request #1786 from caberos/issue1771
slcli hw add-notifications crashes with a bad user
2 parents f75dbf0 + 15400f0 commit 4db35de

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

SoftLayer/CLI/hardware/add_notification.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
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('--users', multiple=True,
14+
@click.option('--users', multiple=True, required=True,
1415
help='UserId to be notified on monitoring failure.')
1516
@environment.pass_env
1617
def cli(env, identifier, users):
@@ -24,8 +25,10 @@ def cli(env, identifier, users):
2425

2526
for user in users:
2627
notification = hardware.add_notification(identifier, user)
27-
table.add_row([notification['id'], notification['hardware']['fullyQualifiedDomainName'],
28-
notification['user']['username'], notification['user']['email'],
29-
notification['user']['firstName'], notification['user']['lastName']])
30-
28+
if notification:
29+
table.add_row([notification['id'], notification['hardware']['fullyQualifiedDomainName'],
30+
notification['user']['username'], notification['user']['email'],
31+
notification['user']['firstName'], notification['user']['lastName']])
32+
else:
33+
raise exceptions.CLIAbort("User not found: {}.".format(user))
3134
env.fout(table)

0 commit comments

Comments
 (0)