neutron: add --mtu for create/set network

Support Neutron network mtu configuration with a new argument, --mtu
that allows CLI users to set MTU for Neutron networks.

Change-Id: I93d23581c7e8c84eaf9bb3b293360036f60f456b
This commit is contained in:
Emilien Macchi 2018-03-15 13:21:41 +01:00
parent e78c9bc00d
commit 18563b4132
5 changed files with 41 additions and 0 deletions

View File

@ -24,6 +24,7 @@ Create new network
[--enable | --disable] [--enable | --disable]
[--share | --no-share] [--share | --no-share]
[--description <description>] [--description <description>]
[--mtu <mtu>]
[--availability-zone-hint <availability-zone>] [--availability-zone-hint <availability-zone>]
[--enable-port-security | --disable-port-security] [--enable-port-security | --disable-port-security]
[--external [--default | --no-default] | --internal] [--external [--default | --no-default] | --internal]
@ -74,6 +75,12 @@ Create new network
*Network version 2 only* *Network version 2 only*
.. option:: --mtu <mtu>
Set network mtu
*Network version 2 only*
.. option:: --availability-zone-hint <availability-zone> .. option:: --availability-zone-hint <availability-zone>
Availability Zone in which to create this network Availability Zone in which to create this network
@ -353,6 +360,7 @@ Set network properties
[--enable | --disable] [--enable | --disable]
[--share | --no-share] [--share | --no-share]
[--description <description>] [--description <description>]
[--mtu <mtu>]
[--enable-port-security | --disable-port-security] [--enable-port-security | --disable-port-security]
[--external [--default | --no-default] | --internal] [--external [--default | --no-default] | --internal]
[--provider-network-type <provider-network-type>] [--provider-network-type <provider-network-type>]
@ -386,6 +394,10 @@ Set network properties
Set network description Set network description
.. option:: --mtu <mtu>
Set network mtu
.. option:: --enable-port-security .. option:: --enable-port-security
Enable port security by default for ports created on Enable port security by default for ports created on

View File

