88from SoftLayer .CLI import environment
99from SoftLayer .CLI import formatting
1010
11+ TWO_FACTO_AUTH = 'externalBindingCount'
12+ CLASSIC_API_KEYS = 'apiAuthenticationKeyCount'
1113
1214COLUMNS = [
1315 column_helper .Column ('id' , ('id' ,)),
1719 column_helper .Column ('status' , ('userStatus' , 'name' )),
1820 column_helper .Column ('hardwareCount' , ('hardwareCount' ,)),
1921 column_helper .Column ('virtualGuestCount' , ('virtualGuestCount' ,)),
20- column_helper .Column ('2FAs ' , ('externalBindingCount' ,)),
21- column_helper .Column ('classicAPIKeys ' , ('apiAuthenticationKeyCount' ,))
22+ column_helper .Column ('2FA ' , (TWO_FACTO_AUTH ,)),
23+ column_helper .Column ('classicAPIKey ' , (CLASSIC_API_KEYS ,))
2224]
2325
2426DEFAULT_COLUMNS = [
2527 'id' ,
2628 'username' ,
2729 'email' ,
28- 'displayName'
30+ 'displayName' ,
31+ '2FA' ,
32+ 'classicAPIKey' ,
2933]
3034
3135
@@ -44,7 +48,16 @@ def cli(env, columns):
4448
4549 table = formatting .Table (columns .columns )
4650 for user in users :
51+ user = _yes_format (user , [TWO_FACTO_AUTH , CLASSIC_API_KEYS ])
4752 table .add_row ([value or formatting .blank ()
4853 for value in columns .row (user )])
4954
5055 env .fout (table )
56+
57+
58+ def _yes_format (user , keys ):
59+ """Changes all dictionary values to yes whose keys are in the list. """
60+ for key in keys :
61+ if user .get (key ):
62+ user [key ] = 'yes'
63+ return user
0 commit comments