319 Commits

Author SHA1 Message Date
Stephen Finucane
3fc585332f volume: Volume names are optional
Who knew?

Change-Id: I1c1a811c0db59250e8a20a87f25c2662bc3ab3e8
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-09-14 13:44:02 +01:00
Zuul
30622272e3 Merge "volume: Correct output of 'volume attachment create'" 2022-06-27 15:54:20 +00:00
Zuul
ec95b58482 Merge "Refactor "volume backup restore" command" 2022-06-20 15:19:56 +00:00
Stephen Finucane
045f2e7e06 volume: Correct output of 'volume attachment create'
When adding these, we missed that the underlying cinder library call
actually returns a dictionary and not a Resource-based object. This
requires slightly different handling. Fix this.

Change-Id: Ie065fe4198ae1238830cb619220e856390d4cb6e
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-05-16 12:47:39 +01:00
Zuul
ccd877dd40 Merge "Fix typos" 2022-05-16 09:36:14 +00:00
Stephen Finucane
53a7e67b41 volume: Add 'block storage resource filter list' command
These are based on the 'cinder list-filters' command, which accepts an
optional '--resource {resource}' option to limit the listed filters to a
single resource type.

  block storage resource filter list
  block storage resource filter show

We used the 'block storage resource filter' terminology rather than
simply 'resource filter' to highlight the fact that this is specific to
the block storage service.

Note that while this feature is a bit weird, good documentation can be
found at [1].

[1] https://docs.openstack.org/cinder/latest/admin/generalized_filters.html

Change-Id: I21e7c0ea427aef1f6665394d4b8e9a1f30d6dbb1
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-05-13 12:42:16 +01:00
Stephen Finucane
d727a65023 volume: Add 'block storage cluster *' commands
These mirror the 'cinder cluster-*' commands, with arguments copied
across essentially verbatim. The only significant departure is the
replacement of "tenant" terminology with "project".

  block storage cluster list
  block storage cluster set
  block storage cluster show

We used the 'block storage' terminology rather than simply 'volume' to
allow us to start distinguishing between the volume service and a volume
resource.

Change-Id: I9105a9e4a139af4929e3b1f3a6de6c9a53e0b598
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-05-13 11:59:23 +01:00
Zuul
dabaec5a7b Merge "volume: fix backup list of deleted volume" 2022-04-11 09:43:13 +00:00
Huanxuan Ao
de4a69a29f Refactor "volume backup restore" command
Make the positional argument "volume" optional and add a "--force"
option (volume v2 only) to the "volume backup restore" command.

Closes-Bug: #1597189
Change-Id: If944e10158bd18e8331be63e96187a23e23095d7
2022-03-10 12:04:11 +00:00
Jan Hartkopf
8acead32ee volume: fix backup list of deleted volume
When trying to list backups of a deleted volume with --volume,
openstackclient fails because the volume does not exist.
However, for listing a volume's backups, the volume itself
does not need to be present.

Fix this issue by allowing the volume of the requested backups
to not exist.

Story: 2009901
Task: 44716
Change-Id: Iea1a567151f427fa0e1ccff3af5cbeab620defcd
Signed-off-by: Jan Hartkopf <jhartkopf@inovex.de>
2022-03-08 16:28:43 +01:00
Dr. Jens Harbott
077c9a77a2 volume list: don't fail when there's no compute service
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
2022-02-17 16:08:57 +01:00
Cyril Roelandt
43639e1118 Fix typos
Change-Id: Idd502c8df21da79ff3b9339870f38378f5337879
2021-10-26 15:53:51 +02:00
Zuul
eca51342c3 Merge "volume: Add 'volume transfer request create --(no-)snapshots' option" 2021-08-26 08:03:53 +00:00
Stephen Finucane
e0dc31f32e volume: Add missing 'volume list --offset' parameter
Looking at the code for the ancient v1 cinder API, we see that this
supported offset-style pagination [1][2][3]. Add this parameter,
simplifying a future patch to standardize pagination across OSC.

