58 Commits

Author SHA1 Message Date
John Griffith
22c3693f8c Attach/Detach V2
Add an attachments API
This includes a new attachment controller and shell
commands.  To use you'll need to set your api version
    `export OS_VOLUME_API_VERSION=3.27`

Now you can do things like attach a volume (cinders part at least):
    `cinder attachment-create --connect True ......`

List/show/delete existing attachments:
    `cinder attachment-list`
    `cinder attachment-show <attachment-id>`
    `cinder attachment-delete <attachemnt-id>`

Change-Id: I2c463f0910b6c9e37502869b7ec33073f12939f1
2017-01-26 23:08:40 +01:00
Jenkins
4c61c6556b Merge "Fix getting metadata attr error in snapshot-list command" 2017-01-26 18:31:34 +00:00
Mykhailo Dovgal
209eebbb12 Fix getting metadata attr error in snapshot-list command
Because of 'start_version' parameter in decorator here [0]
we won't have metadata attr in args using api versions from 3.0 to 3.21.

This patch changes getting metadata from args logic for compatibility with
the api versions 3.0 - 3.21.

[0] - b73b393240/cinderclient/v3/shell.py (L1237)

Change-Id: I4aa099556c57c49e9ad74fe80e5591d738cf3aa0
Closes-Bug: #1659561
2017-01-26 17:19:12 +02:00
wangxiyuan
aaffe41e31 Support filter volumes by group_id
After v3.10, cinder support filter volumes by group_id, this patch
support this feature for client side.

Change-Id: Ie7df4d8b81789fd36ca6f91d96a477c88e8d5a52
Partial-Implements: blueprint improvement-to-query-consistency-group-detail
2017-01-25 11:04:33 +08:00
Ivan Kolodyazhny
204b15ab13 Removed unnecessary 'service_type' decorator
@utils.service_type was introduced with 'Initial split from
python-novaclient' commit and used for CLI. Now both Python and
Command-line APIs for each version  work well without this decorator.

Unused 'get_service_type' function is removed too.

'utils.retype_method' removed as well because everything works well
without it.

Change-Id: Ic2470d8ca9d581b7c47da8d7e6a414c3c78ad27a
Partial-Bug: #1643584
Related-Bug: #1621126
2017-01-23 13:58:33 +02:00
Vivek Agrawal
f08ecd29ad Fix v3 volume list based on image_metadata
volume list filtered on image_metadata does not work as expected.
The filtering based on image_metadata depended on non existent
utility for extracting image_metadata.
Fixed the issue by calling appropriate utility module
for extracting image_metadata. Looks like a typo.

Change-Id: I13e78277fc1afd22d044bb49b6a5ccc00904228c
Closes-bug: #1657650
2017-01-19 08:20:09 -08:00
Vivek Agrawal
056cf5c059 Metadata based snapshop filtering
The snpapshot-list API for cinder gives a list of snapshots based
on certain criteria to the user. From microversion 3.22 onwards
the snapshot-list API has been enhanced to support snapshot list
filtering based on metadata of snapshots. The metadata is stored
as key-value pair for every snapshot.
With this commit cinder will be queried based on metadata key and
value specified in the API snaphot-list. All the snapshots which
match the key, value provided by the user along with any other
filter criteria will be returned.
Added the test cases for the CLI and web requests.

DocImpact: "Filters results by a metadata key and value pair.
Default=None." on cinder snapshot-list
APIImpact

Closes-bug: #1569554

Change-Id: Idec0d0d02e7956843f202508e32c023c3cafbb0f
2017-01-18 06:28:21 -08:00
Ivan Kolodyazhny
603c615ae5 Refactor v2 and v3 APIs support
Now v2 API uses code from v3. It's confusing and logically incorrect.
This patch makes v3 API as an extended version of v2.

The next patches related to this bug duplicated code between v1 and v2,
v2 and v3 will be removed.

Change-Id: I90a2b713556e91db69270a03ef6b798e08f93f90
Partial-Bug: #1643584
2016-12-20 16:29:36 +02:00
Cao ShuFeng
64c8f74a7c Remove extra 'u' from cli output
The unicode_key_value_to_string() function is designed to remove
extra 'u' in cinderclient cli output.
However this patch[1] bring the extra 'u' back.
Let's remove the extra 'u' again.

Closes-bug: #1615921
Closes-bug: #1606904

