Skip to content

Commit 5e4fd4b

Browse files
Merge pull request #1421 from ATGE/issues/1400
Add 2FA and classic APIKeys fields to slcli user list as default values
2 parents 94ab48b + ea5c5c9 commit 5e4fd4b

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

SoftLayer/CLI/user/list.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from SoftLayer.CLI import environment
99
from SoftLayer.CLI import formatting
1010

11+
TWO_FACTO_AUTH = 'externalBindingCount'
12+
CLASSIC_API_KEYS = 'apiAuthenticationKeyCount'
1113

1214
COLUMNS = [
1315
column_helper.Column('id', ('id',)),
@@ -17,15 +19,17 @@
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

2426
DEFAULT_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

SoftLayer/fixtures/SoftLayer_Account.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,13 +691,17 @@
691691
'id': 11100,
692692
'userStatus': {'name': 'Active'},
693693
'username': 'SL1234',
694-
'virtualGuestCount': 99},
694+
'virtualGuestCount': 99,
695+
'externalBindingCount': 1,
696+
'apiAuthenticationKeyCount': 1,
697+
},
695698
{'displayName': 'PulseL',
696699
'hardwareCount': 100,
697700
'id': 11111,
698701
'userStatus': {'name': 'Active'},
699702
'username': 'sl1234-abob',
700-
'virtualGuestCount': 99}
703+
'virtualGuestCount': 99,
704+
}
701705
]
702706

703707
getReservedCapacityGroups = [

0 commit comments

Comments
 (0)