Merge "Merge volume related functional tests of v2 and v2.1"
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f805",
|
||||
"device": "/dev/sdd"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"device": "/dev/vdd"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"device": "/dev/vdd",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "0c92f3f6-c253-4c9b-bd43-e880a8d2eb0a",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"volumeAttachments": [
|
||||
{
|
||||
"device": "/dev/sdd",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
},
|
||||
{
|
||||
"device": "/dev/sdc",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
||||
"serverId": "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"volumes": [
|
||||
{
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "3912f2b4-c5ba-4aec-9165-872876fe202e",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "1999-01-01T01:01:01.000000",
|
||||
"displayDescription": "Volume Description",
|
||||
"displayName": "Volume Name",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"volume": {
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "3912f2b4-c5ba-4aec-9165-872876fe202e",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "2013-02-18T14:51:18.528085",
|
||||
"displayDescription": "Volume Description",
|
||||
"displayName": "Volume Name",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"volumes": [
|
||||
{
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "3912f2b4-c5ba-4aec-9165-872876fe202e",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "2013-02-19T20:01:40.274897",
|
||||
"displayDescription": "Volume Description",
|
||||
"displayName": "Volume Name",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"volume":
|
||||
{
|
||||
"availability_zone": "zone1:host1",
|
||||
"display_name": "Volume Name",
|
||||
"display_description": "Volume Description",
|
||||
"size": 100
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"volume": {
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "3912f2b4-c5ba-4aec-9165-872876fe202e",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "2013-02-18T14:51:17.970024",
|
||||
"displayDescription": "Volume Description",
|
||||
"displayName": "Volume Name",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"snapshot": {
|
||||
"display_name": "snap-001",
|
||||
"display_description": "Daily backup",
|
||||
"volume_id": "521752a6-acf6-4b2d-bc7a-119f9148cd8c",
|
||||
"force": false
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"snapshot": {
|
||||
"createdAt": "2013-02-25T16:27:54.680544",
|
||||
"displayDescription": "Daily backup",
|
||||
"displayName": "snap-001",
|
||||
"id": 100,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": "521752a6-acf6-4b2d-bc7a-119f9148cd8c"
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"snapshots": [
|
||||
{
|
||||
"createdAt": "2013-02-25T16:27:54.671372",
|
||||
"displayDescription": "Default description",
|
||||
"displayName": "Default name",
|
||||
"id": 100,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
},
|
||||
{
|
||||
"createdAt": "2013-02-25T16:27:54.671378",
|
||||
"displayDescription": "Default description",
|
||||
"displayName": "Default name",
|
||||
"id": 101,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
},
|
||||
{
|
||||
"createdAt": "2013-02-25T16:27:54.671381",
|
||||
"displayDescription": "Default description",
|
||||
"displayName": "Default name",
|
||||
"id": 102,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"snapshots": [
|
||||
{
|
||||
"createdAt": "2013-02-25T16:27:54.684999",
|
||||
"displayDescription": "Default description",
|
||||
"displayName": "Default name",
|
||||
"id": 100,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
},
|
||||
{
|
||||
"createdAt": "2013-02-25T16:27:54.685005",
|
||||
"displayDescription": "Default description",
|
||||
"displayName": "Default name",
|
||||
"id": 101,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
},
|
||||
{
|
||||
"createdAt": "2013-02-25T16:27:54.685008",
|
||||
"displayDescription": "Default description",
|
||||
"displayName": "Default name",
|
||||
"id": 102,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"snapshot": {
|
||||
"createdAt": "2013-02-25T16:27:54.724209",
|
||||
"displayDescription": "Default description",
|
||||
"displayName": "Default name",
|
||||
"id": "100",
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"device": "/dev/sdd",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "2390fb4d-1693-45d7-b309-e29c4af16538",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"volumeId": "%(volume_id)s",
|
||||
"device": "%(device)s"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"volumeId": "%(volume_id)s",
|
||||
"device": "%(device)s"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"device": "%(device)s",
|
||||
"id": "%(volume_id)s",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "%(volume_id)s"
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"volumeAttachments": [
|
||||
{
|
||||
"device": "/dev/sdd",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
},
|
||||
{
|
||||
"device": "/dev/sdc",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"volumes": [
|
||||
{
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "%(uuid)s",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "%(uuid)s"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "%(strtime)s",
|
||||
"displayDescription": "%(volume_desc)s",
|
||||
"displayName": "%(volume_name)s",
|
||||
"id": "%(uuid)s",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"volume": {
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "%(uuid)s",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "%(uuid)s"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "%(strtime)s",
|
||||
"displayDescription": "%(volume_desc)s",
|
||||
"displayName": "%(volume_name)s",
|
||||
"id": "%(uuid)s",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"volumes": [
|
||||
{
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "%(uuid)s",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "%(uuid)s"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "%(strtime)s",
|
||||
"displayDescription": "%(volume_desc)s",
|
||||
"displayName": "%(volume_name)s",
|
||||
"id": "%(uuid)s",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"volume":
|
||||
{
|
||||
"availability_zone": "zone1:host1",
|
||||
"display_name": "%(volume_name)s",
|
||||
"display_description": "%(volume_desc)s",
|
||||
"size": 100
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"volume": {
|
||||
"status": "in-use",
|
||||
"displayDescription": "%(volume_desc)s",
|
||||
"availabilityZone": "zone1:host1",
|
||||
"displayName": "%(volume_name)s",
|
||||
"attachments": [
|
||||
{ "device": "/",
|
||||
"serverId": "%(uuid)s",
|
||||
"id": "%(uuid)s",
|
||||
"volumeId": "%(uuid)s"
|
||||
}
|
||||
],
|
||||
"volumeType": "Backup",
|
||||
"snapshotId": null,
|
||||
"metadata": {},
|
||||
"id": "%(uuid)s",
|
||||
"createdAt": "%(strtime)s",
|
||||
"size": 100
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"snapshot": {
|
||||
"display_name": "%(snapshot_name)s",
|
||||
"display_description": "%(description)s",
|
||||
"volume_id": "%(volume_id)s",
|
||||
"force": false
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"snapshot": {
|
||||
"createdAt": "%(strtime)s",
|
||||
"displayDescription": "%(description)s",
|
||||
"displayName": "%(snapshot_name)s",
|
||||
"id": 100,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": "%(uuid)s"
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"snapshots": [
|
||||
{
|
||||
"createdAt": "%(strtime)s",
|
||||
"displayDescription": "Default description",
|
||||
"displayName": "Default name",
|
||||
"id": 100,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
},
|
||||
{
|
||||
"createdAt": "%(strtime)s",
|
||||
"displayDescription": "Default description",
|
||||
"displayName": "Default name",
|
||||
"id": 101,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
},
|
||||
{
|
||||
"createdAt": "%(strtime)s",
|
||||
"displayDescription": "Default description",
|
||||
"displayName": "Default name",
|
||||
"id": 102,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"snapshots": [
|
||||
{
|
||||
"createdAt": "%(strtime)s",
|
||||
"displayDescription": "%(text)s",
|
||||
"displayName": "%(text)s",
|
||||
"id": 100,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
},
|
||||
{
|
||||
"createdAt": "%(strtime)s",
|
||||
"displayDescription": "%(text)s",
|
||||
"displayName": "%(text)s",
|
||||
"id": 101,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
},
|
||||
{
|
||||
"createdAt": "%(strtime)s",
|
||||
"displayDescription": "%(text)s",
|
||||
"displayName": "%(text)s",
|
||||
"id": 102,
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"snapshot": {
|
||||
"createdAt": "%(strtime)s",
|
||||
"displayDescription": "%(description)s",
|
||||
"displayName": "%(snapshot_name)s",
|
||||
"id": "100",
|
||||
"size": 100,
|
||||
"status": "available",
|
||||
"volumeId": 12
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"device": "/dev/sdd",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
}
|
||||
@@ -37,12 +37,10 @@ from nova.cells import utils as cells_utils
|
||||
from nova.cloudpipe import pipelib
|
||||
from nova.compute import api as compute_api
|
||||
from nova.compute import cells_api as cells_api
|
||||
from nova.compute import manager as compute_manager
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
from nova.compute import vm_states
|
||||
from nova.conductor import manager as conductor_manager
|
||||
from nova.console import manager as console_manager # noqa - only for cfg
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova.network import api as network_api
|
||||
@@ -56,8 +54,6 @@ from nova.tests.unit.api.openstack.compute.contrib import test_fping
|
||||
from nova.tests.unit.api.openstack.compute.contrib import test_networks
|
||||
from nova.tests.unit.api.openstack.compute.contrib import test_services
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import fake_block_device
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests.unit import fake_network
|
||||
from nova.tests.unit import fake_network_cache_model
|
||||
from nova.tests.unit import fake_utils
|
||||
@@ -2383,64 +2379,6 @@ class AttachInterfacesSampleJsonTest(ServersSampleBase):
|
||||
self.assertEqual(response.content, '')
|
||||
|
||||
|
||||
class SnapshotsSampleJsonTests(ApiSampleTestBaseV2):
|
||||
extension_name = "nova.api.openstack.compute.contrib.volumes.Volumes"
|
||||
|
||||
create_subs = {
|
||||
'snapshot_name': 'snap-001',
|
||||
'description': 'Daily backup',
|
||||
'volume_id': '521752a6-acf6-4b2d-bc7a-119f9148cd8c'
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(SnapshotsSampleJsonTests, self).setUp()
|
||||
self.stubs.Set(cinder.API, "get_all_snapshots",
|
||||
fakes.stub_snapshot_get_all)
|
||||
self.stubs.Set(cinder.API, "get_snapshot", fakes.stub_snapshot_get)
|
||||
|
||||
def _create_snapshot(self):
|
||||
self.stubs.Set(cinder.API, "create_snapshot",
|
||||
fakes.stub_snapshot_create)
|
||||
|
||||
response = self._do_post("os-snapshots",
|
||||
"snapshot-create-req",
|
||||
self.create_subs)
|
||||
return response
|
||||
|
||||
def test_snapshots_create(self):
|
||||
response = self._create_snapshot()
|
||||
self.create_subs.update(self._get_regexes())
|
||||
self._verify_response("snapshot-create-resp",
|
||||
self.create_subs, response, 200)
|
||||
|
||||
def test_snapshots_delete(self):
|
||||
self.stubs.Set(cinder.API, "delete_snapshot",
|
||||
fakes.stub_snapshot_delete)
|
||||
self._create_snapshot()
|
||||
response = self._do_delete('os-snapshots/100')
|
||||
self.assertEqual(response.status_code, 202)
|
||||
self.assertEqual(response.content, '')
|
||||
|
||||
def test_snapshots_detail(self):
|
||||
response = self._do_get('os-snapshots/detail')
|
||||
subs = self._get_regexes()
|
||||
self._verify_response('snapshots-detail-resp', subs, response, 200)
|
||||
|
||||
def test_snapshots_list(self):
|
||||
response = self._do_get('os-snapshots')
|
||||
subs = self._get_regexes()
|
||||
self._verify_response('snapshots-list-resp', subs, response, 200)
|
||||
|
||||
def test_snapshots_show(self):
|
||||
response = self._do_get('os-snapshots/100')
|
||||
subs = {
|
||||
'snapshot_name': 'Default name',
|
||||
'description': 'Default description'
|
||||
}
|
||||
subs.update(self._get_regexes())
|
||||
self._verify_response('snapshots-show-resp', subs, response, 200)
|
||||
|
||||
|
||||
class AssistedVolumeSnapshotsJsonTest(ApiSampleTestBaseV2):
|
||||
"""Assisted volume snapshots."""
|
||||
extension_name = ("nova.api.openstack.compute.contrib."
|
||||
@@ -2481,238 +2419,6 @@ class AssistedVolumeSnapshotsJsonTest(ApiSampleTestBaseV2):
|
||||
self.assertEqual(response.content, '')
|
||||
|
||||
|
||||
class VolumeAttachmentsSampleBase(ServersSampleBase):
|
||||
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': 'a26887c6-c47b-4654-abb5-dfadf7d3f803',
|
||||
'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'})
|
||||
]
|
||||
return bdms
|
||||
|
||||
self.stubs.Set(db, 'block_device_mapping_get_all_by_instance',
|
||||
fake_bdms_get_all_by_instance)
|
||||
|
||||
def _stub_compute_api_get(self):
|
||||
|
||||
def fake_compute_api_get(self, context, instance_id,
|
||||
want_objects=False, expected_attrs=None):
|
||||
if want_objects:
|
||||
return fake_instance.fake_instance_obj(
|
||||
context, **{'uuid': instance_id})
|
||||
else:
|
||||
return {'uuid': instance_id}
|
||||
|
||||
self.stubs.Set(compute_api.API, 'get', fake_compute_api_get)
|
||||
|
||||
|
||||
class VolumeAttachmentsSampleJsonTest(VolumeAttachmentsSampleBase):
|
||||
extension_name = ("nova.api.openstack.compute.contrib.volumes.Volumes")
|
||||
|
||||
def test_attach_volume_to_server(self):
|
||||
self.stubs.Set(cinder.API, 'get', fakes.stub_volume_get)
|
||||
self.stubs.Set(cinder.API, 'check_attach', lambda *a, **k: None)
|
||||
self.stubs.Set(cinder.API, 'reserve_volume', lambda *a, **k: None)
|
||||
device_name = '/dev/vdd'
|
||||
bdm = objects.BlockDeviceMapping()
|
||||
bdm['device_name'] = device_name
|
||||
self.stubs.Set(compute_manager.ComputeManager,
|
||||
"reserve_block_device_name",
|
||||
lambda *a, **k: bdm)
|
||||
self.stubs.Set(compute_manager.ComputeManager,
|
||||
'attach_volume',
|
||||
lambda *a, **k: None)
|
||||
self.stubs.Set(objects.BlockDeviceMapping, 'get_by_volume_id',
|
||||
classmethod(lambda *a, **k: None))
|
||||
|
||||
volume = fakes.stub_volume_get(None, context.get_admin_context(),
|
||||
'a26887c6-c47b-4654-abb5-dfadf7d3f803')
|
||||
subs = {
|
||||
'volume_id': volume['id'],
|
||||
'device': device_name
|
||||
}
|
||||
server_id = self._post_server()
|
||||
response = self._do_post('servers/%s/os-volume_attachments'
|
||||
% server_id,
|
||||
'attach-volume-to-server-req', subs)
|
||||
|
||||
subs.update(self._get_regexes())
|
||||
self._verify_response('attach-volume-to-server-resp', subs,
|
||||
response, 200)
|
||||
|
||||
def test_list_volume_attachments(self):
|
||||
server_id = self._post_server()
|
||||
|
||||
self._stub_db_bdms_get_all_by_instance(server_id)
|
||||
|
||||
response = self._do_get('servers/%s/os-volume_attachments'
|
||||
% server_id)
|
||||
subs = self._get_regexes()
|
||||
self._verify_response('list-volume-attachments-resp', subs,
|
||||
response, 200)
|
||||
|
||||
def test_volume_attachment_detail(self):
|
||||
server_id = self._post_server()
|
||||
attach_id = "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
self._stub_db_bdms_get_all_by_instance(server_id)
|
||||
self._stub_compute_api_get()
|
||||
response = self._do_get('servers/%s/os-volume_attachments/%s'
|
||||
% (server_id, attach_id))
|
||||
subs = self._get_regexes()
|
||||
self._verify_response('volume-attachment-detail-resp', subs,
|
||||
response, 200)
|
||||
|
||||
def test_volume_attachment_delete(self):
|
||||
server_id = self._post_server()
|
||||
attach_id = "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
self._stub_db_bdms_get_all_by_instance(server_id)
|
||||
self._stub_compute_api_get()
|
||||
self.stubs.Set(cinder.API, 'get', fakes.stub_volume_get)
|
||||
self.stubs.Set(compute_api.API, 'detach_volume', lambda *a, **k: None)
|
||||
response = self._do_delete('servers/%s/os-volume_attachments/%s'
|
||||
% (server_id, attach_id))
|
||||
self.assertEqual(response.status_code, 202)
|
||||
self.assertEqual(response.content, '')
|
||||
|
||||
|
||||
class VolumeAttachUpdateSampleJsonTest(VolumeAttachmentsSampleBase):
|
||||
extends_name = ("nova.api.openstack.compute.contrib.volumes.Volumes")
|
||||
extension_name = ("nova.api.openstack.compute.contrib."
|
||||
"volume_attachment_update.Volume_attachment_update")
|
||||
|
||||
def test_volume_attachment_update(self):
|
||||
self.stubs.Set(cinder.API, 'get', fakes.stub_volume_get)
|
||||
subs = {
|
||||
'volume_id': 'a26887c6-c47b-4654-abb5-dfadf7d3f805',
|
||||
'device': '/dev/sdd'
|
||||
}
|
||||
server_id = self._post_server()
|
||||
attach_id = 'a26887c6-c47b-4654-abb5-dfadf7d3f803'
|
||||
self._stub_db_bdms_get_all_by_instance(server_id)
|
||||
self._stub_compute_api_get()
|
||||
self.stubs.Set(cinder.API, 'get', fakes.stub_volume_get)
|
||||
self.stubs.Set(compute_api.API, 'swap_volume', lambda *a, **k: None)
|
||||
response = self._do_put('servers/%s/os-volume_attachments/%s'
|
||||
% (server_id, attach_id),
|
||||
'update-volume-req',
|
||||
subs)
|
||||
self.assertEqual(response.status_code, 202)
|
||||
self.assertEqual(response.content, '')
|
||||
|
||||
|
||||
class VolumesSampleJsonTest(ServersSampleBase):
|
||||
extension_name = ("nova.api.openstack.compute.contrib.volumes.Volumes")
|
||||
|
||||
def _get_volume_id(self):
|
||||
return 'a26887c6-c47b-4654-abb5-dfadf7d3f803'
|
||||
|
||||
def _stub_volume(self, id, displayname="Volume Name",
|
||||
displaydesc="Volume Description", size=100):
|
||||
volume = {
|
||||
'id': id,
|
||||
'size': size,
|
||||
'availability_zone': 'zone1:host1',
|
||||
'instance_uuid': '3912f2b4-c5ba-4aec-9165-872876fe202e',
|
||||
'mountpoint': '/',
|
||||
'status': 'in-use',
|
||||
'attach_status': 'attached',
|
||||
'name': 'vol name',
|
||||
'display_name': displayname,
|
||||
'display_description': displaydesc,
|
||||
'created_at': datetime.datetime(2008, 12, 1, 11, 1, 55),
|
||||
'snapshot_id': None,
|
||||
'volume_type_id': 'fakevoltype',
|
||||
'volume_metadata': [],
|
||||
'volume_type': {'name': 'Backup'}
|
||||
}
|
||||
return volume
|
||||
|
||||
def _stub_volume_get(self, context, volume_id):
|
||||
return self._stub_volume(volume_id)
|
||||
|
||||
def _stub_volume_delete(self, context, *args, **param):
|
||||
pass
|
||||
|
||||
def _stub_volume_get_all(self, context, search_opts=None):
|
||||
id = self._get_volume_id()
|
||||
return [self._stub_volume(id)]
|
||||
|
||||
def _stub_volume_create(self, context, size, name, description, snapshot,
|
||||
**param):
|
||||
id = self._get_volume_id()
|
||||
return self._stub_volume(id)
|
||||
|
||||
def setUp(self):
|
||||
super(VolumesSampleJsonTest, self).setUp()
|
||||
fakes.stub_out_networking(self.stubs)
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
|
||||
self.stubs.Set(cinder.API, "delete", self._stub_volume_delete)
|
||||
self.stubs.Set(cinder.API, "get", self._stub_volume_get)
|
||||
self.stubs.Set(cinder.API, "get_all", self._stub_volume_get_all)
|
||||
|
||||
def _post_volume(self):
|
||||
subs_req = {
|
||||
'volume_name': "Volume Name",
|
||||
'volume_desc': "Volume Description",
|
||||
}
|
||||
|
||||
self.stubs.Set(cinder.API, "create", self._stub_volume_create)
|
||||
response = self._do_post('os-volumes', 'os-volumes-post-req',
|
||||
subs_req)
|
||||
subs = self._get_regexes()
|
||||
subs.update(subs_req)
|
||||
self._verify_response('os-volumes-post-resp', subs, response, 200)
|
||||
|
||||
def test_volumes_show(self):
|
||||
subs = {
|
||||
'volume_name': "Volume Name",
|
||||
'volume_desc': "Volume Description",
|
||||
}
|
||||
vol_id = self._get_volume_id()
|
||||
response = self._do_get('os-volumes/%s' % vol_id)
|
||||
subs.update(self._get_regexes())
|
||||
self._verify_response('os-volumes-get-resp', subs, response, 200)
|
||||
|
||||
def test_volumes_index(self):
|
||||
subs = {
|
||||
'volume_name': "Volume Name",
|
||||
'volume_desc': "Volume Description",
|
||||
}
|
||||
response = self._do_get('os-volumes')
|
||||
subs.update(self._get_regexes())
|
||||
self._verify_response('os-volumes-index-resp', subs, response, 200)
|
||||
|
||||
def test_volumes_detail(self):
|
||||
# For now, index and detail are the same.
|
||||
# See the volumes api
|
||||
subs = {
|
||||
'volume_name': "Volume Name",
|
||||
'volume_desc': "Volume Description",
|
||||
}
|
||||
response = self._do_get('os-volumes/detail')
|
||||
subs.update(self._get_regexes())
|
||||
self._verify_response('os-volumes-detail-resp', subs, response, 200)
|
||||
|
||||
def test_volumes_create(self):
|
||||
self._post_volume()
|
||||
|
||||
def test_volumes_delete(self):
|
||||
self._post_volume()
|
||||
vol_id = self._get_volume_id()
|
||||
response = self._do_delete('os-volumes/%s' % vol_id)
|
||||
self.assertEqual(response.status_code, 202)
|
||||
self.assertEqual(response.content, '')
|
||||
|
||||
|
||||
class PreserveEphemeralOnRebuildJsonTest(ServersSampleBase):
|
||||
extension_name = ('nova.api.openstack.compute.contrib.'
|
||||
'preserve_ephemeral_rebuild.'
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
import datetime
|
||||
|
||||
from nova.compute import api as compute_api
|
||||
@@ -27,9 +29,17 @@ from nova.tests.unit import fake_block_device
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.volume import cinder
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('osapi_compute_extension',
|
||||
'nova.api.openstack.compute.extensions')
|
||||
|
||||
|
||||
class SnapshotsSampleJsonTests(api_sample_base.ApiSampleTestBaseV3):
|
||||
extension_name = "os-volumes"
|
||||
# TODO(park): Overriding '_api_version' till all functional tests
|
||||
# are merged between v2 and v2.1. After that base class variable
|
||||
# itself can be changed to 'v2'
|
||||
_api_version = 'v2'
|
||||
|
||||
create_subs = {
|
||||
'snapshot_name': 'snap-001',
|
||||
@@ -37,6 +47,13 @@ class SnapshotsSampleJsonTests(api_sample_base.ApiSampleTestBaseV3):
|
||||
'volume_id': '521752a6-acf6-4b2d-bc7a-119f9148cd8c'
|
||||
}
|
||||
|
||||
def _get_flags(self):
|
||||
f = super(SnapshotsSampleJsonTests, self)._get_flags()
|
||||
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
|
||||
f['osapi_compute_extension'].append(
|
||||
'nova.api.openstack.compute.contrib.volumes.Volumes')
|
||||
return f
|
||||
|
||||
def setUp(self):
|
||||
super(SnapshotsSampleJsonTests, self).setUp()
|
||||
self.stubs.Set(cinder.API, "get_all_snapshots",
|
||||
@@ -88,6 +105,17 @@ class SnapshotsSampleJsonTests(api_sample_base.ApiSampleTestBaseV3):
|
||||
|
||||
class VolumesSampleJsonTest(test_servers.ServersSampleBase):
|
||||
extension_name = "os-volumes"
|
||||
# TODO(park): Overriding '_api_version' till all functional tests
|
||||
# are merged between v2 and v2.1. After that base class variable
|
||||
# itself can be changed to 'v2'
|
||||
_api_version = 'v2'
|
||||
|
||||
def _get_flags(self):
|
||||
f = super(VolumesSampleJsonTest, self)._get_flags()
|
||||
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
|
||||
f['osapi_compute_extension'].append(
|
||||
'nova.api.openstack.compute.contrib.volumes.Volumes')
|
||||
return f
|
||||
|
||||
def _get_volume_id(self):
|
||||
return 'a26887c6-c47b-4654-abb5-dfadf7d3f803'
|
||||
@@ -225,7 +253,22 @@ class VolumeAttachmentsSampleBase(test_servers.ServersSampleBase):
|
||||
|
||||
|
||||
class VolumeAttachmentsSampleJsonTest(VolumeAttachmentsSampleBase):
|
||||
extra_extensions_to_load = ["os-access-ips"]
|
||||
extension_name = "os-volumes"
|
||||
# TODO(park): Overriding '_api_version' till all functional tests
|
||||
# are merged between v2 and v2.1. After that base class variable
|
||||
# itself can be changed to 'v2'
|
||||
_api_version = 'v2'
|
||||
|
||||
def _get_flags(self):
|
||||
f = super(VolumeAttachmentsSampleJsonTest, self)._get_flags()
|
||||
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
|
||||
f['osapi_compute_extension'].append(
|
||||
'nova.api.openstack.compute.contrib.volumes.Volumes')
|
||||
f['osapi_compute_extension'].append(
|
||||
'nova.api.openstack.compute.contrib.'
|
||||
'volume_attachment_update.Volume_attachment_update')
|
||||
return f
|
||||
|
||||
def test_attach_volume_to_server(self):
|
||||
self.stubs.Set(cinder.API, 'get', fakes.stub_volume_get)
|
||||
|
||||
Reference in New Issue
Block a user