Skip to content

Commit d4fa12e

Browse files
caberoscaberos
authored andcommitted
add a new column on ipAddress table subnet details
1 parent fb14b43 commit d4fa12e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

SoftLayer/CLI/subnet/detail.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def cli(env, identifier, no_vs, no_hardware):
2626
subnet_id = helpers.resolve_id(mgr.resolve_subnet_ids, identifier,
2727
name='subnet')
2828

29-
mask = 'mask[ipAddresses[id, ipAddress,note, hardware, virtualGuest], datacenter, virtualGuests, hardware,' \
29+
mask = 'mask[ipAddresses[id, ipAddress, note, isBroadcast, isGateway, isNetwork, isReserved, ' \
30+
'hardware, virtualGuest], datacenter, virtualGuests, hardware,' \
3031
' networkVlan[networkSpace,primaryRouter]]'
3132

3233
subnet = mgr.get_subnet(subnet_id, mask=mask)
@@ -55,14 +56,23 @@ def cli(env, identifier, no_vs, no_hardware):
5556

5657
ip_address = subnet.get('ipAddresses')
5758

58-
ip_table = formatting.KeyValueTable(['id', 'ip', 'note'])
59+
ip_table = formatting.KeyValueTable(['id', 'status', 'ip', 'note'])
5960
for address in ip_address:
6061
description = '-'
62+
status = 'Reserved'
63+
if address.get('isGateway'):
64+
status = 'Gateway'
65+
if address.get('isBroadcast'):
66+
status = 'Broadcast'
67+
if address.get('isNetwork'):
68+
status = 'Network'
6169
if address.get('hardware') is not None:
6270
description = address['hardware']['fullyQualifiedDomainName']
71+
status = 'In use'
6372
elif address.get('virtualGuest') is not None:
6473
description = address['virtualGuest']['fullyQualifiedDomainName']
65-
ip_table.add_row([address.get('id'),
74+
status = 'In use'
75+
ip_table.add_row([address.get('id'), status,
6676
address.get('ipAddress') + '/' + description, address.get('note', '-')])
6777

6878
table.add_row(['ipAddresses', ip_table])

0 commit comments

Comments
 (0)