36 Commits

Author SHA1 Message Date
xiexs
6e54ec81fe Fix the incorrect alignment
The "aligns" attribute no longer exists in the Prettytable,
"align" instead. So we should use "align" attribute to force
the output with left alignment by default.

Change-Id: I97b30216000b6e31c1bef614cf0b0d68ab8cfb08
Closes-Bug: #1583880
2016-05-19 23:25:36 -04:00
scottda
3f75b48f06 Support api-microversions
Changes to cinderclient to use microversions.

Implements: blueprint api-microversion-support-for-cinderclient
api-microversion-support-for-cinderclient

Change-Id: I840a1162b88e8ff36fa3fc4e1d6b9317104df3e0
2016-04-19 11:19:45 -06:00
scottda
27e6f6f7f8 Add /v3 endpoint support for cinderclient
Add support for Cinder API /v3 endpoint.
A couple of unit tests for /v3 endpoint were added to v3/test_shell.py
to ensure that the v3 shell works, and to also test that modules work
with:
from cinderclient.v2.availability_zones import *
syntax.

Change-Id: I6ae0ada221bebb4ab1850d9c99b10fcbb585201f
Implements: https://blueprints.launchpad.net/python-cinderclient/+spec/add-v3-endpoint-support
2016-04-18 10:49:51 -06:00
Brandon Palm
6b5e3d1faa Use instanceof instead of type
Adjusted conditional statements to use instanceof when
comparing variables. Instanceof supports inheritance type
checking better than type.

Change-Id: I449f3df92b3646c384de717b7d53f7f85258c449
2016-02-24 13:46:39 -06:00
Sheel Rana
a26c1e67b6 Extra 'u' in output of cinder cli commands
In output of cinder show command, below fields contains extra 'u'
character being unicode:
1. volume_image_metadata
2. metadata

In output of "cinder credentials", below field contains extra 'u'
1. roles

In output of "cinder qos-create", below field contains extra 'u'
1. specs

In output of "cinder qos-list", below field contains extra 'u'
1. specs

In output of "cinder extra-specs-list", below field contains extra 'u'
1. extra_specs

In output of "cinder qos-show", below field contains extra 'u'
1. specs

Change-Id: I8be32f117ddc29b087ee872ff065c175dd70b372
Closes-Bug: #1538413
Closes-Bug: #1538415
2016-02-19 17:26:24 +00:00
Eric Harney
6fe9f20663 Use oslo_utils encodeutils and strutils
With oslo-incubator being deprecated, move
our use of strutils to oslo_utils.

This leaves in place the use of oslo-incubator's
strutils by other oslo-incubator modules for now.

Change-Id: Ic4e50060b42aeca9d1e54424a8a3a123140fbf2a
2015-11-23 10:44:12 -05:00
Ivan Kolodyazhny
df2883e040 Remove unused code from cinderclient.utils module
_format_servers_list_networks method is not used anywhere.
It's safe to delete it.

We'ge got the same cinderclient.openstack.common.apiclient.HookableMixin
class so we don't need to duplicate it in the utils

Change-Id: Ifa7f5c1d00c1673811af48575460e6563d2d3180
2015-09-08 18:12:32 +03:00
Vincent Hou
2d979dc19d Volume status management for volume migration
This patch proposes the following changes
to the 'available' volume:
* Add the --lock-volume flag to cinder migrate
The default value is False, which means the migration is aborted
if the owner of the volume issues commands like attach
or detach during the volume migration. The volume will be in
'available' during migration.
If it is set to True, the migration of this volume will not be
aborted by other commands. The volume will be in 'maintenance'
during migration.

* List migration status for all the volumes
The attribute migration_status will be listed, if the request
is issued by an admin. Otherwise, the migration_status will not
be listed. The option migration_status is added for the admin
to filter the volumes returned via 'cinder list' command.

DocImpact
APIImpact

Partial-implements: blueprint migration-improvement
Change-Id: I5a1a717d1d08f550b45836d958a51f1f3fba5ced
Depends-On: Ia86421f2d6fce61dcfeb073f8e7b9c9dde517373
2015-09-01 22:35:28 +08:00
liyingjun
2ec9a2251d Fixes table when there are multiline in result data
The table doesn't display right when there are multiple line in
result data. Fixes this by replace "\r" with " ".

Change-Id: I0b994466f3c65ea973e80d9f03ca9a248147d49d
Closes-bug: #1476462
2015-08-03 11:14:44 +08:00
Anton Arefiev
c5c2d67b7f Find resource refactoring
The 'name' field for some resources is called something different,
for example 'display_name' for volumes, 'name' for  volumes type.
So class 'resource' has attribute 'NAME_ATTR' wich contains
attribute name for different resources.

This change removes reduntant call find in resource manager, instead
of it checks NAME_ATTR value.

