Commit 7b836ec2 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Merge branch 'feature-compute-v2' into develop

parents eb59dfa0 362ef374
This diff is collapsed.
......@@ -59,7 +59,7 @@ def flavor_to_dict(flavor, detail=True):
if detail:
d['ram'] = flavor.ram
d['disk'] = flavor.disk
d['cpu'] = flavor.cpu
d['vcpus'] = flavor.cpu
d['SNF:disk_template'] = flavor.disk_template
return d
......@@ -83,7 +83,7 @@ def list_flavors(request, detail=False):
'flavors': flavors,
'detail': detail})
else:
data = json.dumps({'flavors': {'values': flavors}})
data = json.dumps({'flavors': flavors})
return HttpResponse(data, status=200)
......
......@@ -54,8 +54,8 @@ urlpatterns = patterns(
(r'^(?:/|.json|.xml)?$', 'demux'),
(r'^/detail(?:.json|.xml)?$', 'list_images', {'detail': True}),
(r'^/([\w-]+)(?:.json|.xml)?$', 'image_demux'),
(r'^/([\w-]+)/meta(?:.json|.xml)?$', 'metadata_demux'),
(r'^/([\w-]+)/meta/(.+?)(?:.json|.xml)?$', 'metadata_item_demux')
(r'^/([\w-]+)/metadata(?:.json|.xml)?$', 'metadata_demux'),
(r'^/([\w-]+)/metadata/(.+?)(?:.json|.xml)?$', 'metadata_item_demux')
)
......@@ -105,7 +105,7 @@ def image_to_dict(image, detail=True):
d['status'] = 'DELETED' if image['deleted_at'] else 'ACTIVE'
d['progress'] = 100 if image['status'] == 'available' else 0
if image['properties']:
d['metadata'] = {'values': image['properties']}
d['metadata'] = image['properties']
return d
......@@ -135,7 +135,7 @@ def list_images(request, detail=False):
data = render_to_string('list_images.xml',
dict(images=reply, detail=detail))
else:
data = json.dumps(dict(images={'values': reply}))
data = json.dumps(dict(images=reply))
return HttpResponse(data, status=200)
......@@ -210,7 +210,8 @@ def list_metadata(request, image_id):
with image_backend(request.user_uniq) as backend:
image = backend.get_image(image_id)
metadata = image['properties']
return util.render_metadata(request, metadata, use_values=True, status=200)
return util.render_metadata(request, metadata, use_values=False,
status=200)
@api.api_method('POST', user_required=True, logger=log)
......
......@@ -101,7 +101,7 @@ def network_to_dict(network, user_id, detail=True):
for nic in network.nics.filter(machine__userid=user_id)
.filter(state="ACTIVE")
.order_by('machine')]
d['attachments'] = {'values': attachments}
d['attachments'] = attachments
return d
......@@ -142,7 +142,7 @@ def list_networks(request, detail=False):
'networks': networks,
'detail': detail})
else:
data = json.dumps({'networks': {'values': networks}})
data = json.dumps({'networks': networks})
return HttpResponse(data, status=200)
......
......@@ -65,8 +65,8 @@ urlpatterns = patterns(
(r'^/(\d+)/action(?:.json|.xml)?$', 'server_action'),
(r'^/(\d+)/ips(?:.json|.xml)?$', 'list_addresses'),
(r'^/(\d+)/ips/(.+?)(?:.json|.xml)?$', 'list_addresses_by_network'),
(r'^/(\d+)/meta(?:.json|.xml)?$', 'metadata_demux'),
(r'^/(\d+)/meta/(.+?)(?:.json|.xml)?$', 'metadata_item_demux'),
(r'^/(\d+)/metadata(?:.json|.xml)?$', 'metadata_demux'),
(r'^/(\d+)/metadata/(.+?)(?:.json|.xml)?$', 'metadata_item_demux'),
(r'^/(\d+)/stats(?:.json|.xml)?$', 'server_stats'),
(r'^/(\d+)/diagnostics(?:.json)?$', 'get_server_diagnostics'),
)
......@@ -133,17 +133,17 @@ def vm_to_dict(vm, detail=False):
d['hostId'] = vm.hostid
d['updated'] = utils.isoformat(vm.updated)
d['created'] = utils.isoformat(vm.created)
d['flavorRef'] = vm.flavor.id
d['imageRef'] = vm.imageid
d['flavor'] = vm.flavor.id
d['image'] = vm.imageid
d['suspended'] = vm.suspended
metadata = dict((m.meta_key, m.meta_value) for m in vm.metadata.all())
if metadata:
d['metadata'] = {'values': metadata}
d['metadata'] = metadata
vm_nics = vm.nics.filter(state="ACTIVE").order_by("index")
attachments = map(nic_to_dict, vm_nics)
d['attachments'] = {'values': attachments}
d['attachments'] = attachments
# include the latest vm diagnostic, if set
diagnostic = vm.get_last_diagnostic()
......@@ -238,7 +238,7 @@ def list_servers(request, detail=False):
'servers': servers,
'detail': detail})
else:
data = json.dumps({'servers': {'values': servers}})
data = json.dumps({'servers': servers})
return HttpResponse(data, status=200)
......@@ -544,7 +544,7 @@ def list_addresses(request, server_id):
if request.serialization == 'xml':
data = render_to_string('list_addresses.xml', {'addresses': addresses})
else:
data = json.dumps({'addresses': {'values': addresses}})
data = json.dumps({'addresses': addresses})
return HttpResponse(data, status=200)
......@@ -585,7 +585,8 @@ def list_metadata(request, server_id):
log.debug('list_server_metadata %s', server_id)
vm = util.get_vm(server_id, request.user_uniq)
metadata = dict((m.meta_key, m.meta_value) for m in vm.metadata.all())
return util.render_metadata(request, metadata, use_values=True, status=200)
return util.render_metadata(request, metadata, use_values=False,
status=200)
@api.api_method(http_method='POST', user_required=True, logger=log)
......
......@@ -50,7 +50,7 @@ class FlavorAPITest(BaseAPITest):
response = self.get('/api/v1.1/flavors')
self.assertSuccess(response)
api_flavors = json.loads(response.content)['flavors']['values']
api_flavors = json.loads(response.content)['flavors']
db_flavors = Flavor.objects.filter(deleted=False)
self.assertEqual(len(api_flavors), len(db_flavors))
for api_flavor in api_flavors:
......@@ -64,14 +64,14 @@ class FlavorAPITest(BaseAPITest):
self.assertSuccess(response)
db_flavors = Flavor.objects.filter(deleted=False)
api_flavors = json.loads(response.content)['flavors']['values']
api_flavors = json.loads(response.content)['flavors']
self.assertEqual(len(db_flavors), len(api_flavors))
for i in range(0, len(db_flavors)):
api_flavor = api_flavors[i]
db_flavor = Flavor.objects.get(id=db_flavors[i].id)
self.assertEqual(api_flavor['cpu'], db_flavor.cpu)
self.assertEqual(api_flavor['vcpus'], db_flavor.cpu)
self.assertEqual(api_flavor['id'], db_flavor.id)
self.assertEqual(api_flavor['disk'], db_flavor.disk)
self.assertEqual(api_flavor['name'], db_flavor.name)
......@@ -88,7 +88,7 @@ class FlavorAPITest(BaseAPITest):
api_flavor = json.loads(response.content)['flavor']
db_flavor = Flavor.objects.get(id=flavor.id)
self.assertEqual(api_flavor['cpu'], db_flavor.cpu)
self.assertEqual(api_flavor['vcpus'], db_flavor.cpu)
self.assertEqual(api_flavor['id'], db_flavor.id)
self.assertEqual(api_flavor['disk'], db_flavor.disk)
self.assertEqual(api_flavor['name'], db_flavor.name)
......@@ -108,7 +108,7 @@ class FlavorAPITest(BaseAPITest):
"""Test that deleted flavors do not appear to flavors list"""
response = self.get('/api/v1.1/flavors')
self.assertSuccess(response)
api_flavors = json.loads(response.content)['flavors']['values']
api_flavors = json.loads(response.content)['flavors']
self.assertEqual(len(api_flavors), 2)
def test_deleted_flavors_details(self):
......@@ -116,7 +116,7 @@ class FlavorAPITest(BaseAPITest):
FlavorFactory(deleted=True)
response = self.get('/api/v1.1/flavors/detail')
self.assertSuccess(response)
api_flavors = json.loads(response.content)['flavors']['values']
api_flavors = json.loads(response.content)['flavors']
self.assertEqual(len(api_flavors), 2)
def test_wrong_flavor(self):
......
......@@ -69,7 +69,7 @@ class ImageAPITest(BaseAPITest):
mimage().list_images.return_value = images
response = self.get('/api/v1.1/images/', 'user')
self.assertSuccess(response)
api_images = json.loads(response.content)['images']['values']
api_images = json.loads(response.content)['images']
self.assertEqual(images, api_images)
@assert_backend_closed
......@@ -102,7 +102,7 @@ class ImageAPITest(BaseAPITest):
'progress': 100,
'created': '2012-11-26T11:52:54+00:00',
'updated': '2012-12-26T11:52:54+00:00',
'metadata': {'values': {'foo':'bar'}}},
'metadata': {'foo':'bar'}},
{'id': 2,
'name': 'image-2',
'status': 'DELETED',
......@@ -118,7 +118,7 @@ class ImageAPITest(BaseAPITest):
mimage().list_images.return_value = images
response = self.get('/api/v1.1/images/detail', 'user')
self.assertSuccess(response)
api_images = json.loads(response.content)['images']['values']
api_images = json.loads(response.content)['images']
self.assertEqual(len(result_images), len(api_images))
self.assertEqual(result_images, api_images)
......@@ -150,7 +150,7 @@ class ImageAPITest(BaseAPITest):
response =\
self.get('/api/v1.1/images/detail?changes-since=%sUTC' % new_time)
self.assertSuccess(response)
api_images = json.loads(response.content)['images']['values']
api_images = json.loads(response.content)['images']
self.assertEqual(1, len(api_images))
@assert_backend_closed
......@@ -169,7 +169,7 @@ class ImageAPITest(BaseAPITest):
'progress': 100,
'created': '2012-11-26T11:52:54+00:00',
'updated': '2012-12-26T11:52:54+00:00',
'metadata': {'values': {'foo': 'bar'}}}
'metadata': {'foo': 'bar'}}
mimage.return_value.get_image.return_value = image
response = self.get('/api/v1.1/images/42', 'user')
self.assertSuccess(response)
......@@ -207,20 +207,20 @@ class ImageMetadataAPITest(BaseAPITest):
'progress': 100,
'created': '2012-11-26T11:52:54+00:00',
'updated': '2012-12-26T11:52:54+00:00',
'metadata': {'values': {'foo': 'bar'}}}
'metadata': {'foo': 'bar'}}
@assert_backend_closed
def test_list_metadata(self, backend):
backend.return_value.get_image.return_value = self.image
response = self.get('/api/v1.1/images/42/meta', 'user')
response = self.get('/api/v1.1/images/42/metadata', 'user')
self.assertSuccess(response)
meta = json.loads(response.content)['metadata']['values']
meta = json.loads(response.content)['metadata']
self.assertEqual(meta, self.image['properties'])
@assert_backend_closed
def test_get_metadata(self, backend):
backend.return_value.get_image.return_value = self.image
response = self.get('/api/v1.1/images/42/meta/foo', 'user')
response = self.get('/api/v1.1/images/42/metadata/foo', 'user')
self.assertSuccess(response)
meta = json.loads(response.content)['meta']
self.assertEqual(meta['foo'], 'bar')
......@@ -228,12 +228,12 @@ class ImageMetadataAPITest(BaseAPITest):
@assert_backend_closed
def test_get_invalid_metadata(self, backend):
backend.return_value.get_image.return_value = self.image
response = self.get('/api/v1.1/images/42/meta/not_found', 'user')
response = self.get('/api/v1.1/images/42/metadata/not_found', 'user')
self.assertItemNotFound(response)
def test_delete_metadata_item(self, backend):
backend.return_value.get_image.return_value = self.image
response = self.delete('/api/v1.1/images/42/meta/foo', 'user')
response = self.delete('/api/v1.1/images/42/metadata/foo', 'user')
self.assertEqual(response.status_code, 204)
backend.return_value.update_metadata.assert_called_once_with('42', {'properties': {'foo2':
'bar2'}})
......@@ -242,7 +242,7 @@ class ImageMetadataAPITest(BaseAPITest):
def test_create_metadata_item(self, backend):
backend.return_value.get_image.return_value = self.image
request = {'meta': {'foo3': 'bar3'}}
response = self.put('/api/v1.1/images/42/meta/foo3', 'user',
response = self.put('/api/v1.1/images/42/metadata/foo3', 'user',
json.dumps(request), 'json')
self.assertEqual(response.status_code, 201)
backend.return_value.update_metadata.assert_called_once_with('42',
......@@ -253,15 +253,15 @@ class ImageMetadataAPITest(BaseAPITest):
def test_create_metadata_malformed_1(self, backend):
backend.return_value.get_image.return_value = self.image
request = {'met': {'foo3': 'bar3'}}
response = self.put('/api/v1.1/images/42/meta/foo3', 'user',
response = self.put('/api/v1.1/images/42/metadata/foo3', 'user',
json.dumps(request), 'json')
self.assertBadRequest(response)
@assert_backend_closed
def test_create_metadata_malformed_2(self, backend):
backend.return_value.get_image.return_value = self.image
request = {'meta': [('foo3', 'bar3')]}
response = self.put('/api/v1.1/images/42/meta/foo3', 'user',
request = {'metadata': [('foo3', 'bar3')]}
response = self.put('/api/v1.1/images/42/metadata/foo3', 'user',
json.dumps(request), 'json')
self.assertBadRequest(response)
......@@ -269,7 +269,7 @@ class ImageMetadataAPITest(BaseAPITest):
def test_create_metadata_malformed_3(self, backend):
backend.return_value.get_image.return_value = self.image
request = {'met': {'foo3': 'bar3', 'foo4': 'bar4'}}
response = self.put('/api/v1.1/images/42/meta/foo3', 'user',
response = self.put('/api/v1.1/images/42/metadata/foo3', 'user',
json.dumps(request), 'json')
self.assertBadRequest(response)
......@@ -277,7 +277,7 @@ class ImageMetadataAPITest(BaseAPITest):
def test_create_metadata_malformed_4(self, backend):
backend.return_value.get_image.return_value = self.image
request = {'met': {'foo3': 'bar3'}}
response = self.put('/api/v1.1/images/42/meta/foo4', 'user',
response = self.put('/api/v1.1/images/42/metadata/foo4', 'user',
json.dumps(request), 'json')
self.assertBadRequest(response)
......@@ -285,7 +285,7 @@ class ImageMetadataAPITest(BaseAPITest):
def test_update_metadata_item(self, backend):
backend.return_value.get_image.return_value = self.image
request = {'metadata': {'foo': 'bar_new', 'foo4': 'bar4'}}
response = self.post('/api/v1.1/images/42/meta', 'user',
response = self.post('/api/v1.1/images/42/metadata', 'user',
json.dumps(request), 'json')
self.assertEqual(response.status_code, 201)
backend.return_value.update_metadata.assert_called_once_with('42',
......@@ -297,6 +297,6 @@ class ImageMetadataAPITest(BaseAPITest):
def test_update_metadata_malformed(self, backend):
backend.return_value.get_image.return_value = self.image
request = {'meta': {'foo': 'bar_new', 'foo4': 'bar4'}}
response = self.post('/api/v1.1/images/42/meta', 'user',
response = self.post('/api/v1.1/images/42/metadata', 'user',
json.dumps(request), 'json')
self.assertBadRequest(response)
......@@ -68,7 +68,7 @@ class NetworkAPITest(BaseAPITest):
self.assertEqual(db_net.public, api_net['public'])
db_nics = ["nic-%d-%d" % (nic.machine.id, nic.index) for nic in
db_net.nics.filter(machine__userid=db_net.userid)]
self.assertEqual(db_nics, api_net['attachments']['values'])
self.assertEqual(db_nics, api_net['attachments'])
def test_create_network_1(self, mrapi):
request = {
......@@ -189,7 +189,7 @@ class NetworkAPITest(BaseAPITest):
self.assertSuccess(response)
db_nets = Network.objects.filter(userid=self.user, deleted=False)
api_nets = json.loads(response.content)["networks"]["values"]
api_nets = json.loads(response.content)["networks"]
self.assertEqual(len(db_nets), len(api_nets))
for api_net in api_nets:
......@@ -205,7 +205,7 @@ class NetworkAPITest(BaseAPITest):
self.assertSuccess(response)
db_nets = Network.objects.filter(userid=self.user, deleted=False)
api_nets = json.loads(response.content)["networks"]["values"]
api_nets = json.loads(response.content)["networks"]
self.assertEqual(len(db_nets), len(api_nets))
for api_net in api_nets:
......@@ -222,7 +222,7 @@ class NetworkAPITest(BaseAPITest):
net.userid)
self.assertSuccess(response)
api_net = json.loads(response.content)["network"]
self.assertEqual(len(api_net["attachments"]["values"]), 0)
self.assertEqual(len(api_net["attachments"]), 0)
def test_network_details_1(self, mrapi):
"""Test that expected details for a network are returned"""
......
......@@ -55,14 +55,14 @@ class ServerAPITest(BaseAPITest):
"""Test if the expected list of servers is returned."""
response = self.get('/api/v1.1/servers')
self.assertSuccess(response)
servers = json.loads(response.content)['servers']['values']
servers = json.loads(response.content)['servers']
self.assertEqual(servers, [])
def test_server_list_2(self):
"""Test if the expected list of servers is returned."""
response = self.get('/api/v1.1/servers', self.user1)
self.assertSuccess(response)
servers = json.loads(response.content)['servers']['values']
servers = json.loads(response.content)['servers']
db_server = self.vm1
self.assertEqual(servers, [{'name': db_server.name,
'id': db_server.id}])
......@@ -74,14 +74,14 @@ class ServerAPITest(BaseAPITest):
self.vm4.id: self.vm4}
response = self.get('/api/v1.1/servers/detail', user)
servers = json.loads(response.content)['servers']['values']
servers = json.loads(response.content)['servers']
self.assertEqual(len(servers), len(user_vms))
for api_vm in servers:
db_vm = user_vms[api_vm['id']]
self.assertEqual(api_vm['flavorRef'], db_vm.flavor.id)
self.assertEqual(api_vm['flavor'], db_vm.flavor.id)
self.assertEqual(api_vm['hostId'], db_vm.hostid)
self.assertEqual(api_vm['id'], db_vm.id)
self.assertEqual(api_vm['imageRef'], db_vm.imageid)
self.assertEqual(api_vm['image'], db_vm.imageid)
self.assertEqual(api_vm['name'], db_vm.name)
self.assertEqual(api_vm['status'], get_rsapi_state(db_vm))
self.assertSuccess(response)
......@@ -98,13 +98,13 @@ class ServerAPITest(BaseAPITest):
response = self.get('/api/v1.1/servers/%d' % db_vm.id, user)
server = json.loads(response.content)['server']
self.assertEqual(server['flavorRef'], db_vm.flavor.id)
self.assertEqual(server['flavor'], db_vm.flavor.id)
self.assertEqual(server['hostId'], db_vm.hostid)
self.assertEqual(server['id'], db_vm.id)
self.assertEqual(server['imageRef'], db_vm.imageid)
self.assertEqual(server['image'], db_vm.imageid)
self.assertEqual(server['name'], db_vm.name)
self.assertEqual(server['status'], get_rsapi_state(db_vm))
api_nic = server['attachments']['values'][0]
api_nic = server['attachments'][0]
self.assertEqual(api_nic['network_id'], str(net.id))
self.assertEqual(api_nic['mac_address'], nic.mac)
self.assertEqual(api_nic['firewallProfile'], nic.firewall_profile)
......@@ -112,7 +112,7 @@ class ServerAPITest(BaseAPITest):
self.assertEqual(api_nic['ipv6'], nic.ipv6)
self.assertEqual(api_nic['id'], 'nic-%s-%s' % (db_vm.id, nic.index))
metadata = server['metadata']['values']
metadata = server['metadata']
self.assertEqual(len(metadata), 1)
self.assertEqual(metadata[db_vm_meta.meta_key], db_vm_meta.meta_value)
self.assertSuccess(response)
......@@ -132,7 +132,7 @@ class ServerAPITest(BaseAPITest):
response = self.get('/api/v1.1/servers/%d' % db_vm.id, user)
server = json.loads(response.content)['server']
nics = server["attachments"]["values"]
nics = server["attachments"]
self.assertEqual(len(nics), 1)
self.assertEqual(nics[0]["network_id"], str(nic2.network_id))
......@@ -203,7 +203,7 @@ class ServerCreateAPITest(BaseAPITest):
api_server = json.loads(response.content)['server']
self.assertEqual(api_server['status'], "BUILD")
self.assertEqual(api_server['progress'], 0)
self.assertEqual(api_server['metadata']['values'],
self.assertEqual(api_server['metadata'],
{"My Server Name": "Apache1"})
self.assertTrue('adminPass' in api_server)
......@@ -253,9 +253,9 @@ class ServerMetadataAPITest(BaseAPITest):
vm = self.vm
create_meta = lambda: mfactory.VirtualMachineMetadataFactory(vm=vm)
metadata = [create_meta(), create_meta(), create_meta()]
response = self.get('/api/v1.1/servers/%d/meta' % vm.id, vm.userid)
response = self.get('/api/v1.1/servers/%d/metadata' % vm.id, vm.userid)
self.assertTrue(response.status_code in [200, 203])
api_metadata = json.loads(response.content)['metadata']['values']
api_metadata = json.loads(response.content)['metadata']
self.assertEqual(len(api_metadata), len(metadata) + 1)
for db_m in metadata:
self.assertEqual(api_metadata[db_m.meta_key], db_m.meta_value)
......@@ -264,12 +264,12 @@ class ServerMetadataAPITest(BaseAPITest):
{'foo': 'bar'},
metadata[0].meta_key: 'bar2'
}
response = self.post('/api/v1.1/servers/%d/meta' % vm.id, vm.userid,
json.dumps(request), 'json')
response = self.post('/api/v1.1/servers/%d/metadata' % vm.id,
vm.userid, json.dumps(request), 'json')
metadata2 = VirtualMachineMetadata.objects.filter(vm=vm)
response = self.get('/api/v1.1/servers/%d/meta' % vm.id, vm.userid)
response = self.get('/api/v1.1/servers/%d/metadata' % vm.id, vm.userid)
self.assertTrue(response.status_code in [200, 203])
api_metadata2 = json.loads(response.content)['metadata']['values']
api_metadata2 = json.loads(response.content)['metadata']
self.assertTrue('foo' in api_metadata2.keys())
self.assertTrue(api_metadata2[metadata[0].meta_key], 'bar2')
self.assertEqual(len(api_metadata2), len(metadata2))
......@@ -278,38 +278,39 @@ class ServerMetadataAPITest(BaseAPITest):
# Create new meta
request = {'meta': {'foo2': 'bar2'}}
response = self.put('/api/v1.1/servers/%d/meta/foo2' % vm.id,
response = self.put('/api/v1.1/servers/%d/metadata/foo2' % vm.id,
vm.userid, json.dumps(request), 'json')
# Get the new meta
response = self.get('/api/v1.1/servers/%d/meta/foo2' % vm.id,
response = self.get('/api/v1.1/servers/%d/metadata/foo2' % vm.id,
vm.userid)
meta = json.loads(response.content)['meta']
self.assertEqual(meta['foo2'], 'bar2')
# Delete the new meta
response = self.delete('/api/v1.1/servers/%d/meta/foo2' % vm.id,
response = self.delete('/api/v1.1/servers/%d/metadata/foo2' % vm.id,
vm.userid)
self.assertEqual(response.status_code, 204)
# Try to get the deleted meta: should raise 404
response = self.get('/api/v1.1/servers/%d/meta/foo2' % vm.id,
response = self.get('/api/v1.1/servers/%d/metadata/foo2' % vm.id,
vm.userid)
self.assertEqual(response.status_code, 404)
def test_invalid_metadata(self):
vm = self.vm
response = self.post('/api/v1.1/servers/%d/meta' % vm.id, vm.userid)
response = self.post('/api/v1.1/servers/%d/metadata' % vm.id,
vm.userid)
self.assertBadRequest(response)
self.assertEqual(len(vm.metadata.all()), 1)
def test_invalid_metadata_server(self):
response = self.post('/api/v1.1/servers/42/meta', 'user')
response = self.post('/api/v1.1/servers/42/metadata', 'user')
self.assertItemNotFound(response)
def test_get_meta_invalid_key(self):
vm = self.vm
response = self.get('/api/v1.1/servers/%d/meta/foo2' % vm.id,
response = self.get('/api/v1.1/servers/%d/metadata/foo2' % vm.id,
vm.userid)
self.assertItemNotFound(response)
......
......@@ -85,7 +85,7 @@ def versions_list(request):
if request.serialization == 'xml':
data = render_to_string('versions_list.xml', {'versions': VERSIONS})
else:
data = json.dumps({'versions': {'values': VERSIONS}})
data = json.dumps({'versions': VERSIONS})
return HttpResponse(data)
......
......@@ -72,14 +72,14 @@
// custom glance api parser
parse: function (resp, xhr) {
if (_.isArray(resp)) {
resp = {'images': {'values': resp }};
resp = {'images': resp };
}
return models.GlanceImages.__super__.parse.call(this, resp, xhr);
},
_read_image_from_request: function(image, msg, xhr) {
var img = {};
img['metadata'] = {values:{}};
img['metadata'] = {};
var headers = snf.util.parseHeaders(xhr.getAllResponseHeaders().toLowerCase());
......@@ -91,7 +91,7 @@
if (key.indexOf("x-image-meta-property") == -1) {
img[key.replace("x-image-meta-","").replace(/-/g,"_")] = _.trim(value);
} else {
img.metadata.values[key.replace('x-image-meta-property-',"").replace(/-/g,"_")] = _.trim(value);
img.metadata[key.replace('x-image-meta-property-',"").replace(/-/g,"_")] = _.trim(value);
}
})
......@@ -102,16 +102,16 @@
parse_meta: function(img) {
if (img.properties) {
img.metadata = {};
img.metadata.values = img.properties;
img.metadata = img.properties;
} else {
if (!img.metadata) {
img.metadata = {values:{}};
img.metadata = {};
}
}
// fixes plankton regression (returns lowercase meta keys)
if (img.metadata.values.os && !img.metadata.values.OS) {
img.metadata.values.OS = img.metadata.values.os;
if (img.metadata.os && !img.metadata.OS) {
img.metadata.OS = img.metadata.os;
}
img = models.GlanceImages.__super__.parse_meta.call(this, img);
......