Add some pagination helpers to configure pagination parameters for
various commands. Two pagination schemes are supported, based on what we
currently support across OSC commands: marker-based pagination and
offset-based pagination.
Change-Id: I551bb4c3ff0568c6df5244a1d0f0669497bee58f
Signed-off-by: Stephen Finucane <sfinucan@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
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
There may be deployments that only have a volume service but no compute
service, possibly as an intermediate step during the initial setup.
Don't fail the "volume list" command when no compute client can be
initiated.
Signed-off-by: Dr. Jens Harbott <harbott@osism.tech>
Change-Id: Idef77bdc8753a456a4c431b0385318dff6581a65
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
1. As mentioned in [1], we should avoid using six.iteritems to achieve
iterators. We can use dict.items instead, as it will return iterators
in PY3 as well. And dict.items/keys will more readable.
2. In py2, the performance about list should be negligible,
see the link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: I4b9edb326444264c0f6c4ad281acaac356a07e85
Implements: blueprint replace-iteritems-with-items
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
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
Cleanup help strings and docs for clarity and to keep things consistent:
* --limit metavar should be <num-resource> to indicate what is being counted
* --marker metavar should be <resource> or <resource-id> to indicate the
type of value being specified
* <*-ip-address> metavars should be just <ip-address> as there is no difference
in format between fixed and floating IPs
* Move all occurances of '(name or ID)' to end of help text
Change-Id: I2c31746ed6ded3845244e03e57d809f8bc0e6b9d
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
Leverage the new cliff command class attribute (_description)
to get the help of a command, this allows us to mark strings
for translation. We could not do this before since the help
was grabbed from the docstring.
This also depends on a new release of cliff and a bump to the
minimum level in osc's requirements.
Closes-Bug: 1636209
Depends-On: Id915f6aa7d95a0ff3dc6e2ceaac5decb3f3bf0da
Change-Id: I8673080bb5625e8e3c499feaefd42dfc7121e96f
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
The error messages are tuples and not substituting variables.
Before:
$ openstack volume set vol1 --size 1
Failed to set volume size: (u'New size must be greater than %s GB', 2)
$ openstack volume set vol1 --size 1
Failed to set volume size: (u'Volume is in %s state, it must be available
before size can be extended', u'error')
After:
$ openstack volume set vol2 --size 3
Failed to set volume size: New size must be greater than 4 GB
$ openstack volume set vol2 --size 3
Failed to set volume size: Volume is in error state, it must be available
before size can be extended
Change-Id: Ide6e644b1c6d1c11a9dc2f3f53c1a1837380b8d5
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
There are some set commands can set object state, it maybe
a danger behavor for users, so add explanation and warning
in the help message of the "--state" option to talk users
be caution when using (cinderclient have done this too)
Change-Id: I6a902887ea98879999c9972f36b1b7ef332173c3
The help message of command "openstack volume show" accepts either
volume-name or volume-ID. But the metavar is "volume-id" as below.
It can easily lead to misunderstanding.
usage: openstack volume show [-h] [-f {json,shell,table,value,yaml}]
[-c COLUMN] [--max-width <integer>]
[--noindent][--prefix PREFIX]
<volume-id>
Change-Id: I57576ea23868b1026cf268be69b39e98a53aafd4
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
Support the error handling follow the rule in
doc/source/command-errors.rst
Also add a unit test for testing the error handling
Change-Id: I98064f4b8c1dc17eb3874f7b25c827a568463c0f
OSC does not support to set volume's state, this
patch is going to add this functionality.
Closes-Bug:#1535213
Change-Id: I5bc1c7e81b8ba61c37f4bfd209fc86c5857fb050
Co-Authored-By: Huanxuan Ao <huanxuan.ao@easystack.cn>
OSC doesn't support deleting volumes with associated snapshots.
This patch provides support for deleting volumes with associated
snapshots by adding an optional argument.
Change-Id: I7e74f251574993ff13a38e508fd2f9debeda8d0a
Closes-Bug: #1589332
Co-Authored-By: Rui Chen <chenrui.momo@gmail.com>
Some delete conmmands in volumev2 did not support
error handling, this patch add them and also add
the unit tests for bulk deletion
Change-Id: I56ade6f9c7396c78fb989547476c4d94ccd76eae
self.app.log is the logger in class OpenStackShell,
which should be used to record logs that have nothing
to do with any specific command.
So, use the file logger instead.
This patch also fixes some usage that doesn't follow
rules in:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html
1. add variables to logger as an argument
2. do not wrap variables with str()
Change-Id: I248861a38a4de0412a080046aa7a6f6473c3e082
Implements: blueprint log-usage