Related-Bug: #1449444
Change-Id: Ide334d7535c73cbdff72c30319eb539d8f5304d6
2015-05-12 14:52:46 +03:00
Gorka Eguileor
6ebe6e98d7 Remove duplicate find request in find_resource
Removed duplicate manager.find method call using search argument
display_name that affected any command that searches for a volume by
display_name or any command that searches for non existent volumes.

Change-Id: I86c99b41dd231b058ed3f6d5d78eafe35a111dec
Closes-Bug: #1429102
2015-04-01 12:38:19 +02:00
yatin karel
0f73c5fb8a cinder list now prints dash '-' when data is None
cinder list used to print None when volume was created without name.
Now it prints '-' dash when display_name is None

Closes-Bug: #1422244
Change-Id: I195ccc37fe96dbb54a0460527fabf55146170bc7
2015-03-16 23:26:22 +05:30
Aaron Rosen
0b38d75a44 Leverage openstack.common.importutils import_class
This patch drops the import_class method from utils and instead
leverages the one in openstack.common.importutils.

Change-Id: I9f740b9941d477776597c4c4ab88a65a39fb4fb8
Closes-bug: 1365273
2015-01-12 22:58:00 +00:00
Steven Kaufer
b0e4cc1b63 Client output is not sorted by --sort_key
The cinder client supports invoking the volumes REST API with the
sort_dir and sort_key parameters. However, the client output table
is always sorted by ID even though the REST API is returning in
sorted order based on the sort key/direction provided.

For example, the command below supplies the 'size' sort key but the
output table is still sorted by ID:

cinder list --sort_key size --sort_dir desc

This fix contains:
* Updates to the print_list utility to prevent any re-ordering so
  that the current object order is maintained
* Updates to the shell to disable re-ordering if the user supplies
  sort parameters

Change-Id: I4cc111a8bdd2b89158dfc4bb0d16fa6dbf36cc57
Closes-Bug: 1402846
2014-12-22 02:23:00 +00:00
Jenkins
59177814a4 Merge "Use immutable arg rather mutable arg" 2014-12-21 16:15:41 +00:00
Rushi Agrawal
542a675568 Remove unused methods from utils.py
Most of these methods were imported when we forked away from
python-novaclient, but over the course of time, their existence
became redundant as no file seems to be importing them. Such
methods are removed in this change.

Change-Id: Ic93fc92ce624eefaeaca6de5c8fd965e88159030
2014-11-17 16:33:07 +05:30
liuqing
31a7ae54f6 Use immutable arg rather mutable arg
Passing mutable objects as default args is a known Python pitfall.
We'd better avoid this. This commit changes mutable default args with
None.

Change-Id: I7817c92069d32d1926e185ca0d0ab14e738b8b3d
2014-07-03 15:06:51 +08:00
Cory Stone
d5334aa929 Add auth_plugin support to cinderclient
With CINDER_RAX_AUTH being rightfully removed, cinderclient is no longer
compatible with Rackspace/any non-keystone auth. To fix this, I stole
auth_system/auth_plugin from novaclient's implementation.

See https://review.openstack.org/#/c/23820/.

Change-Id: If5f84003f868ef02bb7eb7da67cf62018602e8f0
Closes-Bug: 1280393
2014-02-14 15:09:44 -06:00
huangtianhua
5aaa68f09e Fix typo in cinderclient
sematics --> semantics
hypen-separated --> hyphen-separated
typicaly --> typically

Change-Id: I5df277ef7036082d0e4b079c23d41da809e5270f
Closes-Bug: #1254587
2013-11-28 09:28:05 +08:00
Seif Lotfy
6437166e1e Add quota-usage command
Added a new command quota-usage to allow querying the usage of the
quota for a given tenant

