Skip to content

Commit 27ed7fa

Browse files
committed
Updated command - slcli vlan list
1 parent 0c0c799 commit 27ed7fa

File tree

2 files changed

+52
-11
lines changed

2 files changed

+52
-11
lines changed

SoftLayer/CLI/vlan/list.py

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
from SoftLayer.CLI.vlan.detail import get_gateway_firewall
1010
from SoftLayer import utils
1111

12-
COLUMNS = ['id',
13-
'number',
14-
'name',
12+
COLUMNS = ['Id',
13+
'Number',
14+
'Fully qualified name',
15+
'Name',
16+
'Network',
17+
'Data center',
18+
'Pod',
1519
'Gateway/Firewall',
16-
'datacenter',
17-
'hardware',
18-
'virtual_servers',
19-
'public_ips',
20-
'premium',
21-
'tag']
20+
'Hardware',
21+
'Virtual servers',
22+
'Public ips',
23+
'Premium',
24+
'Tags']
2225

2326

2427
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
@@ -35,7 +38,10 @@
3538
show_default=True)
3639
@environment.pass_env
3740
def cli(env, sortby, datacenter, number, name, limit):
38-
"""List VLANs."""
41+
"""List VLANs.
42+
43+
Note: In field Pod, if add (*) indicated that closed soon
44+
"""
3945

4046
mgr = SoftLayer.NetworkManager(env.client)
4147

@@ -46,15 +52,21 @@ def cli(env, sortby, datacenter, number, name, limit):
4652
vlan_number=number,
4753
name=name,
4854
limit=limit)
55+
56+
pods = mgr.get_pods_with_capabilities()
57+
4958
for vlan in vlans:
5059
billing = 'Yes' if vlan.get('billingItem') else 'No'
5160

5261
table.add_row([
5362
vlan.get('id'),
5463
vlan.get('vlanNumber'),
64+
vlan.get('fullyQualifiedName'),
5565
vlan.get('name') or formatting.blank(),
56-
get_gateway_firewall(vlan),
66+
vlan.get('networkSpace').capitalize(),
5767
utils.lookup(vlan, 'primaryRouter', 'datacenter', 'name'),
68+
get_pod_with_closed_announcement(vlan, pods),
69+
get_gateway_firewall(vlan),
5870
vlan.get('hardwareCount'),
5971
vlan.get('virtualGuestCount'),
6072
vlan.get('totalPrimaryIpAddressCount'),
@@ -63,3 +75,16 @@ def cli(env, sortby, datacenter, number, name, limit):
6375
])
6476

6577
env.fout(table)
78+
79+
80+
def get_pod_with_closed_announcement(vlan, pods):
81+
"""Gets pods with announcement to close"""
82+
for pod in pods:
83+
if utils.lookup(pod, 'backendRouterId') == utils.lookup(vlan, 'primaryRouter', 'id') \
84+
or utils.lookup(pod, 'frontendRouterId') == utils.lookup(vlan, 'primaryRouter', 'id'):
85+
if 'CLOSURE_ANNOUNCED' in utils.lookup(pod, 'capabilities'):
86+
name_pod = utils.lookup(pod, 'name').split('.')[1] + '*'
87+
return name_pod.capitalize()
88+
else:
89+
return utils.lookup(pod, 'name').split('.')[1].capitalize()
90+
return ''

SoftLayer/managers/network.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,3 +866,19 @@ def get_datacenter_by_keyname(self, keyname=None):
866866
if len(result) >= 1:
867867
return result[0]
868868
return {}
869+
870+
def get_pods_with_capabilities(self):
871+
"""Calls SoftLayer_Network_Pod::getAllObjects()
872+
873+
returns list of all pods with capabilities for see closing network pods.
874+
"""
875+
order_filter = {
876+
'name': {
877+
'operation': 'orderBy',
878+
'options': [{'name': 'sort', 'value': ['DESC']}]
879+
}
880+
}
881+
882+
mask = """mask[name, datacenterLongName, frontendRouterId, capabilities, datacenterId, backendRouterId,
883+
backendRouterName, frontendRouterName]"""
884+
return self.client.call('SoftLayer_Network_Pod', 'getAllObjects', mask=mask, filter=order_filter)

0 commit comments

Comments
 (0)