Skip to content

Commit a64f8ef

Browse files
Merge pull request #1805 from edsonarios/issue1798
Improve subnet list
2 parents b199c81 + e807325 commit a64f8ef

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

SoftLayer/CLI/subnet/list.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def cli(env, sortby, datacenter, identifier, subnet_type, network_space, ipv4, i
3535
mgr = SoftLayer.NetworkManager(env.client)
3636

3737
table = formatting.Table([
38-
'id', 'identifier', 'type', 'network_space', 'datacenter', 'vlan_id',
39-
'IPs', 'hardware', 'vs',
38+
'Id', 'Identifier', 'Network', 'Type', 'VLAN', 'Location', 'Target',
39+
'IPs', 'Hardware', 'Vs', 'Tags', 'Note'
4040
])
4141
table.sortby = sortby
4242

@@ -55,18 +55,36 @@ def cli(env, sortby, datacenter, identifier, subnet_type, network_space, ipv4, i
5555
)
5656

5757
for subnet in subnets:
58+
subnet_type = subnet.get('subnetType', formatting.blank())
59+
if subnet_type == 'PRIMARY' or subnet_type == 'PRIMARY_6' or subnet_type == 'ADDITIONAL_PRIMARY':
60+
subnet_type = 'Primary'
61+
if subnet_type == 'SECONDARY_ON_VLAN':
62+
subnet_type = 'Portable'
63+
if subnet_type == 'STATIC_IP_ROUTED':
64+
subnet_type = 'Static'
65+
if subnet_type == 'GLOBAL_IP':
66+
subnet_type = 'Global'
67+
68+
network = subnet.get('addressSpace', formatting.blank())
69+
if network is not None:
70+
network = str(network).capitalize()
71+
72+
vlan = utils.lookup(subnet, 'networkVlan', 'fullyQualifiedName')
73+
if vlan is None:
74+
vlan = 'Unrouted'
5875
table.add_row([
5976
subnet['id'],
6077
'%s/%s' % (subnet['networkIdentifier'], str(subnet['cidr'])),
61-
subnet.get('subnetType', formatting.blank()),
62-
utils.lookup(subnet,
63-
'networkVlan',
64-
'networkSpace') or formatting.blank(),
65-
utils.lookup(subnet, 'datacenter', 'name',) or formatting.blank(),
66-
subnet['networkVlanId'],
78+
network,
79+
subnet_type,
80+
vlan,
81+
utils.lookup(subnet, 'datacenter', 'name') or formatting.blank(),
82+
utils.lookup(subnet, 'endPointIpAddress', 'ipAddress') or formatting.blank(),
6783
subnet['ipAddressCount'],
6884
len(subnet['hardware']),
6985
len(subnet['virtualGuests']),
86+
formatting.tags(subnet.get('tagReferences')),
87+
utils.lookup(subnet, 'note') or formatting.blank(),
7088
])
7189

7290
env.fout(table)

SoftLayer/managers/network.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
'usableIpAddressCount',
3535
'note',
3636
'tagReferences[tag]',
37-
'networkVlan[id,networkSpace]'])
37+
'networkVlan[id,networkSpace,fullyQualifiedName]',
38+
'addressSpace',
39+
'endPointIpAddress'
40+
])
3841
DEFAULT_VLAN_MASK = ','.join([
3942
'firewallInterfaces',
4043
'hardwareCount',
@@ -503,7 +506,6 @@ def list_subnets(self, identifier=None, datacenter=None, version=0,
503506
_filter['subnets']['version'] = utils.query_filter(version)
504507
if subnet_type:
505508
_filter['subnets']['subnetType'] = utils.query_filter(subnet_type)
506-
507509
if network_space:
508510
_filter['subnets']['networkVlan']['networkSpace'] = (
509511
utils.query_filter(network_space))

0 commit comments

Comments
 (0)