[1] https://review.openstack.org/#/c/342734/
Change-Id: I26f0ad7149f57e935953c2398ba90b7b3585e201
2016-12-16 16:11:31 +02:00
Ivan Kolodyazhny
b8d1966d93 Fix help message for 'type-list' command
Change help about private volume types according to the implementation.

Change-Id: I59d811c4a6afb1a8162cf25ff1a734facbf68d8d
Related-Bug: #1637549
2016-11-01 16:25:03 +01:00
Jenkins
e30cc55942 Merge "Showing the metadata readonly value as a separate field" 2016-10-18 17:03:16 +00:00
bhagyashris
08863124f7 Fix volume type 'is_public' flag update
Update 'is_public' flag only if flag is passed as an argument
while updating volume type. With this change If 'is_public' flag
is not passed by the user, its value will not be updated and
only arguments passed to the update api will be updated.

Added code to check if none of the argument is passed to update
volume-type then it raises the CommandError exception with
appropriate error message.

Change-Id: Ice52e204ebea5d35f04455e74e16745a8bcce3d4
Closes-Bug: #1548708
2016-10-12 04:40:02 -05:00
Jenkins
30793d6c57 Merge "Volume detail support glance_metadata in CLI" 2016-10-05 15:22:13 +00:00
zheng yin
e5b347c658 remove raise "e"
when it has an exception, it will call raise without  arguments.
we can use "raise" replace "raise e", the result is the same.

Change-Id: I329932dcb2f49dcd3f0dfd88a5896860322e60ec
2016-09-26 04:30:58 +00:00
Cao Shufeng
cd9850b715 Parse filter item "name" correctly for snapshot-list
Cinderclient will parse filter item "name" to "display_name"
when get snapshot list via v2/v3 api.
This works for admin user. However for non-admin user,
cinder-api[1] removes "display_name" as an invalid filter item
and return the full snapshot list.
This change use "name" as filter of snapshots rather than
"display_name".

[1]: https://github.com/openstack/cinder/blob/master/cinder/api/v2/snapshots.py#L87-#L93

Co-Authored-By: cheneydc <dongc@neunn.com>

Change-Id: I63b6049a417293534079012dc6ee2a5b25e176be
Closes-Bug: #1554538
2016-09-12 08:47:23 +00:00
Karthik Prabhu Vinod
23f7d19739 Showing the metadata readonly value as a separate field
Now, cinder show <volume_id>, shows readonly as a separate field. This
helps the user to not have to scan all through the volume's metadata
field

Change-Id: Ib427f7e76e8e28fee97b75413c3032fbee75af86
Closes-bug: #1307098
2016-09-12 04:57:49 +00:00
Yuriy Nesenenko
e15d8e7f09 Deleting volume metadata keys with a single request
Deleting multiple volume metadata keys with a single request
to improve performance. To delete multiple metadata items without
affecting the remaining ones, just update the metadata items with
the updated complete list of ones (without items to delete)
in the body of the request. This patch uses etags to avoid the
lost update problem with volume metadata. The command isn't changed:

 $ cinder metadata volume_id unset k1 k2 k3

Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Depends-On: I575635258c10f299181b8e4cdb51a7ad1f1be764
Implements: blueprint delete-multiple-metadata-keys
Change-Id: I8e18133ffee87c240a7af4b8177683ab99330d9e
2016-09-01 22:53:06 +03:00
Alex Meade
1c87b6fa71 Add v3 user messages with pagination
GET /messages
GET /messages/{id}
DELETE /message/{id}

Partially-Implements: blueprint summarymessage
Depends-On: I398cbd02b61f30918a427291d1d3ae00435e0f4c
Change-Id: Ic057ab521c048a376d2a6bed513b8eb8118810d1
2016-09-01 08:21:57 -04:00
Jenkins
e8d272a167 Merge "Changed backup-restore to accept backup name" 2016-08-26 16:13:16 +00:00
Ellen Leahy
4f833eeaff Changed backup-restore to accept backup name
Beckup-restore does not currently accept the name of the backup,
however other backup actions do and according to its description
backup-restore should as well.

Change-Id: I26d8d2f1fe6cf7362d23d9b9668936dbb0509251
Closes-Bug: #1604892
2016-08-25 15:48:43 +01:00
Cao Shufeng
cbe6c59d9a Enhance help message of upload_to_image
Following the commit fb2c434c2461a25193067104de766fc1142a6024 in
the cinder repo the --force option to upload-to-image is ignored
by default. To enable it the config option enable_force_upload
must be set to true.

