diff options
author | Russell Bryant <rbryant@redhat.com> | 2013-08-16 20:44:37 +0000 |
---|---|---|
committer | Russell Bryant <rbryant@redhat.com> | 2013-09-03 13:18:25 -0400 |
commit | fa13644b058e47fda6bdd28a853cc46597c80a97 (patch) | |
tree | 37029985bef4c6f39696ab169cb48a549bf5e9d3 /nova/tests/integrated | |
parent | 87b3d3a6f05f0b0aefd98855927782aa86a6884a (diff) | |
download | nova-fa13644b058e47fda6bdd28a853cc46597c80a97.tar.gz |
Add os-assisted-volume-snapshots extension
Add a new API extension that exposes assisted volume snapshot
capabilities. This extension is admin only by default. We expect it to
only be called by Cinder. If you have your deployment set up in such a
way that your adminURL is different from the public, this extension can
only be loaded in the admin API instance. Cinder will pull that URL out
of the service catalog to use.
Part of blueprint qemu-assisted-snapshots
Change-Id: I79e22ab6ef66fa16dc534a4336e766065702b2f5
Diffstat (limited to 'nova/tests/integrated')
7 files changed, 79 insertions, 0 deletions
diff --git a/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.json.tpl b/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.json.tpl index e00730a53b..b4607875cf 100644 --- a/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.json.tpl @@ -137,6 +137,14 @@ "updated": "%(timestamp)s" }, { + "alias": "os-assisted-volume-snapshots", + "description": "%(text)s", + "links": [], + "name": "AssistedVolumeSnapshots", + "namespace": "http://docs.openstack.org/compute/ext/assisted-volume-snapshots/api/v2", + "updated": "%(timestamp)s" + }, + { "alias": "os-attach-interfaces", "description": "Attach interface support.", "links": [], diff --git a/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.xml.tpl b/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.xml.tpl index 81955c4b78..a2840f77ab 100644 --- a/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.xml.tpl @@ -228,4 +228,7 @@ <extension alias="os-migrations" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/migrations/api/v2.0" name="Migrations"> <description>%(text)s</description> </extension> + <extension alias="os-assisted-volume-snapshots" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/assisted-volume-snapshots/api/v2" name="AssistedVolumeSnapshots"> + <description>%(text)s</description> + </extension> </extensions> diff --git a/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-req.json.tpl b/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-req.json.tpl new file mode 100644 index 0000000000..a1b94d1c72 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-req.json.tpl @@ -0,0 +1,10 @@ +{ + "snapshot": { + "display_name": "%(snapshot_name)s", + "display_description": "%(description)s", + "volume_id": "%(volume_id)s", + "force": false, + "assisted": true, + "create_info": {} + } +} diff --git a/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-req.xml.tpl b/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-req.xml.tpl new file mode 100644 index 0000000000..45feb5077f --- /dev/null +++ b/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-req.xml.tpl @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> + <snapshot> + <display_name>%(snapshot_name)s</display_name> + <display_description>%(description)s</display_description> + <volume_id>%(volume_id)s</volume_id> + <force>false</force> + <assisted>true</assisted> + <create_info/> + </snapshot> diff --git a/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-resp.json.tpl b/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-resp.json.tpl new file mode 100644 index 0000000000..8d4e7f5709 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-resp.json.tpl @@ -0,0 +1,6 @@ +{ + "snapshot": { + "id": 100, + "volumeId": "%(uuid)s" + } +} diff --git a/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-resp.xml.tpl b/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-resp.xml.tpl new file mode 100644 index 0000000000..5da7d148b1 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-assisted-volume-snapshots/snapshot-create-assisted-resp.xml.tpl @@ -0,0 +1,2 @@ +<?xml version='1.0' encoding='UTF-8'?> +<snapshot volumeId="521752a6-acf6-4b2d-bc7a-119f9148cd8c" id="100"/> diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index ff79462b55..76ec458bc1 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -3697,6 +3697,47 @@ class SnapshotsSampleXmlTests(SnapshotsSampleJsonTests): ctype = "xml" +class AssistedVolumeSnapshotsJsonTest(ApiSampleTestBaseV2): + """Assisted volume snapshots.""" + extension_name = ("nova.api.openstack.compute.contrib." + "assisted_volume_snapshots.Assisted_volume_snapshots") + + def _create_assisted_snapshot(self, subs): + self.stubs.Set(compute_api.API, 'volume_snapshot_create', + fakes.stub_compute_volume_snapshot_create) + + response = self._do_post("os-assisted-volume-snapshots", + "snapshot-create-assisted-req", + subs) + return response + + def test_snapshots_create_assisted(self): + subs = { + 'snapshot_name': 'snap-001', + 'description': 'Daily backup', + 'volume_id': '521752a6-acf6-4b2d-bc7a-119f9148cd8c' + } + subs.update(self._get_regexes()) + response = self._create_assisted_snapshot(subs) + self._verify_response("snapshot-create-assisted-resp", + subs, response, 200) + + def test_snapshots_delete_assisted(self): + self.stubs.Set(compute_api.API, 'volume_snapshot_delete', + fakes.stub_compute_volume_snapshot_delete) + snapshot_id = '100' + response = self._do_delete( + 'os-assisted-volume-snapshots/%s?delete_info=' + '{"volume_id":"521752a6-acf6-4b2d-bc7a-119f9148cd8c"}' + % snapshot_id) + self.assertEqual(response.status, 204) + self.assertEqual(response.read(), '') + + +class AssistedVolumeSnapshotsXmlTest(AssistedVolumeSnapshotsJsonTest): + ctype = "xml" + + class VolumeAttachmentsSampleBase(ServersSampleBase): def _stub_compute_api_get_instance_bdms(self, server_id): |