Merge "Add REST API to get Glance API Version"
This commit is contained in:
commit
903127125f
@ -347,3 +347,7 @@ def metadefs_namespace_remove_resource_type(request,
|
||||
resource_type_name):
|
||||
glanceclient(request, '2').metadefs_resource_type.deassociate(
|
||||
namespace_name, resource_type_name)
|
||||
|
||||
|
||||
def get_version():
|
||||
return VERSIONS.active
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
# Copyright 2015, Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -26,6 +25,19 @@ from openstack_dashboard.api.rest import urls
|
||||
CLIENT_KEYWORDS = {'resource_type', 'marker', 'sort_dir', 'sort_key', 'paginate'}
|
||||
|
||||
|
||||
@urls.register
|
||||
class Version(generic.View):
|
||||
"""API for active glance version.
|
||||
"""
|
||||
url_regex = r'glance/version/$'
|
||||
|
||||
@rest_utils.ajax()
|
||||
def get(self, request):
|
||||
"""Get active glance version.
|
||||
"""
|
||||
return {'version': api.glance.get_version()}
|
||||
|
||||
|
||||
@urls.register
|
||||
class Image(generic.View):
|
||||
"""API for retrieving a single image
|
||||
|
@ -32,6 +32,7 @@
|
||||
*/
|
||||
function glanceAPI(apiService, toastService) {
|
||||
var service = {
|
||||
getVersion: getVersion,
|
||||
getImage: getImage,
|
||||
getImageProps: getImageProps,
|
||||
editImageProps: editImageProps,
|
||||
@ -43,6 +44,14 @@
|
||||
|
||||
///////////////
|
||||
|
||||
// Version
|
||||
function getVersion() {
|
||||
return apiService.get('/api/glance/version/')
|
||||
.error(function () {
|
||||
toastService.add('error', gettext('Unable to get the Glance service version.'));
|
||||
});
|
||||
}
|
||||
|
||||
// Images
|
||||
|
||||
/**
|
||||
|
@ -40,6 +40,12 @@
|
||||
});
|
||||
|
||||
var tests = [
|
||||
{
|
||||
"func": "getVersion",
|
||||
"method": "get",
|
||||
"path": "/api/glance/version/",
|
||||
"error": "Unable to get the Glance service version."
|
||||
},
|
||||
{
|
||||
"func": "getImage",
|
||||
"method": "get",
|
||||
|
@ -19,6 +19,18 @@ from openstack_dashboard.test import helpers as test
|
||||
|
||||
|
||||
class ImagesRestTestCase(test.TestCase):
|
||||
#
|
||||
# Version
|
||||
#
|
||||
@mock.patch.object(glance.api, 'glance')
|
||||
def test_version_get(self, gc):
|
||||
request = self.mock_rest_request()
|
||||
gc.get_version.return_value = '2.0'
|
||||
response = glance.Version().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json, {"version": "2.0"})
|
||||
gc.get_version.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(glance.api, 'glance')
|
||||
def test_image_get_single(self, gc):
|
||||
request = self.mock_rest_request()
|
||||
|
Loading…
x
Reference in New Issue
Block a user