32 Commits

Author SHA1 Message Date
lilintan
b9e584bd07 Use method is_valid_cidr from oslo.utils
Oslo.utils provides same method is_valid_cidr, just use it.

Change-Id: If3c619a118c4c192951d8603a4b3c2b34546a2cf
2016-10-12 04:56:55 +00:00
Lokesh S
d8fa792ee7 Log SHA1 hash of X-Auth-Token value
Remove logging of sensitive information like the
token value from X-Auth-Token. Instead log the sha1
hash of the token value, prefixed with '{SHA1}'.

Closes-Bug: #1367339
Change-Id: I72d2ff5ca569c942aa6896aeadab489ff0097255
2016-04-04 19:25:29 +00:00
Akihiro Motoki
ed17ae60bd Improve str2dict key validation to avoid wrong keys
This commit adds valid_keys and required_keys to str2dict
and define a new function which can be used as argparse type
validator.

By this function, we can declare what fields are valid and what
fields are required for dictionary option in option definition.

Change-Id: Ib7b233e082c15d0bd6e16a754b8acad52e413986
Closes-Bug: #1102897
2016-02-21 11:33:29 +00:00
reedip
5286df8d9f Adding a lowercase converter in utils.py
Certain NeutronClient CLIs require input in lower cases.
In order to allow user to provide input in a case-insensitive format,
similar to the uppercase function already existing in utils.py,
this patch adds a lowercase function.

Reference:
https://review.openstack.org/#/c/140628/16..18/neutronclient/common/utils.py

Change-Id: I3ad44a24a3a341209d3d3a033691b09d98b72e55
2016-01-08 05:01:27 +00:00
Akihiro Motoki
787ba9250b Use _i18n instead of i18n
It is suggested to use _i18n.py per oslo.i18n document.
http://docs.openstack.org/developer/oslo.i18n/usage.html

neutronclient.i18n is now a wrapper module which emits
the derecation warning. It is because might be used in
implementation of the client extensions in other repositories.

Closes-Bug: #1519493
Change-Id: I44969daeedc9a66dd9ad5bf80617516faf245ecc
2015-12-24 14:44:44 +09:00
Manjeet Singh Bhatia
1774ac3586 Allow lower case protocol values
currently in neutron-lbaasv2 only upper case protocol values are
allowed for listener and pool. This patch will make protocol values
case insensitive for pool and listener.

Change-Id: I41fb7b538c81eba848b78c071edaf806663063a1
Related-Bug: #1508687
2015-12-10 04:18:26 +00:00
Ilya Shakhat
8da3dc8f0c Remove newlines from request and response log
Do not surround request and response messages with newline characters
to simplify reading by robots.

Change-Id: I2efec1154cd9a327ed25b342e10d9205a22fda1c
2015-08-10 12:59:58 +03:00
Cedric Brandily
a2ae8ebdc3 Raise user-friendly exceptions in str2dict
Currently str2dict raises non user-friendly exceptions when input is not
valid:

  neutron subnet-create mynetwork 10/23 --allocation-pools=10/24
  # implies str2dict('10/24')
  # raises:
     dictionary update sequence element #0 has length 1; 2 is required

This change updates str2dict implementation in order to raise
user-friendly exceptions.

Closes-Bug: #1460336
Change-Id: Id381865e6e5d9bebcb2c984c0338126566a97c2b
2015-06-08 18:28:23 +00: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
zengfagao
5eb292c30c Fix Python client library for Neutron
To create a subnet, we used to require positional cidr value.
With subnetpool, cidr is now optional value. With optional
positional cidr, the cidr value cannot be parsed into known_args
if it is separated from network value.

To fix the problem, we need to find cidr value from value_specs,
and use it if we find it. Cidr is optional, may not exist.

Change-Id: Ic4bccf4e7384cc891cef71fb7ce3b52fbf997345
Closes-Bug:#1442771
2015-04-21 12:14:30 -07:00
Akihiro Motoki
b0923a3e12 Utility method for boolean argument
In the recent commit, True/False of boolean argument
became case-insensitve and this code is copy-and-paste'ed
in several places.

Now there are several number of patches which add explicit
arguments for *-update or *-list and the code of boolean
argumetns like below will be used more than now.

This commit add a utility method to register such boolean opt.

       parser.add_argument(
           '--enabled',
           dest='enabled', metavar='{True,False}',
           choices=['True', 'true', 'False', 'false'],
           help=_('Whether to enable or disable this rule.'),
           default=argparse.SUPPRESS)

