55
66import SoftLayer
77from SoftLayer .CLI import environment
8+ from SoftLayer .CLI import exceptions
89from 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
1617def 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