Commit Graph

52 Commits

Author SHA1 Message Date
Konrad Gube 2a1a0bc3e2 Add the os-extend_volume_completion volume action
Split off the finalization part of the volume manager's
extend_volume method and make it externally callable as the new
os-extend_volume_completion admin volume action.

This is the first part of a feature that will allow volume drivers
to rely on feedback from Nova when extending attached volumes,
allowing e.g. NFS-based drivers to support online extend.

See the linked blueprint for details.

Implements: bp extend-volume-completion-action
Change-Id: I4aaa5da1ad67a948102c498483de318bd245d86b
2024-02-16 18:14:33 +01:00
Gorka Eguileor 6df1839bdf Reject unsafe delete attachment calls
Due to how the Linux SCSI kernel driver works there are some storage
systems, such as iSCSI with shared targets, where a normal user can
access other projects' volume data connected to the same compute host
using the attachments REST API.

This affects both single and multi-pathed connections.

To prevent users from doing this, unintentionally or maliciously,
cinder-api will now reject some delete attachment requests that are
deemed unsafe.

Cinder will process the delete attachment request normally in the
following cases:

- The request comes from an OpenStack service that is sending the
  service token that has one of the roles in `service_token_roles`.
- Attachment doesn't have an instance_uuid value
- The instance for the attachment doesn't exist in Nova
- According to Nova the volume is not connected to the instance
- Nova is not using this attachment record

There are 3 operations in the actions REST API endpoint that can be used
for an attack:

- `os-terminate_connection`: Terminate volume attachment
- `os-detach`: Detach a volume
- `os-force_detach`: Force detach a volume

In this endpoint we just won't allow most requests not coming from a
service. The rules we apply are the same as for attachment delete
explained earlier, but in this case we may not have the attachment id
and be more restrictive.  This should not be a problem for normal
operations because:

- Cinder backup doesn't use the REST API but RPC calls via RabbitMQ
- Glance doesn't use this interface anymore

Checking whether it's a service or not is done at the cinder-api level
by checking that the service user that made the call has at least one of
the roles in the `service_token_roles` configuration. These roles are
retrieved from keystone by the keystone middleware using the value of
the "X-Service-Token" header.

If Cinder is configured with `service_token_roles_required = true` and
an attacker provides non-service valid credentials the service will
return a 401 error, otherwise it'll return 409 as if a normal user had
made the call without the service token.

Closes-Bug: #2004555
Change-Id: I612905a1bf4a1706cce913c0d8a6df7a240d599a
2023-05-10 19:51:33 +02:00
Yikun Jiang d69e89ea3b Support volume re-image
This patch adds volume re-image API to enable the ability to
re-image a specific volume.

Implements: blueprint add-volume-re-image-api

Co-Authored-by: Rajat Dhasmana <rajatdhasmana@gmail.com>

Change-Id: I031aae50ee82198648f46c503bba04c6e231bbe5
2022-02-24 15:23:38 +05:30
Brian Rosmaita de8b3b0b00 Reject bad img formats for uploaded encrypted vols
Cinder only supports uploading volumes of encrypted volume types as
images with disk format 'raw' and container format 'bare'.  Screen
for this at the REST API layer when the request is made.

Change-Id: Ibb77b8b1be6c35c5db3b07fdc4056afd51d48782
Closes-bug: #1935688
2021-07-09 14:51:51 -04:00
Sofia Enriquez 09ad89b7ee Doc note warning about retyping unencrypted/encrypted volume
As suggested in 662b8210aa and
discussed at Victoria PTG[1] it would be nice to have a notes
warning users to don’t try this.

[1] https://wiki.openstack.org/wiki/CinderVictoriaPTGSummary#Sizing_encrypted_volumes

Change-Id: I3fd514126dbdf56d4d4d8e423e98e462238c683f
Partial-Bug: #1687880
2020-08-06 18:13:24 +00:00
vinay_m 780a23b4a2 cinder:api-ref replace mention of "policy.json"
As end user can use either of "policy.json" or "policy.yaml" , so need
replace the mentioning of "policy.json" to the just "policy
configuration file" in api-ref.

