Skip to content

Commit eeb815f

Browse files
Merge pull request #1767 from caberos/issue1763
add more information on hw credentials
2 parents 1b081f7 + fbb8f95 commit eeb815f

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

SoftLayer/CLI/hardware/credentials.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ def cli(env, identifier):
2222
'hardware')
2323
instance = manager.get_hardware(hardware_id)
2424

25-
table = formatting.Table(['username', 'password'])
25+
table = formatting.Table(['Username', 'Password', 'Software', 'Version'])
2626
for item in instance['softwareComponents']:
2727
if 'passwords' not in item:
2828
raise exceptions.SoftLayerError("No passwords found in softwareComponents")
2929
for credentials in item['passwords']:
30-
table.add_row([credentials.get('username', 'None'), credentials.get('password', 'None')])
30+
table.add_row([credentials.get('username', 'None'),
31+
credentials.get('password', 'None'),
32+
item['softwareLicense']['softwareDescription']['referenceCode'],
33+
item['softwareLicense']['softwareDescription']['version']])
3134
env.fout(table)

tests/CLI/modules/server_tests.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,22 @@ def test_server_credentials(self):
4141
{
4242
"password": "abc123",
4343
"username": "root"
44-
}
45-
]}]
44+
}],
45+
'softwareLicense': {
46+
'softwareDescription':
47+
{
48+
'referenceCode': 'CENTOS_7_64',
49+
'version': '7.8 - 64'}}}]
4650
}
4751
result = self.run_command(['hardware', 'credentials', '12345'])
4852

4953
self.assert_no_fail(result)
50-
self.assertEqual(json.loads(result.output),
51-
[{
52-
'username': 'root',
53-
'password': 'abc123'
54-
}])
54+
self.assertEqual(json.loads(result.output), [
55+
{'Password': 'abc123',
56+
'Software': 'CENTOS_7_64',
57+
'Username': 'root',
58+
'Version': '7.8 - 64'}
59+
])
5560

5661
def test_server_credentials_exception_passwords_not_found(self):
5762
mock = self.set_mock('SoftLayer_Hardware_Server', 'getObject')
@@ -85,7 +90,13 @@ def test_server_credentials_exception_password_not_found(self):
8590
{
8691
"hardwareId": 22222,
8792
"id": 333333,
88-
"passwords": [{}]
93+
"passwords": [{}],
94+
"softwareLicense": {
95+
"softwareDescription": {
96+
"referenceCode": None,
97+
"version": None
98+
}
99+
}
89100
}
90101
]
91102
}

0 commit comments

Comments
 (0)