The help text for upload-to-image in the python cinderclient
should remind user that --force may not work in some cloud now.

Closes-Bug: #1611667
Change-Id: Ib56fb2016d933a9bbbcb0185c50e33d2166b34e6
2016-08-25 10:02:25 +00:00
Jenkins
ca24fd41e2 Merge "Fix useless api_version of Manager class" 2016-08-24 10:03:24 +00:00
Cao ShuFeng
09a76374c3 Fix useless api_version of Manager class
Manager's api_version property is used by api_version.wraps. It
should not be an "empty" class and the real api_version can be
read from Client class.

The 3.0 version's upload-to-image doesn't work as excepted because
of this useless api_version of VolumeManager class. This patch also
fix it and update some unit tests for it, because the changes are
co-dependent on one another.

Co-Authored-By: Nate Potter <nathaniel.potter@intel.com>

Change-Id: I398cbd02b61f30918a427291d1d3ae00435e0f4c
Closes-Bug: #1573414
Closes-Bug: #1589040
2016-08-23 05:32:00 +00:00
Jenkins
f802d1ae1a Merge "deprecate command cinder endpoints" 2016-08-19 08:55:37 +00:00
Steve Martinelli
7a566e6915 deprecate command cinder endpoints
The command `cinder endpoints` will now print a warning message,
indicating that users should use openstackclient instead.
This has already been done in nova's CLI [1].

Related-Bug: 1608166

[1] https://github.com/openstack/python-novaclient/blob/master/novaclient/v2/shell.py#L4071-L4072

Change-Id: If68b40cf8116aa0ec386d8067c58703cb7b7c0da
2016-08-17 14:18:29 -07:00
Cao Shufeng
b76f594413 Add "start_version" and "end_version" support to argparse
Now, "cinder help subcommand" can not show whether an argument
is supported for a specific microversion.
With this change, developers only need to add a start_version or
end_version in the utils.arg wrap, cinderclient will support
the microversion for that arguement.

    @utils.arg(
    '--foo',
    start_version='3.1')
    @utils.arg(
    '--bar',
    start_version='3.2',
    end_version='3.5')
    def do_some_action():
        ......

In previous example, an exception will be raised for such command:
   $ cinder --os-volume-api-version 3.6 --bar some-ation

And only "--foo" will show up for such help command:
   $ cinder --os-volume-api-version 3.1 help some-ation

Change-Id: I74137486992846bbf9fdff53c009851db2356eef
Partial-Bug: #1600567
Co-Authored-By: Nate Potter <nathaniel.potter@intel.com>
2016-08-16 16:16:13 +00:00
Jenkins
8f1bfce806 Merge "Add backup-update" 2016-08-16 01:15:58 +00:00
lisali
0c016c8b96 Add backup-update
Add backup-update command to update name and description
of a backup.

DocImpact

Change-Id: Ie24b2a13f8d1132b65f30e95059479e532fad41a
2016-08-05 09:33:34 +08:00
scottda
af4cfb0f64 Change api-version help to indicate server API
The help for the 'api-version' command should state that
it is displaying the api-version info for the server, not the
client:
Display the server API version information.

Change-Id: Ia4380871ddca1b7ff41a5e6c8cf86488626e69fc
2016-08-04 16:52:19 -06:00
Jenkins
4e0476507c Merge "Add cluster related commands" 2016-08-04 19:58:07 +00:00
Jenkins
cb24088fea Merge "Changed backup-restore to accept backup name" 2016-08-03 12:34:54 +00:00
Jenkins
4aa7e60c5f Merge "Add tenant_id parameter to limits." 2016-08-02 14:29:40 +00:00
Steve Martinelli
f66b0d57d1 print endpoints using new keystoneauth catalog object
cinderclient was assuming an identity v2 styled service catalog
would always be returned (when using `cinder endpoints`).

keystoneclient would return either a v2 or v3 styled catalog,
whereas keystoneauth abstracts out the differences and handles
them internally. the result is that there is no need to look
for specific ['serviceCatalog'] or ['catalog'] keys in the
dictionary returned from keystoneauth.

it should be noted that perhaps cinderclient should deprecate
the ability to list endpoints since that is mostly an identity
and admin level operation, and likely an artifact from early
openstack days, it should now be handled by openstackclient.
further, it's not clear whether the command is meant to list all
endpoints or just the endpoints in the user's token (which it does
now).