Change-Id: Ibb8f56a89d3f188be18cc4ee7de493910a02fb98
Closes-Bug: #1875643
2020-07-07 20:55:09 +05:30
Zuul 9df7837ea7 Merge "Automate generation of volume actions api-ref samples" 2019-03-16 19:34:27 +00:00
Zuul 019d1e9dd6 Merge "[api-ref] Fix the parameter of image metadata" 2019-02-28 16:58:09 +00:00
Zuul 77c6f1010c Merge "Doc8: Stop skipping D001: Line too long" 2019-02-23 22:39:37 +00:00
Lee Yarwood 71ca8578be docs: Add os-migrate_volume_completion api-ref
This admin API is only called externally by Nova at present when
finishing the migration or retype of an attached volume. However for
future reference it would be really useful to have this listed in the
official API reference guide.

Change-Id: I5fad6eb4903784870aa26fa0996a391bbbbb9276
2019-02-20 11:40:30 +00:00
Sean McGinnis d5b539be36
Doc8: Stop skipping D001: Line too long
This cleans up the cases where we had D001 violations so we can stop
skipping that check in doc8 runs.

Change-Id: Ie52f6ecac1a645fcbcc643b9ca63e033b622d830
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2019-02-19 16:51:56 -06:00
whoami-rajat 15d1a00a57 Automate generation of volume actions api-ref samples
This patch adds the following tests:

1) Volume actions
2) Volume manage extensions

Change-Id: I7f27a336a6735f4d346cc47c983dfee55f47f55d
Partially-Implements: blueprint generating-sample-files
2019-02-08 01:13:03 +05:30
Zuul 7ac5101d1d Merge "api-ref: add response body for set-image-metadata-for-a-volume" 2019-01-24 11:17:25 +00:00
liuyamin c119ab87b9 [api-ref] Fix the parameter of image metadata
The value of os-vol-image-meta is not in parameters.yaml, so use
os-show_image_metadata to replace it.

Change-Id: I0400a1bf8dbe34f4b857e62832d11b098a8a2d2f
2018-12-25 10:29:30 +08:00
zhufl eb10e43782 api-ref: add response body for set-image-metadata-for-a-volume
https://developer.openstack.org/api-ref/block-storage/v3/index.html?expanded=set-image-metadata-for-a-volume-detail#set-image-metadata-for-a-volume
"Set image metadata for a volume" interface has response body,
so this is to add response parameter and response example for it.

Change-Id: I8139fd557cb3123dd71ab104e7e36546b862e345
2018-12-10 10:19:17 +08:00
Yikun Jiang 892e402c8e [Doc] Fix status and parameters of vol connection api
The response 'status' of initialize connection is 200, and the
"connector" parameter is required in initialize/terminate connection
API request.

This patch try to fix these wrong content.

Change-Id: I9d8c7c951b03f10fa29e3b3cc107a17e37b0e2bc
2018-11-23 03:29:00 +00:00
whoami-rajat 609412fcd2 Improve/Clean api-ref parameters
The parameters with name like example_1, example_2 ... etc. cause
confusion while updating the api-ref docs like the examples below:

https://review.openstack.org/#/c/609639/
https://review.openstack.org/#/c/609611/

This patch does the following changes :
1) Replace numbering in the parameter with relevant names
2) Clean up unused parameters

Change-Id: I35b343bf068281d729576e5ecc209bda60c28680
2018-11-05 10:47:14 +05:30
Matt Riedemann 76cc9bd02b api-ref: add docs for os-migrate_volume API
Adds the v2 and v3 API reference documentation for the
admin-only (by default) os-migrate_volume volume action
API. The only major difference with the v3 API is the
cluster parameter introduced in the 3.16 microversion.

Change-Id: I70f6b2cc4d25ea155ce09ddeec26b995890a2db3
Partial-Bug: #1607539
2018-08-22 20:38:22 -04:00
Dongcan Ye cb0cb208e3 api-ref: Adds os-update_readonly_flag API
This patch adds "os-update_readonly_flag" volume action API.

