Commit Graph

56 Commits

Author SHA1 Message Date
David Wlazlo e464940f39 Typo - nova CLI deprecation warning
Change-Id: I1e604867bd00d51caebcb049777bbc675a398969
2023-05-17 12:21:29 +10:00
Stephen Finucane 1d8a06da78 tests: Fix Python 3.11 compatibility
The argparse lib in Python 3.11 will not allow you to register a
subparser more than once with the same name. We were inadvertently doing
this in two of our unit tests as part of our check for version handling.
There's no need for this. Stop doing it and simply create a new parser
each time.

An unnecessary check is removed from one of the tests since it confuses
matters.

Change-Id: I93827f84c456c9f6960e30e2424b67947254752c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2022-12-12 17:49:26 +00:00
Takashi Natsume 2af1d0c514 Remove unnecessary testing code
Now PrettyTable >= 0.7.2 in requirements.txt,
remove code for PrettyTable < 0.7.2.

Change-Id: Ie6edcc24fbb67394ff8abe0c5f18ad2bed6903ab
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
2022-09-19 01:12:04 +00:00
Stephen Finucane 0fb7190c06 Deprecate nova CLI
It is time to signal that we're fully committed to delivering a pure
OSC experience.

Based on the neutron change from 6 (!!) years ago [1]

[1] 3a64a7a166

Change-Id: Ib80548e104a751179f36f2a6ebff9916d38fdf1e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2022-04-06 14:17:59 +01:00
Takashi Natsume e85d845b1a Fix undesirable raw Python error
Using the novaclient without a subcommand while
passing an optional argument triggers the raw Python
error `ERROR: 'Namespace' object has no attribute
'func'`. This bug can be reproduced by issuing the
command `nova --os-compute-api-version 2.87`.
Added a default value to `func` and an empty value to
`command` as placeholders so that a help message is
shown instead of the Python error.

Change-Id: Ic3e87b67f6d27d40b03d7d8e520fa0f79a4d09e5
Closes-Bug: #1903727
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
2021-01-04 13:49:20 +09:00
Takashi Natsume 7ef2c28bf3 Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I4d45ae17f6f84f945f5dd049a929216ce6b6b58e
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
2020-04-26 10:12:09 +00:00
Stephen Finucane 8f50f84981 Bump to hacking 2.x
This is compatible with Python 3-only syntax.

Change-Id: I462f4242b9a5f8d8cd6b0cb3d328dfd9d93ba200
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-02-21 09:48:38 +00:00
Stephen Finucane c4c44bcb2d Remove six
Mostly a find-replace job. Let's do this now so we don't have to carry
it for the next decade.

Change-Id: I7bef9fb7c6895f746cee1aca6522786f38b9857c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-02-21 09:48:38 +00:00
shilpa.devharakar ab1f6bd763 Modify novaclient to support basic attributes
Added support for parsing OS_PROJECT_DOMAIN_ID, OS_PROJECT_DOMAIN_NAME,
OS_USER_DOMAIN_ID, and OS_USER_DOMAIN_NAME options.

Change-Id: I9e1a3426f174c2e6d9f4f6bf10e9aecb62bad8d0
Closes-Bug: #1744118
2018-06-15 11:51:31 +05:30
Andrey Kurilin 6049be67c0 [CLI] Fix token auth type
There are 2 known issues which breaks token auth method in CLI:

* The wrong check of flag (the check should be for --os-token since
  arguments are not parsed at that moment) is performed in CLI inner method
  `_append_global_identity_args`. It led to usage of "password" auth
  type by default[1] even if `--os-token` cli argument is specified.
  If `--os-auth-type` is specified to token, keystoneauth1 library makes
  the right decision[2].

* Based on an auth type, keystoneauth library registers different CLI
  arguments[3]. It means that `--os-username` argument is available only
  in password auth type, `--os-token` is available only in token auth
  type, etc.
  It also affects the way in which the python code should access such
  arguments. The arguments which are unrelated to the selected auth type
  are omitted from the parsed arguments object.
  That sounds reasonable, but unfortunately the code assumes the
  unrelated arguments are always present which leads to an
  AttributeError.

Combination of these 2 issues made token auth type broken in CLI layer.

