Skip to content

Commit 50c60bd

Browse files
Merge pull request softlayer#658 from sudorandom/fix-vlan-list
Fix vlan list
2 parents 0ba294e + 6fc4f26 commit 50c60bd

4 files changed

Lines changed: 34 additions & 43 deletions

File tree

SoftLayer/CLI/summary.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,27 @@
88
from SoftLayer.CLI import formatting
99

1010

11+
COLUMNS = ['datacenter',
12+
'hardware',
13+
'virtual_servers',
14+
'vlans',
15+
'subnets',
16+
'public_ips']
17+
18+
1119
@click.command()
1220
@click.option('--sortby',
1321
help='Column to sort by',
1422
default='datacenter',
15-
show_default=True,
16-
type=click.Choice(['datacenter',
17-
'hardware',
18-
'virtual_servers',
19-
'vlans',
20-
'subnets',
21-
'public_ips']))
23+
type=click.Choice(COLUMNS))
2224
@environment.pass_env
2325
def cli(env, sortby):
2426
"""Account summary."""
2527

2628
mgr = SoftLayer.NetworkManager(env.client)
2729
datacenters = mgr.summary_by_datacenter()
2830

29-
table = formatting.Table([
30-
'datacenter',
31-
'hardware',
32-
'virtual_servers',
33-
'vlans',
34-
'subnets',
35-
'public_ips',
36-
])
31+
table = formatting.Table(COLUMNS)
3732
table.sortby = sortby
3833

3934
for name, datacenter in datacenters.items():

SoftLayer/CLI/vlan/detail.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def cli(env, identifier, no_vs, no_hardware):
3434
table.add_row(['number', vlan['vlanNumber']])
3535
table.add_row(['datacenter',
3636
vlan['primaryRouter']['datacenter']['longName']])
37-
table.add_row(['primary router',
37+
table.add_row(['primary_router',
3838
vlan['primaryRouter']['fullyQualifiedDomainName']])
3939
table.add_row(['firewall',
4040
'Yes' if vlan['firewallInterfaces'] else 'No'])
@@ -54,30 +54,28 @@ def cli(env, identifier, no_vs, no_hardware):
5454

5555
table.add_row(['subnets', subnets])
5656

57+
server_columns = ['hostname', 'domain', 'public_ip', 'private_ip']
58+
5759
if not no_vs:
5860
if vlan['virtualGuests']:
59-
vs_table = formatting.KeyValueTable(['Hostname',
60-
'Domain',
61-
'IP'])
62-
vs_table.align['Hostname'] = 'r'
63-
vs_table.align['IP'] = 'l'
61+
vs_table = formatting.KeyValueTable(server_columns)
6462
for vsi in vlan['virtualGuests']:
6563
vs_table.add_row([vsi['hostname'],
6664
vsi['domain'],
67-
vsi.get('primaryIpAddress')])
65+
vsi.get('primaryIpAddress'),
66+
vsi.get('primaryBackendIpAddress')])
6867
table.add_row(['vs', vs_table])
6968
else:
7069
table.add_row(['vs', 'none'])
7170

7271
if not no_hardware:
7372
if vlan['hardware']:
74-
hw_table = formatting.Table(['Hostname', 'Domain', 'IP'])
75-
hw_table.align['Hostname'] = 'r'
76-
hw_table.align['IP'] = 'l'
73+
hw_table = formatting.Table(server_columns)
7774
for hardware in vlan['hardware']:
7875
hw_table.add_row([hardware['hostname'],
7976
hardware['domain'],
80-
hardware.get('primaryIpAddress')])
77+
hardware.get('primaryIpAddress'),
78+
hardware.get('primaryBackendIpAddress')])
8179
table.add_row(['hardware', hw_table])
8280
else:
8381
table.add_row(['hardware', 'none'])

SoftLayer/CLI/vlan/list.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88
from SoftLayer.CLI import formatting
99
from SoftLayer import utils
1010

11+
COLUMNS = ['id',
12+
'number',
13+
'name',
14+
'firewall',
15+
'datacenter',
16+
'hardware',
17+
'virtual_servers',
18+
'public_ips']
19+
1120

1221
@click.command()
1322
@click.option('--sortby',
1423
help='Column to sort by',
15-
type=click.Choice(['id',
16-
'number',
17-
'datacenter',
18-
'IPs',
19-
'hardware',
20-
'vs',
21-
'networking',
22-
'firewall']))
24+
type=click.Choice(COLUMNS))
2325
@click.option('--datacenter', '-d',
2426
help='Filter by datacenter shortname (sng01, dal05, ...)')
2527
@click.option('--number', '-n', help='Filter by VLAN number')
@@ -30,10 +32,7 @@ def cli(env, sortby, datacenter, number, name):
3032

3133
mgr = SoftLayer.NetworkManager(env.client)
3234

33-
table = formatting.Table([
34-
'id', 'number', 'datacenter', 'name', 'IPs', 'hardware', 'vs',
35-
'networking', 'firewall'
36-
])
35+
table = formatting.Table(COLUMNS)
3736
table.sortby = sortby
3837

3938
vlans = mgr.list_vlans(datacenter=datacenter,
@@ -43,13 +42,12 @@ def cli(env, sortby, datacenter, number, name):
4342
table.add_row([
4443
vlan['id'],
4544
vlan['vlanNumber'],
46-
utils.lookup(vlan, 'primaryRouter', 'datacenter', 'name'),
4745
vlan.get('name') or formatting.blank(),
48-
vlan['totalPrimaryIpAddressCount'],
46+
'Yes' if vlan['firewallInterfaces'] else 'No',
47+
utils.lookup(vlan, 'primaryRouter', 'datacenter', 'name'),
4948
len(vlan['hardware']),
5049
len(vlan['virtualGuests']),
51-
len(vlan['networkComponents']),
52-
'Yes' if vlan['firewallInterfaces'] else 'No',
50+
vlan['totalPrimaryIpAddressCount'],
5351
])
5452

5553
env.fout(table)

SoftLayer/managers/network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def summary_by_datacenter(self):
350350
datacenters[name]['vlan_count'] += 1
351351
datacenters[name]['public_ip_count'] += (
352352
vlan['totalPrimaryIpAddressCount'])
353-
datacenters[name]['vlan_count'] += len(vlan['subnets'])
353+
datacenters[name]['subnet_count'] += len(vlan['subnets'])
354354

355355
for hardware in vlan['hardware']:
356356
if hardware['id'] not in unique_servers:

0 commit comments

Comments
 (0)