Skip to content

Commit 29d4dd7

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "neutron: add --mtu for create/set network"
2 parents 350b545 + 18563b4 commit 29d4dd7

5 files changed

Lines changed: 41 additions & 0 deletions

File tree

doc/source/cli/command-objects/network.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Create new network
2424
[--enable | --disable]
2525
[--share | --no-share]
2626
[--description <description>]
27+
[--mtu <mtu>]
2728
[--availability-zone-hint <availability-zone>]
2829
[--enable-port-security | --disable-port-security]
2930
[--external [--default | --no-default] | --internal]
@@ -74,6 +75,12 @@ Create new network
7475
7576
*Network version 2 only*
7677
78+
.. option:: --mtu <mtu>
79+
80+
Set network mtu
81+
82+
*Network version 2 only*
83+
7784
.. option:: --availability-zone-hint <availability-zone>
7885
7986
Availability Zone in which to create this network
@@ -353,6 +360,7 @@ Set network properties
353360
[--enable | --disable]
354361
[--share | --no-share]
355362
[--description <description>]
363+
[--mtu <mtu>]
356364
[--enable-port-security | --disable-port-security]
357365
[--external [--default | --no-default] | --internal]
358366
[--provider-network-type <provider-network-type>]
@@ -386,6 +394,10 @@ Set network properties
386394
387395
Set network description
388396
397+
.. option:: --mtu <mtu>
398+
399+
Set network mtu
400+
389401
.. option:: --enable-port-security
390402
391403
Enable port security by default for ports created on

openstackclient/network/v2/network.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ def _get_attrs_network(client_manager, parsed_args):
107107
if parsed_args.description:
108108
attrs['description'] = parsed_args.description
109109

110+
# set mtu
111+
if parsed_args.mtu:
112+
attrs['mtu'] = parsed_args.mtu
113+
110114
# update_external_network_options
111115
if parsed_args.internal:
112116
attrs['router:external'] = False
@@ -217,6 +221,11 @@ def update_parser_network(self, parser):
217221
metavar='<description>',
218222
help=_("Set network description")
219223
)
224+
parser.add_argument(
225+
'--mtu',
226+
metavar='<mtu>',
227+
help=_("Set network mtu")
228+
)
220229
identity_common.add_project_domain_option_to_parser(parser)
221230
parser.add_argument(
222231
'--availability-zone-hint',
@@ -619,6 +628,11 @@ def get_parser(self, prog_name):
619628
metavar="<description",
620629
help=_("Set network description")
621630
)
631+
parser.add_argument(
632+
'--mtu',
633+
metavar="<mtu",
634+
help=_("Set network mtu")
635+
)
622636
port_security_group = parser.add_mutually_exclusive_group()
623637
port_security_group.add_argument(
624638
'--enable-port-security',

openstackclient/tests/unit/network/v2/fakes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ def create_one_network(attrs=None):
335335
'name': 'network-name-' + uuid.uuid4().hex,
336336
'status': 'ACTIVE',
337337
'description': 'network-description-' + uuid.uuid4().hex,
338+
'mtu': '1350',
338339
'tenant_id': 'project-id-' + uuid.uuid4().hex,
339340
'admin_state_up': True,
340341
'shared': False,

openstackclient/tests/unit/network/v2/test_network.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
6464
'ipv4_address_scope',
6565
'ipv6_address_scope',
6666
'is_default',
67+
'mtu',
6768
'name',
6869
'port_security_enabled',
6970
'project_id',
@@ -87,6 +88,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
8788
_network.ipv4_address_scope_id,
8889
_network.ipv6_address_scope_id,
8990
_network.is_default,
91+
_network.mtu,
9092
_network.name,
9193
_network.is_port_security_enabled,
9294
_network.project_id,
@@ -149,6 +151,7 @@ def test_create_all_options(self):
149151
"--disable",
150152
"--share",
151153
"--description", self._network.description,
154+
"--mtu", self._network.mtu,
152155
"--project", self.project.name,
153156
"--project-domain", self.domain.name,
154157
"--availability-zone-hint", "nova",
@@ -165,6 +168,7 @@ def test_create_all_options(self):
165168
('disable', True),
166169
('share', True),
167170
('description', self._network.description),
171+
('mtu', self._network.mtu),
168172
('project', self.project.name),
169173
('project_domain', self.domain.name),
170174
('availability_zone_hints', ["nova"]),
@@ -188,6 +192,7 @@ def test_create_all_options(self):
188192
'name': self._network.name,
189193
'shared': True,
190194
'description': self._network.description,
195+
'mtu': self._network.mtu,
191196
# TODO(dtroyer): Remove tenant_id when we clean up the SDK refactor
192197
'tenant_id': self.project.id,
193198
'project_id': self.project.id,
@@ -286,6 +291,7 @@ class TestCreateNetworkIdentityV2(TestNetwork):
286291
'ipv4_address_scope',
287292
'ipv6_address_scope',
288293
'is_default',
294+
'mtu',
289295
'name',
290296
'port_security_enabled',
291297
'project_id',
@@ -309,6 +315,7 @@ class TestCreateNetworkIdentityV2(TestNetwork):
309315
_network.ipv4_address_scope_id,
310316
_network.ipv6_address_scope_id,
311317
_network.is_default,
318+
_network.mtu,
312319
_network.name,
313320
_network.is_port_security_enabled,
314321
_network.project_id,
@@ -1023,6 +1030,7 @@ class TestShowNetwork(TestNetwork):
10231030
'ipv4_address_scope',
10241031
'ipv6_address_scope',
10251032
'is_default',
1033+
'mtu',
10261034
'name',
10271035
'port_security_enabled',
10281036
'project_id',
@@ -1046,6 +1054,7 @@ class TestShowNetwork(TestNetwork):
10461054
_network.ipv4_address_scope_id,
10471055
_network.ipv6_address_scope_id,
10481056
_network.is_default,
1057+
_network.mtu,
10491058
_network.name,
10501059
_network.is_port_security_enabled,
10511060
_network.project_id,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
features:
3+
- |
4+
Add ``--mtu`` option to ``network create`` and ``network set``
5+
commands, allowing CLI users to set the MTU for Neutron networks.

0 commit comments

Comments
 (0)