Skip to content

Commit 57b5043

Browse files
authoredAug 4, 2017
Merge pull request #851 from sergiocarlosmorales/sync-vlan-subnet-ip-details
Sync VLAN and subnet detail CLI output
2 parents a7cb4dd + df15591 commit 57b5043

File tree

3 files changed

+72
-9
lines changed

3 files changed

+72
-9
lines changed
 

‎SoftLayer/CLI/subnet/detail.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,24 @@ def cli(env, identifier, no_vs, no_hardware):
4747

4848
if not no_vs:
4949
if subnet['virtualGuests']:
50-
vs_table = formatting.Table(['Hostname', 'Domain', 'IP'])
51-
vs_table.align['Hostname'] = 'r'
52-
vs_table.align['IP'] = 'l'
50+
vs_table = formatting.Table(['hostname', 'domain', 'public_ip', 'private_ip'])
5351
for vsi in subnet['virtualGuests']:
5452
vs_table.add_row([vsi['hostname'],
5553
vsi['domain'],
56-
vsi.get('primaryIpAddress')])
54+
vsi.get('primaryIpAddress'),
55+
vsi.get('primaryBackendIpAddress')])
5756
table.add_row(['vs', vs_table])
5857
else:
5958
table.add_row(['vs', 'none'])
6059

6160
if not no_hardware:
6261
if subnet['hardware']:
63-
hw_table = formatting.Table(['Hostname', 'Domain', 'IP'])
64-
hw_table.align['Hostname'] = 'r'
65-
hw_table.align['IP'] = 'l'
62+
hw_table = formatting.Table(['hostname', 'domain', 'public_ip', 'private_ip'])
6663
for hardware in subnet['hardware']:
6764
hw_table.add_row([hardware['hostname'],
6865
hardware['domain'],
69-
hardware.get('primaryIpAddress')])
66+
hardware.get('primaryIpAddress'),
67+
hardware.get('primaryBackendIpAddress')])
7068
table.add_row(['hardware', hw_table])
7169
else:
7270
table.add_row(['hardware', 'none'])
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
getObject = {'id': 1234, 'billingItem': {'id': 1056}}
1+
getObject = {
2+
'id': 1234,
3+
'billingItem': {
4+
'id': 1056
5+
},
6+
'number': 999,
7+
'networkIdentifier': '1.2.3.4',
8+
'cidr': '26',
9+
'subnetType': 'ADDITIONAL_PRIMARY',
10+
'networkVlan': {
11+
'networkSpace': 'PUBLIC'
12+
},
13+
'gateway': '1.2.3.254',
14+
'broadcastAddress': '1.2.3.255',
15+
'datacenter': {
16+
'name': 'dal10',
17+
'id': 1
18+
},
19+
'virtualGuests': [
20+
{
21+
'hostname': 'hostname0',
22+
'domain': 'sl.test',
23+
'primaryIpAddress': '1.2.3.10',
24+
'primaryBackendIpAddress': '10.0.1.2'
25+
}
26+
],
27+
'hardware': [],
28+
'usableIpAddressCount': 22
29+
}

‎tests/CLI/modules/subnet_tests.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
SoftLayer.tests.CLI.modules.subnet_tests
3+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4+
5+
:license: MIT, see LICENSE for more details.
6+
"""
7+
from SoftLayer import testing
8+
9+
import json
10+
11+
12+
class SubnetTests(testing.TestCase):
13+
def test_detail(self):
14+
result = self.run_command(['subnet', 'detail', '1234'])
15+
16+
self.assert_no_fail(result)
17+
self.assertEqual(
18+
{
19+
'id': 1234,
20+
'identifier': '1.2.3.4/26',
21+
'subnet type': 'ADDITIONAL_PRIMARY',
22+
'network space': 'PUBLIC',
23+
'gateway': '1.2.3.254',
24+
'broadcast': '1.2.3.255',
25+
'datacenter': 'dal10',
26+
'vs': [
27+
{
28+
'hostname': 'hostname0',
29+
'domain': 'sl.test',
30+
'public_ip': '1.2.3.10',
31+
'private_ip': '10.0.1.2'
32+
}
33+
],
34+
'hardware': 'none',
35+
'usable ips': 22
36+
},
37+
json.loads(result.output))

0 commit comments

Comments
 (0)