41 Commits

Author SHA1 Message Date
Sean McGinnis
4669bcc628
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I12e1a2a4a22116cabd09a3b808f871d98e4bd1f2
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-06-01 07:57:23 -05:00
Mykola Yakovliev
0aefe1ccba Ensure API calls for subnets are in URL length limit
Fix situation when with pagination enabled, neutronclient failed
to read subnets information due to too long URI.

Change-Id: I53240c536d77a95510b5c83b81e21782f29d886a
Closes-Bug: 1775922
2018-08-31 20:08:57 +00:00
Hongbin Lu
c50b126771 Remove mox/mox3 usage from test_cli20_network.py
Change-Id: I3c9f53e57ef7fc38b0d4b2eb3138902004cff2b3
Partial-Bug: #1753504
2018-03-19 17:44:06 +00:00
Darek Smigiel (dasm)
6a3a7c6816 Refactor of Network tests
Simplified and removed common parts of tests.

Change-Id: I249dac1c6ae2719979e631de026b12fac7dbf1a2
2016-11-18 00:30:13 +00:00
Jenkins
3328367624 Merge "Show tenant_id in *-list by admin" 2016-10-20 21:23:40 +00:00
Reedip
9ecea3bbf1 Return proper error code for CLI failure
Due to [1] , the return code which was expected from
NeutronClient changed if a particular CLI failed to
find an object belonging to the resource to be deleted.
The following patch fixes it.
[1]: https://review.openstack.org/#/c/263609/

Change-Id: I19b4328361157fbca3e557e02797ed0c895e924b
Closes-Bug:#1623169
2016-10-03 10:32:39 +00:00
Reedip
5799e5daaf Trivial correction in variable name
As mentioned by Akihiro Motoki in I3b8a05698625baad3906784e3ecffb0f0242d660
the variable name "extra_ids" needed a cleanup, which
is done in this patch.

TrivialFix

Change-Id: I9636582a3d76332916f9502c9906dc6570709c12
2016-08-12 11:20:30 +05:30
reedip
b16c9a8d3d Add support for Bulk Delete in NeutronClient
The following patch adds support for BulkDelete in NeutronClient.
Currently, the core existing Neutron CLIs are going to support
Bulk Deletion in NeutronClient. However, if any extension does not
require Bulk Delete, it can be disabled by updating the
class attribute 'bulk_delete'.

DocImpact
Depends-On: Ib23d1e53947b5dffcff8db0dde77cae0a0b31243
Change-Id: I3b8a05698625baad3906784e3ecffb0f0242d660
Closes-Bug: #1495440
2016-08-09 04:55:18 +00:00
Kevin Benton
2db432fbf5 Add parser options for description on resources
This adds the description field to the parsers for all
of the resources that gained description fields in the
dependent patch.

Change-Id: I939b517c5320ea9dd3f387c12adee1ed8876adec
Related-Bug: #1483480
Depends-On: I6e1ef53d7aae7d04a5485810cc1db0a8eb125953
2016-03-08 19:12:58 +00:00
Miguel Lavalle
8d4c0e4ac2 Add DNS integration support to the client
DNS integration has been added to Neutron. This commit complements that
by adding --dns-name and --dns-domain arguments to create and update
commands of networks, ports and floating IPs.

Change-Id: I7a6ec05b6d7483fceb35f586ac476e8713904b59
Closes-Bug: #1547736
2016-02-23 17:42:45 +00:00
Reedip Banerjee
92b5fe9eb1 Provide argument filtering in neutron *-list
This implements a common framework for attribute filtering arguments
and arguments for net-list as an initial support.

Co-Authored-By: Reedip Banerjee <reedip.banerjee@nectechnologies.in>
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>

Change-Id: Ie1b896d6f293b2881a7067ed9232a5957a5180cb
Closes-Bug: #1320798
Partial-Bug: #1488912
2016-02-10 04:34:58 +00:00
Akihiro Motoki
9dbdced729 Show tenant_id in *-list by admin
If API call is done by admin, neutron API returns all resources
from all tenants. We received several times a request that
tenant_id is useful in such case.

This patch displays tenant_id column when *-list is invoked
by a user with 'admin' role by default. If columns to be displayed
are specified by '-c' option, the specified columns are honored
and tenant_id columns is not added.

