212 Commits

Author SHA1 Message Date
Jenkins
4d5cfdead0 Merge "Fix nova bash-completion needs authentication" 2015-09-17 20:50:44 +00:00
Atsushi SAKAI
b1204446ef Fix nova bash-completion needs authentication
CLI-Reference generator requires
   (openstack-doc-tools/bin/doc-tools-update-cli-reference)
  that command line help and bash-completion running without authentication.

  For this purpose, remove authentication check in command and its test.
    Fix nova bash-completion works without authentication.
    Fix nova bash-completion test without setting authentication infomation.

  Define skip_auth for descriminate "nova bash-completion" and do_help.

Change-Id: Ic1a7f84b1b9cb7e8be6721c1b8096f49e9e9ab33
Closes-Bug: #1495424
2015-09-17 09:20:48 +09:00
Victor Stinner
48f9c5a046 Fix unicode issue in shell.main() error handling
shell.main() uses safe_encode() to encode the exception name and
exception message. On Python 3, it displays:

   ERROR (b'Exception'): b'message'

instead of:

   ERROR (Exception): message

Don't encode exception name and message on Python 3. Use
exception_to_unicode() of oslo_utils.encodeutils to get the exception
message as Unicode. On Python 2, let print() encodes the Unicode to
the encoding of sys.stderr.

Blueprint nova-python3
Change-Id: Ib5568546d2aedb2b28c05d840b9ba34f697384ec
2015-09-15 09:53:15 +02:00
Daniel Wallace
b547a3da50 make sure os_password is set for auth_plugins
os_password is not set anywhere for auth_plugins.  It is only set for
keystone sessions.  This makes sure that it gets set before being passed
to Client.

Closes-Bug: #1493977
Change-Id: I94421fd6fa58be391dfe8a9a14479bb4c17c5231
2015-09-10 16:50:28 -05:00
Ramaraja
ca031f9915 Fix nova --help needs authentication
Added --help,-h in do_help flag so that authentication will not be prompted.

Change-Id: Iafb766304eeda58eff0c92b87a127018820832fd
Closes-Bug: #1491677
2015-09-07 15:45:29 +05:30
Jenkins
f2a6573287 Merge "Add ability to use default major version" 2015-08-20 17:17:39 +00:00
Andrey Kurilin
e28f2a0d20 Add ability to use default major version
If user specify os-compute-api-version=None, default major version
(currently 2.0) will be used.

Change-Id: Ie3fc31f4537cb17ed3c0cb97c91c04a9518fbb72
2015-08-11 18:52:50 +03:00
kylin7-sg
cb7be1281a Remove _discover_extensions
Since heat already patched to use discover_extensions [1],
_discover_extensions is no longer used by any other project, it
could be safely removed.

[1]: https://review.openstack.org/#/c/180812/

Change-Id: If527e15dcb9fb19cf9440084f50a2c6551cbd3b3
2015-08-11 09:33:05 +08:00
Andrey Kurilin
02889515a5 Set "latest" as default compute api version
It would be nice to use "latest" version of api by default.

Related to bp api-microversion-support

Change-Id: Ife981c87d32011f01fcbdf871071a9d8273ebb92
2015-08-04 16:15:05 +08:00
Andrey Kurilin
9ed9ab68f7 Add version discover and check in CLI
This patch adds version discovery when user request with latest version.
The latest version means the most recently version between server and
client.

Related to bp api-microversion-support
Co-Authored-By: Alex Xu <hejie.xu@intel.com>
Change-Id: I0b7a95e77371aef6e349bf54b5dd6ce6c6d2732c
2015-08-04 16:15:01 +08:00
Andrey Kurilin
936cf572df Implements 'microversions' api type - Part 2
New decorator "novaclient.api_versions.wraps" replaces original method with
substitution. This substitution searches for methods which desire specified
api version.

Also, this patch updates novaclient shell to discover versioned methods and
arguments.

Related to bp api-microversion-support
Co-Authored-By: Alex Xu <hejie.xu@intel.com>
Change-Id: I1939c19664e58e2def684380d64c465dc1cfc132
2015-07-25 15:57:17 +08:00
Jenkins
3199e6bd34 Merge "Implements 'microversions' api type - Part 1" 2015-07-24 22:34:47 +00:00
Jimmy McCrory
a80ac8523a Set iso8601 log level to WARNING
When debug logging is enabled, set the log level of iso8601 to WARNING
to effectively silence its logging.

