1- """User grant access to devices. """
1+ """Grants a user access to a given device """
22# :license: MIT, see LICENSE for more details.
33
44import click
55import SoftLayer
66
77from SoftLayer .CLI .command import SLCommand as SLCommand
88from SoftLayer .CLI import environment
9+ from SoftLayer .CLI import exceptions
910
1011
1112@click .command (cls = SLCommand , )
1516@click .option ('--dedicated' , help = "dedicated host ID" )
1617@environment .pass_env
1718def cli (env , identifier , hardware , virtual , dedicated ):
18- """Grant access from a user to an specific device.
19+ """Grants a user access to a given device.
1920
2021 Example: slcli user grant-access 123456 --hardware 123456789
2122 """
@@ -25,20 +26,20 @@ def cli(env, identifier, hardware, virtual, dedicated):
2526 if hardware :
2627 result = mgr .grant_hardware_access (identifier , hardware )
2728 if result :
28- click .secho ("Grant to access to hardware: %s" % hardware , fg = 'green' )
29+ click .secho (f"User { identifier } has been given access to hardware { hardware } " , fg = 'green' )
2930
3031 if virtual :
3132 result = mgr .grant_virtual_access (identifier , virtual )
3233 if result :
33- click .secho ("Grant to access to virtual guest: %s" % virtual , fg = 'green' )
34+ click .secho (f"User { identifier } has been given access to hardware { virtual } " , fg = 'green' )
3435
3536 if dedicated :
3637 result = mgr .grant_dedicated_access (identifier , dedicated )
3738 if result :
38- click .secho ("Grant to access to dedicated host: %s" % dedicated , fg = 'green' )
39+ click .secho (f"User { identifier } has been given access to hardware { dedicated } " , fg = 'green' )
3940
4041 if not result :
41- raise SoftLayer . exceptions .SoftLayerError ( 'You need argument a hardware, virtual or dedicated identifier .\n '
42- 'E.g slcli user grant-access 123456 --hardware 91803794\n '
43- ' slcli user grant-access 123456 --dedicated 91803793\n '
44- ' slcli user grant-access 123456 --virtual 91803792' )
42+ raise exceptions .CLIAbort ( 'A device option is required .\n '
43+ 'E.g slcli user grant-access 123456 --hardware 91803794\n '
44+ ' slcli user grant-access 123456 --dedicated 91803793\n '
45+ ' slcli user grant-access 123456 --virtual 91803792' )
0 commit comments