Add provider network options to osc network set
The following patch adds the provider network options to OSC "network set". Change-Id: I23b617077eda25d16164172a8e280082750eaf18 Partial-Bug: #1545537
This commit is contained in:
parent
3f2ed7d19f
commit
aa1495e241
@ -172,6 +172,9 @@ Set network properties
|
||||
[--enable | --disable]
|
||||
[--share | --no-share]
|
||||
[--external [--default | --no-default] | --internal]
|
||||
[--provider-network-type <provider-network-type>]
|
||||
[--provider-physical-network <provider-physical-network>]
|
||||
[--provider-segment <provider-segment>]
|
||||
<network>
|
||||
|
||||
.. option:: --name <name>
|
||||
@ -211,6 +214,19 @@ Set network properties
|
||||
|
||||
Do not use the network as the default external network.
|
||||
|
||||
.. option:: --provider-network-type <provider-network-type>
|
||||
|
||||
The physical mechanism by which the virtual network is implemented.
|
||||
The supported options are: flat, gre, local, vlan, vxlan
|
||||
|
||||
.. option:: --provider-physical-network <provider-physical-network>
|
||||
|
||||
Name of the physical network over which the virtual network is implemented
|
||||
|
||||
.. option:: --provider-segment <provider-segment>
|
||||
|
||||
VLAN ID for VLAN networks or Tunnel ID for GRE/VXLAN networks
|
||||
|
||||
.. _network_set-network:
|
||||
.. describe:: <network>
|
||||
|
||||
|
@ -86,10 +86,40 @@ def _get_attrs(client_manager, parsed_args):
|
||||
attrs['is_default'] = False
|
||||
if parsed_args.default:
|
||||
attrs['is_default'] = True
|
||||
|
||||
# Update Provider network options
|
||||
if parsed_args.provider_network_type:
|
||||
attrs['provider:network_type'] = parsed_args.provider_network_type
|
||||
if parsed_args.physical_network:
|
||||
attrs['provider:physical_network'] = parsed_args.physical_network
|
||||
if parsed_args.segmentation_id:
|
||||
attrs['provider:segmentation_id'] = parsed_args.segmentation_id
|
||||
return attrs
|
||||
|
||||
|
||||
def _add_provider_network_options(parser):
|
||||
# Add provider network options
|
||||
parser.add_argument(
|
||||
'--provider-network-type',
|
||||
metavar='<provider-network-type>',
|
||||
choices=['flat', 'gre', 'local',
|
||||
'vlan', 'vxlan'],
|
||||
help=_("The physical mechanism by which the virtual network "
|
||||
"is implemented. The supported options are: "
|
||||
"flat, gre, local, vlan, vxlan"))
|
||||
parser.add_argument(
|
||||
'--provider-physical-network',
|
||||
metavar='<provider-physical-network>',
|
||||
dest='physical_network',
|
||||
help=_("Name of the physical network over which the virtual "
|
||||
"network is implemented"))
|
||||
parser.add_argument(
|
||||
'--provider-segment',
|
||||
metavar='<provider-segment>',
|
||||
dest='segmentation_id',
|
||||
help=_("VLAN ID for VLAN networks or Tunnel ID for GRE/VXLAN "
|
||||
"networks"))
|
||||
|
||||
|
||||
def _get_attrs_compute(client_manager, parsed_args):
|
||||
attrs = {}
|
||||
if parsed_args.name is not None:
|
||||
@ -100,7 +130,6 @@ def _get_attrs_compute(client_manager, parsed_args):
|
||||
attrs['share_address'] = False
|
||||
if parsed_args.subnet is not None:
|
||||
attrs['cidr'] = parsed_args.subnet
|
||||
|
||||
return attrs
|
||||
|
||||
|
||||
@ -180,29 +209,7 @@ class CreateNetwork(common.NetworkAndComputeShowOne):
|
||||
help=_("Do not use the network as the default external network. "
|
||||
"(default)")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--provider-network-type',
|
||||
metavar='<provider-network-type>',
|
||||
choices=['flat', 'gre', 'local',
|
||||
'vlan', 'vxlan'],
|
||||
help=_("The physical mechanism by which the virtual network "
|
||||
"is implemented. The supported options are: "
|
||||
"flat, gre, local, vlan, vxlan")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--provider-physical-network',
|
||||
metavar='<provider-physical-network>',
|
||||
dest='physical_network',
|
||||
help=_("Name of the physical network over which the virtual "
|
||||
"network is implemented")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--provider-segment',
|
||||
metavar='<provider-segment>',
|
||||
dest='segmentation_id',
|
||||
help=_("VLAN ID for VLAN networks or Tunnel ID for GRE/VXLAN "
|
||||
"networks")
|
||||
)
|
||||
_add_provider_network_options(parser)
|
||||
return parser
|
||||
|
||||
def update_parser_compute(self, parser):
|
||||
@ -215,12 +222,6 @@ class CreateNetwork(common.NetworkAndComputeShowOne):
|
||||
|
||||
def take_action_network(self, client, parsed_args):
|
||||
attrs = _get_attrs(self.app.client_manager, parsed_args)
|
||||
if parsed_args.provider_network_type:
|
||||
attrs['provider:network_type'] = parsed_args.provider_network_type
|
||||
if parsed_args.physical_network:
|
||||
attrs['provider:physical_network'] = parsed_args.physical_network
|
||||
if parsed_args.segmentation_id:
|
||||
attrs['provider:segmentation_id'] = parsed_args.segmentation_id
|
||||
obj = client.create_network(**attrs)
|
||||
columns = _get_columns(obj)
|
||||
data = utils.get_item_properties(obj, columns, formatters=_formatters)
|
||||
@ -412,6 +413,7 @@ class SetNetwork(command.Command):
|
||||
action='store_true',
|
||||
help=_("Do not use the network as the default external network")
|
||||
)
|
||||
_add_provider_network_options(parser)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
@ -484,6 +484,9 @@ class TestSetNetwork(TestNetwork):
|
||||
'--share',
|
||||
'--external',
|
||||
'--default',
|
||||
'--provider-network-type', 'vlan',
|
||||
'--provider-physical-network', 'physnet1',
|
||||
'--provider-segment', '400',
|
||||
]
|
||||
verifylist = [
|
||||
('network', self._network.name),
|
||||
@ -492,6 +495,9 @@ class TestSetNetwork(TestNetwork):
|
||||
('share', True),
|
||||
('external', True),
|
||||
('default', True),
|
||||
('provider_network_type', 'vlan'),
|
||||
('physical_network', 'physnet1'),
|
||||
('segmentation_id', '400'),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -503,6 +509,9 @@ class TestSetNetwork(TestNetwork):
|
||||
'shared': True,
|
||||
'router:external': True,
|
||||
'is_default': True,
|
||||
'provider:network_type': 'vlan',
|
||||
'provider:physical_network': 'physnet1',
|
||||
'provider:segmentation_id': '400',
|
||||
}
|
||||
self.network.update_network.assert_called_once_with(
|
||||
self._network, **attrs)
|
||||
|
@ -2,7 +2,7 @@
|
||||
features:
|
||||
- |
|
||||
Add provider network options ``--provider-network-type``,
|
||||
``--provider-physical-network``, and ``--provider-segmentation-id``
|
||||
to the ``network create`` command.
|
||||
These options are available for Networkv2 only
|
||||
[Bug `1545537 <https://bugs.launchpad.net/bugs/1545537>`_]
|
||||
``--provider-physical-network`` and ``--provider-segment``
|
||||
to the ``network create`` and ``network set`` commands.
|
||||
These options are available for NetworkV2 only.
|
||||
[Bug `1545537 <https://bugs.launchpad.net/bugs/1545537>`_]
|
Loading…
Reference in New Issue
Block a user