72 Commits

Author SHA1 Message Date
Chris Buccella
3dbab161be Code cleanup: use oslo's to_slug() instead of slugify()
The bash completion code is the sole user of the slugify() function
in utils, which is substantially similar to to_slug() provided in
strutils from oslo.

Change-Id: Ib4eb7e4c0fa0e9bc5c4a0856f6391911d8f8fd3b
Closes-bug: #1266118
2014-01-04 22:56:09 +00:00
Jenkins
ab32e406c8 Merge "Replace some utils.bool_from_str with strutils" 2014-01-03 11:47:28 +00:00
Matthew Farrellee
669cdc4ffd Replace some utils.bool_from_str with strutils
Instead of using novaclient.utils' bool_from_str, use bool_from_string
from the oslo incubating strutils

Notes:
 0. utils.bool_from_str was strict, only accepted a small set of
    values, while strutils.bool_from_string is not strict by default,
    anything not true is false
 1. bool_from_string accepts on/off, which bool_from_str did not

Change-Id: I04744844b55697819289def081d3c9117ed0713f
2013-12-25 07:22:24 -05:00
Sahid Orentino Ferdjaoui
2c54f5a037 Nova aggregate-details should be more human friendly
'nova aggregate-details' shows Hosts, Availability Zone
and Metadata in the python unicode notation.

+ Adds some tests about aggregates ported from v1 to the
  v3 shell

Change-Id: I69d80b2e76833d78248dee782ae5e53f42a4f4a9
Closes-Bug: #1132961
2013-12-24 12:07:57 +00:00
Chris Yeoh
50685437ed Enable hacking check for Apache 2.0 license
Removes H102 (license header not found) check from flake8
ignore list.

Adds missing apache license headers.

Change-Id: I109f23c6d8b2e3efb1dac7f764bd77e0d9d335f0
2013-12-06 10:47:41 +10:30
wingwj
81c72dbc34 Fix typo in novaclient
hypen-separated --> hyphen-separated
overrwrite --> overwrite
typicaly --> typically
sematics --> semantics

Fixes bug: 1253881

Change-Id: I4aff614bb36b8f321837a9f54024b26ac0f11d40
2013-11-22 12:13:54 +08:00
Russell Sim
a89159a6e3 Flatten hypervisor-show dictionary for printing
Flatten the nested dicts so that hypervisor information can be more
easily used at the command line.

Change-Id: I5dfcf9d10f917a63bde09f0b5a691784a5e8f02b
Closes-bug: #1243512
2013-10-29 09:02:13 +11:00
Sean Dague
1d2263dae3 Revert "Nova aggregate-details should be more human friendly"
This reverts commit 6374ee04a378b8a970f9e429d66eb37c969bbf7b.

Change-Id: Ib27cc6722ea7cc8cb9b133360b3ecb246a0e4a14
2013-10-28 08:12:16 -04:00
Sahid Orentino Ferdjaoui
6374ee04a3 Nova aggregate-details should be more human friendly
'nova aggregate-details' shows Hosts, Availability Zone
and Metadata in the python unicode notation.

Change-Id: If0028347146439994265c60c429af05dd67912f9
Closes-Bug: #1132961
2013-10-25 17:46:19 +02:00
Russell Sim
34887aa0d6 Print dicts in alphabetical order
Instead of iterating over dicts, print them in alphabetical order.

Change-Id: I630c28ea36266037b1ab4098831f4f960e6c5dc5
Closes-Bug: #1239511
2013-10-14 15:29:12 +11:00
Jenkins
1d9eb715d8 Merge "py33: safe_encode() returns bytes in Python 3" 2013-10-04 19:56:01 +00:00
Kui Shi
f94c625a38 py33: uuid verification in find_resource()
1. strutils.safe_encode() return "bytes" in py33.
2. find_resource() makes use of uuid.UUID() to verify the given
uuid argument, uuid.UUID() will trigger TypeError when input is
"bytes".

so, decode the bytes before uuid.UUID() while run in Python 3.

Close-bug #1232445

Change-Id: I504be7b43236b3a4843655706385e506cd559e4e
2013-09-29 00:19:21 +08:00
Kui Shi
ac50057710 py33: safe_encode() returns bytes in Python 3
Python 2:
str.encode = encode(...)
    S.encode([encoding[,errors]]) -> object

