91 Commits

Author SHA1 Message Date
Christian Berendt
d51b546774 Enabled hacking checks H305 and H307
* H305  imports not grouped correctly
* H307  like imports should be grouped together

Change-Id: I23fdad285508707a2c1d7c832ff8b1a6a10e8f88
2014-07-17 15:31:08 +02:00
Russell Bryant
d678dd2955 Revert "Reuse exceptions from Oslo"
This reverts commit 3bde9c3f427110dae3480644752f49b79ac66ec5.

This change is a part of a series that is not backwards compatible.
It broke applications using the client library.

Change-Id: Id01a0a0feb601539d3855f445ebaf6a3cc000610
Partial-Bug: #1340596
2014-07-14 09:43:44 -04:00
huangtianhua
65b0d36f3c Fix using a variable which is not defined
There is a variable which is not defined but used, we should define it
before using. Add a test for get_resource_manager_extra_kwargs_hook
function, and change the exception to a more detail instead broad
'Exception'.

Change-Id: I7a798dad55a65f06ebbe175925a00028940bb168
2014-06-26 11:32:55 +08:00
Jenkins
1a7f84cb46 Merge ""nova boot" should not log an error if subsidiary commands fail" 2014-06-24 06:33:10 +00:00
ChangBo Guo(gcb)
88d0b6f2d9 Enable F841
F841 detects local variable is assigned to but never used.
This commit fix the violations and enable F841 in gate.

Change-Id: I52419f5e17db70e511ff2d4d61c85458c958e9c3
2014-06-19 09:49:05 +08:00
Jyotsna
b78c0d4f46 "nova boot" should not log an error if subsidiary commands fail
Fix:
Intially the cli was raising "CommadError" in case the requested
flavor or image were not present.
This error category was not approrpiate as it signifies an error
in the command syntax. When the requested resource (flavour/image)
does not exist, a ResourceNotFound error should be raised. So,
added a new error category "ResourceNotFound" to cater for this
scenario and updated the code to raise this new error.
"nova show <instance_name>" command has also been updated to raise
"ResourceNotFound" error when the requested vm for which details
have to be displayed does not exist.

Closes-Bug: #1258488
Change-Id: If64a087944586ef5792efe3baa62e455b9bbaa07
2014-06-17 14:48:11 +05:30
Zhengguang
fdd59e142a Fix the incorrect return messages in keypair show and delete
When we delete or show a keypair, if the keypair doesn't exist,
we'll get "The resource could not be found.(HTTP 404)", this
patch will change it to "ERROR: No keypair with a name or ID of
'keypair_name' exists."

Change-Id: Ifebd8d2213c327f3d3fdd672207170aebbe1bb40
Closes-Bug: #1307338
2014-04-20 10:59:22 -04:00
Jenkins
d703381c45 Merge "Fix i18n messages in novaclient, part I" 2014-02-10 02:25:23 +00:00
Sergio Cazzolato
fc8579dfa8 Flavor ExtraSpecs containing '/' cannot be deleted
This change applies a regular expression in order to filter
flavor extraspects keys with invalid characters.
The characters allowed are: letters, numbers, underscores,
periods, colons, spaces and hyphens.
A new test flavor has been created which doesn't check the
keys in the post body. This flavor has been created in the
third place (instead of in the last) in order to keep
working existent test cases which depend on the last flavor
received in the get method.

Change-Id: Ifd86bed23a05a5946ae8b9ba6f6c9bf4b24b1d4c
Partial-Bug: #1256119
2014-01-31 17:38:19 -05:00
Sergio Cazzolato
6b070c82d4 Fix i18n messages in novaclient, part I
This change make all the text visible by the user i18n. The
messages changes are in prints, logs, exceptions, helps, etc
Pep8 errors about "Multiple positional placeholders" also fixed

Change-Id: I731afea790baddbc34d059b93a35e3d275fc1df8
2014-01-28 14:56:00 -05:00
Jenkins
1e32538cff Merge "Using common methods from oslo cliutils" 2014-01-24 21:06:18 +00:00
Sahid Orentino Ferdjaoui
a5195c5033 Updates nova client to use the latest oslo files
This patchset updates modules based on the config file:
openstack-common.conf

Notes: Some corrections has been added to work with
new files.
  + utils.py: The method safe_decode from strutils.py
    was updated and it is now not necessary to check for
    decode string with py33.
  + base.py: base64 needs a 8-bit string for py33
  + test_shell.py: stdin.encoding is needed for strutils

Change-Id: Iebe474f1226f8b5faa7fb5722e65f41b80d1973c
Related to blueprint common-client-library-2
Closes-Bug: #1265473
2014-01-23 18:08:03 +00:00
Sahid Orentino Ferdjaoui
da11e62216 Using common methods from oslo cliutils
There are some common methods in cliutils we can use in novaclient:
 arg, env, unauthenticated, isunauthenticated.

 + Replaces utils.env to add alias env from cliutils.
 + Replaces utils.arg to add alias arg from cliutils.
 + Removes unused methods: add_arg, unauthenticated, isunauthenticated
   To use methods from clituils.

Related to blueprint common-client-library-2
Change-Id: Ic7c132c37d6a91cf3eae55530300efd153c31903
2014-01-23 09:53:42 +00:00
Jenkins
daa33c56c9 Merge "Fix logic for "nova flavor-show 0#"" 2014-01-23 01:55:54 +00:00
Jenkins
7b44ce6734 Merge "Fixes ambiguous cli output between "None" and NoneType" 2014-01-19 01:07:38 +00:00
Masayuki Igawa
27de89af5f Fix logic for "nova flavor-show 0#"
For perviously logic, if flavor id is
start with "0Number", int(name_or_id)
will convert it to "Number". If flavor
id "Number" exist in DB, it will show
up for query with "0Number".
This fix enter flavor search logic at
the beginning. Also add one more UT
for this function.

Change-Id: Ic48ff4275978404064c0c6fce6f98181660aa84a
Fixes: bug 1268456
2014-01-17 10:09:26 +08:00
Jenkins
16c5337e79 Merge "Ensure that nova client prints dictionaries and arrays correctly" 2014-01-11 15:47:54 +00:00
Shrirang Phadke
1627908b18 Fixes ambiguous cli output between "None" and NoneType
Print hyphen(-) in python client output when attribute value is not
set(NoneType) so that it is distinguishable between "None" string
and NoneType value.

Change-Id: I5ec0f39f13aca45fa95ddb59472c20207c63bf91
Closes-Bug: #1266414
2014-01-09 23:48:05 +05:30
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
Gary Kotton
5c62630a9d Ensure that nova client prints dictionaries and arrays correctly
Print the dictionaries and arrays without the unicode tags.

The patch also updated tests that did not return valid data.

Change-Id: Ia787f98a9510b68beb3ceaf00c285ca5c934f5c0
Closes-bug: #1265002
2013-12-31 05:17:00 -08: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