Remove stubs from VolumeAttachmentsSample API sample test
The amount of DB and compute service stubbing in these functional tests is pretty gross and makes it harder to maintain/extend them for new microversions which makes it harder for new contributors to work with these kinds of tests. This removes the stubs and uses the CinderFixture. The only new stub is dealing with detaching a volume with a device tag since the fake driver does not track device metadata on instances. The API reference doc samples are regenerated using: tox -e api-samples VolumeAttachmentsSample Change-Id: I04bca162c3a1d4fed7056385dfdca72c07bab9a5
This commit is contained in:
parent
c51187ab5b
commit
df28420760
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"device": "/dev/vdd"
|
"device": "/dev/sdb"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/vdd",
|
"device": "/dev/sdb",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"serverId": "0c92f3f6-c253-4c9b-bd43-e880a8d2eb0a",
|
"serverId": "802db873-0373-4bdd-a433-d272a539ba18",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,10 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachments": [
|
"volumeAttachments": [
|
||||||
{
|
{
|
||||||
"device": "/dev/sdd",
|
"device": "/dev/sdb",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"serverId": "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
|
"serverId": "fd5bb1c4-de31-4071-8472-9410bc9155ec",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "/dev/sdc",
|
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
|
||||||
"serverId": "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
|
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f805"
|
"volumeId": "227cc671-f30b-4488-96fd-7d0bf13648d8"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"tag": "foo"
|
"tag": "foo"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/vdd",
|
"device": "/dev/sdb",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"serverId": "189dc814-35bc-428b-bba4-8d5ac0d1e087",
|
"serverId": "69d19439-fa5f-4d6e-8b78-1868e7eb93a5",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,10 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachments": [
|
"volumeAttachments": [
|
||||||
{
|
{
|
||||||
"device": "/dev/sdd",
|
"device": "/dev/sdb",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"serverId": "4bcb3ae6-68aa-4e89-aac3-97b3dac2f714",
|
"serverId": "1b92ff87-0116-40f5-9087-f4b907aeeaf1",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "/dev/sdc",
|
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
|
||||||
"serverId": "4bcb3ae6-68aa-4e89-aac3-97b3dac2f714",
|
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f805"
|
"volumeId": "227cc671-f30b-4488-96fd-7d0bf13648d8"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/sdd",
|
"device": "/dev/sdb",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"serverId": "3dc0a2a6-e1bb-4643-8b6f-c146684d676d",
|
"serverId": "9ad0352c-48ff-4290-9db8-3385a676f035",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"tag": "foo"
|
"tag": "foo"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/vdd",
|
"device": "/dev/sdb",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"serverId": "521b9e49-4855-4a9a-8474-759a86c1b12d",
|
"serverId": "70f5c62a-972d-4a8b-abcf-e1375ca7f8c0",
|
||||||
"tag": "foo",
|
"tag": "foo",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,18 +1,11 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachments": [
|
"volumeAttachments": [
|
||||||
{
|
{
|
||||||
"device": "/dev/sdd",
|
"device": "/dev/sdb",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"serverId": "fb6077e6-c10d-4e81-87fa-cb0f8c103051",
|
"serverId": "297155de-f7f2-4e87-82d0-ccc7d225d491",
|
||||||
"tag": "foo",
|
"tag": "foo",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "/dev/sdc",
|
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
|
||||||
"serverId": "fb6077e6-c10d-4e81-87fa-cb0f8c103051",
|
|
||||||
"tag": null,
|
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f805"
|
"volumeId": "227cc671-f30b-4488-96fd-7d0bf13648d8"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/sdd",
|
"device": "/dev/sdb",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"serverId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"serverId": "d989feee-002d-40f6-b47d-f0dbee48bbc1",
|
||||||
"tag": "foo",
|
"tag": "foo",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"tag": "foo",
|
"tag": "foo",
|
||||||
"delete_on_termination": true
|
"delete_on_termination": true
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/vdd",
|
"delete_on_termination": true,
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"device": "/dev/sdb",
|
||||||
"serverId": "521b9e49-4855-4a9a-8474-759a86c1b12d",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
|
"serverId": "09b3b9d1-b8c5-48e1-841d-62c3ef967a88",
|
||||||
"tag": "foo",
|
"tag": "foo",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
"delete_on_termination": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,20 +1,12 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachments": [
|
"volumeAttachments": [
|
||||||
{
|
{
|
||||||
"device": "/dev/sdd",
|
"delete_on_termination": true,
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"device": "/dev/sdb",
|
||||||
"serverId": "fb6077e6-c10d-4e81-87fa-cb0f8c103051",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
|
"serverId": "09b3b9d1-b8c5-48e1-841d-62c3ef967a88",
|
||||||
"tag": "foo",
|
"tag": "foo",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
"delete_on_termination": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "/dev/sdc",
|
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
|
||||||
"serverId": "fb6077e6-c10d-4e81-87fa-cb0f8c103051",
|
|
||||||
"tag": null,
|
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
|
||||||
"delete_on_termination": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f805"
|
"volumeId": "227cc671-f30b-4488-96fd-7d0bf13648d8"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/sdd",
|
"delete_on_termination": true,
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"device": "/dev/sdb",
|
||||||
"serverId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
|
"serverId": "2aad99d3-7aa4-41e9-b4e6-3f960b115d68",
|
||||||
"tag": "foo",
|
"tag": "foo",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
"delete_on_termination": false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/sdd",
|
"device": "/dev/sdb",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113",
|
||||||
"serverId": "2390fb4d-1693-45d7-b309-e29c4af16538",
|
"serverId": "1ad6852e-6605-4510-b639-d0bff864b49a",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "a07f71dc-8151-4e7d-a0cc-cd24a3f11113"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,10 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachments": [
|
"volumeAttachments": [
|
||||||
{
|
{
|
||||||
"device": "/dev/sdd",
|
"device": "%(device)s",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "%(volume_id)s",
|
||||||
"serverId": "%(uuid)s",
|
"serverId": "%(uuid)s",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "%(volume_id)s"
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "/dev/sdc",
|
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
|
||||||
"serverId": "%(uuid)s",
|
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "%(volume_id)s"
|
"volumeId": "%(new_volume_id)s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachments": [
|
"volumeAttachments": [
|
||||||
{
|
{
|
||||||
"device": "/dev/sdd",
|
"device": "%(device)s",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "%(volume_id)s",
|
||||||
"serverId": "%(uuid)s",
|
"serverId": "%(uuid)s",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "%(volume_id)s"
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "/dev/sdc",
|
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
|
||||||
"serverId": "%(uuid)s",
|
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "%(volume_id)s"
|
"volumeId": "%(new_volume_id)s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/sdd",
|
"device": "%(device)s",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "%(volume_id)s",
|
||||||
"serverId": "%(uuid)s",
|
"serverId": "%(uuid)s",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "%(volume_id)s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,11 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachments": [
|
"volumeAttachments": [
|
||||||
{
|
{
|
||||||
"device": "/dev/sdd",
|
"device": "%(device)s",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "%(volume_id)s",
|
||||||
"serverId": "%(uuid)s",
|
"serverId": "%(uuid)s",
|
||||||
"tag": "%(tag)s",
|
"tag": "%(tag)s",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "%(volume_id)s"
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "/dev/sdc",
|
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
|
||||||
"serverId": "%(uuid)s",
|
|
||||||
"tag": null,
|
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "%(volume_id)s"
|
"volumeId": "%(new_volume_id)s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/sdd",
|
"device": "%(device)s",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "%(volume_id)s",
|
||||||
"serverId": "%(uuid)s",
|
"serverId": "%(uuid)s",
|
||||||
"tag": "%(tag)s",
|
"tag": "%(tag)s",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "%(volume_id)s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,12 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachments": [
|
"volumeAttachments": [
|
||||||
{
|
{
|
||||||
"device": "/dev/sdd",
|
"device": "%(device)s",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "%(volume_id)s",
|
||||||
"serverId": "%(uuid)s",
|
"serverId": "%(uuid)s",
|
||||||
"tag": "%(tag)s",
|
"tag": "%(tag)s",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"volumeId": "%(volume_id)s",
|
||||||
"delete_on_termination": false
|
"delete_on_termination": true
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "/dev/sdc",
|
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
|
||||||
"serverId": "%(uuid)s",
|
|
||||||
"tag": null,
|
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
|
||||||
"delete_on_termination": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"volumeId": "%(volume_id)s"
|
"volumeId": "%(new_volume_id)s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/sdd",
|
"device": "%(device)s",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "%(volume_id)s",
|
||||||
"serverId": "%(uuid)s",
|
"serverId": "%(uuid)s",
|
||||||
"tag": "%(tag)s",
|
"tag": "%(tag)s",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"volumeId": "%(volume_id)s",
|
||||||
"delete_on_termination": false
|
"delete_on_termination": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"volumeAttachment": {
|
"volumeAttachment": {
|
||||||
"device": "/dev/sdd",
|
"device": "%(device)s",
|
||||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
"id": "%(volume_id)s",
|
||||||
"serverId": "%(uuid)s",
|
"serverId": "%(uuid)s",
|
||||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
"volumeId": "%(volume_id)s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,10 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from oslo_utils.fixture import uuidsentinel as uuids
|
|
||||||
|
|
||||||
from nova import context
|
|
||||||
from nova import objects
|
|
||||||
from nova.tests import fixtures
|
from nova.tests import fixtures
|
||||||
from nova.tests.functional.api_sample_tests import api_sample_base
|
from nova.tests.functional.api_sample_tests import api_sample_base
|
||||||
from nova.tests.functional.api_sample_tests import test_servers
|
from nova.tests.functional.api_sample_tests import test_servers
|
||||||
from nova.tests.unit.api.openstack import fakes
|
from nova.tests.unit.api.openstack import fakes
|
||||||
from nova.tests.unit import fake_block_device
|
|
||||||
from nova.tests.unit import fake_instance
|
|
||||||
|
|
||||||
|
|
||||||
class SnapshotsSampleJsonTests(api_sample_base.ApiSampleTestBaseV21):
|
class SnapshotsSampleJsonTests(api_sample_base.ApiSampleTestBaseV21):
|
||||||
@ -198,155 +192,57 @@ class VolumesSampleJsonTest(test_servers.ServersSampleBase):
|
|||||||
class VolumeAttachmentsSample(test_servers.ServersSampleBase):
|
class VolumeAttachmentsSample(test_servers.ServersSampleBase):
|
||||||
sample_dir = "os-volumes"
|
sample_dir = "os-volumes"
|
||||||
|
|
||||||
OLD_VOLUME_ID = 'a26887c6-c47b-4654-abb5-dfadf7d3f803'
|
OLD_VOLUME_ID = fixtures.CinderFixture.SWAP_OLD_VOL
|
||||||
NEW_VOLUME_ID = 'a26887c6-c47b-4654-abb5-dfadf7d3f805'
|
NEW_VOLUME_ID = fixtures.CinderFixture.SWAP_NEW_VOL
|
||||||
|
|
||||||
def _get_tags_per_volume(self):
|
def setUp(self):
|
||||||
"""Allows subclasses to override which volumes have tags
|
super(VolumeAttachmentsSample, self).setUp()
|
||||||
|
self.useFixture(fixtures.CinderFixture(self))
|
||||||
:returns: dict, keyed by volume ID, to tag value; if a volume ID is
|
self.server_id = self._post_server()
|
||||||
not found in the resulting dict it is assumed to not have a tag
|
|
||||||
"""
|
|
||||||
return {}
|
|
||||||
|
|
||||||
# TODO(mriedem): There is really no good reason we should have to stub
|
|
||||||
# so much of this DB and compute service code when we can just use the
|
|
||||||
# CinderFixture. The stubs make these tests very brittle and potentially
|
|
||||||
# false regarding how the API/compute service interaction works.
|
|
||||||
|
|
||||||
def _stub_db_bdms_get_all_by_instance(self, server_id):
|
|
||||||
|
|
||||||
def fake_bdms_get_all_by_instance(context, instance_uuid,
|
|
||||||
use_slave=False):
|
|
||||||
bdms = [
|
|
||||||
fake_block_device.FakeDbBlockDeviceDict(
|
|
||||||
{'id': 1, 'volume_id': self.OLD_VOLUME_ID,
|
|
||||||
'instance_uuid': server_id, 'source_type': 'volume',
|
|
||||||
'destination_type': 'volume', 'device_name': '/dev/sdd'}),
|
|
||||||
fake_block_device.FakeDbBlockDeviceDict(
|
|
||||||
{'id': 2, 'volume_id': 'a26887c6-c47b-4654-abb5-dfadf7d3f804',
|
|
||||||
'instance_uuid': server_id, 'source_type': 'volume',
|
|
||||||
'destination_type': 'volume', 'device_name': '/dev/sdc'})
|
|
||||||
]
|
|
||||||
tags_per_volume = self._get_tags_per_volume()
|
|
||||||
for bdm_dict in bdms:
|
|
||||||
bdm_dict['tag'] = tags_per_volume.get(bdm_dict['volume_id'])
|
|
||||||
return bdms
|
|
||||||
|
|
||||||
self.stub_out('nova.db.api.block_device_mapping_get_all_by_instance',
|
|
||||||
fake_bdms_get_all_by_instance)
|
|
||||||
|
|
||||||
def fake_bdm_get_by_volume_and_instance(
|
|
||||||
self, ctxt, volume_id, instance_uuid, expected_attrs=None):
|
|
||||||
tag = self._get_tags_per_volume().get(self.OLD_VOLUME_ID)
|
|
||||||
return objects.BlockDeviceMapping._from_db_object(
|
|
||||||
ctxt, objects.BlockDeviceMapping(),
|
|
||||||
fake_block_device.FakeDbBlockDeviceDict(
|
|
||||||
{'id': 1, 'volume_id': self.OLD_VOLUME_ID,
|
|
||||||
'instance_uuid': instance_uuid, 'source_type': 'volume',
|
|
||||||
'destination_type': 'volume', 'device_name': '/dev/sdd',
|
|
||||||
'tag': tag, 'delete_on_termination': False})
|
|
||||||
)
|
|
||||||
|
|
||||||
def _stub_compute_api_get(self):
|
|
||||||
|
|
||||||
def fake_compute_api_get(self, context, instance_id,
|
|
||||||
expected_attrs=None,
|
|
||||||
cell_down_support=False):
|
|
||||||
return fake_instance.fake_instance_obj(
|
|
||||||
context, **{'uuid': instance_id})
|
|
||||||
|
|
||||||
self.stub_out('nova.compute.api.API.get', fake_compute_api_get)
|
|
||||||
|
|
||||||
def _get_vol_attachment_subs(self, subs):
|
def _get_vol_attachment_subs(self, subs):
|
||||||
"""Allows subclasses to override/supplement request/response subs"""
|
"""Allows subclasses to override/supplement request/response subs"""
|
||||||
return subs
|
return subs
|
||||||
|
|
||||||
def test_attach_volume_to_server(self):
|
def test_attach_volume_to_server(self):
|
||||||
self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
|
|
||||||
self.stub_out('nova.volume.cinder.API.attachment_create',
|
|
||||||
lambda *a, **k: {'id': uuids.volume})
|
|
||||||
device_name = '/dev/vdd'
|
|
||||||
bdm = objects.BlockDeviceMapping()
|
|
||||||
bdm['device_name'] = device_name
|
|
||||||
bdm['delete_on_termination'] = True
|
|
||||||
self.stub_out(
|
|
||||||
'nova.compute.manager.ComputeManager.reserve_block_device_name',
|
|
||||||
lambda *a, **k: bdm)
|
|
||||||
# 2.79+ will save the delete_on_termination value on the BDM after
|
|
||||||
# reserve_block_device_name "creates" the BDM.
|
|
||||||
self.stub_out('nova.objects.BlockDeviceMapping.save',
|
|
||||||
lambda *a, **k: None)
|
|
||||||
self.stub_out(
|
|
||||||
'nova.compute.manager.ComputeManager.attach_volume',
|
|
||||||
lambda *a, **k: None)
|
|
||||||
|
|
||||||
volume = fakes.stub_volume_get(None, context.get_admin_context(),
|
|
||||||
'a26887c6-c47b-4654-abb5-dfadf7d3f803')
|
|
||||||
subs = {
|
subs = {
|
||||||
'volume_id': volume['id'],
|
'volume_id': self.OLD_VOLUME_ID,
|
||||||
'device': device_name
|
'device': '/dev/sdb'
|
||||||
}
|
}
|
||||||
server_id = self._post_server()
|
|
||||||
subs = self._get_vol_attachment_subs(subs)
|
subs = self._get_vol_attachment_subs(subs)
|
||||||
response = self._do_post('servers/%s/os-volume_attachments'
|
response = self._do_post('servers/%s/os-volume_attachments'
|
||||||
% server_id,
|
% self.server_id,
|
||||||
'attach-volume-to-server-req', subs)
|
'attach-volume-to-server-req', subs)
|
||||||
|
|
||||||
self._verify_response('attach-volume-to-server-resp', subs,
|
self._verify_response('attach-volume-to-server-resp', subs,
|
||||||
response, 200)
|
response, 200)
|
||||||
|
return subs
|
||||||
|
|
||||||
def test_list_volume_attachments(self):
|
def test_list_volume_attachments(self):
|
||||||
server_id = self._post_server()
|
subs = self.test_attach_volume_to_server()
|
||||||
self._stub_db_bdms_get_all_by_instance(server_id)
|
|
||||||
|
|
||||||
response = self._do_get('servers/%s/os-volume_attachments'
|
response = self._do_get('servers/%s/os-volume_attachments'
|
||||||
% server_id)
|
% self.server_id)
|
||||||
subs = self._get_vol_attachment_subs({})
|
|
||||||
self._verify_response('list-volume-attachments-resp', subs,
|
self._verify_response('list-volume-attachments-resp', subs,
|
||||||
response, 200)
|
response, 200)
|
||||||
|
|
||||||
def test_volume_attachment_detail(self):
|
def test_volume_attachment_detail(self):
|
||||||
server_id = self._post_server()
|
subs = self.test_attach_volume_to_server()
|
||||||
self.stub_out(
|
|
||||||
'nova.objects.BlockDeviceMapping.get_by_volume_and_instance',
|
|
||||||
self.fake_bdm_get_by_volume_and_instance)
|
|
||||||
self._stub_compute_api_get()
|
|
||||||
response = self._do_get('servers/%s/os-volume_attachments/%s'
|
response = self._do_get('servers/%s/os-volume_attachments/%s'
|
||||||
% (server_id, self.OLD_VOLUME_ID))
|
% (self.server_id, subs['volume_id']))
|
||||||
subs = self._get_vol_attachment_subs({})
|
|
||||||
self._verify_response('volume-attachment-detail-resp', subs,
|
self._verify_response('volume-attachment-detail-resp', subs,
|
||||||
response, 200)
|
response, 200)
|
||||||
|
|
||||||
def test_volume_attachment_delete(self):
|
def test_volume_attachment_delete(self):
|
||||||
server_id = self._post_server()
|
subs = self.test_attach_volume_to_server()
|
||||||
self.stub_out(
|
|
||||||
'nova.objects.BlockDeviceMapping.get_by_volume_and_instance',
|
|
||||||
self.fake_bdm_get_by_volume_and_instance)
|
|
||||||
self._stub_compute_api_get()
|
|
||||||
self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
|
|
||||||
self.stub_out('nova.compute.api.API.detach_volume',
|
|
||||||
lambda *a, **k: None)
|
|
||||||
response = self._do_delete('servers/%s/os-volume_attachments/%s'
|
response = self._do_delete('servers/%s/os-volume_attachments/%s'
|
||||||
% (server_id, self.OLD_VOLUME_ID))
|
% (self.server_id, subs['volume_id']))
|
||||||
self.assertEqual(202, response.status_code)
|
self.assertEqual(202, response.status_code)
|
||||||
self.assertEqual('', response.text)
|
self.assertEqual('', response.text)
|
||||||
|
|
||||||
def test_volume_attachment_update(self):
|
def test_volume_attachment_update(self):
|
||||||
self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
|
subs = self.test_attach_volume_to_server()
|
||||||
subs = {
|
subs['new_volume_id'] = self.NEW_VOLUME_ID
|
||||||
'volume_id': self.NEW_VOLUME_ID
|
|
||||||
}
|
|
||||||
server_id = self._post_server()
|
|
||||||
self.stub_out(
|
|
||||||
'nova.objects.BlockDeviceMapping.get_by_volume_and_instance',
|
|
||||||
self.fake_bdm_get_by_volume_and_instance)
|
|
||||||
self._stub_compute_api_get()
|
|
||||||
self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
|
|
||||||
self.stub_out('nova.compute.api.API.swap_volume',
|
|
||||||
lambda *a, **k: None)
|
|
||||||
response = self._do_put('servers/%s/os-volume_attachments/%s'
|
response = self._do_put('servers/%s/os-volume_attachments/%s'
|
||||||
% (server_id, self.OLD_VOLUME_ID),
|
% (self.server_id, subs['volume_id']),
|
||||||
'update-volume-req',
|
'update-volume-req',
|
||||||
subs)
|
subs)
|
||||||
self.assertEqual(202, response.status_code)
|
self.assertEqual(202, response.status_code)
|
||||||
@ -360,7 +256,11 @@ class VolumeAttachmentsSampleV249(VolumeAttachmentsSample):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(VolumeAttachmentsSampleV249, self).setUp()
|
super(VolumeAttachmentsSampleV249, self).setUp()
|
||||||
self.useFixture(fixtures.CinderFixture(self))
|
# Stub out ComputeManager._delete_disk_metadata since the fake virt
|
||||||
|
# driver does not actually update the instance.device_metadata.devices
|
||||||
|
# list with the tagged bdm disk device metadata.
|
||||||
|
self.stub_out('nova.compute.manager.ComputeManager.'
|
||||||
|
'_delete_disk_metadata', lambda *a, **kw: None)
|
||||||
|
|
||||||
def _get_vol_attachment_subs(self, subs):
|
def _get_vol_attachment_subs(self, subs):
|
||||||
return dict(subs, tag='foo')
|
return dict(subs, tag='foo')
|
||||||
@ -371,12 +271,6 @@ class VolumeAttachmentsSampleV270(VolumeAttachmentsSampleV249):
|
|||||||
microversion = '2.70'
|
microversion = '2.70'
|
||||||
scenarios = [('v2_70', {'api_major_version': 'v2.1'})]
|
scenarios = [('v2_70', {'api_major_version': 'v2.1'})]
|
||||||
|
|
||||||
def _get_tags_per_volume(self):
|
|
||||||
return {
|
|
||||||
self.OLD_VOLUME_ID: 'foo',
|
|
||||||
self.NEW_VOLUME_ID: None
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class VolumeAttachmentsSampleV279(VolumeAttachmentsSampleV270):
|
class VolumeAttachmentsSampleV279(VolumeAttachmentsSampleV270):
|
||||||
"""Microversion 2.79 adds the "delete_on_termination" parameter to the
|
"""Microversion 2.79 adds the "delete_on_termination" parameter to the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user