[1] ee2221f052/novaclient/shell.py (L255-L257)
[2] 14dd37b34c/keystoneauth1/loading/cli.py (L51-L52)
[3] 14dd37b34c/keystoneauth1/loading/cli.py (L65-L73)

Closes-Bug: #1659015
Change-Id: Ibc861d396b71fe105288d8336623cc22cf92523e
2018-04-19 18:43:45 +00:00
Matt Riedemann 8bfcd2b0e6 Remove SecretsHelper
This code hasn't worked for over two years when
9ed9ab68f7 was added
which does API version discovery, which requires auth,
which happens before the SecretsHelper is used. That was
back in the 2.27.0 release in the Liberty series.

Given how long this has been broken without anyone noticing,
and it's undocumented and untested (basically), and
python-openstackclient properly handles prompting for a password,
we should just remove this code rather than try to fix it.

Change-Id: I62188e73a48f6878ce920a3b4724dba101564aef
Closes-Bug: #1732744
2017-11-16 12:45:51 -05:00
Chris Friesen 78986dcae2 2.47: Show flavor info in server details
This adds support for microversion 2.47 which directly embeds the
flavor information in the server details.  With this change, CLI
requests with microversion >= 2.47 will no longer need to do
additional queries to get the flavor and flavor extra_specs
information.  Instead, the flavor information will be output
as separate key/value pairs with the keys namespaced with the
"flavor:" prefix.  As one would expect, these keys can also be
specified as output fields when listing servers.

Change-Id: Ic00ec95485485dff0fd4dcf8cad6ca56a481d512
Implements: blueprint instance-flavor-api
Depends-On: If646149efb7eec8c90bf7d07c39ff4c495349941
2017-06-26 09:50:50 -06:00
Chris Friesen c496531435 Clean up ShellTest unit tests
Convert all the individual tests to use the common mocked client
that is defined in setUp().  This simplifies the individual tests
and lays the groundwork for supporting specifying the API version
in the mocked client since it'll be needed in a future commit.

Change-Id: I4c0722296d3b1997eed878e5b90198f8982157d1
2017-06-14 13:11:28 +00:00
jichenjc 4c18c8bd97 Remove version 1.1 support
v2 and v2.1 is supported now and it ask user to use v2.x API
should be what we wanted , this already deprecated for a
couple of release, so we can remove it now

Change-Id: I8de6fdbf21ccc4969297044a49590ffcd9cd27d8
2017-03-26 17:58:58 +08:00
Matt Riedemann adf7d1e48c Remove deprecated network-related resource commands
In Newton we deprecated the various network-related resource
commands which were either for nova-network or were proxy
APIs to Neutron, because of the 2.36 microversion which deprecated
those APIs.

This removes the deprecated commands. Because of the size of this
change, the deprecated python API binding removals will come in a
separate change.

Change-Id: I6ecca49e7208f9dc0969bf377930a729c4b407b8
2017-02-23 08:56:27 -05:00
Boris Pavlovic 0fed79fd8f Add profiling support to novaclient
To be able to create profiling traces for Nova, client should be
able to send special HTTP header that contains trace info.
This patch is also important to be able to make cross project
traces. (Typical case heat calls nova via python client, if
profiler is initialized in heat, nova client will add extra
header, that will be parsed by special osprofiler middleware in nova
api.)

Security considerations: trace information is signed by one of the
HMAC keys that are set in nova.conf. So only person who knows HMAC key
is able to send proper header.

oslo-spec: https://review.openstack.org/#/c/103825/
Based on: https://review.openstack.org/#/c/105089/

Co-Authored-By: Dina Belova <dbelova@mirantis.com>
Co-Authored-By: Roman Podoliaka <rpodolyaka@mirantis.com>
Co-Authored-By: Tovin Seven <vinhnt@vn.fujitsu.com>

Partially implements: blueprint osprofiler-support-in-nova

Depends-On: I82d2badc8c1fcec27c3fce7c3c20e0f3b76414f1
Change-Id: I56ce4b547230e475854994c9d2249ef90e5b656c
2017-01-19 03:50:06 +00:00
Jenkins 22eade1b11 Merge "Use more specific asserts in tests" 2017-01-02 12:22:07 +00:00
Pavel Kholkin 8a8540303f remove variable '_' from tests
TrivialFix

