Skip to content

Commit 6539959

Browse files
Merge pull request #1572 from caberos/issue1571
add new feature on vlan
2 parents cdef7d6 + 00b7d81 commit 6539959

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@
354354

355355
('vlan', 'SoftLayer.CLI.vlan'),
356356
('vlan:create', 'SoftLayer.CLI.vlan.create:cli'),
357+
('vlan:create-options', 'SoftLayer.CLI.vlan.create_options:cli'),
357358
('vlan:detail', 'SoftLayer.CLI.vlan.detail:cli'),
358359
('vlan:edit', 'SoftLayer.CLI.vlan.edit:cli'),
359360
('vlan:list', 'SoftLayer.CLI.vlan.list:cli'),
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Vlan order options."""
2+
# :license: MIT, see LICENSE for more details.
3+
# pylint: disable=too-many-statements
4+
import click
5+
6+
import SoftLayer
7+
from SoftLayer.CLI import environment
8+
from SoftLayer.CLI import formatting
9+
10+
11+
@click.command(short_help="Get options to use for creating Vlan servers.")
12+
@environment.pass_env
13+
def cli(env):
14+
"""List all the options for creating VLAN"""
15+
16+
mgr = SoftLayer.NetworkManager(env.client)
17+
datacenters = mgr.get_list_datacenter()
18+
19+
table = formatting.Table(['Options', 'Value'], title="Datacenters")
20+
router_table = formatting.Table(['Datacenter', 'Router/Pod'])
21+
dc_table = formatting.Table(['Datacenters'])
22+
table.add_row(['VLAN type', 'Private, Public'])
23+
24+
for datacenter in datacenters:
25+
dc_table.add_row([datacenter['name']])
26+
routers = mgr.get_routers(datacenter['id'])
27+
for router in routers:
28+
router_table.add_row([datacenter['name'], router['hostname']])
29+
30+
table.add_row(['Datacenters', dc_table])
31+
table.add_row(['Routers', router_table])
32+
33+
env.fout(table)

SoftLayer/fixtures/SoftLayer_Location_Datacenter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
"name": "dal09"
1111
}
1212
]
13+
14+
getHardwareRouters = []

SoftLayer/managers/network.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,3 +789,17 @@ def get_pods(self, datacenter=None):
789789
_filter = {"datacenterName": {"operation": datacenter}}
790790

791791
return self.client.call('SoftLayer_Network_Pod', 'getAllObjects', filter=_filter)
792+
793+
def get_list_datacenter(self):
794+
"""Calls SoftLayer_Location::getDatacenters()
795+
796+
returns all datacenter locations.
797+
"""
798+
return self.client.call('SoftLayer_Location_Datacenter', 'getDatacenters')
799+
800+
def get_routers(self, identifier):
801+
"""Calls SoftLayer_Location::getRouters()
802+
803+
returns all routers locations.
804+
"""
805+
return self.client.call('SoftLayer_Location_Datacenter', 'getHardwareRouters', id=identifier)

docs/cli/vlan.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ VLANs
77
:prog: vlan create
88
:show-nested:
99

10+
.. click:: SoftLayer.CLI.vlan.create_options:cli
11+
:prog: vlan create-options
12+
:show-nested:
13+
1014
.. click:: SoftLayer.CLI.vlan.detail:cli
1115
:prog: vlan detail
1216
:show-nested:

tests/CLI/modules/vlan_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ def test_detail(self):
1818
result = self.run_command(['vlan', 'detail', '1234'])
1919
self.assert_no_fail(result)
2020

21+
def test_create_options(self):
22+
result = self.run_command(['vlan', 'create-options'])
23+
self.assert_no_fail(result)
24+
2125
def test_detail_no_vs(self):
2226
result = self.run_command(['vlan', 'detail', '1234', '--no-vs'])
2327
self.assert_no_fail(result)

0 commit comments

Comments
 (0)