Python 3:
str.encode = encode(...)
    S.encode(encoding='utf-8', errors='strict') -> bytes

In Python 3, strings are always Unicode.  safe_encode() returns
"bytes", the "\n" will be printed literally, it is not expected.

bytes.decode() will transform bytes to str, which will be printed
properly.

Close-bug: #1229150
Change-Id: If926d3f7837673b4608ae667d34cea3c78e82e5d
2013-09-25 15:48:42 +08:00
Jenkins
ecb9b8bf3c Merge "Allow name argument to flavor-access-add" 2013-09-17 18:43:00 +00:00
Jenkins
ff97f4de78 Merge "python3: Fix Traceback while running unit tests" 2013-09-17 18:42:53 +00:00
Chuck Short
605a7ed2f2 python3: Fix Traceback while running unit tests
Python3 uses the the concepts of text and (binary) data
instead of Unicode strings and 8-bit strings. In python3
all text is unicode; however encoded unicode is represented
as binary data.

Use the six module to use six.binary_types and six.text_types
where apporiate:
- six.text_type unicode() in python2 and str in python3.
- six.basestring() in python2 and str in python3.

blueprint python3-novaclient

Change-Id: Ie7b393abe6beac22eaf127b7fc7bbc372c338211
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-09-13 10:51:13 -04:00
Chuck Short
9d8869e01c Python3: Fix traceback while running unit tests
While running the unit tests with python3 the following
traceback appears:

TypeError: can't use a string pattern on a bytes-like object

This is due to the way that python2 and python3 handles unicodes.

Change-Id: I401f1cefed69780073222cae98d8da4c3d8031a8
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-09-07 12:35:13 -04:00
fujioka yuuichi
97da33fcf5 Allow name argument to flavor-access-add
Administrator cannot use the flavor name in arguments of
"nova flavor-access-add" and "nova flavor-access-remove".

This patch fixes this problem.

Change-Id: I68b267dc071382f1978efc2088cd8e837455e8b4
Related-Bug: #1205298
2013-09-03 02:07:35 +09:00
Jenkins
dc1b1cda06 Merge "Fix and gate on H501, no locals for string formatting" 2013-08-28 19:18:43 +00:00
Jenkins
27700f9b36 Merge "Allow name argument to flavor-access-add" 2013-08-23 01:33:06 +00:00
Joe Gordon
e0e5c2dfe5 Fix and gate on H501, no locals for string formatting
Change-Id: I07e4a1a733639a343d4b3ee20927d50ba04bd7a3
2013-08-15 19:11:28 -04:00
Yuuichi Fujioka
476e50f4d7 Allow name argument to flavor-access-add
Administrator cannot use the flavor name in arguments of
"nova flavor-access-add" and "nova flavor-access-remove"
in following conditions.

1. The flavor is non-public.
2. The falvor doesn't belong administrator's tenant.

This patch fixes this problem.

Change-Id: Ic5e3222d0ff62667e003a61e6a94e85833da5d11
Fixes: bug #1205298
2013-08-15 03:06:51 +09:00
Vincent Hou
852e2e5f31 Check whether the security group id is integer
Fixed Bug 1206847.

Change-Id: I2194d6538a5c5475b876ee026b5d625be2df076f
2013-08-01 09:59:29 -04:00
Dirk Mueller
af7ca70e3e Fix and enable gating on H402
End one-line docstrings with punctuation.
Change them to command style where necessary.

Change-Id: I8ff689c3a2f20d489286f80112c6dc95c97f2f31
2013-07-17 15:44:05 +02:00
Jenkins
a45c49bafc Merge "python3: Fix unicode compatibility python2/python3" 2013-07-10 04:09:58 +00:00
Chuck Short
a25d4fe59a python3: Compatibility for iteritems differences
In python3 dict.iteritems(), dict.iterkeys(), and
dict.itervalues() are no longer supported. So use
six.iteritems() where it is appropriate.

Change-Id: I8b07dc2a89d790ec275d45f859e1644e9b00c837
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-06-24 11:51:04 -05:00
Chuck Short
8c4e145b92 python3: Fix unicode compatibility python2/python3
Python3 enforces the distinction between byte strings and text strings
more rigorously than python2. So use six.text_type/six.u()
where appropriate

