1616"""Identity v3 Role action implementations"""
1717
1818import logging
19- import sys
2019
2120from keystoneauth1 import exceptions as ks_exc
2221from osc_lib .command import command
@@ -129,7 +128,9 @@ def take_action(self, parsed_args):
129128
130129 if (not parsed_args .user and not parsed_args .domain
131130 and not parsed_args .group and not parsed_args .project ):
132- return
131+ msg = _ ("Role not added, incorrect set of arguments "
132+ "provided. See openstack --help for more details" )
133+ raise exceptions .CommandError (msg )
133134
134135 domain_id = None
135136 if parsed_args .role_domain :
@@ -143,11 +144,6 @@ def take_action(self, parsed_args):
143144
144145 kwargs = _process_identity_and_resource_options (
145146 parsed_args , self .app .client_manager .identity )
146- if not kwargs :
147- sys .stderr .write (_ ("Role not added, incorrect set of arguments "
148- "provided. See openstack --help for more "
149- "details\n " ))
150- return
151147
152148 identity_client .roles .grant (role .id , ** kwargs )
153149
@@ -372,10 +368,10 @@ def take_action(self, parsed_args):
372368 '<group-name> --project <project-name> --names '
373369 'instead.' ))
374370 else :
375- sys . stderr . write ( _ ("Error: If a user or group is specified, "
376- "either --domain or --project must also be "
377- "specified to list role grants.\n " ) )
378- return ([], [] )
371+ msg = _ ("Error: If a user or group is specified, "
372+ "either --domain or --project must also be "
373+ "specified to list role grants." )
374+ raise exceptions . CommandError ( msg )
379375
380376 return (columns ,
381377 (utils .get_item_properties (
@@ -405,9 +401,9 @@ def take_action(self, parsed_args):
405401
406402 if (not parsed_args .user and not parsed_args .domain
407403 and not parsed_args .group and not parsed_args .project ):
408- sys . stderr . write ( _ ("Incorrect set of arguments provided. "
409- "See openstack --help for more details\n " ) )
410- return
404+ msg = _ ("Incorrect set of arguments provided. "
405+ "See openstack --help for more details" )
406+ raise exceptions . CommandError ( msg )
411407
412408 domain_id = None
413409 if parsed_args .role_domain :
@@ -421,11 +417,6 @@ def take_action(self, parsed_args):
421417
422418 kwargs = _process_identity_and_resource_options (
423419 parsed_args , self .app .client_manager .identity )
424- if not kwargs :
425- sys .stderr .write (_ ("Role not removed, incorrect set of arguments "
426- "provided. See openstack --help for more "
427- "details\n " ))
428- return
429420 identity_client .roles .revoke (role .id , ** kwargs )
430421
431422
0 commit comments