Commit Graph

26 Commits

Author SHA1 Message Date
Alan Bishop 31b34e91e0 Remove the need for project_id from API endpoints
Inclusion of a project_id in API URLs is now optional, and no longer
required. Removing the project_id requirement facilitates supporting
Secure RBAC's notion of system scope, in which an API method is not
associated with a specific project.

The API v3 routing is enhanced to provide duplicate routes for API
methods that traditionally required a project_id in the URL:
- The existing route for which a project_id is in the URL
- A new route for when the URL does not include a project_id

To test both routes and ensure there are no regresssions, the "API
samples" functional tests include a project_id in the URLs, and the
rest of the functional tests do not include the project_id. This is
handled by changing the 'noauth' WSGI middleware to no longer add the
project_id, and adding a new 'noauth_include_project_id' middleware
filter that implements the legacy behavior.

A new microversion V3.67 is introduced, but it only serves to inform
clients whether the project_id is optional or required. When an API
node supports mv 3.67, the project_id is optional in all API requests,
even when the request specifies a earlier microversion. See the spec
Ia44f199243be8f862520d7923007e7182b32f67d for more details on this
behavior.

Note: Much of the groundwork for this is based on manila's patch
I5127e150e8a71e621890f30dba6720b3932cf583.

DocImpact
APIImpact

Implements: blueprint project-id-optional-in-urls
Change-Id: I3729cbe1902ab4dc335451d13ed921ec236fb8fd
2022-02-08 08:32:23 -08:00
Brian Rosmaita e05b261af7 Remove Block Storage API v2
In this patch:
- adjusted VersionsController to return only v3
- removed cinder.api.v2.router
- adjustments to cinder.tests.unit.api.contrib to use /v3 only
- moved cinder.api.v2.snapshot_metadata (and tests) to cinder.api.v3
- moved cinder.api.v2.types (and view, tests) to cinder.api.v3
- updated versions response in api-ref
- removed unnecessary config option
- updated various sample config files
- removed experimental tempest-cinder-v2-api job
- updated some docs
- updated non-voting rally job config

Some cinder.api.v2 modules are left because the v3 classes depend on
them, but with the v2 router removed, these are unreachable via the
/v2 path.

Depends-on: https://review.opendev.org/c/openstack/rally-openstack/+/794891
(changes rally to use Block Storage API v3)
Depends-on: https://review.opendev.org/c/openstack/requirements/+/794894
(corrects regression in upper-constraint on Sphinx)

Change-Id: I2093d77db9beec7543c7524d2cd273e79dd5fd5d
2021-06-04 17:21:28 -04:00
Rajat Dhasmana e63cb8548a Default type overrides
This patch adds a feature by which we allow setting default volume types
for projects.
The following changes are made to achieve the feature:

1) Add 4 set of APIs, set, get, get_all, unset volume type
2) All policies (except get_all) default to system/domain/project admin
3) Preference order: project default, conf default
4) Logic to not allow deletion of default type

We validate set, get and unset APIs with keystone to verify a valid
project id is passed in the request and user has proper authorization
rights to show the project.

The policies are system/domain/project admin by default except get_all
policy which defaults to system admin.

Implements: Blueprint multiple-default-volume-types

Change-Id: Idcc949ed6adbaea0c2337fac83014998b81ff1f8
2020-09-16 14:05:31 +00:00
zhufl 27afe71476 [Trivial fix]Remove unnecessary slash
This is to remove the unncessary slash when the line doesn't
exceed the length of 79, to make the code more readable.

Change-Id: I3fea5d24692be8b8575379aff7b75a5479f314ef
2019-05-06 13:56:27 +08:00
Sean McGinnis 5dd4a04f86
Correct volume-transfers API endpoint
Routing was set up to map to volume_transfers, but the cinder client and
other places expected it to be volume-transfer. The - is more correct
for API endpoints, and the client is currently in feature freeze, so
easiest way to correct this for this new feature is to update the
endpoint to the expected name.

Change-Id: Ib0002c441a2e860e8b74a4d9e6df890b398210f4
Closes-bug: #1785325
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2018-08-03 17:56:14 -05:00
wanghao c0efaa1d46 Transfer snapshots with volumes
This feature changes Cinder to transfer
snapshots with volumes at the same time by default.
If user doesn't want to transfer snapshots, they could use
a new optional argument '--no-snapshots' after microversion 3.55.
And we also introduce the new V3 api 'v3/volume_transfers'
to move this API out of contrib into Cinder V3 API.