Change-Id: I890e19cb857e10f0292aabdaebaa8e7a7bd8db23
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-06-24 11:47:15 -05:00
Kaushik Chandrashekar
ee411a6a2e Cells Support
Adding support for Cell show and Cell capacities calls

Implements: blueprint cell-capacity
Change-Id: I83243cf224a4487d720d55d8942d28c52924b734
2013-06-11 12:09:04 -05:00
Emanuele Rocca
ecbf7705d1 Cleanup unused local variables
This patch cleans up a few unused local variables, found with pyflakes.

Change-Id: Id65acc5d47380c7d6bfbbfe075dc23e1de30813c
2013-05-22 18:24:08 +02:00
Shane Wang
bc0ad1cb9d Reuse oslo for is_uuid_like() implementation
In the original code, isalnum() in is_uuid_like() doesn't allow "-",
while for UUID, format like aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa should be
allowed. This patch is to reuse uuidutils's API in oslo.

Change-Id: I339974c75a32d27f8e4443a1b97bb6e410933aa4
Signed-off-by: Shane Wang <shane.wang@intel.com>
2013-05-22 11:47:23 +08:00
Shane Wang
3c97f768e5 Cleanup some flavor commands
Some cleanups include:
 - Add flavor sub-commands into README.rst
 - Check flavor ID when creating a flavor
 - Remove check_uuid_like() because it isn't used
 - Remove parameter cs in some _print_XXX functions because cs is
   not used

Change-Id: If47ce557d33db05f53e382f0670f436e05a340b7
Signed-off-by: Shane Wang <shane.wang@intel.com>
2013-05-15 15:55:27 +08:00
Shane Wang
075e9ca76e Fix the default parameter in print_list
Because sort_index = 0 by default, "if sort_index is not None" doesn't
make any sense.
Here sort_index should be None by default, which means "donot want to
sort".

Change-Id: I823ab75eb7a92bdc426dd96a3d1e56f187118729
Signed-off-by: Shane Wang <shane.wang@intel.com>
2013-05-14 13:20:56 +08:00
Alvaro Lopez Garcia
abd75f24b1 Improve authentication plugins management.
The current auth plugin system lacks some functionality to be used with
other methods that might require additional configuration options or
that do not require a user to pass some options that are now compulsory
(for example, X.509 authentication needs to get a certificate file, and
does not need either a username or a password). This commit extends
the current system to handle these extra features, while remaining
compatible with older plugins.

DocImpact: We should documment how to implement additional
authentication plugins, such as BasicAuth, X509, etc.
Implements: blueprint authentication-plugins

Change-Id: I7b0ef4981efba8160dea94bf852dba7e2e4068f5
2013-04-01 14:19:01 +00:00
Jenkins
5c9fc02468 Merge "Check if tenant flag is uuid_like for all quota operations" 2013-03-11 16:43:23 +00:00
Jenkins
2f2f4fcf2b Merge "Add wrap option to nova credentials for humans" 2013-03-11 16:43:19 +00:00
Joe Gordon
21dca44202 Add wrap option to nova credentials for humans
When using Keystone PKI, a token ID can be over 3200 chars long.
Add optional --wrap option to make 'keystone token-get' human readable
By default wrap=64 (to fit in 80 char terminal).  And can be turned off by
setting wrap=0

Fix bug 1131001

Change-Id: I50be7ebb4323ab1bf07af557403f5136b49080a4
2013-03-07 17:30:01 -08:00
Joe Gordon
1882b99734 Check if tenant flag is uuid_like for all quota operations
Fix bug 1145706

Change-Id: I9089ea4f968797b248f80bf84027a602e59ccd00
2013-03-07 14:55:55 -08:00
Flaper Fesp
47e6bc25ae Decodes input and encodes output
Currently novaclient 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 decodes
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 novaclient 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 nova client with and
    without setting any locale (export LANG=).

Fixes bug: 1061156

Change-Id: I20b75e42b0c3dac89f1048faa1127253a64f86c7
2013-03-04 19:01:27 +01:00
Thomas Schreiber
68e6af73ba A minimum of Python3 fixes so that installation works without errors/warnings.
Fixes bug: 1130937
Change-Id: I740652fcd5804fc1c120fc409afdf4693c8e5781
2013-02-20 23:17:49 +01:00
Kieran Spear
e800196860 Support showing extra fields in server list
Adds a --fields argument that sets the fields to display.
ID is always displayed.

