Skip to content

Commit cc9392d

Browse files
Merge pull request #2209 from softlayer/issues2208
Migrated away from using Vlan.primaryRouter to find a VLAN's datacenter
2 parents 26c7d62 + c80fe7f commit cc9392d

File tree

4 files changed

+29
-35
lines changed

4 files changed

+29
-35
lines changed

SoftLayer/CLI/subnet/detail.py

+20-18
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@ 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, isBroadcast, isGateway, isNetwork, isReserved, ' \
30-
'hardware, virtualGuest], datacenter, virtualGuests, hardware,' \
31-
' networkVlan[networkSpace,primaryRouter]]'
29+
mask = """mask[
30+
networkIdentifier, cidr, subnetType, gateway, broadcastAddress, usableIpAddressCount, note, id,
31+
ipAddresses[
32+
id, ipAddress, note, isBroadcast, isGateway, isNetwork, isReserved,
33+
hardware[id, fullyQualifiedDomainName],
34+
virtualGuest[id, fullyQualifiedDomainName]
35+
],
36+
datacenter[name], networkVlan[networkSpace], tagReferences,
37+
virtualGuests[id, fullyQualifiedDomainName, hostname, domain, primaryIpAddress, primaryBackendIpAddress],
38+
hardware[id, fullyQualifiedDomainName, hostname, domain, primaryIpAddress, primaryBackendIpAddress]
39+
]"""
3240

3341
subnet = mgr.get_subnet(subnet_id, mask=mask)
3442

@@ -37,22 +45,15 @@ def cli(env, identifier, no_vs, no_hardware):
3745
table.align['value'] = 'l'
3846

3947
table.add_row(['id', subnet['id']])
40-
table.add_row(['identifier',
41-
'%s/%s' % (subnet['networkIdentifier'],
42-
str(subnet['cidr']))])
48+
table.add_row(['identifier', f"{subnet['networkIdentifier']}/{subnet['cidr']}"])
4349
table.add_row(['subnet type', subnet.get('subnetType', formatting.blank())])
44-
table.add_row(['network space',
45-
utils.lookup(subnet, 'networkVlan', 'networkSpace')])
50+
table.add_row(['network space', utils.lookup(subnet, 'networkVlan', 'networkSpace')])
4651
table.add_row(['gateway', subnet.get('gateway', formatting.blank())])
47-
table.add_row(['broadcast',
48-
subnet.get('broadcastAddress', formatting.blank())])
52+
table.add_row(['broadcast', subnet.get('broadcastAddress', formatting.blank())])
4953
table.add_row(['datacenter', subnet['datacenter']['name']])
50-
table.add_row(['usable ips',
51-
subnet.get('usableIpAddressCount', formatting.blank())])
52-
table.add_row(['note',
53-
subnet.get('note', formatting.blank())])
54-
table.add_row(['tags',
55-
formatting.tags(subnet.get('tagReferences'))])
54+
table.add_row(['usable ips', subnet.get('usableIpAddressCount', formatting.blank())])
55+
table.add_row(['note', subnet.get('note', formatting.blank())])
56+
table.add_row(['tags', formatting.tags(subnet.get('tagReferences'))])
5657

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

@@ -72,8 +73,9 @@ def cli(env, identifier, no_vs, no_hardware):
7273
elif address.get('virtualGuest') is not None:
7374
description = address['virtualGuest']['fullyQualifiedDomainName']
7475
status = 'In use'
75-
ip_table.add_row([address.get('id'), status,
76-
address.get('ipAddress') + '/' + description, address.get('note', '-')])
76+
ip_table.add_row([
77+
address.get('id'), status, f"{address.get('ipAddress')}/{description}", address.get('note', '-')
78+
])
7779

7880
table.add_row(['ipAddresses', ip_table])
7981

SoftLayer/CLI/vlan/detail.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def cli(env, identifier, no_vs, no_hardware, no_trunks):
2626
vlan_id = helpers.resolve_id(mgr.resolve_vlan_ids, identifier, 'VLAN')
2727