[1] https://github.com/openstack/cinder/blob/juno-eol/cinder/api/v1/volumes.py#L259
[2] https://github.com/openstack/cinder/blob/juno-eol/cinder/api/v1/volumes.py#L292
[3] https://github.com/openstack/cinder/blob/juno-eol/cinder/api/common.py#L120

Change-Id: Ifec208ea9ed7afb4bebced6132abb96a3af034b5
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-07-27 11:15:23 +01:00
Stephen Finucane
a821d6b7c5 volume: Add 'volume transfer request create --(no-)snapshots' option
This closes a gap with cinderclient's 'transfer-create' command.

Change-Id: I7386a7be15c0e3ee87abbcfc2275ba8524c10ff8
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Story: 2009054
Task: 42831
2021-07-13 20:33:35 +01:00
Stephen Finucane
7f66dfe0e3 volume: Add more missing 'volume backup *' options
Add an additional '--no-property' option to the 'volume backup set'
command, along with a brand spanking new 'volume backup unset' command.

Change-Id: Id7ca925e0ada03e259f0ecaf3e02af11c900641e
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-06-10 11:21:25 +01:00
Stephen Finucane
34de2d3352 volume: Add 'volume group snapshot *' commands
These mirror the 'cinder group-snapshot-*' commands, with arguments
copied across essentially verbatim. The only significant departure is
the replacement of "tenant" terminology with "project".

  volume group snapshot create
  volume group snapshot delete
  volume group snapshot list
  volume group snapshot show

Change-Id: Ia5084749b7c1a5a936fd6d6e8d89b9b80969f68c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-06-10 11:21:22 +01:00
Stephen Finucane
83551d2a0c volume: Add 'volume group type *' commands
These mirror the 'cinder group-type-*' commands, with arguments copied
across essentially verbatim. The only significant departure is the
merging of some commands, such as 'group-type-default' and
'group-type-list' into 'group type list', and 'group-type-update' and
'group-type-key' into 'group type set/unset'.

  volume group type create
  volume group type delete
  volume group type list
  volume group type show
  volume group type set
  volume group type unset

Change-Id: Iee6ee2f1f276e6ef6f75a74f8f2980f14c0d5e2f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-06-03 18:00:50 +01:00
Stephen Finucane
4c2e8523a9 volume: Add 'volume group *' commands
These mirror the 'cinder group-*' commands, with arguments copied across
essentially verbatim. The only significant departures are the
replacement of "tenant" terminology with "project" and the merging of
the various volume group replication action commands into the parent
volume group (e.g. 'openstack volume group set --enable-replication'
instead of 'cinder group enable-replication')

  volume group create
  volume group delete
  volume group list
  volume group show
  volume group set
  volume group failover

Change-Id: I3b2c0cb92b8a53cc1c0cefa3313b80f59c9e5835
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-06-03 17:58:48 +01:00
Stephen Finucane
524af4a23e volume: Add missing 'volume backup *' options
Add a couple of missing options to each command:

  volume backup create
    --no-incremental
    --property
    --availability-zone

  volume backup set
    --property

Most of these are version dependent so we add the relevant version
checks as part of this work. While we're here, we also make the
formatting a little easier on the eye in places.

Change-Id: I328d5c981cb32b2ee9a4b1bd43aa36b22347ff63
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-06-03 15:52:18 +01:00
Stephen Finucane
0eddab36e5 volume: Add 'volume message *' commands
This patch implements the necessary commands to utilize the Messages API
introduced in Cinder API version 3.3. Version 3.5 built upon this by
implementing pagination support for these commands which is present in
this patch as well.

  volume message get
  volume message list
  volume message delete

