Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more information on hw credentials #1767

Merged
merged 3 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
63 changes: 37 additions & 26 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 Expand Up @@ -704,19 +715,19 @@ def test_dns_sync_both(self, confirm_mock):
'getResourceRecords')
getResourceRecords.return_value = []
createAargs = ({
'type': 'a',
'host': 'hardware-test1',
'domainId': 12345, # from SoftLayer_Account::getDomains
'data': '172.16.1.100',
'ttl': 7200
},)
'type': 'a',
'host': 'hardware-test1',
'domainId': 12345, # from SoftLayer_Account::getDomains
'data': '172.16.1.100',
'ttl': 7200
},)
createPTRargs = ({
'type': 'ptr',
'host': '100',
'domainId': 123456,
'data': 'hardware-test1.test.sftlyr.ws',
'ttl': 7200
},)
'type': 'ptr',
'host': '100',
'domainId': 123456,
'data': 'hardware-test1.test.sftlyr.ws',
'ttl': 7200
},)

result = self.run_command(['hw', 'dns-sync', '1000'])

Expand Down Expand Up @@ -759,12 +770,12 @@ def test_dns_sync_v6(self, confirm_mock):
}
}
createV6args = ({
'type': 'aaaa',
'host': 'hardware-test1',
'domainId': 12345, # from SoftLayer_Account::getDomains
'data': '2607:f0d0:1b01:0023:0000:0000:0000:0004',
'ttl': 7200
},)
'type': 'aaaa',
'host': 'hardware-test1',
'domainId': 12345, # from SoftLayer_Account::getDomains
'data': '2607:f0d0:1b01:0023:0000:0000:0000:0004',
'ttl': 7200
},)
server.return_value = test_server
result = self.run_command(['hw', 'dns-sync', '--aaaa-record', '1000'])
self.assert_no_fail(result)
Expand Down