Change-Id: I9575eeef32154a8b92589c2cc7889803216bddb2
2015-01-27 18:51:23 +00:00
Hideki Saito
02c108fd00 Fix mixed usage of _
* all modules are using function of _ from oslo.i18n
* remove the definition of _ from openstack.common.__init__.py for safety

Change-Id: Ice2f8be1190fd13e8991a8c7fa55ca636341e875
Closes-Bug: #1382476
2014-11-08 22:40:41 +09: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
Aaron Rosen
72afc0f424 Leverage neutronclient.openstack.common.importutils import_class
This patch allows us to drop our version of import_class in favor
of openstack.common.importutils version's.

Change-Id: Ia96f06e2dc7dfb9824377e3a7381da2732dd2c15
Closes-bug: 1365273
2014-10-09 04:21:27 +00: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
Jenkins
a85773cf48 Merge "Unify doc-strings format" 2014-09-12 05:41:57 +00:00
Jenkins
46630bad74 Merge "Small improve of str2dict function" 2014-09-09 03:09:59 +00: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
Stanislav Kudriashev
48da7226c0 Unify doc-strings format
Change-Id: If6cf2caeae294db30a8988ab861441211b651580
2014-08-28 11:42:12 +03:00
Stanislav Kudriashev
a71611f916 Small improve of str2dict function
Change-Id: Ifa8974f2cbdac4fdc0cbd47d7ad9910a5bd31cb7
2014-08-28 10:59:03 +03: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
Cyril Roelandt
dae498eedb Python 3: use six.iteritems()
Change-Id: I9d86dd948bc2241bbb69a04c0024f90b805d7cc8
2014-07-22 18:26:01 +04:00
Christian Berendt
73e608d354 debug level logs should not be translated
According to the OpenStack translation policy available at
https://wiki.openstack.org/wiki/LoggingStandards debug messages
should not be translated. Like mentioned in several changes in
Nova by garyk this is to help prioritize log translation.

Change-Id: I639624cbe64749085654b32ac85596fdae577230
2014-06-23 10:58:36 +00:00
Jenkins
4ac92ccef1 Merge "Python3: fix syntax issue in _encode_item()" 2014-06-08 04:37:31 +00:00
armando-migliaccio
70f2e7113e Use requests module for HTTP/HTTPS
This change introduces the use of requests in lieu of httplib2
to ensure proper handling of SSL termination.

Implements: blueprint tls-verify

Change-Id: If182f2addf26421873b8c3d2b60f8cba9b7a9450
2014-04-23 08:37:13 -07:00
Jenkins
1246cd977a Merge "session_persistence: invalid str2dict value: u''" 2014-04-17 20:59:58 +00:00
Cyril Roelandt
ce60624a2f Python3: fix syntax issue in _encode_item()
In Python 3, this is not a valid syntax:

    def _encode_item((k, v)): ...

Pass a single parameter to the function, and start by unpacking.

Change-Id: I73743073113a4696b9adc79bdb646575794c1e2b
2014-04-08 16:23:07 +02: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
armando-migliaccio
9235f83d68 Rename Nicira NVP to VMware NSX in neutronclient
Use new naming scheme to reflect rebranding.

Partial-implements blueprint nicira-plugin-renaming

Change-Id: I694fbda1c228e92a0b910358523787fa742d9ab2
2014-01-28 17:21:06 -08:00
Marcos Lobo
43ef5172ab session_persistence: invalid str2dict value: u''
Can't receive empty session_persistence dict to update the vip.
It would raise the following error:

$ neutron lb-vip-update vip --session_persistence type=dict ""
usage: neutron [--session_persistence SESSION_PERSISTENCE]
neutron: error: argument --session_persistence: invalid str2dict value: u''

Change-Id: Ice43bbe19138be6af85b47c2090359d22c70b29f
Closes-Bug: #1262582
2014-01-28 10:20:57 +01:00
Sergio Cazzolato
6d937f3e85 Fix i18n messages in neutronclient
Using tools/check_i18n.py to scan source directory, and fix most of
the errors.
    - Message internationalization
    - First letter must be capital
    - Using comma instead of percent in LOG.xxx

Partial-Bug: #1217100
Change-Id: I312f999f97e33d84c3f06fa1caacf32affc26a78
2013-11-29 19:16:22 -05:00
Mark McClain
93ac15bfeb Rename quantumclient to neutronclient
Implements Blueprint: remove-use-of-quantum

Change-Id: Idebe92d56d277435ffd23f292984f9b8b8fdb2df
2013-07-03 11:56:44 -04:00