Change-Id: I17d7e6d5776b2369a2f8c42fd88f6c6790ad1b80
Closes-bug: #1441639
2015-07-19 11:14:05 -07:00
Andrey Kurilin
ea0b3bd608 Implements 'microversions' api type - Part 1
Compute API version will be transmitted to API side via
X-OpenStack-Nova-API-Version header, if minor part of version is presented.

New module "novaclient.api_versions" was added as storage for all api versions
related functions, classes, variables and etc.

`novaclient.api_versions.APIVersion` class is similar to
`nova.api.openstack.api_version_request.APIVersionRequest`. The main
difference relates to compare methods(method `cmp` is missed from Py3) and
processing "latest" version.

Related to bp api-microversion-support

Change-Id: I0e6574ddaec11fdd053a49adb6b9de9056d0fbac
2015-07-16 16:06:28 +03:00
Jimmy McCrory
784a8b4a91 Cache a new token when the existing token expires
The client.keyring_saver attribute was not being reliably set so the
client._save_keys function was not storing any new tokens in the
keyring.

Add a unit test to ensure keyring_saver is being property set.

Closes-Bug: #1397732
Change-Id: If0df24c819d71b4df302309d049079a867a11c76
2015-06-10 23:54:28 -07:00
kylin7-sg
02c04c5658 Make _discover_extensions public
Heat uses `novaclient.shell.OpenStackComputeShell._discover_extensions`
function, which is private currently. It's better to change this method
to public for public use.

Change-Id: I15879d56db2ec88a9bef99b6af8924ebd4ad169b
Closes-bug: #1440779
2015-05-06 14:10:59 +08:00
Andrey Kurilin
61ef35fe79 Deprecate v1.1 and remove v3
Module novaclient.v1_1 is already deprecated, so it's time to stop using it
inside novaclient.

Since support of v3 nova is undocumented feature, which uses v2
implementation, we can remove code related to it.

Also, this patch removes redundant check for compute api version != 1.0.

Change-Id: I06b349f704d5ae2c592d8d286da268870f2a69e9
2015-04-22 15:03:07 +03:00
Andrey Kurilin
ccff3d3c94 Remove all imports from oslo namespace
oslo namespace is deprecated

Change-Id: I345eb210222d8e973b99f27821099f52883ab27d
2015-04-20 13:52:38 +03:00
ZhiQiang Fan
1c39f8fabf Don't record time when self.timing is False
The expected behavior is when timing is True, then we record each
request's time, then we should call reset_timings() to release memory.

However, the shell, client.{HTTPClient,SessionClient} will record each
request's time no matter what timing is set, then after long running
time in service like ceilometer-agent-compute, the memory keeps increasing.

We'd better not record request's time when timing is set to False.
Users are not responiable to call reset_timings() when they don't want
timing functionality.

Change-Id: I3e7d2fadf9a21be018781d528a1b6562228da6dd
Closes-Bug: #1433491
2015-03-21 19:27:36 +08:00
Jenkins
7a1066fb79 Merge "allow --endpoint-type internal|admin|public" 2015-02-26 01:21:18 +00:00
Sergey Nikitin
4f9797a659 Removed unused 'e' from 'try except' statements
Change-Id: I57dee43ffcd42fe17914ae01078ae06baf3b4315
2015-02-25 14:05:09 +03:00
yatin karel
e6883d24d0 allow --endpoint-type internal|admin|public
other openstack clients like glance, cinder  use --endpoint-type
(internal|admin|public). This allows users to use the same arguments
with the nova cli.

Partial-bug: #1367389

Change-Id: Ia55cad797ac0dca7fa60f55c1f2dfba0b64d0fd3
2015-02-25 10:02:41 +00:00
Andrew Laski
ac6636a54d Revert "Overhaul bash-completion to support non-UUID based IDs"
This reverts commit 4c8cefb98a425382204df2f38f24e6b5b71520dd.

The cache completion was causing a bug where 'nova volume-attach' would
then try to query Nova for volume information using a URL that was not
valid.  This caused it to appear that the attach had failed.

Additionally the idea of making extra API queries for a bash completion
cache should be thought through more.

Conflicts:

	novaclient/client.py
	novaclient/shell.py
	novaclient/v2/client.py
	novaclient/v3/client.py