Add functional tests to cover this change. This feature depends
on keystoneauth1 and unit tests cannot cover this change.

Closes-Bug: #1526238
Change-Id: Id58a0b795f76b4fe24aaf89f1f6486c23f19a553
2016-01-24 23:44:32 +09:00
Akihiro Motoki
131160ed56 refactor: Get rid of usage of get_data in favor of take_action
Previously the dropped OpenStackCommand uses get_data()
as an interface which subclasses should implement.
On the other hand, cliff Command recommends to implement
take_action() in subclasses and there is no reason not to
follow this convention.

Partial-Bug: #1532258
Change-Id: I164d6f31152df621611985a84eef76e7dfa54d44
2016-01-18 13:01:57 +09:00
shu-mutou
ec4e482731 Fix H405 violations
There are a lot of H405 violation codes.
We need to fix the code for avoiding more violations.

Change-Id: Iaa83626b81a3d8369b16e2b4f394e2bc4628998a
Closes-Bug: #1521899
2015-12-13 05:48:42 +09:00
Jenkins
2d5b6e6699 Merge "Remove XML support" 2015-12-11 18:21:14 +00:00
Elena Ezhova
54a4aea969 Remove XML support
As XML support has been removed from neutron, there is no need
to keep it in client.

Dropped XML serializer and deserializer and deprecated "request-format"
CLI option, making JSON the default and the only supported request
format.

DocImpact

Change-Id: I88b0fdd65a649694252d5ff43a174e75026df5b1
Closes-Bug: #1380787
2015-12-09 11:09:26 +03:00
Hirofumi Ichihara
709928b550 Add availability_zone CLI
This patch adds the availability_zone support for CLI.

Change-Id: I13faf6d90e84f401f07376c517c643ba9eda2295
Co-Authored-By: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Partially-implements: blueprint add-availability-zone
2015-12-08 22:36:58 +09:00
Reedip Banerjee
18ce7d9f2e Fix arg order of assertEqual and use assertTrue
assertEqual expects that the arguments provided to it should be
(expected, observed).If a particluar order is kept as a convention,
then it helps to provide a cleaner message to the developer if Unit Tests
fail. There are several Unit Test files where the arguments for assertEqual
have been swapped. This commit fixes the issue in python-neutronclient.

Additionally instead of using assertEqual(True,xxx), assertTrue(xxx) should
be used. The same has been fixed in this patch.

Partial-Bug: #1259292
Related-Bug: #1259292

Change-Id: I83ec45af75f61f8005a60efc8176db0df5cfbe9a
2015-10-07 13:40:57 +05:30
Ramanjaneya
002a0c7375 Support QoS neutron-client (1/2).
This patch adds the command line support for
1. QoS policy
2. QoS policy association with the neutron network
3. QoS policy association with the neutron port