Change-Id: Ibfcccedee5baf43f5b5c517d37e3f046c8743078
Closes-Bug: 1608166
2016-07-30 21:06:16 -07:00
Dimitri Mazmanov
1a973235f0 Add tenant_id parameter to limits.
Cinder API allows specifying tenant_id to get tenant
specific resource usage. This was missing in the client.
This fix should allow fetching tenant specific resource usage
directly from the client. Added tenant argument to the limits CLI.

Closes-Bug: #1580562
Change-Id: I3fbd6341f6d018a79e7c343107ac974b6fbb9239
2016-07-29 12:41:44 +02:00
Ellen Leahy
2b0bd49b24 Changed backup-restore to accept backup name
Edited do_backup_restore function to accept the name of the backup
as well as its id. Changed the test to comply with this.

DocImpact

Closes-Bug: #1604892

Change-Id: Iaec69dd053a119366fa5a8437701a6f7c3da2235
2016-07-29 09:54:19 +01:00
Jenkins
3722a2a9d5 Merge "Support name option for volume restore" 2016-07-28 18:37:55 +00:00
Avishay Traeger
d24ba31afa List manageable volumes and snapshots
Cinder currently has the ability to take over the management of
existing volumes and snapshots ("manage existing") and to relinquish
management of volumes and snapshots ("unmanage"). The API to manage an
existing volume takes a reference, which is a driver-specific string
that is used to identify the volume on the storage backend.  This
patch adds the client code for APIs for listing volumes and snapshots
available for management to make this flow more user-friendly.

Change-Id: Icd81a77294d9190ac6dbaa7e7d35e4dedf45e49f
Implements: blueprint list-manage-existing
2016-07-19 18:57:09 -04:00
xing-yang
f7928c4058 Add support for group snapshots
This patch adds support for group snapshots.

Server side API patch was merged:
    https://review.openstack.org/#/c/361369/

Current microversion is 3.14. The following CLI's are supported:
cinder --os-volume-api-version 3.14 group-create-from-src
    --name my_group --group-snapshot <group snapshot uuid>
cinder --os-volume-api-version 3.14 group-create-from-src
    --name my_group --source-group <source group uuid>
cinder --os-volume-api-version 3.14 group-snapshot-create
    --name <name> <group uuid>
cinder --os-volume-api-version 3.14 group-snapshot-list
cinder --os-volume-api-version 3.14 group-snapshot-show
    <group snapshot uuid>
cinder --os-volume-api-version 3.14 group-snapshot-delete
    <group snapshot uuid>

Depends-on: I2e628968afcf058113e1f1aeb851570c7f0f3a08
Partial-Implements: blueprint generic-volume-group
Change-Id: I5c311fe5a6aeadd1d4fca60493f4295dc368944c
2016-07-19 16:35:45 -04:00
xing-yang
6c5a764c77 Add generic volume groups
This patch adds support to generic volume groups.

Server patch is here: https://review.openstack.org/#/c/322459/

Current microversion is 3.13. The following CLI's are supported:
cinder --os-volume-api-version 3.13 group-create --name my_group
    <group type uuid> <volume type uuid>
cinder --os-volume-api-version 3.13 group-list
cinder --os-volume-api-version 3.13 create --group-id <group uuid>
    --volume-type <volume type uuid> <size>
cinder --os-volume-api-version 3.13 group-update <group uuid>
    --name new_name  description new_description
    --add-volumes <uuid of volume to add>
    --remove-volumes <uuid of volume to remove>
cinder --os-volume-api-version 3.13 group-show <group uuid>
cinder --os-volume-api-version 3.13 group-delete
    --delete-volumes <group uuid>

Depends-on: I35157439071786872bc9976741c4ef75698f7cb7
Change-Id: Icff2d7385bde0a7c023c2ca38fffcd4bc5460af9
Partial-Implements: blueprint generic-volume-group
2016-07-19 00:37:36 -04:00
xing-yang
37ac58cc62 Add group types and group specs
This patch adds support for group types and group specs
in the client.

Server patch is merged: https://review.openstack.org/#/c/320165/

Current microversion is 3.11. The following CLI's are supported.
cinder --os-volume-api-version 3.11 group-type-create my_test_group
cinder --os-volume-api-version 3.11 group-type-list
cinder --os-volume-api-version 3.11 group-type-show my_test_group
cinder --os-volume-api-version 3.11 group-type-key my_test_group
    set test_key=test_val