Change-Id: I9fa3b55d8d5a281b9b17becae1818e2def5b877c
2016-12-08 10:49:56 +03:00
Gábor Antal ce184797f0 Use more specific asserts in tests
I changed asserts with more specific assert methods.
e.g.: from assertTrue(sth == None) to assertIsNone(*) or
assertTrue(isinstance(inst, type)) to assertIsInstace(inst, type) or
assertTrue(not sth) to assertFalse(sth).

The code gets more readable, and a better description will be shown on fail.

Change-Id: I8be876e0d2a1ea5d6f8454ca973e2d874d10283d
2016-12-06 09:43:12 +01:00
Matt Riedemann daa9bdc823 Remove support for non-keystone auth systems
The support for non-keystone auth systems and plugins
was deprecated with 1f11840dd8
back in the 3.1.0 release in mitaka.

Now that we're working on shoring up the support for
keystone auth sessions in the client and eventually moving
to remove support for the non-session HTTPClient, we should
also remove the support to load non-keystone auth plugins.

The whole concept of non-keystone auth systems/plugins is
a legacy artifact and is a barrier to interoperability which
is a goal of nova and OpenStack in general.

Change-Id: Ia649db257c416ca054977812ecb3f1a8044fa584
2016-10-20 12:04:58 -04:00
Kevin_Zheng 6f8667990c Clean up deprecated CLI options
Clean up all deprecated CLI options that are marked to
be removed in version 3.3.0 as we are already in
version 4.0.0

Change-Id: Ia9c5602df1be987e7c12f625d4f8359590678a19
2016-07-04 11:37:12 +08:00
Jenkins bbba47448c Merge "Use assertIsNone instead of assertEqual(None, ***)" 2016-02-24 23:02:40 +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
Takashi NATSUME f55e426dd4 Use assertIsNone instead of assertEqual(None, ***)
Instead of using assertEqual(None, ***), developers should
use assertIsNone(***).

Change-Id: I55e9161a4df9197546603385228ea85528de43a7
Closes-Bug: #1510006
2016-02-23 20:15:06 +09: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 d045019f0f 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
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
Jenkins 0820a9e793 Merge "Remove redundant help command test and commonize" 2015-09-16 15:53:16 +00: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
melanie witt b4e9af99d7 Remove redundant help command test and commonize
This is a follow up patch to https://review.openstack.org/#/c/221488/
which added unit tests for 'nova -h' and 'nova --help' and commonized
some code. It was missed that a test for 'nova' without any options or
subcommands already existed as "test_help_no_options"

This patch also refactors "test_help_on_subcommand" use the common
"_test_help" function since that was also missed.

Change-Id: Iccaf91207ba35001c8f58abb550cd1c3be542b38
2015-09-15 00:20:23 +00:00
Jenkins 37d1e29a0b Merge "make sure os_password is set for auth_plugins" 2015-09-11 17:06:35 +00: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
melanie witt d0b44893ac Add unit tests for different help commands
Related-Bug: #1491677

Change-Id: I7e6b74e60dafa0e869a5b3355793cda1cf08c389
2015-09-08 20:11:17 +00:00
Jenkins e89e5fe1bb Merge "Set "latest" as default compute api version" 2015-08-07 13:33:31 +00:00
Jenkins 59abce6462 Merge "Add version discover and check in CLI" 2015-08-07 13:33:19 +00: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
Jenkins 40a4070f28 Merge "Implements 'microversions' api type - Part 2" 2015-07-27 23:13:36 +00:00
Jenkins 6e192c8087 Merge "rename root-password to set-password" 2015-07-27 11:39:37 +00: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
James Penick 3bf6f8fe99 rename root-password to set-password
all references to `root password` have been changed to `admin password`
but the `root-password` command remained. This changes it to
`set-password` which is less ambiguous and consistent with existing
commands `clear-password` and `get-password`

Change-Id: I8683e4ecd4d9294989eb3d8d27d1fb75c16b261b
2015-07-22 19:32:55 +00: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