The cinderclient patch: https://review.openstack.org/#/c/577611/

Change-Id: If848d131e5edcdb77d0b3c2ca45a99c4d5e14d1e
Implements: blueprint transfer-snps-with-vols
2018-07-19 09:42:43 +08:00
wangxiyuan 4a2448bd15 Add project_id admin filter to limits API
"cinder absolute-limits" command supports <tenant_id> filter,
But server side doesn't, this patch added the support for server
side.

APIImpact

Closes-bug: #1668416
Change-Id: Ib31ab87d0954c2bedf55c6d71623b2c7d07b5fa7
2017-06-18 18:15:35 +08:00
TommyLike 8fcb809509 Add 'resource_filters' API to support generalized filtering
This patch adds ``resource_filters`` API to retrieve
configured resource filters.

APIImpact

Partial: blueprint generalized-filtering-for-cinder-list-resource
Depends-On: ff3d41b15a

Change-Id: I387268b277c46c72624a3d3b5eabf03724a7a847
2017-05-20 10:33:21 +08:00
John Griffith 22e6998868 Add new attachment APIS
Replaces the original patch:
  https://review.openstack.org/#/c/387712/

Use the python-cinderclient WIP:
  https://review.openstack.org/#/c/387716/

Here's what you can do currently:
  `cinder attachment-create <volume-uuid>`
      Currently only tested/implemented the reserve piece
      Will create an attachment object, set volume to a
      status of 'reserved'
  `cinder attachment-list`
      Simple list output of attachments
  `cinder attachment-show <attachment-uuid>`
      Detailed list of specified attachment
  `cinder attachment-delete <attachment-uuid>`
      Removes an attachment

Change-Id: Ie15233c99d91de67279b56d27a5508c5ea98d769
2017-01-20 11:47:10 -07:00
Gorka Eguileor efa8e210c9 Allow triggering cleanup from API
Now that we support having multiple c-vol services using the same
storage backend under one cluster, they no longer clean all resources
from the backend with ongoing statuses in the DB, only those from their
own host because those are failed operations that were left "in the air"
when the service was stopped.  So we need a way to trigger the cleanup
of resources that were being processed by another c-vol service that
failed in the same cluster.

This patch adds a new API endpoint (/workers/cleanup) that will trigger
cleanup for c-vol services as microversion 3.19.

The cleanup will be performed by other services that share the same
cluster, so at least one of them must be up to be able to do the
cleanup.

Cleanup cannot be triggered during a cloud upgrade, but a restarted
service will still cleanup it's own resources during an upgrade.

If no arguments are provided cleanup will try to issue a clean message
for all nodes that are down, but we can restrict which nodes we want to
be cleaned using parameters `service_id`, `cluster_name`, `host`,
`binary`, and `disabled`.

Cleaning specific resources is also possible using `resource_type` and
`resource_id` parameters.

We can even force cleanup on nodes that are up with `is_up`, but that's
not recommended and should only used if you know what you are doing.
For example if you know a specific cinder-volume is down even though
it's still not being reported as down when listing the services and you
know the cluster has at least another service to do the cleanup.

API will return a dictionary with 2 lists, one with services that have
been issued a cleanup request (`cleaning` key) and another list with
services that cannot be cleaned right now because there is no
alternative service to do the cleanup in that cluster (`unavailable`
key).

Data returned for each service element in these two lists consist of the
`id`, `host`, `binary`, and `cluster_name`.  These are not the services
that will be performing the cleanup, but the services that will be
cleaned up or couldn't be cleaned up.

Specs: https://specs.openstack.org/openstack/cinder-specs/specs/newton/ha-aa-cleanup.html

APIImpact: New /workers/cleanup entry
Implements: blueprint cinder-volume-active-active-support
Change-Id: If336b6569b171846954ed6eb73f5a4314c6c7e2e
2017-01-13 14:34:45 +01:00
TommyLike 304ff4c23d [2/4]Reset group snapshot status
Currently the administrator could only reset the group snapshot
status by db operation, this change intends to add new admin
action to achieve this.

