Skip to content

Commit de11c8f

Browse files
caberoscaberos
authored andcommitted
add more information on hw credentials
1 parent 2c86f68 commit de11c8f

File tree

2 files changed

+44
-28
lines changed

2 files changed

+44
-28
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: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,24 @@ 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+
{
56+
'username': 'root',
57+
'password': 'abc123',
58+
'Software': 'CENTOS_7_64',
59+
'Version': '7.8 - 64'
60+
}
61+
])
5562

5663
def test_server_credentials_exception_passwords_not_found(self):
5764
mock = self.set_mock('SoftLayer_Hardware_Server', 'getObject')
@@ -85,7 +92,13 @@ def test_server_credentials_exception_password_not_found(self):
8592
{
8693
"hardwareId": 22222,
8794
"id": 333333,
88-
"passwords": [{}]
95+
"passwords": [{}],
96+
"softwareLicense": {
97+
"softwareDescription": {
98+
"referenceCode": None,
99+
"version": None
100+
}
101+
}
89102
}
90103
]
91104
}
@@ -704,19 +717,19 @@ def test_dns_sync_both(self, confirm_mock):
704717
'getResourceRecords')
705718
getResourceRecords.return_value = []
706719
createAargs = ({
707-
'type': 'a',
708-
'host': 'hardware-test1',
709-
'domainId': 12345, # from SoftLayer_Account::getDomains
710-
'data': '172.16.1.100',
711-
'ttl': 7200
712-
},)
720+
'type': 'a',
721+
'host': 'hardware-test1',
722+
'domainId': 12345, # from SoftLayer_Account::getDomains
723+
'data': '172.16.1.100',
724+
'ttl': 7200
725+
},)
713726
createPTRargs = ({
714-
'type': 'ptr',
715-
'host': '100',
716-
'domainId': 123456,
717-
'data': 'hardware-test1.test.sftlyr.ws',
718-
'ttl': 7200
719-
},)
727+
'type': 'ptr',
728+
'host': '100',
729+
'domainId': 123456,
730+
'data': 'hardware-test1.test.sftlyr.ws',
731+
'ttl': 7200
732+
},)
720733

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

@@ -759,12 +772,12 @@ def test_dns_sync_v6(self, confirm_mock):
759772
}
760773
}
761774
createV6args = ({
762-
'type': 'aaaa',
763-
'host': 'hardware-test1',
764-
'domainId': 12345, # from SoftLayer_Account::getDomains
765-
'data': '2607:f0d0:1b01:0023:0000:0000:0000:0004',
766-
'ttl': 7200
767-
},)
775+
'type': 'aaaa',
776+
'host': 'hardware-test1',
777+
'domainId': 12345, # from SoftLayer_Account::getDomains
778+
'data': '2607:f0d0:1b01:0023:0000:0000:0000:0004',
779+
'ttl': 7200
780+
},)
768781
server.return_value = test_server
769782
result = self.run_command(['hw', 'dns-sync', '--aaaa-record', '1000'])
770783
self.assert_no_fail(result)

0 commit comments

Comments
 (0)