Add service catalog get for keystone REST API

This adds full access to the keystone service catalog for the user.

The service catalog can be used to determine whether or not
Neutron or Nova networking is enabled. This is needed in
launch instance.

Change-Id: I9e19563b0d9b8d106274d6806b302eb01bb51915
Partially Implements: blueprint launch-instance-redesign
This commit is contained in:
Richard Jones 2015-02-20 17:13:14 +11:00 committed by Travis Tripp
parent fda45dbcc5
commit 1c91850542
3 changed files with 33 additions and 0 deletions

View File

@ -200,6 +200,13 @@ limitations under the License.
horizon.alert('error', gettext('Unable to grant the role.'));
});
};
this.serviceCatalog = function() {
return apiService.get('/api/keystone/svc-catalog/')
.error(function () {
horizon.alert('error', gettext('Unable to fetch the service catalog.'));
});
};
}
angular.module('hz.api')

View File

@ -487,3 +487,15 @@ class ProjectRole(generic.View):
user_id,
role_id
)
@urls.register
class ServiceCatalog(generic.View):
url_regex = r'keystone/svc-catalog/$'
@rest_utils.ajax()
def get(self, request):
"""Return the Keystone service catalog associated with the current
user.
"""
return request.user.service_catalog

View File

@ -16,6 +16,8 @@ import testtools
from django.conf import settings
from oslo_serialization import jsonutils
from openstack_dashboard.api.rest import keystone
from rest_test_utils import construct_request # noqa
@ -529,3 +531,15 @@ class KeystoneRestTestCase(testtools.TestCase):
description=None,
domain='domain123',
enabled=None)
#
# Service Catalog
#
@mock.patch.object(keystone.api, 'keystone')
def test_service_catalog_get(self, kc):
request = construct_request()
response = keystone.ServiceCatalog().get(request)
self.assertStatusCode(response, 200)
content = jsonutils.dumps(request.user.service_catalog,
sort_keys=settings.DEBUG)
self.assertEqual(content, response.content)