Closes-Bug: #1423695
Change-Id: I6676a11f9b5318a1cda2d03a5d4550bda549d5c2
2015-02-20 01:35:57 +00:00
Andrey Kurilin
0a60aae852 Rename v1_1 to v2
Module novaclient.v1_1 is used as implementation of V1.1, V2 and V3.
Since future development(microversioning) will be done across V2,
implementation should be done in appropriate module(to prevent misleading).

Despite the fact that implementation for all versions are equal, discover
method for contrib path worked only for v1.1. This patch fixes this bug and
modifies shell tests to check all versions.

Change-Id: Ib6798f4dfe177586302141f522dc593560ce6a5b
2015-02-04 17:40:46 +02:00
Jenkins
e25bd57555 Merge "Avoid "ambiguous option" when only current/deprecated forms match" 2014-12-11 17:51:55 +00:00
Andrey Kurilin
96a124fae6 Remove aliases for args and env in utils
To remove aliases for `arg` and `env` functions in novaclient.utils,
we should use `arg` and `env` directly from cliutils in novaclients modules.

This patch removes aliases in `novaclient.utils` and starts using
`args` and `env` from novaclient.openstack.common.cliutils directly.

Change-Id: I4585adae62bc66ad6bc9d19be10d4679bb3dc5a1
2014-12-04 17:22:12 +02:00
Andrey Kurilin
cc62efef41 Remove code related to V3
Since V3 API is not supported, code related to it should be removed.

Discussion in mailing:
http://lists.openstack.org/pipermail/openstack-dev/2014-December/052095.html

Change-Id: Iac5c5e6d81479cbeb8bf10cfcda1cc5617680de8
2014-12-03 14:11:39 +02:00
Eugeniya Kudryashova
1aa020989e Enable check for E128 rule
Fix E128 failures in novaclient/client and
novaclient/shell and enable check for E128

E128 continuation line under-indented for visual indent

Change-Id: Id3ac46ccdbb8a9f97e54b4643240d93b06fac6ea
2014-11-27 14:19:55 +02:00
David Hu
8597a0c234 Support using the Keystone V3 API from the Nova CLI
This changeset enables support for Keystone V3 authentication
on the Nova CLI. This provides consistency between using
novaclient as the Nova CLI and using it as a library
as the Keystone V3 support already exists for the libary usecase.

The bulk of the change surrounds the use of the keystoneclient
session object for authentication, retriving the service catalog,
and HTTP connection/session management.

Co-Authored-By: Morgan Fainberg <morgan.fainberg@gmail.com>
Change-Id: Iece9f41320a8770176c7eeb5acd86be4d80cc58f
2014-11-11 21:04:20 -08:00
Jenkins
d485d755ec Merge "support OS_ENDPOINT_TYPE in nova client" 2014-10-30 00:03:34 +00:00
Miguel Grinberg
607ac48e6c support OS_ENDPOINT_TYPE in nova client
This change makes the handling of the endpoint_type setting in the nova
client more consistent while keeping backwards compatibility. The
NOVA_ENDPOINT_TYPE environment variable is checked first, and if it is
not set then the more generic OS_ENDPOINT_TYPE variable is checked. A
--os-endpoint-type command line option was added as well.

Change-Id: I0d96f9f87106fc41a9853920f557ffad724859e7
Closes-Bug: 1382249
2014-10-28 19:21:26 +00:00
Jenkins
bf439b370a Merge "Update novaclient shell to use shared arguments from Session" 2014-10-24 23:27:42 +00:00
Andrey Kurilin
3065afd6c0 Enable check for E129
E129 visually indented line with same indent as next logical line

Change-Id: I438bf0d9de7f61ab65e753169c9a8007e84b215a
2014-10-23 14:28:57 +00:00
Andrey Kurilin
ae6c39397e Enable check for E127
E127 continuation line over-indented for visual indent

Change-Id: I9dfd489565ee2d1469b2048a930c3a8384dd245d
2014-10-23 14:28:50 +00:00
Andrey Kurilin
8de2237cc4 Enable check for E126
E126 continuation line over-indented for hanging indent

Change-Id: Id64edce8278d96c1b2d4a6ca536e9fc8fbef478c
2014-10-23 17:28:25 +03:00
Morgan Fainberg
c8a7e6a02d Update novaclient shell to use shared arguments from Session
The novaclient implemented it's own version of the CLI arguments that
are now provided by keystoneclient's session object. This changeset
converts nova over to utilizing the shared argument registration.

