diff --git a/contrib/heat_magnum/heat_magnum/client.py b/contrib/heat_magnum/heat_magnum/client.py index dc12ce0c2..da458e6b8 100644 --- a/contrib/heat_magnum/heat_magnum/client.py +++ b/contrib/heat_magnum/heat_magnum/client.py @@ -22,9 +22,11 @@ magnum_client = importutils.try_import('magnumclient.v1.client') class MagnumClientPlugin(client_plugin.ClientPlugin): + service_types = ['container'] + def _create(self): endpoint_type = self._get_client_option('magnum', 'endpoint_type') - endpoint = self.url_for(service_type='container', + endpoint = self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) args = { diff --git a/heat/engine/clients/client_plugin.py b/heat/engine/clients/client_plugin.py index a5d93963c..9dc8b8b28 100644 --- a/heat/engine/clients/client_plugin.py +++ b/heat/engine/clients/client_plugin.py @@ -32,6 +32,10 @@ class ClientPlugin(object): # may emit exceptions_module = None + # supported service types, service like cinder support multiple service + # types, so its used in list format + service_types = [] + def __init__(self, context): self.context = context self.clients = context.clients diff --git a/heat/engine/clients/os/barbican.py b/heat/engine/clients/os/barbican.py index bb2a31bb0..a504def67 100644 --- a/heat/engine/clients/os/barbican.py +++ b/heat/engine/clients/os/barbican.py @@ -19,9 +19,11 @@ from barbicanclient import client as barbican_client class BarbicanClientPlugin(client_plugin.ClientPlugin): + service_types = ['key-manager'] + def _create(self): endpoint_type = self._get_client_option('barbican', 'endpoint_type') - endpoint = self.url_for(service_type='key-manager', + endpoint = self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) self._keystone_session.auth = self.context.auth_plugin client = barbican_client.Client( diff --git a/heat/engine/clients/os/ceilometer.py b/heat/engine/clients/os/ceilometer.py index 53d948b09..de467624d 100644 --- a/heat/engine/clients/os/ceilometer.py +++ b/heat/engine/clients/os/ceilometer.py @@ -21,16 +21,17 @@ from heat.engine.clients import client_plugin class CeilometerClientPlugin(client_plugin.ClientPlugin): exceptions_module = [exc, api_exc] + service_types = ['metering'] def _create(self): con = self.context endpoint_type = self._get_client_option('ceilometer', 'endpoint_type') - endpoint = self.url_for(service_type='metering', + endpoint = self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) args = { 'auth_url': con.auth_url, - 'service_type': 'metering', + 'service_type': self.service_types[0], 'project_id': con.tenant, 'token': lambda: self.auth_token, 'endpoint_type': endpoint_type, diff --git a/heat/engine/clients/os/cinder.py b/heat/engine/clients/os/cinder.py index 735f18244..6822df6c3 100644 --- a/heat/engine/clients/os/cinder.py +++ b/heat/engine/clients/os/cinder.py @@ -31,17 +31,19 @@ LOG = logging.getLogger(__name__) class CinderClientPlugin(client_plugin.ClientPlugin): exceptions_module = exceptions + service_types = ['volume', 'volumev2'] def get_volume_api_version(self): '''Returns the most recent API version.''' endpoint_type = self._get_client_option('cinder', 'endpoint_type') try: - self.url_for(service_type='volumev2', endpoint_type=endpoint_type) + self.url_for(service_type=self.service_types[1], + endpoint_type=endpoint_type) return 2 except ks_exceptions.EndpointNotFound: try: - self.url_for(service_type='volume', + self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) return 1 except ks_exceptions.EndpointNotFound: @@ -53,10 +55,10 @@ class CinderClientPlugin(client_plugin.ClientPlugin): volume_api_version = self.get_volume_api_version() if volume_api_version == 1: - service_type = 'volume' + service_type = self.service_types[0] client_version = '1' elif volume_api_version == 2: - service_type = 'volumev2' + service_type = self.service_types[1] client_version = '2' else: raise exception.Error(_('No volume service available.')) diff --git a/heat/engine/clients/os/glance.py b/heat/engine/clients/os/glance.py index e02f12003..552399fea 100644 --- a/heat/engine/clients/os/glance.py +++ b/heat/engine/clients/os/glance.py @@ -28,16 +28,17 @@ LOG = logging.getLogger(__name__) class GlanceClientPlugin(client_plugin.ClientPlugin): exceptions_module = exc + service_types = ['image'] def _create(self): con = self.context endpoint_type = self._get_client_option('glance', 'endpoint_type') - endpoint = self.url_for(service_type='image', + endpoint = self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) args = { 'auth_url': con.auth_url, - 'service_type': 'image', + 'service_type': self.service_types[0], 'project_id': con.tenant, 'token': self.auth_token, 'endpoint_type': endpoint_type, diff --git a/heat/engine/clients/os/heat_plugin.py b/heat/engine/clients/os/heat_plugin.py index 751777429..153982364 100644 --- a/heat/engine/clients/os/heat_plugin.py +++ b/heat/engine/clients/os/heat_plugin.py @@ -20,6 +20,8 @@ from heat.engine.clients import client_plugin class HeatClientPlugin(client_plugin.ClientPlugin): exceptions_module = exc + service_types = ['orchestration', + 'cloudformation'] def _create(self): args = { @@ -60,13 +62,13 @@ class HeatClientPlugin(client_plugin.ClientPlugin): heat_url = heat_url % {'tenant_id': tenant_id} else: endpoint_type = self._get_client_option('heat', 'endpoint_type') - heat_url = self.url_for(service_type='orchestration', + heat_url = self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) return heat_url def get_heat_cfn_url(self): endpoint_type = self._get_client_option('heat', 'endpoint_type') - heat_cfn_url = self.url_for(service_type='cloudformation', + heat_cfn_url = self.url_for(service_type=self.service_types[1], endpoint_type=endpoint_type) return heat_cfn_url diff --git a/heat/engine/clients/os/keystone.py b/heat/engine/clients/os/keystone.py index 3c749c43f..8bb49e3cb 100644 --- a/heat/engine/clients/os/keystone.py +++ b/heat/engine/clients/os/keystone.py @@ -22,6 +22,7 @@ from heat.engine import constraints class KeystoneClientPlugin(client_plugin.ClientPlugin): exceptions_module = exceptions + service_types = ['identity'] def _create(self): return hkc.KeystoneClient(self.context) diff --git a/heat/engine/clients/os/manila.py b/heat/engine/clients/os/manila.py index 83b44f99e..0a15d2422 100644 --- a/heat/engine/clients/os/manila.py +++ b/heat/engine/clients/os/manila.py @@ -21,6 +21,7 @@ MANILACLIENT_VERSION = "1" class ManilaClientPlugin(client_plugin.ClientPlugin): exceptions_module = exceptions + service_types = ['share'] @staticmethod def is_available(): @@ -28,7 +29,7 @@ class ManilaClientPlugin(client_plugin.ClientPlugin): def _create(self): endpoint_type = self._get_client_option('manila', 'endpoint_type') - endpoint = self.url_for(service_type='share', + endpoint = self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) args = { diff --git a/heat/engine/clients/os/mistral.py b/heat/engine/clients/os/mistral.py index f754d4051..2a85a539d 100644 --- a/heat/engine/clients/os/mistral.py +++ b/heat/engine/clients/os/mistral.py @@ -21,13 +21,15 @@ mistral_client = importutils.try_import('mistralclient.api.client') class MistralClientPlugin(client_plugin.ClientPlugin): + service_types = ['workflowv2'] + @staticmethod def is_available(): return mistral_base is not None def _create(self): endpoint_type = self._get_client_option('mistral', 'endpoint_type') - endpoint = self.url_for(service_type='workflowv2', + endpoint = self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) args = { diff --git a/heat/engine/clients/os/neutron.py b/heat/engine/clients/os/neutron.py index 399801e32..04ddd8c44 100644 --- a/heat/engine/clients/os/neutron.py +++ b/heat/engine/clients/os/neutron.py @@ -28,18 +28,19 @@ from heat.engine import constraints class NeutronClientPlugin(client_plugin.ClientPlugin): exceptions_module = exceptions + service_types = ['network'] def _create(self): con = self.context endpoint_type = self._get_client_option('neutron', 'endpoint_type') - endpoint = self.url_for(service_type='network', + endpoint = self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) args = { 'auth_url': con.auth_url, - 'service_type': 'network', + 'service_type': self.service_types[0], 'token': self.auth_token, 'endpoint_url': endpoint, 'endpoint_type': endpoint_type, diff --git a/heat/engine/clients/os/nova.py b/heat/engine/clients/os/nova.py index 97495cf9e..c17f81e2b 100644 --- a/heat/engine/clients/os/nova.py +++ b/heat/engine/clients/os/nova.py @@ -58,10 +58,11 @@ class NovaClientPlugin(client_plugin.ClientPlugin): 'VERIFY_RESIZE'] exceptions_module = exceptions + service_types = ['compute'] def _create(self): endpoint_type = self._get_client_option('nova', 'endpoint_type') - management_url = self.url_for(service_type='compute', + management_url = self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) computeshell = novashell.OpenStackComputeShell() @@ -70,7 +71,7 @@ class NovaClientPlugin(client_plugin.ClientPlugin): args = { 'project_id': self.context.tenant, 'auth_url': self.context.auth_url, - 'service_type': 'compute', + 'service_type': self.service_types[0], 'username': None, 'api_key': None, 'extensions': extensions, diff --git a/heat/engine/clients/os/sahara.py b/heat/engine/clients/os/sahara.py index 98d72d724..a47259d03 100644 --- a/heat/engine/clients/os/sahara.py +++ b/heat/engine/clients/os/sahara.py @@ -32,14 +32,15 @@ LOG = logging.getLogger(__name__) class SaharaClientPlugin(client_plugin.ClientPlugin): exceptions_module = sahara_base + service_types = ['data-processing'] def _create(self): con = self.context endpoint_type = self._get_client_option('sahara', 'endpoint_type') - endpoint = self.url_for(service_type='data-processing', + endpoint = self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) args = { - 'service_type': 'data-processing', + 'service_type': self.service_types[0], 'input_auth_token': self.auth_token, 'auth_url': con.auth_url, 'project_name': con.tenant, diff --git a/heat/engine/clients/os/swift.py b/heat/engine/clients/os/swift.py index 65a290ad1..8e3f2fef2 100644 --- a/heat/engine/clients/os/swift.py +++ b/heat/engine/clients/os/swift.py @@ -32,6 +32,7 @@ MAX_EPOCH = 2147483647 class SwiftClientPlugin(client_plugin.ClientPlugin): exceptions_module = exceptions + service_types = ['object-store'] def _create(self): @@ -44,7 +45,7 @@ class SwiftClientPlugin(client_plugin.ClientPlugin): 'key': None, 'authurl': None, 'preauthtoken': self.auth_token, - 'preauthurl': self.url_for(service_type='object-store', + 'preauthurl': self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type), 'os_options': {'endpoint_type': endpoint_type}, 'cacert': self._get_client_option('swift', 'ca_file'), diff --git a/heat/engine/clients/os/trove.py b/heat/engine/clients/os/trove.py index 2d654df7a..adf6fd513 100644 --- a/heat/engine/clients/os/trove.py +++ b/heat/engine/clients/os/trove.py @@ -23,13 +23,14 @@ from heat.engine import constraints class TroveClientPlugin(client_plugin.ClientPlugin): exceptions_module = exceptions + service_types = ['database'] def _create(self): con = self.context endpoint_type = self._get_client_option('trove', 'endpoint_type') args = { - 'service_type': 'database', + 'service_type': self.service_types[0], 'auth_url': con.auth_url or '', 'proxy_token': con.auth_token, 'username': None, @@ -40,7 +41,7 @@ class TroveClientPlugin(client_plugin.ClientPlugin): } client = tc.Client('1.0', **args) - management_url = self.url_for(service_type='database', + management_url = self.url_for(service_type=self.service_types[0], endpoint_type=endpoint_type) client.client.auth_token = con.auth_token client.client.management_url = management_url diff --git a/heat/engine/clients/os/zaqar.py b/heat/engine/clients/os/zaqar.py index 45c110ec2..3798174f8 100644 --- a/heat/engine/clients/os/zaqar.py +++ b/heat/engine/clients/os/zaqar.py @@ -26,6 +26,7 @@ from heat.engine.clients import client_plugin class ZaqarClientPlugin(client_plugin.ClientPlugin): exceptions_module = zaqar_errors + service_types = ['messaging'] def _create(self): return self.create_for_tenant(self.context.tenant_id) @@ -40,12 +41,12 @@ class ZaqarClientPlugin(client_plugin.ClientPlugin): 'os_auth_token': con.auth_token, 'os_auth_url': con.auth_url, 'os_project_id': tenant_id, - 'os_service_type': 'messaging', + 'os_service_type': self.service_types[0], } auth_opts = {'backend': 'keystone', 'options': opts} conf = {'auth_opts': auth_opts} - endpoint = self.url_for(service_type='messaging') + endpoint = self.url_for(service_type=self.service_types[0]) client = zaqarclient.Client(url=endpoint, conf=conf, version=1.1) diff --git a/heat/tests/test_clients.py b/heat/tests/test_clients.py index 00fefd33f..a24c4b264 100644 --- a/heat/tests/test_clients.py +++ b/heat/tests/test_clients.py @@ -348,6 +348,9 @@ class TestClientPluginsInitialise(common.HeatTestCase): self.assertEqual(con, plugin.context) self.assertIsNone(plugin._client) self.assertTrue(clients.has_client(plugin_name)) + self.assertTrue(isinstance(plugin.service_types, list)) + self.assertTrue(len(plugin.service_types) >= 1, + 'service_types is not defined for plugin') class TestIsNotFound(common.HeatTestCase):