Change-Id: I64aa0b4a8d4468baa8c63e5e30ee31de68df999d
2021-06-03 15:52:18 +01:00
Stephen Finucane
6dc94e1fb8 volume: Add 'volume attachment *' commands
These mirror the 'cinder attachment-*' commands, with arguments copied
across essentially verbatim. The only significant departure is the
replacement of "tenant" terminology with "project".

  volume attachment create
  volume attachment delete
  volume attachment list
  volume attachment complete
  volume attachment set
  volume attachment show

Full support for filtering is deferred for now since that's a more
complicated change that requires additional commands be added first.
TODOs are included to this effect.

Change-Id: If47c2b56fe65ee2cee07c000d6ae3688d5ef3b42
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-06-03 15:52:18 +01:00
Stephen Finucane
0f28588e48 volume: Allow more versions
Copy the API version checks from the 'openstackclient.compute.client'
module. These will only be necessary until we migrate everything to SDK
but it's very helpful until then.

Change-Id: I2d9c68db5bf891ffa25fd5a7fc9e8953e44b73ab
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-06-03 15:52:18 +01:00
Brian Rosmaita
b019a56187 Add check for cinderclient.v2 support
Block Storage API v2 support is being removed from the cinderclient
during the Xena development cycle [0], so add a check to determine
whether the available cinderclient has v2 support.

[0] https://wiki.openstack.org/wiki/CinderXenaPTGSummary#Removing_the_Block_Storage_API_v2

Change-Id: Id54da1704d94526071f500c36a6e38d6d84aa7b8
2021-05-20 09:20:56 -04:00
Dmitriy Rabotyagov
4c0bfb03fc Allow to resize in-use volumes
Since Pike (microversion 3.42) [1] Cinder API allows to resize in-use
volumes. So no reason not to implement it in CLI.

[1] https://opendev.org/openstack/cinder/src/branch/master/cinder/api/openstack/rest_api_version_history.rst#user-content-section-39

Change-Id: I22462a56d261e0a100aac3f27af7be47223edec0
2020-11-11 09:18:49 +00:00
Zuul
21c883b3d3 Merge "Switch image to use SDK" 2020-03-25 15:19:20 +00:00
Zuul
81dcc91214 Merge "Fix faulthy state argument choice" 2020-03-24 21:34:44 +00:00
Monty Taylor
cdac869412 Honor endpoint override from config for volume
I'm guessing we should do this for everyone, but we have volume on
the brain right now. Rackspace is in the weird situation where
they do support v2 but only have v1 in the catalog (wut) So we
need to override the block-storage enpdoint by config. To do that,
we need to actually honor the config setting over here in OSC.

NOTE: We need to systemically overhaul how we're injesting config
over here - because there's too much variation. But we can leave
that for another day.

Story: 2007459
Task: 39137
Change-Id: Ifddf1ddd5abaa768ab18049c09d18bc269f3a4f5
2020-03-24 07:29:35 -05:00
Artem Goncharov
60e7c51df4 Switch image to use SDK
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
2020-03-23 14:38:32 -05:00
lihaijing
d15bbada73 Replace six.iteritems() with .items()
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
2020-01-09 18:41:29 +09:00
Bram Verschueren
69870ae439
Fix faulthy state argument choice
The correct state name for a failing volume snapshot deletion is
'error_deleting' instead of 'error-deleting'. [1]

[1] 89d6a5042f/cinder/objects/fields.py (L126)

Task: #37844
Story: #2007037

Change-Id: Ia99900ece4f1cd29769b22ddaa3965789d719556
2019-12-19 09:48:17 +01:00
Sean McGinnis
a96089ff6d Default to Cinder v3 API
This switches the default Cinder API version to v3 to prepare for v2
going away.

Change-Id: Icca1512b715409e3001c0fd2d1ea663d5e71ec02
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2019-09-09 09:35:44 -05:00
Zuul
46ef850ce9 Merge "Use cliff formattable columns in volume v2 commands" 2019-06-23 00:45:37 +00:00
Akihiro Motoki
4cd614305f Use cliff formattable columns in volume v2 commands
Partial-Bug: #1687955
Partially implement blueprint osc-formattable-columns

