135 Commits

Author SHA1 Message Date
Jenkins
0aa6200544 Merge "catch NoKeyringDaemonError from gnomekeyring" 2013-04-02 16:10:35 +00:00
Jenkins
d195c6a6f7 Merge "Improve authentication plugins management." 2013-04-02 16:10:34 +00:00
Alan Pevec
49ab03e6a6 do not ignore --os-cache
Change-Id: Ib8808da00967163faa9ce05e580605f4e499891d
2013-04-02 12:22:05 +02: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
Davanum Srinivas
adb5941df9 catch NoKeyringDaemonError from gnomekeyring
Looks like we need to add more exceptions, start to maintain
a tuple of exceptions

Change-Id: I3a027f5d2d8f82fe397e3096ff82358040f3729e
2013-03-31 18:45:49 +00:00
Alvaro Lopez Garcia
e9e05d7dfe Set up debug level on root logger.
If we set up the debug level on the root logger, this can be used by the
submodules that might need to print some debug output.

Change-Id: I2a00b40d4748cc62e6081df7d6a44622f5ad4467
2013-03-15 10:28:12 +01:00
Davanum Srinivas
c5b579926f Fix Copyright Headers from LLC to Foundation
follow the lead from nova and oslo projects

Change-Id: I270c5f1e4eefa4b72e292bfb4a4c60de0c3f6e4a
2013-03-13 20:12:23 -04:00
Jenkins
b01ce12995 Merge "Decodes input and encodes output" 2013-03-11 16:37:11 +00:00
Alvaro Lopez Garcia
f1e5a88d2b Fix typo in error message
Change-Id: Ia37ec318329dc527b30a1835e4a52ace14b2bda3
2013-03-07 09:40:42 +01: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
Vasyl Khomenko
8ac304f7f5 Fixed bug with password prompt, added tests
Fixes: bug #1131237

Change-Id: Ifcd9543ed5ac9526e32025ff3acd51d36b27a224
2013-03-04 11:00:44 +00:00
Jenkins
4e2c829135 Merge "A minimum of Python3 fixes so that installation works without errors/warnings." 2013-03-01 23:50:39 +00:00
Davanum Srinivas
34c8a6bb7a Missing import for gnomekeyring
follow on to previous attempt to fix to bug 1116302,
looks like we missed an import

Fixes LP#1116302

Change-Id: If56e3cedaa63a594907bb851a2701bd64806ed85
2013-02-21 11:41:02 -05: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
Jenkins
76bacaa645 Merge "Allow extensions to provide a name when discovered on the python path." 2013-02-15 23:41:42 +00:00
Davanum Srinivas
132465231a Issue when gnomekeyring is present but not the current backend
Issue was identified in the review for the previous
patch for bug 1116302. Took this chance to rename _IOError
to a better name (KeyringIOError)

Change-Id: I321353d519eaebea27617702f92ecafe2052eb8e
2013-02-15 10:11:51 -05:00
David Scannell
c0e85a84b0 Allow extensions to provide a name when discovered on the python path.
Using novaclient with some extensions via python code, you might have an
invocation like this:

    extensions = shell.OpenStackComputeShell()._discover_extensions("1.1")
    novaclient = Client("1.1", user, apikey, project, authurl, extensions=extensions,
                        endpoint_type=shell.DEFAULT_NOVA_ENDPOINT_TYPE,
                        service_type=shell.DEFAULT_NOVA_SERVICE_TYPE)

If you have an extension like 'myextension.py' in the v1_1/contrib directory, you'll
end up with a very sensible attribute on the resulting novaclient object, i.e.

    novaclient.myextension

If you have a package distributed in the package myextension_python_novaclient_ext,
then it'll automatically be picked up as an extension (awesome!) but the name is not
as intuitive.

    novaclient.myextension_python_novaclient_ext

This patch simply changes this to allow the Extension to provide a name for itself.
The possibility of collisions exists, but is not really any more significant than
before (where you might have different versions of the same package installed in the
system or heck, even a bizarrely named 'myextension_python_novaclient_ext.py' in the
contrib/ directory).

Fixes bug 1058366

Change-Id: Ie68463ffd7a939744e035b20fd50a7dc8da605de
2013-02-14 13:22:25 -05:00
Davanum Srinivas
d1d4f33aca Fix IOError with gnomekeyring.find_network_password_sync
find_network_password_sync throws a gnomekeyring.IOError
when a non-root user tries to run nova client
from a ssh console. If we don't catch this exception nova client
throws the traceback (shown in the bug report) and stops.
If we catch this exception (just like we catch ValueError),
and return None, Nova client executes just fine.

