diff options
| author | Rick Harris <rick.harris@rackspace.com> | 2011-08-08 01:52:36 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-08-08 01:52:36 +0000 |
| commit | ec57e2a27ebfc8eba84d82f5372408e3d85a9272 (patch) | |
| tree | 57cd78fcb99565961ddcd30e2ed2c61677a24cf8 /nova/tests | |
| parent | c911c6d737e9794cb6e4a64d530bc98056c005a0 (diff) | |
| parent | 7a5bb39ef11d630df26f2fcfbf249f0c34e9fa55 (diff) | |
Adds ability to disable snapshots in the Openstack API.
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/openstack/test_images.py | 10 | ||||
| -rw-r--r-- | nova/tests/api/openstack/test_server_actions.py | 18 |
2 files changed, 28 insertions, 0 deletions
diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py index 8e2e3f390..38495bbe7 100644 --- a/nova/tests/api/openstack/test_images.py +++ b/nova/tests/api/openstack/test_images.py @@ -1049,6 +1049,16 @@ class ImageControllerWithGlanceServiceTest(test.TestCase): response = req.get_response(fakes.wsgi_app()) self.assertEqual(400, response.status_int) + def test_create_image_snapshots_disabled(self): + self.flags(allow_instance_snapshots=False) + body = dict(image=dict(serverId='123', name='Snapshot 1')) + req = webob.Request.blank('/v1.0/images') + req.method = 'POST' + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + response = req.get_response(fakes.wsgi_app()) + self.assertEqual(400, response.status_int) + @classmethod def _make_image_fixtures(cls): image_id = 123 diff --git a/nova/tests/api/openstack/test_server_actions.py b/nova/tests/api/openstack/test_server_actions.py index 7e24d24fd..bf18bc1b0 100644 --- a/nova/tests/api/openstack/test_server_actions.py +++ b/nova/tests/api/openstack/test_server_actions.py @@ -458,6 +458,7 @@ class ServerActionsTestV11(test.TestCase): self.service.delete_all() self.sent_to_glance = {} fakes.stub_out_glance_add_image(self.stubs, self.sent_to_glance) + self.flags(allow_instance_snapshots=True) def tearDown(self): self.stubs.UnsetAll() @@ -775,6 +776,23 @@ class ServerActionsTestV11(test.TestCase): location = response.headers['Location'] self.assertEqual('http://localhost/v1.1/images/123', location) + def test_create_image_snapshots_disabled(self): + """Don't permit a snapshot if the allow_instance_snapshots flag is + False + """ + self.flags(allow_instance_snapshots=False) + body = { + 'createImage': { + 'name': 'Snapshot 1', + }, + } + req = webob.Request.blank('/v1.1/servers/1/action') + req.method = 'POST' + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + response = req.get_response(fakes.wsgi_app()) + self.assertEqual(400, response.status_int) + def test_create_image_with_metadata(self): body = { 'createImage': { |