Change-Id: Idad24f9a17af3323a26ed487f1f0d20306bf935f
Closes-Bug: #1775915
Closes-Bug: #1771390
2018-06-21 04:38:16 +00:00
Zuul 9a7b250606 Merge "[api-ref] Fix the parameter metadata in v3" 2018-06-12 14:06:56 +00:00
liuyamin 45f954d894 [api-ref] Fix the parameter metadata in v3
Change-Id: I5dffe060d73f700de6cd29101127e205362e203d
2018-06-11 16:02:58 +08:00
liuyamin cfcd94bc9a Add missing volume APIs
A bunch of volume APIs are missing in current documentation, such
as os-reserve/os-unreserve/os-begin_detaching/os-roll_detaching
os-initialize_connection/os-terminate_connection, this patch is aim to
add the missing APIs.

Change-Id: If0732aa94db4e8cdef30a2be0c53314b507ee002
Closes-bug: #1761049
2018-05-15 20:15:49 +08:00
Sean McGinnis a96fad9f3b Fix api-ref response code title levels
Using the wrong character resulted in the wrong title level
being used for the response codes, which in turn caused the
"detail" show/hide toggle to not be able to hide all of the
per-endpoint details. This corrects these to be at the correct
level.

Also ran into issues after changing them where sphinx was not
happy with the random title levels. This appears to be due to
the order processed and whether not earlier included files had
all subsequent levels. Adding an additional title in our first
included file resolved that problem.

Change-Id: I19405778980310f2d6d06eb7b23102f74a3d6e03
Closes-bug: #1755566
2018-03-13 15:57:54 -05:00
Sean McGinnis 2e5a91da72 Use rest_status_code for api-ref response codes
Rather than our freeform way of listing response codes in our
api-ref, we should be using the os-api-ref extension option to
get nicely formatted response code listings.

https://docs.openstack.org/os-api-ref/latest/usage.html#rest-status-code

Change-Id: Iee21f54fe7cf0ea28258966e2d0f8fa2849c83f2
2018-03-08 21:59:37 -06:00
liuyamin bd9bd9612f [api-ref] Fix 'volume_id' for in the v3/volumes-v3-volumes-actions.inc
The 'volume_id' in "Revert volume to snapshot" shoud be in the path.
So fix the paremeter.

Change-Id: Ia3e791f82f11740533e4320d546cb0cd67942712
2018-03-05 17:46:36 +08:00
Matt Riedemann d9a32fd7bf api-ref: note that force detach is admin-only by default
I had to dig into the code to figure out that the force
detach volume action was for admins by default. We should
make that clear in the API reference.

Change-Id: I3493e23dba8267fb7e403d30dd0d1e90c8f7726b
2018-02-15 09:21:04 -05:00
Matt Riedemann 2e1d31a44a api-ref: add multiattach considerations to retype docs
This adds some notes about two things to consider with a volume
retype operation on an in-use multiattach volume:

1. The volume API will reject a retype operation on an in-use volume
   where the volume's multiattach value would change.

2. Retyping an in-use volume that has more than one active read/write
   attachment is not recommended because on the nova side the swap
   volume operation performs a blockRebase which could potentially
   lead to data corruption.

In the future, we (nova or cinder or both) will likely need to make
some changes as to what the default attach_mode is for secondary
attachments to a multiattach volume, since today we default to read/write
if it's not specified by the caller when making the attachment.

Change-Id: Ib5a2830ea3cd37236947677225252ef42edaa347
2018-01-25 13:48:05 -05:00
Rui Yuan Dou 320096f0ca Add microversion and volume status limit to revert api ref doc
Change-Id: I55ca72cd26e4ae1ec9428c5785af49c5b6471b4b
2017-12-22 14:59:09 +08:00
Xiaojun Liao be3ed99428 Keep v3 api-ref error response code 404 for reverting
Client can still receive the 404/NotFound when attempting
the fetch of the volume.