Note: Neutronclient support for QoS rule-types will be addressed via a separate patch
(https://review.openstack.org/#/c/198277/)

DocImpact
APIImpact

Partially-Implements: blueprint quantum-qos-api
Co-Authored-By: Ramanjaneya Reddy Palleti <ramanjieee@gmail.com>
Co-Authored-By: John Schwarz <jschwarz@redhat.com>
Co-Authored-By: vikram.choudhary <vikram.choudhary@huawei.com>
Change-Id: If7460516a3b3e3ccb91f2e7becfe7335ff809bda
2015-08-26 16:26:21 +03:00
nmagnezi
da3a4156a2 Revert "Add '--router:external' option to 'net-create'"
This reverts commit 096fd1b175085fcc3c46a248b4afb67561fd29ef.

In previous neutronclient versions, we allowed the following syntax to
set network as external: --router:external=False or --router:external=True.
Since Ibb100d54a5fd8b04ac5e1fc3a26826c695f4d951 was merged, this syntax
no longer works.

Conflicts:
	neutronclient/neutron/v2_0/network.py

Change-Id: Idbae5461dcaeff3da48d773e323977afcdc6f85e
Closes-Bug: #1451391
2015-06-30 13:47:29 +03:00
Doug Hellmann
d9113f17ac Drop use of 'oslo' namespace package
The Oslo libraries have moved all of their code out of the 'oslo'
namespace package into per-library packages. The namespace package was
retained during kilo for backwards compatibility, but will be removed by
the liberty-2 milestone. This change removes the use of the namespace
package, replacing it with the new package names.

The patches in the libraries will be put on hold until application
patches have landed, or L2, whichever comes first. At that point, new
versions of the libraries without namespace packages will be released as
a major version update.

Please merge this patch, or an equivalent, before L2 to avoid problems
with those library releases.

Blueprint: remove-namespace-packages
https://blueprints.launchpad.net/oslo-incubator/+spec/remove-namespace-packages

Change-Id: I474dcd9de166b00d02b3586858a28797e97a3231
2015-05-06 19:39:35 +00:00
Pritesh Kothari
af3fcb7420 Adding VLAN Transparency support to neutronclient
Adding VLAN Transparency support to neutronclient, it allows
to create new vlan transparent networks. It adds support for
displaying the network vlan transparency support via net-list.

DocImpact
Depends-on: Ie87087a70b83dab589419aa5c17ce7ccafd64cbd
Implements: blueprint nfv-vlan-trunks

Change-Id: I24c2eecd34123933f98b596654baaf76ed1453e8
2015-04-04 12:49:51 -07:00
Anand Shanmugam
5f0f2802a8 Fix failures when calling list operations using Python binding
This bug is caused because of the regression caused by
I1b719bed406b83c5f2deac06e127798a91f51ad7 . The original bug was
raised because check_max_uri was not working after the introduction
of sessionclient.  The change created a regression in which the
python bindings of the neutron client was not usable and causing
traces.

The fix is to revert the change id and add a new check_max_uri to
the sessionclient.  Now uri length will be checked in sessionclient
and  httpclient as well.  please see bug for further info.

Closes-Bug: #1431449

Change-Id: Ief2352a90bb75a76e8c671d51beb0fb7a53a22f9
2015-03-21 00:18:35 +05:30
Mark Rawlings
4b6ed760d4 Reinstate Max URI length checking to V2_0 Client
A previous commit 799e288f48e5d99731dedbfb94808a8cbe01c05c
has broken the ability to recognise long URIs (>8192) and
raise an exception used to prevent the excessive URI being sent
to the server. This impacts the commands net-list and
security-group-rule-list.

The previous edit removed one of the duplicate _check_uri_length functions.
This edit 'swaps' the removal and updates the unit test stubbing accordingly.

The capability to split excessive URIs into managable chunks remained in
the code, but no longer executed because this exception was not raised.
It should be noted that as a side effect of recognising the
long URI, data is returned with the exception that indicates
'how excessive' the URI length was. This allows the URI to be
broken into chunks that will be supported.

Restore the capability to recognise that an excessive URI has
been provided and to raise the expected exception with
related data.

Closes-Bug: #1422736
Change-Id: I1b719bed406b83c5f2deac06e127798a91f51ad7
2015-03-09 16:37:49 +00:00
sridhargaddam
cb5d462f6e Parse provider network attributes in net_create
Currently when provider network attributes are placed before the network
name in neutron net-create command, the network name is incorrectly parsed
to one of the provider attribute values. This patch addresses the issue by
parsing the provider network attributes, which inturn allows us to place
these attributes at any location in the argument list.

Closes-Bug: #1384984
Change-Id: I930ced12d1f6747df91a47af8f34585ed36b84f3
2015-01-13 10:15:24 +00:00
Jenkins
adf358d2b0 Merge "Add '--router:external' option to 'net-create'" 2015-01-13 04:15:00 +00:00
shihanzhang
096fd1b175 Add '--router:external' option to 'net-create'
Change-Id: Ibb100d54a5fd8b04ac5e1fc3a26826c695f4d951
Closes-bug: #1320793
2015-01-12 09:34:44 +08:00
Jamie Lennox
799e288f48 Use adapter from keystoneclient
The adapter in keystoneclient is there to abstract the common client
parameters that may be used when sending a request. We should use that
rather than keeping our own methods.

Closes-Bug: #1403726
Change-Id: I727ac76babb6f6aef1a0f619c011ad67a6e2fccf
2014-12-23 10:33:17 +10:00
Akihiro Motoki
9c464ba53f Use graduated oslo libraries
The following libraries have been graduated:
- gettextutils -> oslo.i18n
- jsonutils -> oslo.serialization
- strutils, timeutils -> oslo.utils

Add neutronclient.i18n module as oslo.i18n adapter.

Remove openstack.common related files completely
because neutronclient no longer use any oslo-incubator modules.

Closes-Bug: #1382017
Change-Id: Ib7ebcb691a12858049baab3b122f95bf43038f18
2014-10-21 15:37:00 +09:00
Ilya Shakhat
9bf8b71e33 Fix Py3 compatibility issues
* Replace of urllib by six urlparse
* Convert dict keys into list to be able to retrieve the first element
* Use integer division for integers
* Use int instead of long in XML serialization/deserialization under Py3

Co-author: Cyril Roelandt <cyril.roelandt@enovance.com>

Change-Id: Ia79c831310775bf1c3dbec06010f8949c3a73887
2014-09-16 12:57:14 +04:00
Aaron Rosen
54a2d3d866 Leverage openstack.common.jsonutils
This patch removes our own home brewed json helper functions and leverages
the ones from openstack.common.jsonutils instead.

Change-Id: Idc5ee0fec56b0a0f337433a830647d4f421a8283
Closes-bug: 1365263
2014-09-03 21:38:27 -07:00
Jenkins
76d5c1a422 Merge "Avoid modifying default function arguments" 2014-08-30 06:36:26 +00:00
Angus Lees
16e04a5312 Avoid modifying default function arguments
Modifying passed arguments inadvertently is an easy pitfall in python.
Even more serious is modifying the default value to a function, since
that modification will be preserved across future function calls.

The typical defense against the latter is to avoid using mutable default
values.

This change replaces several def foo(bar=[]) with bar=() or similar, and
then fixes a few cases that were exposed where the argument was indeed
permanently modified.

Change-Id: I3d04dcb39e3816942f8e80ce499c47d774a773c6
2014-08-12 14:16:23 +10:00
Ilya Shakhat
ef39ff0002 Fix unit tests to succeed on any PYTHONHASHSEED
Many tests rely on order of parameters in URL query, but
queries are constructed from dicts and order of parameters
is non-deterministic. The issue doesn't occur if PYTHONHASHSEED
stays constant, but breaks if random. The fix is needed for
tox>1.7 and Py3.

Closes-Bug: 1348818

Change-Id: I01145df689e90ccd6100fa82092ba3ed222af8fc
2014-08-08 19:41:36 +04:00
Dirk Mueller
58e48df0f8 Switch over to mox3
mox3 is a Python 3.x compatible drop-in and allows
to continue with the porting effort to Python 3.x with
minimal code changes.

Closes-Bug: #1283482
Change-Id: Ib052f1b87e312481e4c7c8d775ece94f53e7106b
2014-06-26 11:54:50 +02:00
Jenkins
58a7e01b8f Merge "Use assertIn where appropriate" 2014-02-22 03:23:36 +00:00
liu-sheng
e955a1fc80 Remove vi modelines
We don't need to have the vi modelines in each source file,
it can be set in a user's vimrc if required.

Change-Id: Ic30e91df1b0e25beda9b8d8c19be58573cdae4f6
Closes-Bug: #1229324
2014-02-10 17:00:28 +08:00
Wu Wenxiang
c989bad9e8 Remove start index 0 in range()
Remove the useless arg ("start index" = 0) in files, since its default
value is 0, to make code cleaner.

Fixes bug #1261580

Change-Id: Ieeace91e8cbd540ddccd8288002331a6e5a70c58
2013-12-17 07:53:52 +08:00
Dirk Mueller
710bcbc81a Use assertIn where appropriate
Change-Id: I27038279067183352e5a54766fb74515057d581a
2013-12-05 18:10:42 +01:00
ZhiQiang Fan
3cabda68d9 Use assertEqual instead of assertEquals
For unittest, assertEquals is deprecated in py3, use assertEqual
instead.

Closes-Bug: #1218190
Change-Id: I51d68578e4a2bf10230bc95fc5fa62762ae0acea
2013-09-03 10:17:49 +08:00
Monty Taylor
e34a06adf0 Move tests back to neutronclient package
Neutron itself has all of its tests in neutron/tests, as do 2/3 of
the projects in OpenStack. There are a wealth of reasons to put
them in the package, not the least of which that tests/__init__.py
implies a code living in a global namespace called tests.

Change-Id: I2aaacfe59d6790648aa4587e89e6dd28a9149a6c
2013-08-22 09:10:36 -04:00