Change-Id: I761ccac126208927594ad0d98a3cf5ad8b44bd48
2019-06-22 14:56:10 -05:00
Akihiro Motoki
1af3056e30 Use cliff formattable columns in volume v1 commands
Partial-Bug: #1687955
Partially implement blueprint osc-formattable-columns

Change-Id: Ib4c5798171e32a8ddc08a37ee1d416e366a71d76
2019-06-22 14:53:28 -05:00
Zuul
c20421c467 Merge "Remove deprecated volume commands and args" 2019-06-22 07:17:28 +00:00
Sean McGinnis
e76e10c0ba Remove deprecated volume commands and args
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>
2019-05-20 14:05:18 -05:00
melissaml
aabc67f3a2 Rename review.openstack.org to review.opendev.org
There are many references to review.openstack.org, and while the
redirect should work, we can also go ahead and fix them.

Change-Id: I82e3797dd4c05e4944f40c950b4fafe9a5334cbf
2019-05-12 04:41:27 +08:00
Zuul
303cb4735d Merge "Add --attached / --detached parameter to volume set" 2019-03-06 00:58:17 +00:00
David Rabel
e776a4f026 Add --attached / --detached parameter to volume set
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
2019-02-28 15:48:34 +00:00
whoami-rajat
24255ad0dd Fix: Restore output 'VolumeBackupsRestore' object is not iterable
VolumeBackupsRetore object has '_info' attribute
which contains the output data of the restore
command which should be returned instead of the
'VolumeBackupsRestore' object.

Change-Id: I64b75649c1ac9c24e05a197f7280975564b4d386
Story: 2004740
Task: 28811
2019-02-27 22:28:09 +00:00
Sean McGinnis
b90c780d2b
Add volume backup import/export commands
This adds commands to import and export volume backup records so they
can be imported and restored on other Cinder instances or to the
original instance if the service or database has been lost and had to be
rebuilt.

I know this is a commonly used process by some users, so it would be
good to have this functionality in osc so they do not have to switch
clients.

More details about the export and import process can be found here:

https://docs.openstack.org/cinder/latest/admin/blockstorage-volume-backups-export-import.html

Change-Id: Ic95f87b36a416a2b50cb2193fd5759ab59336975
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2018-11-10 02:11:04 -06:00
Zuul
51986b1eae Merge "Remove invalid 'unlock-volume' migration arg" 2018-11-08 19:11:06 +00:00
Sean McGinnis
f00ffebea6
Remove invalid 'unlock-volume' migration arg
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
2018-10-26 12:02:58 -05:00
Zuul
02f492ae4c Merge "Handle not having cinderclient.v1 available" 2018-10-15 22:07:43 +00:00
Sean McGinnis
651f0c38a1
Handle not having cinderclient.v1 available
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>
2018-10-12 14:19:51 -05:00
Sean McGinnis
9647d43bd5
Add volume backend pool list command
Adds an equivalent for "cinder get-pools" with "volume backend pool list"
and "cinder get-pools --detail" with "volume backend pool list --long".

Story: 1655624
Task: 136949

Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Change-Id: I826c9946ffe11340d44ad57914f72fc2a72b6938
2018-10-09 15:56:58 -05:00
Sean McGinnis
4039d0d94f
Add volume backend capability show command
Adds and equivalend for "cinder get-capabilities" command to show the
capabilities supported by a Cinder backend.

Story: 1655624
Task: 26947

Change-Id: I38686a26cd503e45ce0102705a6632994ef10274
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2018-10-09 15:31:35 -05:00
Alan Bishop
030fd71390 Deprecate volume create --project and --user options
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
2018-08-10 10:20:34 -04:00
Fan Zhang
def83a0e94 Fix broken gate jobs
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>
2018-08-07 09:32:00 +00:00