Support --provider-* options in the network list command
Add --provider-network-type, --provider-physical-network, --provider-segment options into network list command. Change-Id: I02546170211fb3e7e55d5dc7e7cdc6d387fd26e5 Closes-Bug: #1635580 Partially-Implements: blueprint network-commands-options
This commit is contained in:
parent
8ca1cc6370
commit
960b2658dc
@ -193,53 +193,96 @@ List networks
|
||||
[--project <project> [--project-domain <project-domain>]]
|
||||
[--share | --no-share]
|
||||
[--status <status>]
|
||||
[--provider-network-type <provider-network-type>]
|
||||
[--provider-physical-network <provider-physical-network>]
|
||||
[--provider-segment <provider-segment>]
|
||||
|
||||
.. option:: --external
|
||||
|
||||
List external networks
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --internal
|
||||
|
||||
List internal networks
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --long
|
||||
|
||||
List additional fields in output
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --name <name>
|
||||
|
||||
List networks according to their name
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --enable
|
||||
|
||||
List enabled networks
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --disable
|
||||
|
||||
List disabled networks
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --project <project>
|
||||
|
||||
List networks according to their project (name or ID)
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --project-domain <project-domain>
|
||||
|
||||
Domain the project belongs to (name or ID).
|
||||
This can be used in case collisions between project names exist.
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --share
|
||||
|
||||
List networks shared between projects
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --no-share
|
||||
|
||||
List networks not shared between projects
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --status <status>
|
||||
|
||||
List networks according to their status
|
||||
('ACTIVE', 'BUILD', 'DOWN', 'ERROR')
|
||||
|
||||
.. option:: --provider-network-type <provider-network-type>
|
||||
|
||||
List networks according to their physical mechanisms.
|
||||
The supported options are: flat, geneve, gre, local, vlan, vxlan.
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --provider-physical-network <provider-physical-network>
|
||||
|
||||
List networks according to name of the physical network
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --provider-segment <provider-segment>
|
||||
|
||||
List networks according to VLAN ID for VLAN networks
|
||||
or Tunnel ID for GENEVE/GRE/VXLAN networks
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
network set
|
||||
-----------
|
||||
|
||||
|
@ -304,7 +304,7 @@ class DeleteNetwork(common.NetworkAndComputeDelete):
|
||||
class ListNetwork(common.NetworkAndComputeLister):
|
||||
"""List networks"""
|
||||
|
||||
def update_parser_common(self, parser):
|
||||
def update_parser_network(self, parser):
|
||||
router_ext_group = parser.add_mutually_exclusive_group()
|
||||
router_ext_group.add_argument(
|
||||
'--external',
|
||||
@ -361,6 +361,29 @@ class ListNetwork(common.NetworkAndComputeLister):
|
||||
help=_("List networks according to their status "
|
||||
"('ACTIVE', 'BUILD', 'DOWN', 'ERROR')")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--provider-network-type',
|
||||
metavar='<provider-network-type>',
|
||||
choices=['flat', 'geneve', 'gre', 'local',
|
||||
'vlan', 'vxlan'],
|
||||
help=_("List networks according to their physical mechanisms. "
|
||||
"The supported options are: flat, geneve, gre, local, "
|
||||
"vlan, vxlan.")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--provider-physical-network',
|
||||
metavar='<provider-physical-network>',
|
||||
dest='physical_network',
|
||||
help=_("List networks according to name of the physical network")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--provider-segment',
|
||||
metavar='<provider-segment>',
|
||||
dest='segmentation_id',
|
||||
help=_("List networks according to VLAN ID for VLAN networks "
|
||||
"or Tunnel ID for GENEVE/GRE/VXLAN networks")
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
def take_action_network(self, client, parsed_args):
|
||||
@ -433,6 +456,13 @@ class ListNetwork(common.NetworkAndComputeLister):
|
||||
if parsed_args.status:
|
||||
args['status'] = parsed_args.status
|
||||
|
||||
if parsed_args.provider_network_type:
|
||||
args['provider:network_type'] = parsed_args.provider_network_type
|
||||
if parsed_args.physical_network:
|
||||
args['provider:physical_network'] = parsed_args.physical_network
|
||||
if parsed_args.segmentation_id:
|
||||
args['provider:segmentation_id'] = parsed_args.segmentation_id
|
||||
|
||||
data = client.networks(**args)
|
||||
|
||||
return (column_headers,
|
||||
|
@ -291,6 +291,8 @@ class FakeNetwork(object):
|
||||
'shared': False,
|
||||
'subnets': ['a', 'b'],
|
||||
'provider_network_type': 'vlan',
|
||||
'provider_physical_network': 'physnet1',
|
||||
'provider_segmentation_id': "400",
|
||||
'router:external': True,
|
||||
'availability_zones': [],
|
||||
'availability_zone_hints': [],
|
||||
|
@ -65,6 +65,8 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
||||
'port_security_enabled',
|
||||
'project_id',
|
||||
'provider_network_type',
|
||||
'provider_physical_network',
|
||||
'provider_segmentation_id',
|
||||
'router:external',
|
||||
'shared',
|
||||
'status',
|
||||
@ -82,6 +84,8 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
||||
_network.is_port_security_enabled,
|
||||
_network.project_id,
|
||||
_network.provider_network_type,
|
||||
_network.provider_physical_network,
|
||||
_network.provider_segmentation_id,
|
||||
network._format_router_external(_network.is_router_external),
|
||||
_network.shared,
|
||||
_network.status,
|
||||
@ -229,6 +233,8 @@ class TestCreateNetworkIdentityV2(TestNetwork):
|
||||
'port_security_enabled',
|
||||
'project_id',
|
||||
'provider_network_type',
|
||||
'provider_physical_network',
|
||||
'provider_segmentation_id',
|
||||
'router:external',
|
||||
'shared',
|
||||
'status',
|
||||
@ -246,6 +252,8 @@ class TestCreateNetworkIdentityV2(TestNetwork):
|
||||
_network.is_port_security_enabled,
|
||||
_network.project_id,
|
||||
_network.provider_network_type,
|
||||
_network.provider_physical_network,
|
||||
_network.provider_segmentation_id,
|
||||
network._format_router_external(_network.is_router_external),
|
||||
_network.shared,
|
||||
_network.status,
|
||||
@ -681,6 +689,57 @@ class TestListNetwork(TestNetwork):
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
||||
|
||||
def test_network_list_provider_network_type(self):
|
||||
network_type = self._network[0].provider_network_type
|
||||
arglist = [
|
||||
'--provider-network-type', network_type,
|
||||
]
|
||||
verifylist = [
|
||||
('provider_network_type', network_type),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network.networks.assert_called_once_with(
|
||||
**{'provider:network_type': network_type}
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
||||
|
||||
def test_network_list_provider_physical_network(self):
|
||||
physical_network = self._network[0].provider_physical_network
|
||||
arglist = [
|
||||
'--provider-physical-network', physical_network,
|
||||
]
|
||||
verifylist = [
|
||||
('physical_network', physical_network),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network.networks.assert_called_once_with(
|
||||
**{'provider:physical_network': physical_network}
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
||||
|
||||
def test_network_list_provider_segment(self):
|
||||
segmentation_id = self._network[0].provider_segmentation_id
|
||||
arglist = [
|
||||
'--provider-segment', segmentation_id,
|
||||
]
|
||||
verifylist = [
|
||||
('segmentation_id', segmentation_id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network.networks.assert_called_once_with(
|
||||
**{'provider:segmentation_id': segmentation_id}
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
||||
|
||||
|
||||
class TestSetNetwork(TestNetwork):
|
||||
|
||||
@ -805,6 +864,8 @@ class TestShowNetwork(TestNetwork):
|
||||
'port_security_enabled',
|
||||
'project_id',
|
||||
'provider_network_type',
|
||||
'provider_physical_network',
|
||||
'provider_segmentation_id',
|
||||
'router:external',
|
||||
'shared',
|
||||
'status',
|
||||
@ -822,6 +883,8 @@ class TestShowNetwork(TestNetwork):
|
||||
_network.is_port_security_enabled,
|
||||
_network.project_id,
|
||||
_network.provider_network_type,
|
||||
_network.provider_physical_network,
|
||||
_network.provider_segmentation_id,
|
||||
network._format_router_external(_network.is_router_external),
|
||||
_network.shared,
|
||||
_network.status,
|
||||
@ -1111,10 +1174,7 @@ class TestListNetworkCompute(TestNetworkCompute):
|
||||
|
||||
def test_network_list_no_options(self):
|
||||
arglist = []
|
||||
verifylist = [
|
||||
('external', False),
|
||||
('long', False),
|
||||
]
|
||||
verifylist = []
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
# In base command class Lister in cliff, abstract method take_action()
|
||||
|
6
releasenotes/notes/bug-1635580-54e0039b469ad5a6.yaml
Normal file
6
releasenotes/notes/bug-1635580-54e0039b469ad5a6.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``--provider-network-type``, ``--provider-physical-network``, and
|
||||
``--provider-segment`` options to the ``network list`` command.
|
||||
[Bug `1635580 <https://bugs.launchpad.net/bugs/1635580>`_]
|
Loading…
Reference in New Issue
Block a user