If you use the former, you get a pretty error message when there's a
failure. If you use the latter, you get an ugly traceback when used with
the '--debug' flag.
Without this change:
$ openstack flavor create ... --property '' foo
...
Traceback (most recent call last):
File "/tmp/venv/lib/python3.11/site-packages/cliff/app.py", line 402, in run_subcommand
parsed_args = cmd_parser.parse_args(sub_argv)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/argparse.py", line 1862, in parse_args
args, argv = self.parse_known_args(args, namespace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/argparse.py", line 1895, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/argparse.py", line 2107, in _parse_known_args
start_index = consume_optional(start_index)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/argparse.py", line 2047, in consume_optional
take_action(action, args, option_string)
File "/usr/lib64/python3.11/argparse.py", line 1971, in take_action
action(self, namespace, argument_values, option_string)
File "/tmp/venv/lib/python3.11/site-packages/osc_lib/cli/parseractions.py", line 45, in __call__
raise argparse.ArgumentTypeError(msg % str(values))
argparse.ArgumentTypeError: Expected 'key=value' type, but got:
clean_up CreateFlavor: Expected 'key=value' type, but got:
With this change:
$ openstack flavor create ... --property '' foo
...
usage: openstack flavor create [-h] [-f {json,shell,table,value,yaml}] [-c COLUMN]
[--noindent] [--prefix PREFIX] [--max-width <integer>]
[--fit-width] [--print-empty] [--id <id>]
[--ram <size-mb>] [--disk <size-gb>]
[--ephemeral <size-gb>] [--swap <size-mb>]
[--vcpus <vcpus>] [--rxtx-factor <factor>]
[--public | --private] [--property <key=value>]
[--project <project>] [--description <description>]
[--project-domain <project-domain>]
<flavor-name>
openstack flavor create: error: argument --property: Expected 'key=value' type, but got:
clean_up CreateFlavor:
Change-Id: I9e78b35ad9d016d7a33655141ec579397c5344c0
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
When creating a volume, the scheduler hints can be supplied as strings.
The "same_host" and "different_host" hints can also be supplied as a
list if affinity/anti-affinity to multiple volumes is requested [0]
The previously-used `KeyValueAction` only supplies strings as values - the
last one if multiple --hint contain the same key. An alternative already
used in `CreateServer` would be `KeyValueAppendAction`, but only a subset of
the scheduler hints accept lists, so we cannot use that in general.
Therefore, we create `KeyValueHintAction`. It contains both a
`KeyValueAction` and a `KeyValueAppendAction` object and calls the
appropriate action based on the beginning of the given values as defined
in `APPEND_KEYS`.
[0] d96b705774/cinder/api/schemas/scheduler_hints.py (L31-L65)
Change-Id: Ida7f4662dc9fea24510758541fd4f2622b73bf31
This removes the need for a number of base test case subclasses. We use
'volume_client' rather than 'client' to avoid conflicts with clients for
other services.
Change-Id: I28d78f32142bb3a3fde0ba1780c504adc31cc77c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This ensures we are speccing the image proxy API, as we did previously
for the network tests in Ic203964c7dede7dd80ae2d93b8fa1b7e6634a758.
Change-Id: I09539cbf35444272fb3aaabfecd5d731d1ecc4a8
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This removes the need for a number of base test case subclasses. We use
'image_client' rather than 'client' to avoid conflicts with clients for
other services.
Note that this highlights a minor bug with the 'volume create' command
when using the v1 block storage API and creating a volume from an image.
This is corrected, though it can be assumed that no one is actually
using this code path to say it hasn't been reported in the few years
since the bug was introduced in Ussuri.
Change-Id: I571be27f68bb7669dcb883f3b4799731b4a35479
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Black used with the '-l 79 -S' flags.
A future change will ignore this commit in git-blame history by adding a
'git-blame-ignore-revs' file.
Change-Id: Ic318617c67ab7ce6527f9016b759a1d4b0b80802
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This patch add a check to be sure that the volume created is in a
available state before trying to set bootable or readonly flag.
Story: 2002158
Change-Id: I8db71fd8cf5bd14eb67880f76d2e9135edeb3ed2
This patch adds a test to create a new volume from source.
We also include code changes to pass the right size i.e. either
size passed by the user via --size argument or the source volume
size. This case is already handled at the API layer[1] but it
helps being consistent with passing the right size value as in case
of creating a volume from snapshot or backup.
[1] 7c1a5ce7b1/cinder/api/v3/volumes.py (L381-L382)
Change-Id: Idc71636dad6bb678fe24f19b0836d2e9bd92d7d2
Support for creating a volume from backup was added in
microversio 3.47. This patch adds a --backup option
to the volume create command to add that support.
Change-Id: Ib26d2d335475d9aacbf77c0fd7b7cda2ba743943
We're no longer creating fake versions of glanceclient's 'Resource'
object but rather openstacksdk objects. As such, there's no point
nesting things under a fake resource class.
Change-Id: I39cd5302622f4542db9eebcccfad0cb90d077441
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
There are more types than just volume types.
Change-Id: I6af66f966a221437ff79fabcb0b81fd38586fe67
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
assertItemsEqual was removed from Python's unittest.TestCase in
Python 3.3 [1][2]. We have been able to use them since then, because
testtools required unittest2, which still included it. With testtools
removing Python 2.7 support [3][4], we will lose support for
assertItemsEqual, so we should switch to use assertCountEqual.
[1] - https://bugs.python.org/issue17866
[2] - https://hg.python.org/cpython/rev/d9921cb6e3cd
[3] - testing-cabal/testtools#286
[4] - testing-cabal/testtools#277
Change-Id: I0bbffbec8889b8b3067cfe17d258f5cb16624f38
This requires fixes found in cliff 3.5.0 [1] and osc-lib 2.3.0 [2]. With
these fixes in place, we can remove the icky, still broken
'assertItemEqual' and 'assertListItemEqual' helpers.
[1] https://review.opendev.org/761421
[2] https://review.opendev.org/761394
Change-Id: Id6c26b37c3c7d5ec6761361abca57f9219b76838
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This is a work to switch OSC from using glanceclient to OpenStackSDK.
With this change only v2 is using OpenStackSDK. V1 is still using
glanceclient and will be switched in a separate change.
Remove the direct depend on keystoneauth- let that flow through
openstacksdk.
Depends-on: https://review.opendev.org/#/c/698972
Change-Id: I36f292fb70c98f6e558f58be55d533d979c47ca7
We had this library capped at a release that is a few years old. Now
that we have dropped py2 testing, we can pick up the latest version.
This uncovered a few things to clean up. Mostly the fact that mock is
now a part of the StdLib unittest since Python 3.3.
Change-Id: I27484dd4c25378413ff16e97a35a1a46062357bc
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
The following were deprecated over two years ago and can now be removed:
* Remove ``backup`` commands in favor of ``volume backup``
* Remove ``snapshot`` commands in favor of ``volume snapshot``
* Remove ``volume create`` options ``--project``, ``--user`` and ``--multi-attach``
* Use of an auth-key positional argument in volume transfers
* ``volume transfer request`` no longer accepts 'auth_key' as a positional arg,
``--auth-key`` is now required
Internal (non-user-visible)
* Rename backup.py to volume_backup.py for Volume v1 and v2, update tests
These are backwards incompatible changes and will require a major
version bump after they are merged.
Change-Id: I94aa7a9824e44f9585ffb45e5e7637b9588539b4
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
As to reflect cinder reset-state --attach-status functionality,
this patch adds --attached / --detached parameter to OSC's volume set
command.
Change-Id: Ic8ee928c9ab0e579512cfb7608f63bfcc2993c7b
Closes-Bug: #1745699
There is an optional flag that can be passed in to a
volume migration to tell Cinder to 'lock' a volume so
no other process can abort the migration. This is
reflected correctly with the --lock-volume argument
flag to `openstack volume migrate`, but there is
another --unlock-volume flag that is shown in the help
text for this command that does not do anything and is
not used anywhere.
Since there is no action to "unlock" a volume, this
just causes confusion - including for Cinder developers
that know this API. To avoid confusion, this invalid
flag should just be removed from the command.
Change-Id: I5f111ed58803a1bf5d34e828341d735099247108
The Cinder v1 API was deprecated several years ago and may be removed
from python-cinderclient in the near future. To handle the case where v1
is no longer present, this updates cinderclient initialization to work
without it and give an appropriate error if v1 is requested with a
version where it is no longer available.
Change-Id: I277d7b48b8ad4cce383ec3722f8117938378f615
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Cinder's volume create API does not support overriding the project_id and
user_id, and it silently igores those API inputs. Cinder always uses the
project and user info in the keystone identity associated with the API
request.
If a user specifies the --project or --user option, the volume create is
aborted and a CommandError exception is raised. This prevents a volume
from being created, but without the desired project/user values.
A user wishing to specify alternate values can still do so using identity
overrides (e.g. --os-username, --os-project-id).
Story: 2002583
Task: 22192
Change-Id: Ia9f910ea1b0e61797e8c8c463fa28e7390f15bf9
This patch aims at fixing the broken gate jobs because of
cinder and glance patches [1], [2], [3] and [4].
* Remove parameter `--source-replicated` to drop volume
replication v1 support
* Address some timing issues with volume transfer requests
* Only run Image v1 tests when the test cloud has v1 available
* Get tolerant of unexpected additional attributes being
returned in Image data
[1].https://review.openstack.org/#/c/586293/
[2].https://review.openstack.org/#/c/532503/
[3].https://review.openstack.org/#/c/533564/
[4].https://review.openstack.org/#/c/578755/
Co-Authored-By: Dean Troyer <dtroyer@gmail.com>
Co-Authored-By: Monty Taylor <mordred@inaugust.com>
Depends-on: https://review.openstack.org/588664
Change-Id: I2a785750e92155185d3344e6116c7f5c6fdd3cbe
Signed-off-by: Fan Zhang <zh.f@outlook.com>
When creating a volume from a snapshot, the size parameter is required
and type is checked. Since we have to pass something and it needs to be
a valid data type (None is not acceptable) grab the size from the
snapshot object and pass it.
Change-Id: Ie23e3d23828919234e40336b5c65b22e140d337c
In reviews we usually check import grouping but it is boring.
By using flake8-import-order plugin, we can avoid this.
It enforces loose checking so it sounds good to use it.
This flake8 plugin is already used in tempest.
Note that flake8-import-order version is pinned to avoid unexpected
breakage of pep8 job.
Setup for unit tests of hacking rules is tweaked to disable
flake8-import-order checks. This extension assumes an actual file exists
and causes hacking rule unit tests.
Change-Id: I12b596820727aeeb379bee16c2bc993dee9eb637
Current "volume list --name" command use "display_name" as search_opts
to send to cinder API, and show the result table with "Display Name"
column title in osc, cinder list API support "name" as search opts too,
and there is "name" attribute in volume response body, so we can replace
all "Display Name" by "Name" in order to keep "volume list" command
consistent with other commands, like: server list, network list and so
on, only use "Name" attribute for all objects.
Support a mapping for volume list -c "Display Name" (Volume v1 and v2)
and volume create/show -c "display_name" (Volume v1) for minimal
backward compatibility until R release.
Change-Id: I120be0118e7bb30093b4237c5eeb69a9eedef077
Closes-Bug: #1657956
Depends-On: I1fb62219b092346ea380099811cbd082cae5bafe
This patch fixed a bug of unable to filter volume list by '--project',
'--user' in "openstack volume list".
Modify uint test for 'volume list' to check parameter of list method.
Change-Id: I1fc4296c4c7eca0f7a803dbfd5e15e3bc0d6403f
Add "--bootable", "--non-bootable", "--read-only" and "--read-write" options
to "volume create" command for setting some attributes at the time of crration.
Change-Id: I71b4e9fccb4ee0ab1a90e7179d6d2d34dbbae909
Implements: bp cinder-command-support
Add "--type" and "--retype-policy" options to
"volume set" command in volume v2 (v2 only) to
support changing the volume type for a volume
Change-Id: I0153abdb967aee790586a57cef31930e32005c1b
Implements: bp cinder-command-support
Add "--read-only" and "--read-write" options in "volume set"
command to set volume access mode.
Implements: bp cinder-command-support
Change-Id: I76ba85c7d3ff0eb026a9cbd794368d8b2b0d17fe
Add "volume migrate" command in volume v1 and v2
to support migrating volume to a new host
Change-Id: Ie4e6037171a31a872006a13f9fd1e15eaa627c26
Implements: bp cinder-command-support
1.Add mutually exclusive options into a mutually
exclusive group.
2.Add "--source-replicated", "--consistency-group",
"--hint" and "multi-attach" options
3.Make --size option to be optional under some cases
Closes-Bug: #1568005
Closes-Bug: #1627913
Implements: bp implement-cinder-features
Co-Authored-By: Roman Vasilets <rvasilets@mirantis.com>
Change-Id: I2c4c3073195d33774e477f4d7f22e383b14b41dd
Add --bootable | --non-bootable option in volume set
to mark or unmark volume as bootable.
Change-Id: Ifa6c2dd1642202f55b6d50e3b8614d3513d488f6
Closes-Bug:#1535704
Support multi REST API calls error handling for "volume unset"
command follow the rule in doc/source/command-errors.rst.
Also add a unit test for testing the error handling
Change-Id: I2de7a7bd5a7a5e39817ed5cf6952abf4afba75e4
this will better isolate the unit tests from the functional tests.
unfortunately, the "integration" tests had to be lumped into the
"unit" tests since we need the separation in testr.conf
Change-Id: Ifd12198c1f90e4e3c951c73bfa1884ab300d8ded