Skip to content

Commit 10600bf

Browse files
authored
Use network space over address space (softlayer#736)
1 parent 62515bd commit 10600bf

4 files changed

Lines changed: 20 additions & 14 deletions

File tree

SoftLayer/CLI/subnet/detail.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from SoftLayer.CLI import environment
88
from SoftLayer.CLI import formatting
99
from SoftLayer.CLI import helpers
10+
from SoftLayer import utils
1011

1112

1213
@click.command()
@@ -35,6 +36,8 @@ def cli(env, identifier, no_vs, no_hardware):
3536
'%s/%s' % (subnet['networkIdentifier'],
3637
str(subnet['cidr']))])
3738
table.add_row(['subnet type', subnet['subnetType']])
39+
table.add_row(['network space',
40+
utils.lookup(subnet, 'networkVlan', 'networkSpace')])
3841
table.add_row(['gateway', subnet.get('gateway', formatting.blank())])
3942
table.add_row(['broadcast',
4043
subnet.get('broadcastAddress', formatting.blank())])

SoftLayer/CLI/subnet/list.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
type=click.Choice(['id',
1616
'identifier',
1717
'type',
18-
'address_space',
18+
'network_space',
1919
'datacenter',
2020
'vlan_id',
2121
'IPs',
@@ -25,18 +25,18 @@
2525
help="Filter by datacenter shortname (sng01, dal05, ...)")
2626
@click.option('--identifier', help="Filter by network identifier")
2727
@click.option('--subnet-type', '-t', help="Filter by subnet type")
28-
@click.option('--address-space', help="Filter by address space")
28+
@click.option('--network-space', help="Filter by network space")
2929
@click.option('--v4', '--ipv4', is_flag=True, help="Display only IPv4 subnets")
3030
@click.option('--v6', '--ipv6', is_flag=True, help="Display only IPv6 subnets")
3131
@environment.pass_env
32-
def cli(env, sortby, datacenter, identifier, subnet_type, address_space,
32+
def cli(env, sortby, datacenter, identifier, subnet_type, network_space,
3333
ipv4, ipv6):
3434
"""List subnets."""
3535

3636
mgr = SoftLayer.NetworkManager(env.client)
3737

3838
table = formatting.Table([
39-
'id', 'identifier', 'type', 'address_space', 'datacenter', 'vlan_id',
39+
'id', 'identifier', 'type', 'network_space', 'datacenter', 'vlan_id',
4040
'IPs', 'hardware', 'vs',
4141
])
4242
table.sortby = sortby
@@ -52,15 +52,17 @@ def cli(env, sortby, datacenter, identifier, subnet_type, address_space,
5252
version=version,
5353
identifier=identifier,
5454
subnet_type=subnet_type,
55-
address_space=address_space,
55+
network_space=network_space,
5656
)
5757

5858
for subnet in subnets:
5959
table.add_row([
6060
subnet['id'],
6161
'%s/%s' % (subnet['networkIdentifier'], str(subnet['cidr'])),
6262
subnet.get('subnetType', formatting.blank()),
63-
subnet.get('addressSpace', formatting.blank()),
63+
utils.lookup(subnet,
64+
'networkVlan',
65+
'networkSpace') or formatting.blank(),
6466
utils.lookup(subnet, 'datacenter', 'name',) or formatting.blank(),
6567
subnet['networkVlanId'],
6668
subnet['ipAddressCount'],

SoftLayer/managers/network.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'datacenter',
1515
'ipAddressCount',
1616
'virtualGuests',
17-
'addressSpace'])
17+
'networkVlan[id,networkSpace]'])
1818
DEFAULT_VLAN_MASK = ','.join([
1919
'firewallInterfaces',
2020
'hardwareCount',
@@ -245,7 +245,7 @@ def list_global_ips(self, version=None, identifier=None, **kwargs):
245245
return self.account.getGlobalIpRecords(**kwargs)
246246

247247
def list_subnets(self, identifier=None, datacenter=None, version=0,
248-
subnet_type=None, address_space=None, **kwargs):
248+
subnet_type=None, network_space=None, **kwargs):
249249
"""Display a list of all subnets on the account.
250250
251251
This provides a quick overview of all subnets including information
@@ -258,7 +258,7 @@ def list_subnets(self, identifier=None, datacenter=None, version=0,
258258
:param int version: Only returns subnets of this version (4 or 6).
259259
:param string subnet_type: If specified, it will only returns subnets
260260
of this type.
261-
:param string address_space: If specified, it will only returns subnets
261+
:param string network_space: If specified, it will only returns subnets
262262
with the given address space label.
263263
:param dict \\*\\*kwargs: response-level options (mask, limit, etc.)
264264
"""
@@ -280,9 +280,9 @@ def list_subnets(self, identifier=None, datacenter=None, version=0,
280280
else:
281281
# This filters out global IPs from the subnet listing.
282282
_filter['subnets']['subnetType'] = {'operation': '!= GLOBAL_IP'}
283-
if address_space:
284-
_filter['subnets']['addressSpace'] = utils.query_filter(
285-
address_space)
283+
if network_space:
284+
_filter['subnets']['networkVlan']['networkSpace'] = (
285+
utils.query_filter(network_space))
286286

287287
kwargs['filter'] = _filter.to_dict()
288288

tests/managers/network_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def test_list_subnets_with_filters(self):
193193
datacenter='dal00',
194194
version=4,
195195
subnet_type='PRIMARY',
196-
address_space='PUBLIC',
196+
network_space='PUBLIC',
197197
)
198198

199199
self.assertEqual(result, fixtures.SoftLayer_Account.getSubnets)
@@ -205,9 +205,10 @@ def test_list_subnets_with_filters(self):
205205
},
206206
'version': {'operation': 4},
207207
'subnetType': {'operation': '_= PRIMARY'},
208-
'addressSpace': {'operation': '_= PUBLIC'},
208+
'networkVlan': {'networkSpace': {'operation': '_= PUBLIC'}},
209209
}
210210
}
211+
211212
self.assert_called_with('SoftLayer_Account', 'getSubnets',
212213
mask='mask[%s]' % network.DEFAULT_SUBNET_MASK,
213214
filter=_filter)

0 commit comments

Comments
 (0)