Fix Nova-net netowrk commands · openstack/python-openstackclient@589a65c · GitHub
Skip to content

Commit 589a65c

Browse files
author
Dean Troyer
committed
Fix Nova-net netowrk commands
In cleaning up functional tests for nova-net, I discovered some problems in network create: * --subnet option is required in network create command * Switch API to use /os-networks rather than /os-tenant-networks as this is what we were actually using via novaclient * Fix functional tests for nova-net * Normalize some private function names in network/v2/network.py Change-Id: I426b864406756d58d140575a3a45ee9aee67ce84
1 parent 7b609eb commit 589a65c

7 files changed

Lines changed: 299 additions & 143 deletions

File tree

doc/source/backwards-incompatible.rst

Lines changed: 7 additions & 1 deletion

doc/source/command-objects/network.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ Create new network
7171
7272
Set network description
7373
74+
*Network version 2 only*
75+
7476
.. option:: --availability-zone-hint <availability-zone>
7577
7678
Availability Zone in which to create this network

openstackclient/api/compute_v2.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,25 @@ def network_create(
202202
):
203203
"""Create a new network
204204
205-
https://developer.openstack.org/api-ref/compute/#create-project-network
205+
https://developer.openstack.org/api-ref/compute/#create-network
206206
207207
:param string name:
208-
Network label
208+
Network label (required)
209209
:param integer subnet:
210-
Subnet for IPv4 fixed addresses in CIDR notation
210+
Subnet for IPv4 fixed addresses in CIDR notation (required)
211211
:param integer share_subnet:
212212
Shared subnet between projects, True or False
213213
:returns: A dict of the network attributes
214214
"""
215215

216-
url = "/os-tenant-networks"
216+
url = "/os-networks"
217217

218218
params = {
219219
'label': name,
220220
'cidr': subnet,
221-
'share_address': share_subnet,
222221
}
222+
if share_subnet is not None:
223+
params['share_address'] = share_subnet
223224

224225
return self.create(
225226
url,
@@ -232,13 +233,13 @@ def network_delete(
232233
):
233234
"""Delete a network
234235
235-
https://developer.openstack.org/api-ref/compute/#delete-project-network
236+
https://developer.openstack.org/api-ref/compute/#delete-network
236237
237238
:param string network:
238239
Network name or ID
239240
"""
240241

241-
url = "/os-tenant-networks"
242+
url = "/os-networks"
242243

243244
network = self.find(
244245
url,
@@ -256,14 +257,14 @@ def network_find(
256257
):
257258
"""Return a network given name or ID
258259
259-
https://developer.openstack.org/api-ref/compute/#show-project-network-details
260+
https://developer.openstack.org/api-ref/compute/#show-network-details
260261
261262
:param string network:
262263
Network name or ID
263264
:returns: A dict of the network attributes
264265
"""
265266

266-
url = "/os-tenant-networks"
267+
url = "/os-networks"
267268

268269
return self.find(
269270
url,
@@ -276,13 +277,13 @@ def network_list(
276277
):
277278
"""Get networks
278279
279-
https://developer.openstack.org/api-ref/compute/#list-project-networks
280+
https://developer.openstack.org/api-ref/compute/#list-networks
280281
281282
:returns:
282283
list of networks
283284
"""
284285

285-
url = "/os-tenant-networks"
286+
url = "/os-networks"
286287

287288
return self.list(url)["networks"]
288289

openstackclient/network/v2/network.py

Lines changed: 23 additions & 22 deletions

0 commit comments

Comments
 (0)