225 Commits

Author SHA1 Message Date
Kevin_Zheng
93913c84b6 Use novaclient/utils directly and remove openstack/common (1/4)
We can use novaclient/utils directly and get rid
of openstack/common folder.

This is the first part.

Change-Id: Iaec234fbcf4d0f8c7e8f2175eae11d3083a62090
Partial-Bug: #1551603
2016-03-03 01:23:34 +00:00
Bartosz Górski
e43c66a0aa Adds missing internationalization for help message
Change-Id: I676daed583cac49f72593c79e9f79f7c9908a57c
Related-Bug: #1491492
Signed-off-by: Bartosz Górski <bartosz@codilime.com>
2016-02-25 07:05:35 +00:00
Andrey Kurilin
ca5b06f6ae [microversions] fix help msg for versioned args
If command has arguments with one name, but for different versions(see an
example below), both arguments will be displayed. This patch fixes this
issue.

Example of arguments:

    @cliutils.args("name",
                   help="Name of a good action.",
                   start_version="2.1",
                   end_version="2.20")
    @cliutils.args("name",
                   help="Name of a very good action.",
                   start_version="2.21")
    def do_something_good(cs, args):
        pass

Example of helpoutput before patch:

    Positional arguments:
      <name>    Name of a good action. (Supported by API versions '2.0' - '2.20')
      <name>    Name of a very good action. (Supported by API versions '2.21' -
                '2.latest')

Change-Id: I59f155675e2aae642a5b90cb70008eb5647ffe79
2016-02-24 20:10:31 +02:00
Kevin L. Mitchell
08c4b746b2 Add a mechanism to call out deprecated options
We have had deprecated command line options in novaclient for a long
time, but no warnings about the deprecations were ever emitted, despite
the help text being suppressed.  It would be nice to finally get rid of
those deprecated options.  This change sets up the precondition to
accomplish this, by emitting appropriate warnings when a deprecated
option is used.

Note: The "use" text for the deprecated options has been deliberately
      chosen to reduce the number of translations required.

Change-Id: Ibe13faa56c5abca97f85f9c5172ef5a5591b5f71
2016-01-07 11:07:44 -06:00
Jenkins
86a9cc8371 Merge "Fix help strings" 2016-01-04 13:32:43 +00:00
Andreas Jaeger
8f320313f3 Fix help strings
Reviewing the import of novaclient 3.1.0 into the CLI Reference (change
Ib39cdfdd563a2a53f0e6de1f8d2dc4f8c4678c15), a few inconsistencies where
found and fixed:
* Missing "." at end of help string
* Inconsistent capitalization of "DEPRECATED, use"
* Inconsistent capitalization of "Set or delete"
* It's IPv4 and IPv6
* It's ID

Change-Id: I425cd6575ca31efd92fc7f0be6192031886fcc41
2015-12-28 08:10:44 +01:00
Andrey Kurilin
01961d68a2 Cleanup needless code from oslo-incubator
oslo-incubator was deprecated and all modules used by novaclient were
removed from oslo-incubator master branch. This patch removes all unused
code from novaclient's repo.

Change-Id: Ie3c542d19da6ed4d25ec490faf6a86a82f48cd34
2015-12-18 08:46:12 +00:00
Jenkins
88ef0542dc Merge "Migrate to keystoneauth from keystoneclient" 2015-12-16 15:06:19 +00:00
Monty Taylor
1f11840dd8 Migrate to keystoneauth from keystoneclient
As a stepping stone to the os-client-config patch, first switch to
using keystoneauth, its Session and its argparse registration and
plugin loading to sort out any issues with that level of plumbing.
The next patch will layer on the ability to use os-client-config
for argument processing and client construction.

Change-Id: Id681e5eb56b47d06000620f7c92c9b0c5f8d4408
2015-12-12 20:39:57 -08:00
Andrey Kurilin
8aaf0a9080 Fix help message in case of microversions
novaclient should display help message of the proper versioned method
(based on api_version value).

Closes-Bug: #1523649
Closes-Bug: #1523651

Change-Id: I67f7fc2befde9d312400e9a1569e590bd763156e
2015-12-08 17:09:31 +02:00
He Jie Xu
28bf8ddb06 Correct usage of API_MAX_VERSION and DEFAULT_OS_COMPUTE_API_VERSION
Commit d045019f0f2d28f26730b3617f7d7b993506b6e8 use the variables
API_MAX_VERSION and DEFAULT_OS_COMPUTE_API_VERSION with wrong way.

API_MAX_VERSION means the max version of client supported. This
variable only be changed when client support the new version. And
it's must bumped sequentially.

DEFAULT_OS_COMPUTE_API_VERSION is default value of option
'--os-compute-api-version', this value decided the default behaviour
of nova client. The nova client CLI behaviour should be that client
negotiate with server side to find out most recent version betweeyn
client and server. So the value should be '2.latest'. And it won't
be changed except we decided to change the default behaviour of nova
client CLI.

Change-Id: Iba9bfa136245bd2899c427ac0c231a30c00bd7f3
Closes-Bug: #1508244
2015-10-21 11:07:32 +08:00
Matt Riedemann
d045019f0f Set DEFAULT_OS_COMPUTE_API_VERSION to 2.5
The client currently implements support for microversions 2.2, 2.4 and
2.11.

According the nova API microversion history:

http://docs.openstack.org/developer/nova/api_microversion_history.html

2.3 just returns extra attributes in the response so it's not a problem
for the client. We should expose those at some point but it's not a
breaking change.

2.5 is a server-side only change since the client allows filtering
servers by IPv6 address but the server wasn't honoring that until 2.5.
There are no client side changes for that microversion.

2.6 is the first backwards incompatible microversion since it replaces
the old specific console APIs (RDP/serial/SPICE/VNC) with a new generic
remote-consoles API. The client must be updated to handle this since
requesting any microversion >=2.6 for consoles will fail right now. This
is exposed on the CLI right now because the CLI defaults to the 2.latest
microversion.

So even though the client actually supports the 2.11 microversion, we
shouldn't default to higher than 2.5 because we have gaps in handling
2.6->2.10.

This change fixes the default for the CLI by setting
DEFAULT_OS_COMPUTE_API_VERSION=2.5.

Partial-Bug: #1500688

Change-Id: I52074f9a3e7faa6a7a51c3fa9766100acf25dee2
2015-10-01 14:18:05 -07:00
Andreas Jaeger
3e99d3f875 Improve help strings
For consistency:
* Adjust capitalization, e.g. use ID or UUID.
* Slight wording improvements.
* Add "." at end of all strings.

Change-Id: I252c023438c4fe82873a1616b36391f2a2048853
2015-09-19 15:00:08 +02:00
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