Skip to content

Commit 00c149a

Browse files
author
reedip
committed
Add VLAN Transparent option to osc network
osc network set and network create now support --transparent-vlan|--no-transparent-vlan options to add/remove vlan transparency from the network. Change-Id: I845eb8f541cd32a4c4b28f929a63b205e7e31756 Closes-Bug: 1545537
1 parent 4639148 commit 00c149a

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
@@ -21,6 +21,7 @@ Create new network
2121
[--provider-network-type <provider-network-type>]
2222
[--provider-physical-network <provider-physical-network>]
2323
[--provider-segment <provider-segment>]
24+
[--transparent-vlan | --no-transparent-vlan]
2425
<name>
2526
2627
.. option:: --project <project>
@@ -116,6 +117,18 @@ Create new network
116117
117118
*Network version 2 only*
118119
120+
.. option:: --transparent-vlan
121+
122+
Make the network VLAN transparent
123+
124+
*Network version 2 only*
125+
126+
.. option:: --no-transparent-vlan
127+
128+
Do not make the network VLAN transparent
129+
130+
*Network version 2 only*
131+
119132
.. _network_create-name:
120133
.. describe:: <name>
121134
@@ -175,6 +188,7 @@ Set network properties
175188
[--provider-network-type <provider-network-type>]
176189
[--provider-physical-network <provider-physical-network>]
177190
[--provider-segment <provider-segment>]
191+
[--transparent-vlan | --no-transparent-vlan]
178192
<network>
179193
180194
.. option:: --name <name>
@@ -227,6 +241,14 @@ Set network properties
227241
228242
VLAN ID for VLAN networks or Tunnel ID for GRE/VXLAN networks
229243
244+
.. option:: --transparent-vlan
245+
246+
Make the network VLAN transparent
247+
248+
.. option:: --no-transparent-vlan
249+
250+
Do not make the network VLAN transparent
251+
230252
.. _network_set-network:
231253
.. describe:: <network>
232254

openstackclient/network/v2/network.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,17 @@ def _get_attrs(client_manager, parsed_args):
9393
attrs['provider:physical_network'] = parsed_args.physical_network
9494
if parsed_args.segmentation_id:
9595
attrs['provider:segmentation_id'] = parsed_args.segmentation_id
96+
# Update VLAN Transparency for networks
97+
if parsed_args.transparent_vlan:
98+
attrs['vlan_transparent'] = True
99+
if parsed_args.no_transparent_vlan:
100+
attrs['vlan_transparent'] = False
96101
return attrs
97102

98103

99-
def _add_provider_network_options(parser):
100-
# Add provider network options
104+
def _add_additional_network_options(parser):
105+
# Add additional network options
106+
101107
parser.add_argument(
102108
'--provider-network-type',
103109
metavar='<provider-network-type>',
@@ -119,6 +125,16 @@ def _add_provider_network_options(parser):
119125
help=_("VLAN ID for VLAN networks or Tunnel ID for GRE/VXLAN "
120126
"networks"))
121127

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

123139
def _get_attrs_compute(client_manager, parsed_args):
124140
attrs = {}
@@ -209,7 +225,7 @@ def update_parser_network(self, parser):
209225
help=_("Do not use the network as the default external network. "
210226
"(default)")
211227
)
212-
_add_provider_network_options(parser)
228+
_add_additional_network_options(parser)
213229
return parser
214230

215231
def update_parser_compute(self, parser):
@@ -413,7 +429,7 @@ def get_parser(self, prog_name):
413429
action='store_true',
414430
help=_("Do not use the network as the default external network")
415431
)
416-
_add_provider_network_options(parser)
432+
_add_additional_network_options(parser)
417433
return parser
418434

419435
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
@@ -149,6 +149,7 @@ def test_create_all_options(self):
149149
"--provider-network-type", "vlan",
150150
"--provider-physical-network", "physnet1",
151151
"--provider-segment", "400",
152+
"--transparent-vlan",
152153
self._network.name,
153154
]
154155
verifylist = [
@@ -162,6 +163,7 @@ def test_create_all_options(self):
162163
('provider_network_type', 'vlan'),
163164
('physical_network', 'physnet1'),
164165
('segmentation_id', '400'),
166+
('transparent_vlan', True),
165167
('name', self._network.name),
166168
]
167169

@@ -179,6 +181,7 @@ def test_create_all_options(self):
179181
'provider:network_type': 'vlan',
180182
'provider:physical_network': 'physnet1',
181183
'provider:segmentation_id': '400',
184+
'vlan_transparent': True,
182185
})
183186
self.assertEqual(self.columns, columns)
184187
self.assertEqual(self.data, data)
@@ -487,6 +490,7 @@ def test_set_this(self):
487490
'--provider-network-type', 'vlan',
488491
'--provider-physical-network', 'physnet1',
489492
'--provider-segment', '400',
493+
'--no-transparent-vlan',
490494
]
491495
verifylist = [
492496
('network', self._network.name),
@@ -498,6 +502,7 @@ def test_set_this(self):
498502
('provider_network_type', 'vlan'),
499503
('physical_network', 'physnet1'),
500504
('segmentation_id', '400'),
505+
('no_transparent_vlan', True),
501506
]
502507

503508
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -512,6 +517,7 @@ def test_set_this(self):
512517
'provider:network_type': 'vlan',
513518
'provider:physical_network': 'physnet1',
514519
'provider:segmentation_id': '400',
520+
'vlan_transparent': False,
515521
}
516522
self.network.update_network.assert_called_once_with(
517523
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)