Fixes bug #1076473

Change-Id: If3462e6a490ea16da4834a7f40f96b111c9e8227
2013-02-11 11:19:42 +11:00
Jenkins
c70144aced Merge "Check tenant_id's format in "nova quota-update"" 2013-01-29 20:04:35 +00:00
Jenkins
dbc186aa88 Merge "make print_dict split strings with newlines into multiple rows" 2013-01-29 20:03:36 +00:00
Haiwei Xu
168636e744 Check tenant_id's format in "nova quota-update"
Fix bug 1088835
"nova quota-update" command is executed without checking the format of
the tenant_id argument. The tenant_id should be in the format of UUID.
The tenant_id of quotas should be in accord with the form of keystone's
tenant_id. So this patch checks the format of the tenant_id when "nova
quota-update" command is executed.

Change-Id: I47c4f2ff9adbab5da4697270dcf024ac88e24529
2013-01-24 08:04:28 +00:00
Melanie Witt
f9aa5ec834 make print_dict split strings with newlines into multiple rows
When printing a dict e.g. "nova show" one of the properties
is "fault". When the user is admin, "details" of the fault
is shown, which includes a backtrace. This causes the
printing of the table to be unreadable as the backtrace
overflows the table row. This patch adds a separate row
for each substring after splitting on newlines.

Change-Id: I4c1bc8725a2bb6970be2c884c5e044d9eade8302
2013-01-21 23:37:31 +00:00
zhiyanliu
3e190c5e49 Ensure list output function can support non-sorting printing
Ensure list printing function in utils can handle non-sorting
calls. Allow result list can be formatted and outputted without any
sorting field, keep natural order to the list printing. Adding necessary
checking to avoid prettytable (0.6.1 for me) exception: "Invalid field
name: None!".

Fix bug: #1099732

Change-Id: Ied869d987e608fff8b8b5f5a65d21e02f0cebeaa
Signed-off-by: zhiyanliu <lzy.dev@gmail.com>
2013-01-17 11:51:46 +08:00
Rohan Rhishikesh Kanade
9937419888 Fix find for alphanumeic flavor id/name
Fixes LP bug #1089299

Change-Id: Ia9cc756b85096532acfc9ecacd1330de8a765fba
2012-12-20 03:14:39 -08:00
Nikola Dipanov
7ddc2fdfcd Fixes utils.findresource checking for integer
Fixes the novaclient.utils.find_resource function to properly handle
non integer values and not break with an AttributeError.

Adds a test case to test a few more non valid inputs.

Fixes bug #1065367

Change-Id: Iaa2025f4eb580234f754596c3572e2f87872170e
2012-11-02 18:21:04 +01:00
Russell Cloran
7bf93a52f8 Validate that boolean parameters are boolean
Ensure that values which are supposed to be boolean look like correct
user input, instead of assuming that any non true-looking input is
False.

Also, update the flavor manager to raise a CommandError if is_public is
not a boolean value.

Fixes bug 1059414

Change-Id: I3275e4bba103b14081becf91f723f1be060391e5
2012-10-30 11:38:58 -07:00
unicell
f160a20fd9 Implement project specific flavors API, client bindings
blueprint project-specific-flavors

This change implements client bindings for the project specific flavor API in following change
https://review.openstack.org/#/c/11270/

Change-Id: Id8d559985f9369f53926e63ee5f5ce23a051e25b
2012-08-27 22:38:36 +08:00
Vishvananda Ishaya
576a64fbb5 Allow resources to use any field as 'name'
The 'name' field for some resources is called something different,
for example 'display_name' for volumes. There was a hack in our
find method to search for display_name as well.

This change adds a new class variable to a Resource to tell it
which attribute to use for searching by name. Volumes and snapshots
were switched to use 'display_name' and hypervisors were switched
to use 'hypervisor_hostname'.

Tests fixed and added.

Fixes bug 1034536

Change-Id: I1b4fb969d42c59d1ab8e3e275a563bbe158e9264
2012-08-08 12:01:40 -07:00