2828
mask = """mask[
29-
firewallInterfaces, primaryRouter[id, fullyQualifiedDomainName, datacenter[longName]],
29+
firewallInterfaces, datacenter[name, longName], primaryRouter[fullyQualifiedDomainName],
3030
totalPrimaryIpAddressCount,
3131
networkSpace, id, vlanNumber, fullyQualifiedName, name,
3232
hardware[id, hostname, domain, primaryIpAddress, primaryBackendIpAddress, tagReferences],
@@ -52,7 +52,7 @@ def cli(env, identifier, no_vs, no_hardware, no_trunks):
5252

5353
table.add_row(['id', vlan.get('id')])
5454
table.add_row(['number', vlan.get('vlanNumber')])
55-
table.add_row(['datacenter', utils.lookup(vlan, 'primaryRouter', 'datacenter', 'longName')])
55+
table.add_row(['datacenter', utils.lookup(vlan, 'datacenter', 'longName')])
5656
table.add_row(['primary_router', utils.lookup(vlan, 'primaryRouter', 'fullyQualifiedDomainName')])
5757
table.add_row(['Gateway/Firewall', get_gateway_firewall(vlan)])
5858

SoftLayer/CLI/vlan/list.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,9 @@ def cli(env, sortby, datacenter, number, name, limit):
4646
table = formatting.Table(COLUMNS)
4747
table.sortby = sortby
4848

49-
vlans = mgr.list_vlans(datacenter=datacenter,
50-
vlan_number=number,
51-
name=name,
52-
limit=limit)
49+
vlans = mgr.list_vlans(datacenter=datacenter, vlan_number=number, name=name, limit=limit)
5350

54-
pod_mask = """mask[
55-
name, datacenterLongName, capabilities, datacenterId,
56-
backendRouterId, backendRouterName, frontendRouterName, frontendRouterId
57-
]"""
51+
pod_mask = """mask[name, capabilities]"""
5852
pods = mgr.get_pods(mask=pod_mask)
5953

6054
for vlan in vlans:
@@ -66,7 +60,7 @@ def cli(env, sortby, datacenter, number, name, limit):
6660
vlan.get('fullyQualifiedName'),
6761
vlan.get('name') or formatting.blank(),
6862
vlan.get('networkSpace', 'Direct Link').capitalize(),
69-
utils.lookup(vlan, 'primaryRouter', 'datacenter', 'name'),
63+
utils.lookup(vlan, 'datacenter', 'name'),
7064
get_pod_with_closed_announcement(vlan, pods),
7165
get_gateway_firewall(vlan),
7266
vlan.get('hardwareCount'),
@@ -82,8 +76,7 @@ def cli(env, sortby, datacenter, number, name, limit):
8276
def get_pod_with_closed_announcement(vlan, pods):
8377
"""Gets pods with announcement to close"""
8478
for pod in pods:
85-
if utils.lookup(pod, 'backendRouterId') == utils.lookup(vlan, 'primaryRouter', 'id') \
86-
or utils.lookup(pod, 'frontendRouterId') == utils.lookup(vlan, 'primaryRouter', 'id'):
79+
if utils.lookup(pod, 'name') == utils.lookup(vlan, 'podName'):
8780
if 'CLOSURE_ANNOUNCED' in utils.lookup(pod, 'capabilities'):
8881
name_pod = utils.lookup(pod, 'name').split('.')[1] + '*'
8982
return "[red]" + name_pod.capitalize() + "[/red]"

SoftLayer/managers/network.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,10 @@ def list_vlans(self, datacenter=None, vlan_number=None, name=None, limit=100, ma
517517
518518
"""
519519
vlan_mask = """mask[
520-
networkSpace, id, vlanNumber, fullyQualifiedName, name,
520+
networkSpace, id, vlanNumber, fullyQualifiedName, name, datacenter[name], podName,
521521
networkVlanFirewall[id,fullyQualifiedDomainName], attachedNetworkGateway[id,name],
522-
firewallInterfaces, primaryRouter[id, fullyQualifiedDomainName, datacenter[name]],
523-
hardwareCount, subnetCount, totalPrimaryIpAddressCount, virtualGuestCount,
524-
billingItem[id], tagReferences[tag[name]]
522+
firewallInterfaces, billingItem[id], tagReferences[tag[name]],
523+
hardwareCount, subnetCount, totalPrimaryIpAddressCount, virtualGuestCount
525524
]"""
526525
_filter = utils.NestedDict(_filter or {})
527526

0 commit comments

Comments
 (0)