Change-Id: Ieafaae5ccb5a23b4d3ad37b8e7eee40484346cfc
Signed-off-by: Xiaojun Liao <xiaojunliao85@gmail.com>
2017-12-13 11:04:45 +08:00
Xiaojun Liao 7241a8ee52 Modify v3 api-ref error response codes for reverting
Change-Id: Id20000e483246b96d2dd478b041a56c2b1e119ff
Signed-off-by: Xiaojun Liao <xiaojunliao85@gmail.com>
2017-12-12 08:55:21 +08:00
Sean McGinnis fffdac20c2 api-ref: Make v3 enclosing objects consistent
Some request details provided information about the other
JSON value while others didn't. To make things consistent
and to make sure API consumers understand how the requests
need to be structured, this adds missing instances. It also
reorders some parameter lists to be a little more logical,
so even though we can't show the nested nature of some of
these, it at least doesn't show inner values before outer
ones.

This also corrects many errors seen while going through
the API ref. This is by no means exhaustive, and is already
somewhat out of the scope for this patch, so it is expected
that there are some (many) cases that are not addressed by
this patch. Those will be fixed with ongoing effort in
future patches.

Partial-bug: #1713517
Change-Id: I30964ba8d829778fd01174d639d44ba07e4b77a6
2017-09-01 09:54:34 -05:00
TommyLike 663c4e383f Correct 'os-show_image_metadata' API document
The 'os-show_image_metadata' API is outdated.
Rewrite the document, also correct the response
codes for image metadata's create/delete APIs.

Change-Id: I50a5b3571973564b8b5010b412d94303866e8dcd
2017-08-02 08:55:46 +08:00
Mathieu Gagné 3dd842de82 Add ability to extend 'in-use' volume
This change adds the ability to extend 'in-use' volume.

Once the volume size is extended, Nova is informed of the size change
through the external-event extension so the virt driver can perform
the appropriate actions for the host and guest to detect the new volume size.

Tempest related patches:

1. https://review.openstack.org/#/c/480746/
2. https://review.openstack.org/#/c/480778/

Depends-On: If10cffd0dc4c9879f6754ce39bee5fae1d04f474

Blueprint: extend-attached-volume
Co-Authored-By: TommyLike <tommylikehu@gmail.com>
APIImpact
Change-Id: I60c8ea9eb0bbcfe41f5f0a30ed8dc67bdcab3ebc
2017-07-12 11:48:32 -04:00
wangxiyuan a8b353e923 Api-ref: Add upload-to-image api-ref
The upload-to-image action for volume action is missing.

Closes-bug: #1566069
Change-Id: I3db7fe7fcca4936f35e0bb260d2d82ef6fbe6028
2017-06-29 09:19:10 +08:00
TommyLike 8fba9a9080 Cinder volume revert to snapshot
This patch implements the spec of reverting volume to
latest snapshot.
Related tempest and client patches:

[1] https://review.openstack.org/#/c/463906/
[2] https://review.openstack.org/#/c/464903/

APIImpact
DocImpact
Partial-Implements: blueprint revert-volume-to-snapshot

Change-Id: Ib20d749c2118c350b5fa0361ed1811296d518a17
2017-06-21 10:35:32 +08:00
Matt Riedemann 622a0ff424 api-ref: clarify retype docs around default policy permissions
Cinder's default policy allows the owner of a volume to initiate
a retype, even if they aren't an admin. However, if the volume
is going to be migrated during the retype operation, then Cinder
is going to call the Nova swap volume API, which by default is
admin-only. So if a non-admin user tries to retype and migrate
their volume, which is attached to a server instance, then it's
going to fail with a 403 error from Nova.

En lieu of a more complete solution, like Cinder using an
elevated service token to call Nova, this change just attempts
to document the restriction in the API reference.

Change-Id: I6282a6d319beead979780a33880947987906c2f3
Related-Bug: #1698224
2017-06-15 18:19:46 -04:00
luqitao e9acdab687 [api-ref]Adds API documentation for 'os-set_bootable' action
There is no document about update a volume's bootable status,
so add the missing doc.