Change-Id: Ifc9ddc08614e28358229db84cb9b54552ca36d51
Co-Authored-By: David Hu <david.hu@hp.com>
2014-10-22 17:39:44 -07:00
Andrey Kurilin
dc09cf27e3 Port to use oslo.i18n
Module gettextutils from oslo-incubator was graduated to separate
library (oslo.i18n) and removed from repository, so we should use
new library.

Change-Id: I15d36ac5a2bb88b332ffa38d29488b75c55a20a9
2014-10-16 01:19:48 +03:00
Cedric Brandily
f4709f02c2 Avoid "ambiguous option" when only current/deprecated forms match
argparse.ArgumentParser allows to specify partially options:

  nova boot ... --key-nam mykey
  # is equivalent to
  nova boot ... --key-name mykey

an error is raised if the provided prefix matchs 0 or 2+ options:

  nova boot ... --os value
  # raises an "ambiguous option" error because --os could match
  # --os-username, --os_username ...

even if the provided prefix matchs only the current/deprecated
forms of the same attribute:

  nova boot ... --key mykey
  # raises an "ambiguous option" error because --key could match
  # --my-key, --my_key ...

This change extends argparse.ArgumentParser to avoid raising an
"ambiguous option" when the provided prefix matchs only the current and
deprecated forms of the same attribute.

Change-Id: I1089901de769df3312d4a15b6d6e5e60b1ed51e0
2014-10-13 11:19:21 +02:00
Rakesh H S
09f97e9ee4 return 130 for keyboard interrupt
when keyboard interrupt is received by novaclient, the return code as
of now is 1.

But since the client was terminated by an keyboard interrupt, the return
code should be 130. (http://tldp.org/LDP/abs/html/exitcodes.html)
It is useful when people are writing automation test cases and want to
validate based on the return code.
I have also changed the message that is printed on shell to match other
clients.

Change-Id: If544ade154c53b1f18518773f4d49cd335a394d0
Closes-Bug: #1373231
2014-09-26 20:45:49 +05:30
Andrey Kurilin
d03014cdb0 Use common code instead of novaclient.utils
Module `novaclient.utils` contains a lot of functions which are
presented in modules from common code.

* service_type -> novaclient.openstack.common.cliutils.service_type
* get_service_type -> novaclient.openstack.common.cliutils.get_service_type
* pretty_choice_list ->
      novaclient.openstack.common.cliutils.pretty_choice_list
* import_class -> oslo.utils.importutils.importclass
* HookableMixin -> novaclient.openstack.common.apiclient.base.HookableMixin

Change-Id: Ia6cac058da12c852d92f26875a66ae31cc4c63d4
2014-09-19 16:56:13 +03:00
Andrey Kurilin
392148c7ef Use oslo.utils
Modules `strutils`, `timeutils` and `network_utils` from common code are
graduated in `oslo.utils`, so we can:
 1. remove `novaclient.openstack.common.network_utils` and use
    `oslo.utils.netutils` instead.
 2. use `oslo.utils.encodeutils` and `oslo.utils.strutils` instead of
    `novaclient.openstack.common.strutils`.
 3. use `oslo.utils.timeutils` instead of
    `novaclient.openstack.common.timeutils`.

Additional information:
 - modules `importutils`, `strutils` and `timeutils` from
   `novaclient.openstack.common` cannot be removed, because:
   - importutils is used by apiclient and jsonutils;
   - strutils is used by apiclient, cliutils and jsonutils;
   - timeutils is used by jsonutils
 - additional check for `safe_encode` in Py3 is required, since
   If91a866d864a22d28a352152beff4c7406a27b7b was merged.

Change-Id: Ib8d79d9c85af4916e87a76a1a67a13488ddaa111
2014-08-28 12:17:22 +03:00
Jenkins
b6246ea844 Merge "Fix variable error for nova --service-type" 2014-08-23 01:50:50 +00:00
liyingjun
c55383f734 Fix variable error for nova --service-type
When running 'nova' with '--service-type' option, it raises an variable
error.

$ nova --service-type compute list
ERROR: local variable 'os_compute_api_version' referenced before
assignment

When '--service-type' option is given, the default value of
'os_compute_api_version' does not apply.

Change-Id: I19554756e8eb56e3a5984ed3078137af9687f986
Closes-bug: 1315368
2014-08-07 08:11:29 +08:00
Christian Berendt
33058cbe8e Enable several checks and do not check docs/source/conf.py
* E265 block comment should start with '# '
* H302 import only modules

Do not check docs/source/conf.py. The file is imported from the
cookiecutter template.

Documented why checks are ignored and if they should be enabled
in the future.

Change-Id: I367064ecaa6d1fd9d918f7ce003303e2db660647
2014-08-05 22:18:14 +02:00
Rick Harris
4c8cefb98a Overhaul bash-completion to support non-UUID based IDs
There are a few things currently wrong with bash-completion as it stands now:

    1) IDs are currently required to be UUIDs. This is an arbitrary limitation
       and doesn't make sense for certain kinds of objects, like `Flavors`
       where a valid ID could be `performance-16gb`.

    2) The code is spread out between Oslo's `Resource` and Novaclient's
       `Manager` class. This makes it difficult to improve the code because it
       requires changes to two separate projects. We should centralize the
       code in Novaclient until the API is stable, then import the code into
       Oslo in its entirety, not partially like it is now.

    3) The completion code is handled by the `Manager` of which there is one
       per Resource-type. In the interest of centralizing this functionality,
       we should create a `CompletionCache` class and hang it off of `Client`
       of which there is one-per-session.

    4) The completion-code currently runs by default even in headless mode
       (e.g. novaclient without the shell). It'd be much more efficient to
       only write to the completion cache if we're accessing the `Client` from
       the novaclient shell. We can make this an option to support third-party
       CLI clients that want to use the completion-cache as well.