Change-Id: I720e6df94f9fedbb8b6385bd1707600542aaea08
2013-10-03 17:43:20 +00:00
ZhiQiang Fan
5ad95e9fd2 Replace OpenStack LLC with OpenStack Foundation
NOTE:
* openstack/common/* should be synced from oslo, so i leave them
untouched.
* add (c) symbol for related lines, leave others untouched.

Change-Id: I46a87c7f248d3468b1fdf5661411962faf2fb875
Fixes-Bug: #1214176
2013-09-28 23:13:54 +08:00
Ken'ichi Ohmichi
405702c8c0 Add volume name arguments
This patch adds volume name arguments to the following subcommands:
 * snapshot-create
 * backup-create
 * backup-restore
 * transfer-create

Fixes bug #1220590

Change-Id: Ib0ff6e62d45abb14fa8c7313511ef6f72befe0d5
2013-09-18 16:44:51 +09:00
Mike Perez
6193f2ba96 Remove locals() from cinder client code base
Hacking file now disallows locals() usage.

Change-Id: I5049c718c2706d606c12913ae0b33a0fb3263542
2013-07-31 16:03:17 -07:00
John Griffith
3d30126e93 Revert "Use exceptions from oslo"
This reverts commit a7cce08eab5e2e42275b84bd56127bd09b00f5bf

Change-Id: I6c0047adbc33d0d6b5890f11853974578c36c78c
2013-07-15 10:30:05 -06:00
Alessio Ababilov
a7cce08eab Use exceptions from oslo
These exceptions can be used in novaclient, keystoneclient,
glanceclient, and other client projects.

Partially implements: blueprint common-client-library

Change-Id: I43918316622b1c1d722872fe30199db6a3a7bb76
2013-07-01 11:55:31 +03:00
Chuck Short
1197fb3701 python3: Strutils is not needed
strutils is used to safely encode and decode unicode strings
for python2.7. Since unicode strings are the default in python3,
ignore the use of strutils when running with python3.

Change-Id: I9a8e296b4f2153b1ef4302a7dcd797fbb4561c35
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-06-22 12:50:23 -05:00
Chuck Short
3044671b36 python3: Fix traceback while running tests
The testsuite is full of the following:

TypeError: 'dict_keys' object does not support indexing

This is due to the fact in python3 dict methods dict.keys(),
dict.items() and dict.values() return “views” instead of lists.

Change-Id: Ifa5383e6485fdbabf363fd1442877b2452346c1c
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-06-19 20:52:22 -05:00
Chuck Short
dc1105ebca python3: Fix unicode strings
Python3 enforces the distinction between byte
strings and text strings more rigorously than
python2. So use six.text_type where approiate.

Change-Id: I46b3f5fe1f990fc1b7a3ee32904d608b070fc4c3
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-06-13 01:43:35 +00:00
Chuck Short
4b1cdab2fe python3: Basic python3 compatibility.
Basic python3 compatibilty.

Change-Id: I4388f5956cf397f8e33d20085aae6c6a728dbbda
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-06-12 07:59:44 -05:00
Chuck Short
d12d7a73ff python3: compatibility for iteritems and iterkeys
Use six to allow python2/pyton3 for iteritems and
iterkeys.

six.iteriems() replaces dictionary.iteritems() (python2)
and dictionary.iterms() (python3)

six.iterkeys() replaces dictionary.iterkeys (python2)
and dictionary.keys() (python3)

Change-Id: I26c80b78a7dedf3aa32eedf01a83ff6d1e592ba7
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-06-11 13:29:13 -05:00
Hugh Saunders
95e142a173 Allow generator as input to utils.print_list.
Once the table is built, the length of the prettytable's internal array
is checked rather than re-iterrating over the input.

Adds tests for utils.print_list with list and generator input.

Change-Id: I4c0bd08bf0c943de42ad90d255a2d831c2e98828
Fixes: bug #1180059
2013-05-15 08:51:28 +01:00
Chuck Short
2ed5cdcb5f Add license information.
Several files were missing the license issue, so simply
add them.

Change-Id: I866ec03096a72fe8ae7d776e2ffe040379ec5bc6
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-05-09 10:49:35 -05:00
John Griffith
0b781536b2 Don't print the empty table on list operations.
Changes to strutils.safe_encode cause the empty
table to be printed out when no objects are actually
retrieved.

This patch just adds a check of the object list length
before calling strutils.safe_encode, if the length is NOT
> 0 we just return like we used to.

Change-Id: I57930b5210c975baa7c4510fcf82b17157e17788
2013-04-11 19:21:55 -06:00
Flaper Fesp
03a4806d97 Decodes input and encodes output
Currently cinderclient doesn't handle properly incoming and outgoing
encode / decode process. As a solution for this, this patch implements a
decoding process for all data incoming from the user side and encodes
everything going out of the client, i.e: http requests, prints, etc.

This patch introduces a new module (strutils.py) taken from
oslo-incubator in order to use 2 of the functions present in it:

About safe_(decode|encode):

    Both functions try to encode / decode the incoming text using the
    stdin encoding, fallback to python's default encoding if that
    returns None or to UTF-8 as the last option.

    In both functions only basestring objects are accepted and they both
    raise TypeError if an object of another type is passed.

About the general cinderclient changes:

    In order to better support non-ASCII characters, it is a good
    practice to use unicode interanlly and encode everything that has to
    go out. This patch aims to do that and introduces this behaviour in
    the client.

Testing:

    A good test (besides using tox) is to use cinder client with and
    without setting any locale (export LANG=).

Fixes bug: 1130572

Change-Id: Idb7d06954c29e003f68a0c4aa0b80ecc7017cbc9
2013-03-29 13:50:48 +01:00
Eric Harney
01dad32c07 Fix support for Unicode volume names
It is possible to create a Unicode volume from the command line,
but it cannot be manipulated by name for operations such as delete.
This is because the find_resource function tries to match the
Unicode string to a regular byte string, and a UnicodeWarning is
issued, failing the match.  Fix by decoding the Unicode name when
trying to match.

Fixes bug 1065275.

Change-Id: I8e19a78bbc1ccb503ccd39dc3b904fc4f6f77858
2012-10-23 15:50:33 -04:00
Jenkins
471704df64 Initial split from python-novaclient. 2012-05-21 16:32:35 -04:00