Skip to content

Commit

Permalink
Merge pull request #1767 from caberos/issue1763
Browse files Browse the repository at this point in the history
add more information on hw credentials
  • Loading branch information
allmightyspiff authored Oct 17, 2022
2 parents 1b081f7 + fbb8f95 commit eeb815f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
7 changes: 5 additions & 2 deletions SoftLayer/CLI/hardware/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ def cli(env, identifier):
'hardware')
instance = manager.get_hardware(hardware_id)

table = formatting.Table(['username', 'password'])
table = formatting.Table(['Username', 'Password', 'Software', 'Version'])
for item in instance['softwareComponents']:
if 'passwords' not in item:
raise exceptions.SoftLayerError("No passwords found in softwareComponents")
for credentials in item['passwords']:
table.add_row([credentials.get('username', 'None'), credentials.get('password', 'None')])
table.add_row([credentials.get('username', 'None'),
credentials.get('password', 'None'),
item['softwareLicense']['softwareDescription']['referenceCode'],
item['softwareLicense']['softwareDescription']['version']])
env.fout(table)
27 changes: 19 additions & 8 deletions tests/CLI/modules/server_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,22 @@ def test_server_credentials(self):
{
"password": "abc123",
"username": "root"
}
]}]
}],
'softwareLicense': {
'softwareDescription':
{
'referenceCode': 'CENTOS_7_64',
'version': '7.8 - 64'}}}]
}
result = self.run_command(['hardware', 'credentials', '12345'])

self.assert_no_fail(result)
self.assertEqual(json.loads(result.output),
[{
'username': 'root',
'password': 'abc123'
}])
self.assertEqual(json.loads(result.output), [
{'Password': 'abc123',
'Software': 'CENTOS_7_64',
'Username': 'root',
'Version': '7.8 - 64'}
])

def test_server_credentials_exception_passwords_not_found(self):
mock = self.set_mock('SoftLayer_Hardware_Server', 'getObject')
Expand Down Expand Up @@ -85,7 +90,13 @@ def test_server_credentials_exception_password_not_found(self):
{
"hardwareId": 22222,
"id": 333333,
"passwords": [{}]
"passwords": [{}],
"softwareLicense": {
"softwareDescription": {
"referenceCode": None,
"version": None
}
}
}
]
}
Expand Down

0 comments on commit eeb815f

Please sign in to comment.