NOTE:
    * The corresponding Oslo patch is here:

        https://review.openstack.org/#/c/101376/

    * This patch was tested in multithreaded mode to prevent any regression
      from:

        https://bugs.launchpad.net/python-novaclient/+bug/1213958.

Change-Id: Idada83de103358974b739f81d4f392574f9e1237
Closes-Bug: 1332270
2014-06-20 16:37:28 -05:00
Jenkins
b8e900fe86 Merge "Overwrite HelpFormatter constructur to extend argument column" 2014-06-10 06:43:49 +00:00
Christian Berendt
8bef1e1110 Overwrite HelpFormatter constructur to extend argument column
Overwrite the HelpFormatter constructor in the class
OpenStackHelpFormatter to modify the default value of the
max_help_position to extend the width of the argument column
in the help output.

example output before this patch:

    volume-snapshot-create
                        Add a new snapshot.
    volume-snapshot-delete
                        Remove a snapshot.
    volume-snapshot-list
                        List all the snapshots.
    volume-snapshot-show
                        Show details about a snapshot.

example output after this patch:

    volume-snapshot-create      Add a new snapshot.
    volume-snapshot-delete      Remove a snapshot.
    volume-snapshot-list        List all the snapshots.
    volume-snapshot-show        Show details about a snapshot.

Change-Id: I517098748947e7bded03160a15e778bf79475d0d
Closes-Bug: #1326471
2014-06-04 20:16:46 +02:00
Rick Harris
85faf9cbf0 Add NOVACLIENT_BYPASS_URL env variable
Currently, in order to use a bypass URL, you need to specify it using the
`--bypass-url` command-line option each time, which is inconvenient if you
plan on always using a bypass URL.

This patch adds a `NOVACLIENT_BYPASS_URL` environment variable which can be
placed in the `novarc` to persistently set this option.

Change-Id: I49e67ee1fc3570a43e49dc1d78d8ca0b26945bc8
Closes-Bug: 1326134
2014-06-03 15:33:15 -05:00
Johannes Erdfelt
656cf91f89 Fix error when run with no arguments on Python 3
Python 3 changed the map built-in to return an iterable instead of a list.
When tested in a boolean context, this always returns True, even if it
would not return anything when iterated.

Instead of the usage being printed, this error was printed:
ERROR: 'Namespace' object has no attribute 'func'

Use list comprehension instead to ensure that an iterable isn't returned

Change-Id: Ie15f2fa8ee93ab26490e371133fa0f944430737b
Closes-bug: 1295356
2014-03-25 08:49:05 -07:00
Jenkins
733f1e58d8 Merge "Fix authentication bug when booting an server in V3" 2014-03-25 05:33:57 +00:00