Change-Id: If706205678cfd7a803e2d7733bec34494b47fc66
Partial-Bug: #1607539
2017-06-04 07:44:47 -04:00
Vu Cong Tuan 7404ba21b8 Trivial fix typos
Change-Id: Icd38d004eb89f1902365d71d64aa34a65eee9d37
2017-06-01 09:25:28 +07:00
Jenkins e4bf29c88f Merge "Fix incorrect volume_id request description in api-ref" 2017-05-22 16:22:39 +00:00
liuyamin 238a16a8a6 Add API documentation for force-delete volume in v2 and v3.
There is no API doc found for force-delete volume in cinder.
We need to add the API doc for the operation with its description,
request and response parameters.

Change-Id: Id25b4070a3946d2d7d89f44bdc81039286a5d8fe
Closes-bug: #1673644
2017-05-19 15:52:17 +08:00
wanghao 0b675b0438 Add missing retype API documentation
Now retype is missing in v2/v3 API documentation.
Add it in doc.

Change-Id: I2ba0d7b993a5b3e21c396ed3d0862808e0daf0b3
Closes-Bug: #1603293
2017-05-18 11:47:20 +08:00
wanghao 7e17004018 Fix incorrect volume_id request description in api-ref
Now some API documents for volume actions like
extending volume(https://developer.openstack.org/api-ref/
block-storage/v3/?expanded=extend-a-volume-size-detail) are
using incorrect request argument description
'volume_id in body'.

It should be 'in path'.

Change-Id: I2006b4af4dfc09fb0403c1a78ecef4ac920a51c4
Closes-Bug: #1691358
2017-05-17 14:41:51 +08:00
Jenkins bb9692cb2c Merge "Add missing and incorrect response and error codes in cinder api-ref" 2017-04-11 04:15:55 +00:00
Matt Riedemann b3400efd96 api-ref: Fix volume_id parameter for the path
When the volume_id is in the path for an API, it is
required. This fixes the volume_id_1 parameter for the
path argument by making it required and also renaming
it to be more clear of what it's used for. And finally,
this fixes the os-attach parameter to indicate volume_id
is in the path and is required, not optional.

Change-Id: I0e8868d35b5ea06ef809c896f943d92ad8e71e3e
2017-03-23 13:02:52 -04:00
wangzhenyu f242907f01 Add missing and incorrect response and error codes in cinder api-ref
Closes-bug: 1674161

Change-Id: I963f0aa7de6c3df95c1341cac15da178032db1d3
2017-03-20 14:52:24 +00:00
wangzhenyu 92a90efaf8 Add API documentation for volume detach in v3.
Change-Id: Id8211478bf093b28ea568f741c6e8b34f3696e0c
Closes-Bug: #1671372
2017-03-15 07:15:02 +08:00
Nicholas Jones aa9cabdb42 Fix Block Storage API reference nesting
Modifies heading levels in .inc files to allow nested display in
table of contents. Table of contents depth has been changed to allow
this.

Change-Id: I3d8c9cf38a12272f0d32d3aa183d741277767535
2017-02-09 08:37:27 -06:00
Jenkins 49ee50c6f6 Merge "[api-ref]Change tenant to project" 2017-02-05 22:26:37 +00:00
wangxiyuan 144ddd5a4c [api-ref]Change tenant to project
Keystone API v2 was deprecated in Mitaka and uses "project"
instead of "tenant" in V3 now.

This patch change the "tenant" to "project" in Cinder API v3 doc.

Change-Id: I06d400f3e38d78014e9eae89b29b075adaecffe4
2017-01-26 23:18:32 +08:00
Gorka Eguileor bc7c001d76 Fix api-ref status parameter
In the api ref most of our references to the status parameter are wrong,
since they are all referencing `status`, which in most cases is:

 status:
   description: |
     The ``status`` of the consistency group snapshot.

This patch fixes this by referencing the right status parameter.

TrivialFix

Change-Id: I3f76ad10bacd8c75f742efc3ff3395a7effc31b5
2017-01-26 13:28:42 +01:00