Fixes LP# 1116302

Change-Id: If6937b3f8eafb1dc55224b2ca2bd0f93ae07f8c6
2013-02-14 11:58:08 -05:00
Joe Gordon
96630b8248 Upgrade to pep8 1.3.3
Also expand scope of what is covered by pep8 test

Change-Id: Ifc8924914b5a0d625bc8df6442ee85eb21459cde
2013-02-01 12:24:19 -08:00
Vishvananda Ishaya
1e4a778bf8 Store tenant_id from keystone and use for quotas
Some calls in nova require a tenant_id when it could be interpreted
from the current authentication data, so save the tenant id and
use it in the quotas command if tenant_id is not specified.

Change-Id: I89647cfe9da73bc474ef80a61a5678db42a5571c
2013-01-31 14:38:21 -08:00
Joshua Harlow
7c6f538cf6 Fix the usage of password, keyrings, and tokens.
Fix how you keep on getting prompted for the password
all over the place and at the wrong time (the keyring code
should be used before a auth request, and not during).

Fix this by trying to use the token first (which comes from
the keyring module), then falling back to using the password
(which will get a token, and then store said token so that it
 isn't fetched again).

Change-Id: I58e69f3b3fbcc7a467797f25695b7ca59178a1d7
2013-01-30 12:53:47 -08:00
Joshua Harlow
9fd2c8a59d Allow request timeout to be specified.
Add a new cli argument (--timeout) which
is by default 600 seconds which will be
set in the requests library so that timeouts
can occur correctly.

Change-Id: I716ac15fe08f42c9464ee43010bc8fd2667bcbde
2013-01-16 17:57:56 -08:00
Dean Troyer
aa1df04bad Use requests module for HTTP/HTTPS
* Implement correct certificate verification
* Add --os-cacert
* Rework tests for requests

Pinned requests module to < 1.0 as 1.0.2 is now current in pipi
as of 17Dec2012.

Blueprint: tls-verify

Change-Id: I9a25a94c8dfcaf483c4c8328439809d65cf10b38
2012-12-20 13:04:46 -06:00
Vishvananda Ishaya
80a72e1a92 Makes the OS_NO_CACHE env variable work again
The commit to replace --os-no-cache with --os-no-cache works fine
with the cli options, but the env variable is stored in os_cache
which has the opposite of the intended effect. This patch converts
the variable to a bool and then inverts it before it stores it
in os_cache. This makes it work properly again.

Fixes bug 1089696

Change-Id: Iea12806603ecdc39c6475ad4d6f867ebb1e01633
2012-12-12 15:59:13 -08:00
Dan Prince
e483455a12 Adds --os-cache to replace old --no-cache.
Deprecates the old --no-cache option in favor of --os-cache.

The old CLI args (--no_cache and --no-cache) and ENV option
(OS_NO_CACHE) are still supported but no longer show up
in help.

The new option for --os-cache can also be set via the OS_CACHE ENV
variable... which now defaults to False. This should be much more user friendly.

Fixes LP Bug #1087776.

Change-Id: I3cea089c7e11ce75f22c2d7f3242b02b80441323
2012-12-11 12:58:37 -05:00
melwitt
aa5622147f discover extensions via entry points
Currently, nova client can only discover extensions in two ways:

1. Installing the extension in the novaclient/v1_1/contrib/ directory.
2. Installing the extension in the top-level python path or modifying
   the path to be picked up by pkgutils.iter_modules()

This patch allows a third, more flexible option of discovering
extensions via entry points. This means the extension can be
installed anywhere and entry points can be registered with python
to be picked up by pkg_resources.iter_entry_points().
To register an entry point, simply add the extension module to
the setup() call in setup.py like this:

setuptools.setup(
    name='mydistribution',
    packages=setuptools.find_packages(),
    entry_points={
        'novaclient.extension' : [
            'foo = mydistribution.mynovaclientexts.foo'
        ]
    },
)

Change-Id: Ic1e223a9173546131e742506897f585f4ac65767
2012-11-09 01:57:53 +00:00
Christian Berendt
4ad512b50e show help when calling without arguments
When calling nova without arguments you'll receive the following
output:

error: too few arguments
Try 'nova help ' for more information.

Changing 'and' to 'or' the help is also shown when calling nova
without arguments. I think that's the expected behavior.

Change-Id: Id14f0292ad00e6e45ad66dd010f449c3abbf3871
2012-11-08 22:46:26 +01:00
Eric Harney
5cdc584efd Add support for Unicode secgroup names
Fixes bug 934081.

Previously, manipulating secgroups with Unicode names would fail
in _get_secgroup, due to the command-line argument being a raw
byte string, and the secgroup name from cs.security_groups.list()
being a Unicode string.  This causes a UnicodeWarning and the
"if secgroup == s.name" test to fail for the desired secgroup, so
secgroup-add-rule and secgroup-delete would fail.

This change converts them to byte strings for comparison, fixing
these commands.

Likewise, error messages containing Unicode secgroup names would
fail to print. (i.e. "Security group <x> already exists")

Change-Id: Ie90cb49b8f11e3283fe509e95a8e9fd468cc9892
2012-09-13 15:14:40 -04:00
Jenkins
6de710fa18 Merge "Change '_' to '-' in options" 2012-08-27 20:22:56 +00:00
Dean Troyer
9101741960 Change '_' to '-' in options
This changes every command-line option with a '_' in its name
and changes them to '-'.  The old option names are maintained
for backward compatibility but are no longer in the help text.

BP command-options

Note: there is a dodgy hack in novaclient/shell.py to handle
usage-list's --end option that conflicts with --endpoint-type
if --endpoint_type is also present for backward compatibility.
If --endpoint_type is not added to the parser it works.  Go figure.
Better solutions that do not break backward compatibility are welcome.

Rebased due to https://review.openstack.org/11072 merging.
Note: --availability_zone changed to --availability-zone with no
backward compatability since this s a new option.

Change-Id: I09ab546659be0a0d3f0eadb22ab5e13fac2f059d
2012-08-24 15:22:44 -05:00
Rick Harris
b54330bfd2 Adding --version option
Change-Id: I7d37af1ddee186af22457baea9af71a955720053
2012-08-24 19:17:46 +00:00
Chmouel Boudjnah
86c713b17a Allow different auth providers via plugin system.
- Remove the NOVA_RAX_AUTH hack and provide (temporary) compatibility
  with the new system.
- Example plugin for RAX and HP provided here :
    RAX - https://github.com/emonty/rackspace-auth-openstack
    HP - https://github.com/emonty/hpcloud-auth-openstack
- Plugin are allowed to specify their own auth_url directly.
- Thanks to mtaylor for helping on this.

Change-Id: Ie96835be617c6a20d9c3fc3bd1536083aecfdc0b
2012-08-06 09:10:00 +02:00
Sascha Peilicke
186a38cbc6 Clarify usage of --insecure flag
Change-Id: Iad52212ea2ba7bfc93c597c23cc6314f9916edb9
2012-07-20 10:20:45 +02:00
Major Hayden
6483ad10a7 Bring back the output from client.http_log()
Change-Id: If7c583751abe9ae60f299515a5f7778db72fa70c
2012-07-02 15:42:02 -05:00
Jenkins
08cf0bf95e Merge "Indicate unused variables and other misc. house cleaning." 2012-06-29 16:48:19 +00:00
Sandy Walsh
1c6e044bdc Auth token caching on by default. --no_cache to disable. Better bypass support too.
Will use and/or store your Openstack Auth token in the operating
system's keyring if available. Cuts about a 1/2 second off operations.

Change-Id: Ibe2dc0c49baefd23afe3844a78c1df884a4fb7c7
2012-06-27 16:43:58 -03:00
Josh Kearney
d4c9b12f39 Indicate unused variables and other misc. house cleaning.
Change-Id: I4529d8b6b27dddb1b79ee2167a054b471eaf0dbc
2012-06-27 11:55:36 -05:00
Sandy Walsh
a2a62a5f71 option to bypass managment endpoint and timings support
--timings = show timings for each call made to nova (including auth)
--bypass_url = api node endpoint to use instead of one from service catalog

For example:
nova --timings --bypass_url=http://10.24.31.37:8774/v1.1/nova-staging boot --image f304d266-0a49-4877-b34c-63aea8360297 --flavor 3 delete_me_2

Change-Id: Ib2a258b7e969ad56ce4ee2bd64c61310278cb856
2012-06-18 13:03:58 -03:00
Chuck
636f32b00a refactored --service_name to only work with compute calls and added
--volume_service_name for volume calls

Change-Id: I2b1188fb57f9576daebfaceaddc6eea44a47b4ee
2012-05-09 11:11:38 -05:00
Christian Berendt
c36ac8b3d7 really output the description of an exception
example without patch:

nova [...] flavor-delete 123
ERROR:

example with this patch:

nova [...] flavor-delete 123
ERROR: Flavor 123 could not be found. (HTTP 404)

fixes bug 981286

Change-Id: I9c5cead521e48b4970850262fb9af279ec5a7753
2012-04-26 18:57:55 +02:00
Josh Kearney
765f551a26 Rename NOVA_VERSION to OS_COMPUTE_API_VERSION.
Fixes bug 940432.

Change-Id: I18187eb68d936632b4ae78676a0a9f062afba8f2
2012-04-13 10:48:05 -05:00
Adam Spiers
ad4a04a64e Make '--help' argument more useful.
With no other arguments, '--help' now outputs the same as 'help', so
that the list of subcommands are no longer omitted.  Additionally,
'$subcommand --help' now yields the same output as 'help $subcommand'.

Change-Id: Iabd926574e296ad14b622862b9fba038fdede66e
2012-04-11 15:35:27 +01:00
Andrew Bogott
565d144611 Fixed the subcommand error message for nova shell.
Previously we were giving advice like this:

"Try 'nova volume-show help' for more information."

Bad advice -- that doesn't work. Now when there's a subcommand
specified we make a proper suggestion:

"Try 'nova help volume-show' for more information."

Change-Id: I6ef49f9e4e1b67074f51ab442abd4a196d437b00
2012-04-10 15:01:53 -05:00
Pádraig Brady
97953f52e1 Improve the error message from the nova shell
Output 'nova help' on error rather than `nova'

Change-Id: I71c3fb6786472c42b0bfd93a085168ba75d37590
Old-Change-Id: I67360589a4af5697d3f90afa74b8504eefaf4976
2012-03-21 09:48:26 +00:00
Rick Harris
3d9a2284d3 Adds NOVACLIENT_INSECURE option.
Fixes bug 960704

Change-Id: I885fddaac57c113b66b4b71120c2a537fa391b09
2012-03-20 23:15:41 +00:00
Dean Troyer
cc72d6dfe2 Change CLIAuth arg names
Change the argument names used for common Keystone authentication per the
updated http://wiki.openstack.org/CLIAuth:

--auth_url -> --os_auth_url
--password -> --os_password
--username -> --os_username
--tenant_name -> os_tenant_name
--region_name -> os_region_name

All old args are depricated but available for backward compatibility.

Fixes bug 954531

Change-Id: Ic67c447e4e4b8d793f587c789cecd149446194f3
2012-03-14 12:30:38 -05:00
Vishvananda Ishaya
03f54c57e1 Makes novaclient use the volumes endpoint
* Depends on https://review.openstack.org/#change,4479
 * Adds support to change service type including tests
 * Adds decorator for methods that need to use another service type
 * Changes volume and snapshots to use the volume endpoint
 * These extensions will move into the volume client once it exists
 * Fixes bug 940017

Change-Id: I683e4ca6c67e278d8aa8a9acec3dc0f1872f43f2
2012-02-26 06:11:12 +00:00
Dave Walker (Daviey)
1ee77c7fe3 Allow UUID_CACHE_DIR overriding via env variable.
This is declared as NOVACLIENT_UUID_CACHE_DIR.
Resolves bug 932468 , defaulting to previous behaviour.
Added myself to AUTHORS

Change-Id: I154500517d7c882a4a090588a95f4b3bfee70595
2012-02-15 21:58:27 +00:00
Cole Robinson
5f89c8487d shell: Hook --debug up to more stuff
Particularly to pythons logging infrastructure, and to always print
a backtrace if the CLI throws an exception. Show --debug in the
help output since end users may certainly have legitimate reasons for
wanting debug output.

Change-Id: Icfdaaf5511db8eecbf650e7ef4437b342b560141
2012-02-13 16:43:11 -08:00
Dean Troyer
e2d869d1da Fixes bug 924588: Remove proto-keystone client from novaclient
Change-Id: Ib3f3b8bfdefe56a13889796948a0186309c9a313
2012-02-03 17:54:47 -06:00