Skip to content

Commit 3d12ae8

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add VLAN Transparent option to osc network"
2 parents f0e64eb + 00c149a commit 3d12ae8

4 files changed

Lines changed: 57 additions & 4 deletions

File tree

doc/source/command-objects/network.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Create new network
2828
[--provider-network-type <provider-network-type>]
2929
[--provider-physical-network <provider-physical-network>]
3030
[--provider-segment <provider-segment>]
31+
[--transparent-vlan | --no-transparent-vlan]
3132
<name>
3233
3334
.. option:: --project <project>
@@ -123,6 +124,18 @@ Create new network
123124
124125
*Network version 2 only*
125126
127+
.. option:: --transparent-vlan
128+
129+
Make the network VLAN transparent
130+
131+
*Network version 2 only*
132+
133+
.. option:: --no-transparent-vlan
134+
135+
Do not make the network VLAN transparent
136+
137+
*Network version 2 only*
138+
126139
.. _network_create-name:
127140
.. describe:: <name>
128141
@@ -182,6 +195,7 @@ Set network properties
182195
[--provider-network-type <provider-network-type>]
183196
[--provider-physical-network <provider-physical-network>]
184197
[--provider-segment <provider-segment>]
198+
[--transparent-vlan | --no-transparent-vlan]
185199
<network>
186200
187201
.. option:: --name <name>
@@ -234,6 +248,14 @@ Set network properties
234248
235249
VLAN ID for VLAN networks or Tunnel ID for GRE/VXLAN networks
236250
251+
.. option:: --transparent-vlan
252+
253+
Make the network VLAN transparent
254+
255+
.. option:: --no-transparent-vlan
256+
257+
Do not make the network VLAN transparent
258+
237259
.. _network_set-network:
238260
.. describe:: <network>
239261

openstackclient/network/v2/network.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,17 @@ def _get_attrs(client_manager, parsed_args):
9090
attrs['provider:physical_network'] = parsed_args.physical_network
9191
if parsed_args.segmentation_id:
9292
attrs['provider:segmentation_id'] = parsed_args.segmentation_id
93+
# Update VLAN Transparency for networks
94+
if parsed_args.transparent_vlan:
95+
attrs['vlan_transparent'] = True
96+
if parsed_args.no_transparent_vlan:
97+
attrs['vlan_transparent'] = False
9398
return attrs
9499

95100

96-
def _add_provider_network_options(parser):
97-
# Add provider network options
101+
def _add_additional_network_options(parser):
102+
# Add additional network options
103+
98104
parser.add_argument(
99105
'--provider-network-type',
100106
metavar='<provider-network-type>',
@@ -116,6 +122,16 @@ def _add_provider_network_options(parser):
116122
help=_("VLAN ID for VLAN networks or Tunnel ID for GRE/VXLAN "
117123
"networks"))
118124

125+
vlan_transparent_grp = parser.add_mutually_exclusive_group()
126+
vlan_transparent_grp.add_argument(
127+
'--transparent-vlan',
128+
action='store_true',
129+
help=_("Make the network VLAN transparent"))
130+
vlan_transparent_grp.add_argument(
131+
'--no-transparent-vlan',
132+
action='store_true',
133+
help=_("Do not make the network VLAN transparent"))
134+
119135

120136
def _get_attrs_compute(client_manager, parsed_args):
121137
attrs = {}
@@ -206,7 +222,7 @@ def update_parser_network(self, parser):
206222
help=_("Do not use the network as the default external network. "
207223
"(default)")
208224
)
209-
_add_provider_network_options(parser)
225+
_add_additional_network_options(parser)
210226
return parser
211227

212228
def update_parser_compute(self, parser):
@@ -410,7 +426,7 @@ def get_parser(self, prog_name):
410426
action='store_true',
411427
help=_("Do not use the network as the default external network")
412428
)
413-
_add_provider_network_options(parser)
429+
_add_additional_network_options(parser)
414430
return parser
415431

416432
def take_action(self, parsed_args):

openstackclient/tests/network/v2/test_network.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def test_create_all_options(self):
148148
"--provider-network-type", "vlan",
149149
"--provider-physical-network", "physnet1",
150150
"--provider-segment", "400",
151+
"--transparent-vlan",
151152
self._network.name,
152153
]
153154
verifylist = [
@@ -161,6 +162,7 @@ def test_create_all_options(self):
161162
('provider_network_type', 'vlan'),
162163
('physical_network', 'physnet1'),
163164
('segmentation_id', '400'),
165+
('transparent_vlan', True),
164166
('name', self._network.name),
165167
]
166168

@@ -178,6 +180,7 @@ def test_create_all_options(self):
178180
'provider:network_type': 'vlan',
179181
'provider:physical_network': 'physnet1',
180182
'provider:segmentation_id': '400',
183+
'vlan_transparent': True,
181184
})
182185
self.assertEqual(self.columns, columns)
183186
self.assertEqual(self.data, data)
@@ -486,6 +489,7 @@ def test_set_this(self):
486489
'--provider-network-type', 'vlan',
487490
'--provider-physical-network', 'physnet1',
488491
'--provider-segment', '400',
492+
'--no-transparent-vlan',
489493
]
490494
verifylist = [
491495
('network', self._network.name),
@@ -497,6 +501,7 @@ def test_set_this(self):
497501
('provider_network_type', 'vlan'),
498502
('physical_network', 'physnet1'),
499503
('segmentation_id', '400'),
504+
('no_transparent_vlan', True),
500505
]
501506

502507
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -511,6 +516,7 @@ def test_set_this(self):
511516
'provider:network_type': 'vlan',
512517
'provider:physical_network': 'physnet1',
513518
'provider:segmentation_id': '400',
519+
'vlan_transparent': False,
514520
}
515521
self.network.update_network.assert_called_once_with(
516522
self._network, **attrs)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
features:
3+
- |
4+
``network create`` and ``network set`` now support
5+
``--transparent-vlan`` and ``--no-transparent-vlan``
6+
options to add/remove VLAN transparency attributes
7+
from networks.
8+
This option is available in Network V2 only.
9+
[Bug `1545537 <https://bugs.launchpad.net/bugs/1545537>`_]

0 commit comments

Comments
 (0)