@ -107,6 +107,10 @@ def _get_attrs_network(client_manager, parsed_args):
if parsed_args.description: if parsed_args.description:
attrs['description'] = parsed_args.description attrs['description'] = parsed_args.description
# set mtu
if parsed_args.mtu:
attrs['mtu'] = parsed_args.mtu
# update_external_network_options # update_external_network_options
if parsed_args.internal: if parsed_args.internal:
attrs['router:external'] = False attrs['router:external'] = False
@ -217,6 +221,11 @@ class CreateNetwork(common.NetworkAndComputeShowOne):
metavar='<description>', metavar='<description>',
help=_("Set network description") help=_("Set network description")
) )
parser.add_argument(
'--mtu',
metavar='<mtu>',
help=_("Set network mtu")
)
identity_common.add_project_domain_option_to_parser(parser) identity_common.add_project_domain_option_to_parser(parser)
parser.add_argument( parser.add_argument(
'--availability-zone-hint', '--availability-zone-hint',
@ -619,6 +628,11 @@ class SetNetwork(command.Command):
metavar="<description", metavar="<description",
help=_("Set network description") help=_("Set network description")
) )
parser.add_argument(
'--mtu',
metavar="<mtu",
help=_("Set network mtu")
)
port_security_group = parser.add_mutually_exclusive_group() port_security_group = parser.add_mutually_exclusive_group()
port_security_group.add_argument( port_security_group.add_argument(
'--enable-port-security', '--enable-port-security',

View File

@ -335,6 +335,7 @@ class FakeNetwork(object):
'name': 'network-name-' + uuid.uuid4().hex, 'name': 'network-name-' + uuid.uuid4().hex,
'status': 'ACTIVE', 'status': 'ACTIVE',
'description': 'network-description-' + uuid.uuid4().hex, 'description': 'network-description-' + uuid.uuid4().hex,
'mtu': '1350',
'tenant_id': 'project-id-' + uuid.uuid4().hex, 'tenant_id': 'project-id-' + uuid.uuid4().hex,
'admin_state_up': True, 'admin_state_up': True,
'shared': False, 'shared': False,

View File

@ -64,6 +64,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
'ipv4_address_scope', 'ipv4_address_scope',
'ipv6_address_scope', 'ipv6_address_scope',
'is_default', 'is_default',
'mtu',
'name', 'name',
'port_security_enabled', 'port_security_enabled',
'project_id', 'project_id',
@ -87,6 +88,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
_network.ipv4_address_scope_id, _network.ipv4_address_scope_id,
_network.ipv6_address_scope_id, _network.ipv6_address_scope_id,
_network.is_default, _network.is_default,
_network.mtu,
_network.name, _network.name,
_network.is_port_security_enabled, _network.is_port_security_enabled,
_network.project_id, _network.project_id,
@ -149,6 +151,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
"--disable", "--disable",
"--share", "--share",
"--description", self._network.description, "--description", self._network.description,
"--mtu", self._network.mtu,
"--project", self.project.name, "--project", self.project.name,
"--project-domain", self.domain.name, "--project-domain", self.domain.name,
"--availability-zone-hint", "nova", "--availability-zone-hint", "nova",
@ -165,6 +168,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
('disable', True), ('disable', True),
('share', True), ('share', True),
('description', self._network.description), ('description', self._network.description),
('mtu', self._network.mtu),
('project', self.project.name), ('project', self.project.name),
('project_domain', self.domain.name), ('project_domain', self.domain.name),
('availability_zone_hints', ["nova"]), ('availability_zone_hints', ["nova"]),
@ -188,6 +192,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
'name': self._network.name, 'name': self._network.name,
'shared': True, 'shared': True,
'description': self._network.description, 'description': self._network.description,
'mtu': self._network.mtu,
# TODO(dtroyer): Remove tenant_id when we clean up the SDK refactor # TODO(dtroyer): Remove tenant_id when we clean up the SDK refactor
'tenant_id': self.project.id, 'tenant_id': self.project.id,
'project_id': self.project.id, 'project_id': self.project.id,
@ -286,6 +291,7 @@ class TestCreateNetworkIdentityV2(TestNetwork):
'ipv4_address_scope', 'ipv4_address_scope',
'ipv6_address_scope', 'ipv6_address_scope',
'is_default', 'is_default',
'mtu',
'name', 'name',
'port_security_enabled', 'port_security_enabled',
'project_id', 'project_id',
@ -309,6 +315,7 @@ class TestCreateNetworkIdentityV2(TestNetwork):
_network.ipv4_address_scope_id, _network.ipv4_address_scope_id,
_network.ipv6_address_scope_id, _network.ipv6_address_scope_id,
_network.is_default, _network.is_default,
_network.mtu,
_network.name, _network.name,
_network.is_port_security_enabled, _network.is_port_security_enabled,
_network.project_id, _network.project_id,
@ -1023,6 +1030,7 @@ class TestShowNetwork(TestNetwork):
'ipv4_address_scope', 'ipv4_address_scope',
'ipv6_address_scope', 'ipv6_address_scope',
'is_default', 'is_default',
'mtu',
'name', 'name',
'port_security_enabled', 'port_security_enabled',
'project_id', 'project_id',
@ -1046,6 +1054,7 @@ class TestShowNetwork(TestNetwork):
_network.ipv4_address_scope_id, _network.ipv4_address_scope_id,
_network.ipv6_address_scope_id, _network.ipv6_address_scope_id,
_network.is_default, _network.is_default,
_network.mtu,
_network.name, _network.name,
_network.is_port_security_enabled, _network.is_port_security_enabled,
_network.project_id, _network.project_id,

View File

@ -0,0 +1,5 @@
---
features:
- |
Add ``--mtu`` option to ``network create`` and ``network set``
commands, allowing CLI users to set the MTU for Neutron networks.