The patch list:
    1. group API(https://review.openstack.org/#/c/389091/).
    2. group snapshot API(this).
    3. cinder client(https://review.openstack.org/390169/).
    4. documentation(https://review.openstack.org/#/c/395464/).

APIImpact
DocImpact
Partial-Implements: blueprint reset-cg-and-cgs-status

Change-Id: I9e3a26950c435038cf40bea4b27aea1bd5049e95
2016-12-22 11:11:02 +08:00
TommyLike 842d17f63e Fix condition parameter bug in routes
'Mapper.connect' use 'method' as condition parameter not
'action' [1], this patch tries to fix this.

[1] https://routes.readthedocs.io/en/latest/setting_up.html#conditions

Change-Id: I5eda9a8a61b3a9b349f8153d70aaa490fac3844e
2016-12-14 11:36:22 +08:00
Yuriy Nesenenko 54ae45264e Deleting volume metadata keys with a single request
Deleting multiple volume metadata keys with a single request to
improve performance. This patch uses etags to avoid the lost update
problem with volume metadata. To inject the response's `Etag` header
the index method returns webob.Response object with this tag.

APIImpact
Related blueprint: delete-multiple-metadata-keys
Change-Id: I575635258c10f299181b8e4cdb51a7ad1f1be764
2016-09-01 02:31:15 +03:00
xing-yang 708b9be9c0 Add group snapshots - APIs
This is the fifth patch that implements the generic-volume-group
bluerpint. It adds APIs for group snapshots and create group
from source.

This patch depends on the fourth patch which implements group
snapshots support in the volume manager:
    https://review.openstack.org/#/c/361376/

Client side patch is here:
    https://review.openstack.org/#/c/329770/

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>

APIImpact
DocImpact
Partial-Implements: blueprint generic-volume-group

Change-Id: I2e628968afcf058113e1f1aeb851570c7f0f3a08
2016-07-19 11:27:15 -04:00
xing-yang 8c74c74695 Add generic volume groups
This is the second patch that implements the generic-volume-group
bluerpint. It adds the groups table and introduces create/delete/
update/list/show APIs for groups.

It depends on the first patch which adds group types and group specs:
    https://review.openstack.org/#/c/320165/

Client side patch is here:
    https://review.openstack.org/#/c/322627/

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>

APIImpact
DocImpact
Change-Id: I35157439071786872bc9976741c4ef75698f7cb7
Partial-Implements: blueprint generic-volume-group
2016-07-16 19:34:39 -04:00
Satish Venkatasubramanian 3db21d003f Add volumes/summary API support
Add a new API to display volumes summary with total number of volumes
and total size in GB (total_size: 500 and total_count: 20).

DocImpact
APIImpact
Partially-Implements: blueprint display-volumes-summary-details

Co-Authored-By: MR Swami Reddy <swamireddy@gmail.com>

Change-Id: I0117a233afbd834a165ade9e1358f8dd38fbcfac
2016-08-15 05:30:04 +05:30
xing-yang 8cf9786e00 Add group type and group specs
This patch adds support for group types and group specs.
This is the first patch to implement the blueprint
generic-volume-group.

The client side patch is here:
https://review.openstack.org/#/c/320157/

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

APIImpact
DocImpact
Change-Id: I38b938782e0c3b2df624f975bd07e0b81684c888
Partial-Implements: blueprint generic-volume-group
2016-07-08 14:26:39 -04:00
lisali c5ebe48b8e Add backup update function (microversion)
Add update interface so that users can update
name and description of a backup.

This new API endpoint is added in microversion 3.9.

APIImpact
Add PUT to /backups/<id>.

DocImpact

Change-Id: If592b53c7e1dcdc36dbcaa89425b8e44a51684c3
2016-07-28 09:57:25 +00:00
Avishay Traeger 0b0000f8fc Map volume/snapshot manage extensions to v3
Create routes for the resources in the volume_manage and snapshot_manage
extensions in v3, and bump the microversion.

APIImpact
DocImpact
Implements: blueprint list-manage-existing
Change-Id: Ia0df241a43f41cac4248efffc0b9828032daf63a
2016-07-26 15:50:27 +03:00
Gorka Eguileor 8b713e5327 Modify API to include cluster related operations
This patch adds new API /cluster that allows summary and detailed
listings, show and update operations.

It also updates service listings to return cluster_name for each
service.

DocImpact: 3 new policies have been added for cluster, "get", "get_all" and
           "update".
APIImpact: Return cluster_name in service listings and add /cluster endpoint.
Specs: https://review.openstack.org/327283
Implements: blueprint cinder-volume-active-active-support
Change-Id: If1ef3a80900ca6d117bf854ad3de142d93694adf
2016-07-22 21:00:12 +02:00
lisali 1a0dd6be5a Fix consisgroup V3 interfaces
The consisgroup list/show etc interfaces are blocked in V3 API,
this patch is to fix it.

Change-Id: I428a661a12d1020ed844f55021a94bbf61c79169
Closes-Bug: #1597223
2016-07-04 16:21:44 +08:00
haobing1 e22c244106 Allow setting CG name or description to empty value
This change allow API user to remove the consistency group name
or description information.
If user use the `cinder consisgroup-update consisgroup-id --name ''`
or `cinder consisgroup-update consisgroup-id --description ''`
to update the consisgroup's name or description information,
the consisgroup's name or description information will be removed.

APIImpact

Change-Id: I0d661775994d6de580f8788397f0e91e90148edd
Closes-Bug: #1572986
2016-06-17 12:24:52 +08:00
Zhihai Song e33d6bfb0b Remove unused logging import and LOG global var
In some modules the global LOG is not used any more. And the import
of logging is not used. This patch removes the unused logging import
and LOG vars.

Co-Authored-By: ChangBo Guo(gcb) <eric.guo@easystack.cn>
Change-Id: Ia72f99688ce00aeecca9239f9ef123611259a2fa
2016-05-20 17:17:38 +08:00
Alex Meade 53cfde43b8 User messages API for error cases
This patch implements basic user messages with the following APIs.
GET /messages
GET /messages/<message_id>
DELETE /messages/<message_id>

Implements : blueprint summarymessage

Co-Authored-By: Alex Meade <mr.alex.meade@gmail.com>
Co-Authored-By: Sheel Rana <ranasheel2000@gmail.com>

Change-Id: Id8a4a700c1159be24b15056f401a2ea77804d0a0
2016-04-29 18:41:10 +00:00
Sheel Rana 0b6c68a8c1 Microversion of Bootable filter in cinder list
Currently cinder treats all non zero values passed to it
as True for bootable filter in volume GET call.
For ex, if bootable=invalid, it converts it into True being
bootable as boolean value in db table 'volume'.

Need to update filtering functionality in cinder to address
'True' and 'False' values separately and raise exception if
anything than True/False/true/false/0/1 is passed in this filter.

But as this will change the API behavior, microversioning is done
for this fix.

Closes-Bug: #1551535

Change-Id: Idd57014c1504eb4fc9ea0eabe894d2000ea9c364
2016-04-21 15:17:15 +00:00
scottda 6b11d276d1 cinder-api-microversions code
Many changes to the Cinder REST API require changes to the consumers of the API.
For example, If we need to add a required parameter to a method that is called
 by Nova, we'd need both the Nova calling code and the cinderclient that
Nova uses to change. But newer Cinder versions with the change must work with
older Nova versions, and there is no mechanism for this at the moment. Adding
microversions will solve this problem.
With microversions, the highest supported version will be negotiated by a field
in the HTTP header that is sent to the Cinder API. In the case where the field
'versions' is not sent (i.e. clients and scripts that pre-date this change),
then the lowest supported version would be used. In order to ensure that the
API consumer is explicitly asking for a microversioned API, a new endpoint v3
is added, which is identical to API version v2. This means that our new
Cinder API v3 would be the default, and consumers of the API that wished to
use a newer version could do so by using that endpoint and a microversion in
the HTTP header.
New tests for microversioned API features on endpoint /v3 should be added to
cinder/tests/unit/api/v3/ directory. Existing functionality will be tested via
the .../v2/ unit tests.

DocImpact
APIImpact
Implements: https://blueprints.launchpad.net/cinder/+spec/cinder-api-microversions
Change-Id: I48cdbbc900c2805e59ee9aebc3b1c64aed3212ae
2016-02-24 06:50:54 -07:00