summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-01-18 07:54:33 +0000
committerGerrit Code Review <review@openstack.org>2012-01-18 07:54:33 +0000
commitd49d4b98f950b896ee9cfb9890b863d008f09a01 (patch)
tree578e75c932a669688e410bf7ef86b6e92f49ad55
parentad8843740154ebfa1e1be90413b9c5e973af9849 (diff)
parent301bc0ca1a847f921c330dced1d4b1c82946ec55 (diff)
downloadnova-d49d4b98f950b896ee9cfb9890b863d008f09a01.tar.gz
nova-d49d4b98f950b896ee9cfb9890b863d008f09a01.tar.xz
nova-d49d4b98f950b896ee9cfb9890b863d008f09a01.zip
Merge "Set instance_ref property when creating snapshots."
-rw-r--r--nova/api/openstack/compute/contrib/admin_actions.py5
-rw-r--r--nova/api/openstack/compute/views/images.py8
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_admin_actions.py3
-rw-r--r--nova/tests/api/openstack/compute/test_images.py16
-rw-r--r--nova/tests/api/openstack/fakes.py2
5 files changed, 15 insertions, 19 deletions
diff --git a/nova/api/openstack/compute/contrib/admin_actions.py b/nova/api/openstack/compute/contrib/admin_actions.py
index a4164fcb8..b44f16a1e 100644
--- a/nova/api/openstack/compute/contrib/admin_actions.py
+++ b/nova/api/openstack/compute/contrib/admin_actions.py
@@ -232,10 +232,7 @@ class AdminActionsController(wsgi.Controller):
msg = _("createBackup attribute 'rotation' must be an integer")
raise exc.HTTPBadRequest(explanation=msg)
- # preserve link to server in image properties
- server_ref = os.path.join(req.application_url, 'servers', id)
- props = {'instance_ref': server_ref}
-
+ props = {}
metadata = entity.get('metadata', {})
common.check_img_metadata_quota_limit(context, metadata)
try:
diff --git a/nova/api/openstack/compute/views/images.py b/nova/api/openstack/compute/views/images.py
index c4cfe8031..5ef1af59b 100644
--- a/nova/api/openstack/compute/views/images.py
+++ b/nova/api/openstack/compute/views/images.py
@@ -50,11 +50,13 @@ class ViewBuilder(common.ViewBuilder):
"links": self._get_links(request, image["id"]),
}
- server_ref = image.get("properties", {}).get("instance_ref")
+ instance_uuid = image.get("properties", {}).get("instance_uuid")
- if server_ref is not None:
+ if instance_uuid is not None:
+ server_ref = os.path.join(request.application_url, 'servers',
+ instance_uuid)
image_dict["server"] = {
- "id": common.get_id_from_href(server_ref),
+ "id": instance_uuid,
"links": [{
"rel": "self",
"href": server_ref,
diff --git a/nova/tests/api/openstack/compute/contrib/test_admin_actions.py b/nova/tests/api/openstack/compute/contrib/test_admin_actions.py
index f8a5d1103..0ffb4fdd1 100644
--- a/nova/tests/api/openstack/compute/contrib/test_admin_actions.py
+++ b/nova/tests/api/openstack/compute/contrib/test_admin_actions.py
@@ -229,9 +229,6 @@ class CreateBackupTests(test.TestCase):
response = request.get_response(self.app)
self.assertTrue(response.headers['Location'])
- instance_ref = self.backup_stubs.extra_props_last_call['instance_ref']
- expected_server_location = 'http://localhost/v2/servers/%s' % self.uuid
- self.assertEqual(expected_server_location, instance_ref)
def test_create_backup_raises_conflict_on_invalid_state(self):
body = {
diff --git a/nova/tests/api/openstack/compute/test_images.py b/nova/tests/api/openstack/compute/test_images.py
index d8884e934..893574241 100644
--- a/nova/tests/api/openstack/compute/test_images.py
+++ b/nova/tests/api/openstack/compute/test_images.py
@@ -96,7 +96,7 @@ class ImagesControllerTest(test.TestCase):
}],
},
"metadata": {
- "instance_ref": server_href,
+ "instance_uuid": server_uuid,
"user_id": "fake",
},
"links": [{
@@ -430,7 +430,7 @@ class ImagesControllerTest(test.TestCase):
'id': '124',
'name': 'queued snapshot',
'metadata': {
- u'instance_ref': server_href,
+ u'instance_uuid': server_uuid,
u'user_id': u'fake',
},
'updated': NOW_API_FORMAT,
@@ -468,7 +468,7 @@ class ImagesControllerTest(test.TestCase):
'id': '125',
'name': 'saving snapshot',
'metadata': {
- u'instance_ref': server_href,
+ u'instance_uuid': server_uuid,
u'user_id': u'fake',
},
'updated': NOW_API_FORMAT,
@@ -506,7 +506,7 @@ class ImagesControllerTest(test.TestCase):
'id': '126',
'name': 'active snapshot',
'metadata': {
- u'instance_ref': server_href,
+ u'instance_uuid': server_uuid,
u'user_id': u'fake',
},
'updated': NOW_API_FORMAT,
@@ -544,7 +544,7 @@ class ImagesControllerTest(test.TestCase):
'id': '127',
'name': 'killed snapshot',
'metadata': {
- u'instance_ref': server_href,
+ u'instance_uuid': server_uuid,
u'user_id': u'fake',
},
'updated': NOW_API_FORMAT,
@@ -582,7 +582,7 @@ class ImagesControllerTest(test.TestCase):
'id': '128',
'name': 'deleted snapshot',
'metadata': {
- u'instance_ref': server_href,
+ u'instance_uuid': server_uuid,
u'user_id': u'fake',
},
'updated': NOW_API_FORMAT,
@@ -620,7 +620,7 @@ class ImagesControllerTest(test.TestCase):
'id': '129',
'name': 'pending_delete snapshot',
'metadata': {
- u'instance_ref': server_href,
+ u'instance_uuid': server_uuid,
u'user_id': u'fake',
},
'updated': NOW_API_FORMAT,
@@ -721,7 +721,7 @@ class ImagesControllerTest(test.TestCase):
'id': '124',
'name': 'queued snapshot',
'metadata': {
- u'instance_ref': server_href,
+ u'instance_uuid': server_uuid,
u'user_id': u'fake',
},
'updated': NOW_API_FORMAT,
diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py
index d96d8289b..d3289623e 100644
--- a/nova/tests/api/openstack/fakes.py
+++ b/nova/tests/api/openstack/fakes.py
@@ -247,7 +247,7 @@ def _make_image_fixtures():
# Snapshot for User 1
uuid = 'aa640691-d1a7-4a67-9d3c-d35ee6b3cc74'
server_ref = 'http://localhost/v2/servers/' + uuid
- snapshot_properties = {'instance_ref': server_ref, 'user_id': 'fake'}
+ snapshot_properties = {'instance_uuid': uuid, 'user_id': 'fake'}
for status in ('queued', 'saving', 'active', 'killed',
'deleted', 'pending_delete'):
add_fixture(id=image_id, name='%s snapshot' % status,