Skip to content

Commit bd7e1d3

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add provider network options to osc network create"
2 parents 60a91a6 + 1b351e1 commit bd7e1d3

4 files changed

Lines changed: 63 additions & 0 deletions

File tree

doc/source/command-objects/network.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Create new network
1818
[--share | --no-share]
1919
[--availability-zone-hint <availability-zone>]
2020
[--external [--default | --no-default] | --internal]
21+
[--provider-network-type <provider-network-type>]
22+
[--provider-physical-network <provider-physical-network>]
23+
[--provider-segmentation-id <provider-segmentation-id>]
2124
<name>
2225
2326
.. option:: --project <project>
@@ -83,6 +86,22 @@ Create new network
8386
By default, no network is set as an external network.
8487
(Network v2 only)
8588
89+
.. option:: --provider-network-type <provider-network-type>
90+
91+
The physical mechanism by which the virtual network is implemented.
92+
The supported options are: flat, gre, local, vlan, vxlan
93+
(Network v2 only)
94+
95+
.. option:: --provider-physical-network <provider-physical-network>
96+
97+
Name of the physical network over which the virtual network is implemented
98+
(Network v2 only)
99+
100+
.. option:: --provider-segmentation-id <provider-segmentation-id>
101+
102+
VLAN ID for VLAN networks or tunnel-id for GRE/VXLAN networks
103+
(Network v2 only)
104+
86105
.. _network_create-name:
87106
.. describe:: <name>
88107

openstackclient/network/v2/network.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,26 @@ def update_parser_network(self, parser):
165165
action='store_true',
166166
help='Do not use the network as the default external network.'
167167
'By default, no network is set as an external network.')
168+
parser.add_argument(
169+
'--provider-network-type',
170+
metavar='<provider-network-type>',
171+
choices=['flat', 'gre', 'local',
172+
'vlan', 'vxlan'],
173+
help='The physical mechanism by which the virtual network '
174+
'is implemented. The supported options are: '
175+
'flat, gre, local, vlan, vxlan')
176+
parser.add_argument(
177+
'--provider-physical-network',
178+
metavar='<provider-physical-network>',
179+
dest='physical_network',
180+
help='Name of the physical network over which the virtual '
181+
'network is implemented')
182+
parser.add_argument(
183+
'--provider-segmentation-id',
184+
metavar='<provider-segmentation-id>',
185+
dest='segmentation_id',
186+
help='VLAN ID for VLAN networks or tunnel-id for GRE/VXLAN '
187+
'networks')
168188
return parser
169189

170190
def update_parser_compute(self, parser):
@@ -185,6 +205,12 @@ def take_action_network(self, client, parsed_args):
185205
attrs['is_default'] = False
186206
if parsed_args.default:
187207
attrs['is_default'] = True
208+
if parsed_args.provider_network_type:
209+
attrs['provider:network_type'] = parsed_args.provider_network_type
210+
if parsed_args.physical_network:
211+
attrs['provider:physical_network'] = parsed_args.physical_network
212+
if parsed_args.segmentation_id:
213+
attrs['provider:segmentation_id'] = parsed_args.segmentation_id
188214
obj = client.create_network(**attrs)
189215
columns = _get_columns(obj)
190216
data = utils.get_item_properties(obj, columns, formatters=_formatters)

openstackclient/tests/network/v2/test_network.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ def test_create_all_options(self):
142142
"--project-domain", identity_fakes_v3.domain_name,
143143
"--availability-zone-hint", "nova",
144144
"--external", "--default",
145+
"--provider-network-type", "vlan",
146+
"--provider-physical-network", "physnet1",
147+
"--provider-segmentation-id", "400",
145148
self._network.name,
146149
]
147150
verifylist = [
@@ -152,6 +155,9 @@ def test_create_all_options(self):
152155
('availability_zone_hints', ["nova"]),
153156
('external', True),
154157
('default', True),
158+
('provider_network_type', 'vlan'),
159+
('physical_network', 'physnet1'),
160+
('segmentation_id', '400'),
155161
('name', self._network.name),
156162
]
157163

@@ -166,6 +172,9 @@ def test_create_all_options(self):
166172
'tenant_id': identity_fakes_v3.project_id,
167173
'is_default': True,
168174
'router:external': True,
175+
'provider:network_type': 'vlan',
176+
'provider:physical_network': 'physnet1',
177+
'provider:segmentation_id': '400',
169178
})
170179
self.assertEqual(self.columns, columns)
171180
self.assertEqual(self.data, data)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
features:
3+
- |
4+
New options have been added to the ``network create`` command
5+
to support provider network functionality.
6+
These options are ``--provider-network-type``, ``--provider-physical-network``,
7+
and ``--provider-segmentation-id``.
8+
These options are available for Networkv2 only
9+
[Bug `1545537 <https://bugs.launchpad.net/bugs/1545537>`_]

0 commit comments

Comments
 (0)