diff --git a/SoftLayer/CLI/routes.py b/SoftLayer/CLI/routes.py index 2d44a824f..2dbb519e6 100644 --- a/SoftLayer/CLI/routes.py +++ b/SoftLayer/CLI/routes.py @@ -354,6 +354,7 @@ ('vlan', 'SoftLayer.CLI.vlan'), ('vlan:create', 'SoftLayer.CLI.vlan.create:cli'), + ('vlan:create-options', 'SoftLayer.CLI.vlan.create_options:cli'), ('vlan:detail', 'SoftLayer.CLI.vlan.detail:cli'), ('vlan:edit', 'SoftLayer.CLI.vlan.edit:cli'), ('vlan:list', 'SoftLayer.CLI.vlan.list:cli'), diff --git a/SoftLayer/CLI/vlan/create_options.py b/SoftLayer/CLI/vlan/create_options.py new file mode 100644 index 000000000..0b03b06af --- /dev/null +++ b/SoftLayer/CLI/vlan/create_options.py @@ -0,0 +1,33 @@ +"""Vlan order options.""" +# :license: MIT, see LICENSE for more details. +# pylint: disable=too-many-statements +import click + +import SoftLayer +from SoftLayer.CLI import environment +from SoftLayer.CLI import formatting + + +@click.command(short_help="Get options to use for creating Vlan servers.") +@environment.pass_env +def cli(env): + """List all the options for creating VLAN""" + + mgr = SoftLayer.NetworkManager(env.client) + datacenters = mgr.get_list_datacenter() + + table = formatting.Table(['Options', 'Value'], title="Datacenters") + router_table = formatting.Table(['Datacenter', 'Router/Pod']) + dc_table = formatting.Table(['Datacenters']) + table.add_row(['VLAN type', 'Private, Public']) + + for datacenter in datacenters: + dc_table.add_row([datacenter['name']]) + routers = mgr.get_routers(datacenter['id']) + for router in routers: + router_table.add_row([datacenter['name'], router['hostname']]) + + table.add_row(['Datacenters', dc_table]) + table.add_row(['Routers', router_table]) + + env.fout(table) diff --git a/SoftLayer/fixtures/SoftLayer_Location_Datacenter.py b/SoftLayer/fixtures/SoftLayer_Location_Datacenter.py index e9aa9b48e..b0b937cf4 100644 --- a/SoftLayer/fixtures/SoftLayer_Location_Datacenter.py +++ b/SoftLayer/fixtures/SoftLayer_Location_Datacenter.py @@ -10,3 +10,5 @@ "name": "dal09" } ] + +getHardwareRouters = [] diff --git a/SoftLayer/managers/network.py b/SoftLayer/managers/network.py index 4bdb1c18a..6638a29d3 100644 --- a/SoftLayer/managers/network.py +++ b/SoftLayer/managers/network.py @@ -789,3 +789,17 @@ def get_pods(self, datacenter=None): _filter = {"datacenterName": {"operation": datacenter}} return self.client.call('SoftLayer_Network_Pod', 'getAllObjects', filter=_filter) + + def get_list_datacenter(self): + """Calls SoftLayer_Location::getDatacenters() + + returns all datacenter locations. + """ + return self.client.call('SoftLayer_Location_Datacenter', 'getDatacenters') + + def get_routers(self, identifier): + """Calls SoftLayer_Location::getRouters() + + returns all routers locations. + """ + return self.client.call('SoftLayer_Location_Datacenter', 'getHardwareRouters', id=identifier) diff --git a/docs/cli/vlan.rst b/docs/cli/vlan.rst index 72c9a54cf..be4890ce3 100644 --- a/docs/cli/vlan.rst +++ b/docs/cli/vlan.rst @@ -7,6 +7,10 @@ VLANs :prog: vlan create :show-nested: +.. click:: SoftLayer.CLI.vlan.create_options:cli + :prog: vlan create-options + :show-nested: + .. click:: SoftLayer.CLI.vlan.detail:cli :prog: vlan detail :show-nested: diff --git a/tests/CLI/modules/vlan_tests.py b/tests/CLI/modules/vlan_tests.py index 204788d4d..6c8fbce01 100644 --- a/tests/CLI/modules/vlan_tests.py +++ b/tests/CLI/modules/vlan_tests.py @@ -18,6 +18,10 @@ def test_detail(self): result = self.run_command(['vlan', 'detail', '1234']) self.assert_no_fail(result) + def test_create_options(self): + result = self.run_command(['vlan', 'create-options']) + self.assert_no_fail(result) + def test_detail_no_vs(self): result = self.run_command(['vlan', 'detail', '1234', '--no-vs']) self.assert_no_fail(result)