Merge "Refactor Adding service_types to client_plugins"
This commit is contained in:
commit
e7e940e107
@ -19,11 +19,11 @@ from barbicanclient import client as barbican_client
|
||||
|
||||
class BarbicanClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
service_types = ['key-manager']
|
||||
service_types = [KEY_MANAGER] = ['key-manager']
|
||||
|
||||
def _create(self):
|
||||
endpoint_type = self._get_client_option('barbican', 'endpoint_type')
|
||||
endpoint = self.url_for(service_type=self.service_types[0],
|
||||
endpoint = self.url_for(service_type=self.KEY_MANAGER,
|
||||
endpoint_type=endpoint_type)
|
||||
self._keystone_session.auth = self.context.auth_plugin
|
||||
client = barbican_client.Client(
|
||||
|
@ -21,17 +21,18 @@ from heat.engine.clients import client_plugin
|
||||
class CeilometerClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = [exc, api_exc]
|
||||
service_types = ['metering']
|
||||
|
||||
service_types = [METERING] = ['metering']
|
||||
|
||||
def _create(self):
|
||||
|
||||
con = self.context
|
||||
endpoint_type = self._get_client_option('ceilometer', 'endpoint_type')
|
||||
endpoint = self.url_for(service_type=self.service_types[0],
|
||||
endpoint = self.url_for(service_type=self.METERING,
|
||||
endpoint_type=endpoint_type)
|
||||
args = {
|
||||
'auth_url': con.auth_url,
|
||||
'service_type': self.service_types[0],
|
||||
'service_type': self.METERING,
|
||||
'project_id': con.tenant,
|
||||
'token': lambda: self.auth_token,
|
||||
'endpoint_type': endpoint_type,
|
||||
|
@ -31,19 +31,20 @@ LOG = logging.getLogger(__name__)
|
||||
class CinderClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = exceptions
|
||||
service_types = ['volume', 'volumev2']
|
||||
|
||||
service_types = [VOLUME, VOLUME_V2] = ['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=self.service_types[1],
|
||||
self.url_for(service_type=self.VOLUME_V2,
|
||||
endpoint_type=endpoint_type)
|
||||
return 2
|
||||
except ks_exceptions.EndpointNotFound:
|
||||
try:
|
||||
self.url_for(service_type=self.service_types[0],
|
||||
self.url_for(service_type=self.VOLUME,
|
||||
endpoint_type=endpoint_type)
|
||||
return 1
|
||||
except ks_exceptions.EndpointNotFound:
|
||||
@ -55,10 +56,10 @@ class CinderClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
volume_api_version = self.get_volume_api_version()
|
||||
if volume_api_version == 1:
|
||||
service_type = self.service_types[0]
|
||||
service_type = self.VOLUME
|
||||
client_version = '1'
|
||||
elif volume_api_version == 2:
|
||||
service_type = self.service_types[1]
|
||||
service_type = self.VOLUME_V2
|
||||
client_version = '2'
|
||||
else:
|
||||
raise exception.Error(_('No volume service available.'))
|
||||
|
@ -25,11 +25,11 @@ class DesignateClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = [exceptions]
|
||||
|
||||
service_types = ['dns']
|
||||
service_types = [DNS] = ['dns']
|
||||
|
||||
def _create(self):
|
||||
args = self._get_client_args(service_name='designate',
|
||||
service_type=self.service_types[0])
|
||||
service_type=self.DNS)
|
||||
|
||||
return client.Client(auth_url=args['auth_url'],
|
||||
project_id=args['project_id'],
|
||||
|
@ -28,17 +28,18 @@ LOG = logging.getLogger(__name__)
|
||||
class GlanceClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = exc
|
||||
service_types = ['image']
|
||||
|
||||
service_types = [IMAGE] = ['image']
|
||||
|
||||
def _create(self):
|
||||
|
||||
con = self.context
|
||||
endpoint_type = self._get_client_option('glance', 'endpoint_type')
|
||||
endpoint = self.url_for(service_type=self.service_types[0],
|
||||
endpoint = self.url_for(service_type=self.IMAGE,
|
||||
endpoint_type=endpoint_type)
|
||||
args = {
|
||||
'auth_url': con.auth_url,
|
||||
'service_type': self.service_types[0],
|
||||
'service_type': self.IMAGE,
|
||||
'project_id': con.tenant,
|
||||
'token': self.auth_token,
|
||||
'endpoint_type': endpoint_type,
|
||||
|
@ -20,8 +20,9 @@ from heat.engine.clients import client_plugin
|
||||
class HeatClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = exc
|
||||
service_types = ['orchestration',
|
||||
'cloudformation']
|
||||
|
||||
service_types = [ORCHESTRATION,
|
||||
CLOUDFORMATION] = ['orchestration', 'cloudformation']
|
||||
|
||||
def _create(self):
|
||||
args = {
|
||||
@ -62,13 +63,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=self.service_types[0],
|
||||
heat_url = self.url_for(service_type=self.ORCHESTRATION,
|
||||
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=self.service_types[1],
|
||||
heat_cfn_url = self.url_for(service_type=self.CLOUDFORMATION,
|
||||
endpoint_type=endpoint_type)
|
||||
return heat_cfn_url
|
||||
|
@ -22,7 +22,8 @@ from heat.engine import constraints
|
||||
class KeystoneClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = exceptions
|
||||
service_types = ['identity']
|
||||
|
||||
service_types = [IDENTITY] = ['identity']
|
||||
|
||||
def _create(self):
|
||||
return hkc.KeystoneClient(self.context)
|
||||
|
@ -22,7 +22,7 @@ magnum_client = importutils.try_import('magnumclient.v1.client')
|
||||
|
||||
class MagnumClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
service_types = ['container']
|
||||
service_types = [CONTAINER] = ['container']
|
||||
|
||||
@staticmethod
|
||||
def is_available():
|
||||
@ -30,7 +30,7 @@ class MagnumClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
def _create(self):
|
||||
endpoint_type = self._get_client_option('magnum', 'endpoint_type')
|
||||
endpoint = self.url_for(service_type=self.service_types[0],
|
||||
endpoint = self.url_for(service_type=self.CONTAINER,
|
||||
endpoint_type=endpoint_type)
|
||||
|
||||
args = {
|
||||
|
@ -22,11 +22,12 @@ MANILACLIENT_VERSION = "1"
|
||||
class ManilaClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = exceptions
|
||||
service_types = ['share']
|
||||
|
||||
service_types = [SHARE] = ['share']
|
||||
|
||||
def _create(self):
|
||||
endpoint_type = self._get_client_option('manila', 'endpoint_type')
|
||||
endpoint = self.url_for(service_type=self.service_types[0],
|
||||
endpoint = self.url_for(service_type=self.SHARE,
|
||||
endpoint_type=endpoint_type)
|
||||
|
||||
args = {
|
||||
|
@ -21,7 +21,7 @@ mistral_client = importutils.try_import('mistralclient.api.client')
|
||||
|
||||
class MistralClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
service_types = ['workflowv2']
|
||||
service_types = [WORKFLOW_V2] = ['workflowv2']
|
||||
|
||||
@staticmethod
|
||||
def is_available():
|
||||
@ -29,7 +29,7 @@ class MistralClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
def _create(self):
|
||||
endpoint_type = self._get_client_option('mistral', 'endpoint_type')
|
||||
endpoint = self.url_for(service_type=self.service_types[0],
|
||||
endpoint = self.url_for(service_type=self.WORKFLOW_V2,
|
||||
endpoint_type=endpoint_type)
|
||||
|
||||
args = {
|
||||
|
@ -28,19 +28,20 @@ from heat.engine import constraints
|
||||
class NeutronClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = exceptions
|
||||
service_types = ['network']
|
||||
|
||||
service_types = [NETWORK] = ['network']
|
||||
|
||||
def _create(self):
|
||||
|
||||
con = self.context
|
||||
|
||||
endpoint_type = self._get_client_option('neutron', 'endpoint_type')
|
||||
endpoint = self.url_for(service_type=self.service_types[0],
|
||||
endpoint = self.url_for(service_type=self.NETWORK,
|
||||
endpoint_type=endpoint_type)
|
||||
|
||||
args = {
|
||||
'auth_url': con.auth_url,
|
||||
'service_type': self.service_types[0],
|
||||
'service_type': self.NETWORK,
|
||||
'token': self.auth_token,
|
||||
'endpoint_url': endpoint,
|
||||
'endpoint_type': endpoint_type,
|
||||
|
@ -57,11 +57,12 @@ class NovaClientPlugin(client_plugin.ClientPlugin):
|
||||
'VERIFY_RESIZE']
|
||||
|
||||
exceptions_module = exceptions
|
||||
service_types = ['compute']
|
||||
|
||||
service_types = [COMPUTE] = ['compute']
|
||||
|
||||
def _create(self):
|
||||
endpoint_type = self._get_client_option('nova', 'endpoint_type')
|
||||
management_url = self.url_for(service_type=self.service_types[0],
|
||||
management_url = self.url_for(service_type=self.COMPUTE,
|
||||
endpoint_type=endpoint_type)
|
||||
|
||||
if hasattr(nc, 'discover_extensions'):
|
||||
@ -78,7 +79,7 @@ class NovaClientPlugin(client_plugin.ClientPlugin):
|
||||
args = {
|
||||
'project_id': self.context.tenant,
|
||||
'auth_url': self.context.auth_url,
|
||||
'service_type': self.service_types[0],
|
||||
'service_type': self.COMPUTE,
|
||||
'username': None,
|
||||
'api_key': None,
|
||||
'extensions': extensions,
|
||||
|
@ -32,15 +32,16 @@ LOG = logging.getLogger(__name__)
|
||||
class SaharaClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = sahara_base
|
||||
service_types = ['data-processing']
|
||||
|
||||
service_types = [DATA_PROCESSING] = ['data-processing']
|
||||
|
||||
def _create(self):
|
||||
con = self.context
|
||||
endpoint_type = self._get_client_option('sahara', 'endpoint_type')
|
||||
endpoint = self.url_for(service_type=self.service_types[0],
|
||||
endpoint = self.url_for(service_type=self.DATA_PROCESSING,
|
||||
endpoint_type=endpoint_type)
|
||||
args = {
|
||||
'service_type': self.service_types[0],
|
||||
'service_type': self.DATA_PROCESSING,
|
||||
'input_auth_token': self.auth_token,
|
||||
'auth_url': con.auth_url,
|
||||
'project_name': con.tenant,
|
||||
|
@ -32,7 +32,8 @@ MAX_EPOCH = 2147483647
|
||||
class SwiftClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = exceptions
|
||||
service_types = ['object-store']
|
||||
|
||||
service_types = [OBJECT_STORE] = ['object-store']
|
||||
|
||||
def _create(self):
|
||||
|
||||
@ -45,7 +46,7 @@ class SwiftClientPlugin(client_plugin.ClientPlugin):
|
||||
'key': None,
|
||||
'authurl': None,
|
||||
'preauthtoken': self.auth_token,
|
||||
'preauthurl': self.url_for(service_type=self.service_types[0],
|
||||
'preauthurl': self.url_for(service_type=self.OBJECT_STORE,
|
||||
endpoint_type=endpoint_type),
|
||||
'os_options': {'endpoint_type': endpoint_type},
|
||||
'cacert': self._get_client_option('swift', 'ca_file'),
|
||||
|
@ -23,14 +23,15 @@ from heat.engine import constraints
|
||||
class TroveClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = exceptions
|
||||
service_types = ['database']
|
||||
|
||||
service_types = [DATABASE] = ['database']
|
||||
|
||||
def _create(self):
|
||||
|
||||
con = self.context
|
||||
endpoint_type = self._get_client_option('trove', 'endpoint_type')
|
||||
args = {
|
||||
'service_type': self.service_types[0],
|
||||
'service_type': self.DATABASE,
|
||||
'auth_url': con.auth_url or '',
|
||||
'proxy_token': con.auth_token,
|
||||
'username': None,
|
||||
@ -41,7 +42,7 @@ class TroveClientPlugin(client_plugin.ClientPlugin):
|
||||
}
|
||||
|
||||
client = tc.Client('1.0', **args)
|
||||
management_url = self.url_for(service_type=self.service_types[0],
|
||||
management_url = self.url_for(service_type=self.DATABASE,
|
||||
endpoint_type=endpoint_type)
|
||||
client.client.auth_token = con.auth_token
|
||||
client.client.management_url = management_url
|
||||
|
@ -26,7 +26,8 @@ from heat.engine.clients import client_plugin
|
||||
class ZaqarClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = zaqar_errors
|
||||
service_types = ['messaging']
|
||||
|
||||
service_types = [MESSAGING] = ['messaging']
|
||||
|
||||
DEFAULT_TTL = 3600
|
||||
|
||||
@ -43,12 +44,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': self.service_types[0],
|
||||
'os_service_type': self.MESSAGING,
|
||||
}
|
||||
auth_opts = {'backend': 'keystone',
|
||||
'options': opts}
|
||||
conf = {'auth_opts': auth_opts}
|
||||
endpoint = self.url_for(service_type=self.service_types[0])
|
||||
endpoint = self.url_for(service_type=self.MESSAGING)
|
||||
|
||||
client = zaqarclient.Client(url=endpoint, conf=conf, version=1.1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user