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>
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>
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>
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>
This is compatible with Python 3-only syntax.
Change-Id: I462f4242b9a5f8d8cd6b0cb3d328dfd9d93ba200
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
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>
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
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
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
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
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
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
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
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
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
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
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
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
Instead of using assertEqual(None, ***), developers should
use assertIsNone(***).
Change-Id: I55e9161a4df9197546603385228ea85528de43a7
Closes-Bug: #1510006
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
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
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
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
novaclient should display help message of the proper versioned method
(based on api_version value).
Closes-Bug: #1523649
Closes-Bug: #1523651
Change-Id: I67f7fc2befde9d312400e9a1569e590bd763156e
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
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
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
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
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
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
It would be nice to use "latest" version of api by default.
Related to bp api-microversion-support
Change-Id: Ife981c87d32011f01fcbdf871071a9d8273ebb92
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
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
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
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