cinder --os-volume-api-version 3.11 group-specs-list
cinder --os-volume-api-version 3.11 group-type-key my_test_group
    unset test_key
cinder --os-volume-api-version 3.11 group-type-update <group type uuid>
    --name "new_group" --description "my group type"
cinder --os-volume-api-version 3.11 group-type-delete new_group

Change-Id: I161a96aa53208e78146cb115d500fd6b2c42d046
Partial-Implements: blueprint generic-volume-group
2016-07-14 03:36:39 -04:00
scottda
09b51a294e Add api-version to get server versions
Mitaka Cinder added an API to return Versions from the base
endpoint URL:
http://<url>:8776/
This patch exposes that API for /v3 endpoint microversions 3.0 and
above with the command:
cinder api-version

Implements: blueprint add-get-server-versions

Change-Id: Ieb1a56b28188ec17946fe5564b28c165833ffc24
2016-07-11 10:44:12 -06:00
Jenkins
7d136caf48 Merge "Fix output error for type-show command" 2016-07-08 04:40:28 +00:00
Huanxuan Ao
724901e374 Fix output error for type-show command
Before this patch, the output of "extra_specs"
in type-show command is this:
| extra_specs | {u'Alpha': u'a'} |
Becuase the type of "extra_specs" is not a string
and need to use unicode_key_value_to_string()
method to change it to string.

This patch add formatters and call
unicode_key_value_to_string() mothod for
"extra_specs" and change the output to this:
| extra_specs | {'Alpha': 'a'} |

Change-Id: Ia2e2633068ce5b5e6622474b145a1d4f074fd551
Closes-Bug: #1589461
2016-07-07 22:37:33 +08:00
xiexs
e5e0a7ee49 Add strict Boolean checking
Because of lack of strict boolean checking, the unexpected
'False' value will always be send to server if invalid bool
value is specifed.
For instance:
  the parameter 'is-public' of cinder type-update,
  the parameter 'force' of cinder qos-delete
as so forth.

This patch tries to add a strict checking for them
to prevent invalid bool value.

Change-Id: I896ddbb6ec4760bfd4d721db960138e2df0b86e1
Closes-Bug: #1596418
2016-06-27 08:41:11 -04:00
Jenkins
63b3087c57 Merge "Fixing parsing problem of cascade in client" 2016-06-24 22:51:49 +00:00
Gorka Eguileor
25bc7e7402 Add cluster related commands
This patch updates client to support cluster related changes on the API
done on microversion 3.7.

Service listing will include "cluster_name" field and we have 4 new
commands, "cluster-list", "cluster-show", "cluster-enable" and
"cluster-disable".

Specs: https://review.openstack.org/327283
Implements: blueprint cinder-volume-active-active-support
Depends-On: If1ef3a80900ca6d117bf854ad3de142d93694adf
Change-Id: I824f46b876e21e552d9f0c5cd3e836f35ea31837
2016-06-21 19:02:15 +02:00
wanghao
86fe5617aa Fixing parsing problem of cascade in client
We have implemented cascade deleting volume in CLI now,
but there's still something that should be improved:

1. A parsing problem of cascade is existing that always
evaluate parameter to True.

So now change the cascade parameter to a flag that don't
accept value anymore.

If user want to delete volume with snapshot, just need to
use 'cinder delete --cascade [volume_id]'.

Change-Id: I92e9400d5d7fbb741607bdbde7ac0c0667fca85d
Closes-Bug: #1585441
Implements: blueprint support-deleting-vols-with-snps-in-cli
2016-06-16 07:20:58 +00:00
Mitsuhiro Tanino
df63cd03d5 Support name option for volume restore
Volume restore API supports name option to specify volume name
for new volume creation, but CLI doesn't support this option.
This change simply add name option for backup-restore command.

Change-Id: I22ccc303c86b958cb21862f718ef89f57234a027
Partial-Bug: #1539667
2016-06-02 17:10:27 -04:00
Jenkins
3d06d358ad Merge "Support for snapshot force delete" 2016-06-02 19:44:24 +00:00
wanghao
a3c5e06693 Volume detail support glance_metadata in CLI
Add supporting to allow list volumes
filtering by glance_metadata.

Cinder code has merged, support it in client.

Change-Id: Ifc2124b88c4199700d91a89c9fe68598630877db
Implements: blueprint support-volume-glance-metadata-query
2016-05-30 11:03:03 +08:00