Skip to content

Commit c10b3c5

Browse files
committed
Updated command slcli subnet list
1 parent 0656879 commit c10b3c5

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
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 & 4 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,9 +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-
else:
507-
# This filters out global IPs from the subnet listing.
508-
_filter['subnets']['subnetType'] = {'operation': '!= GLOBAL_IP'}
509509
if network_space:
510510
_filter['subnets']['networkVlan']['networkSpace'] = (
511511
utils.query_filter(network_space))

tests/managers/network_tests.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,8 @@ def test_list_subnets_default(self):
313313
result = self.network.list_subnets()
314314

315315
self.assertEqual(result, fixtures.SoftLayer_Account.getSubnets)
316-
_filter = {'subnets': {'subnetType': {'operation': '!= GLOBAL_IP'}}}
317316
self.assert_called_with('SoftLayer_Account', 'getSubnets',
318-
mask='mask[%s]' % network.DEFAULT_SUBNET_MASK,
319-
filter=_filter)
317+
mask='mask[%s]' % network.DEFAULT_SUBNET_MASK)
320318

321319
def test_list_subnets_with_filters(self):
322320
result = self.network.list_subnets(

0 commit comments

Comments
 (0)