Browse Source

Merge "Refactor Adding service_types to client_plugins"

changes/25/197825/4
Jenkins 7 years ago committed by Gerrit Code Review
parent
commit
e7e940e107
  1. 4
      heat/engine/clients/os/barbican.py
  2. 7
      heat/engine/clients/os/ceilometer.py
  3. 11
      heat/engine/clients/os/cinder.py
  4. 4
      heat/engine/clients/os/designate.py
  5. 7
      heat/engine/clients/os/glance.py
  6. 9
      heat/engine/clients/os/heat_plugin.py
  7. 3
      heat/engine/clients/os/keystone.py
  8. 4
      heat/engine/clients/os/magnum.py
  9. 5
      heat/engine/clients/os/manila.py
  10. 4
      heat/engine/clients/os/mistral.py
  11. 7
      heat/engine/clients/os/neutron.py
  12. 7
      heat/engine/clients/os/nova.py
  13. 7
      heat/engine/clients/os/sahara.py
  14. 5
      heat/engine/clients/os/swift.py
  15. 7
      heat/engine/clients/os/trove.py
  16. 7
      heat/engine/clients/os/zaqar.py

4
heat/engine/clients/os/barbican.py

@ -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(

7
heat/engine/clients/os/ceilometer.py

@ -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,

11
heat/engine/clients/os/cinder.py

@ -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.'))

4
heat/engine/clients/os/designate.py

@ -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'],

7
heat/engine/clients/os/glance.py

@ -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,

9
heat/engine/clients/os/heat_plugin.py

@ -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

3
heat/engine/clients/os/keystone.py

@ -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)

4
heat/engine/clients/os/magnum.py

@ -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 = {

5
heat/engine/clients/os/manila.py

@ -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 = {

4
heat/engine/clients/os/mistral.py

@ -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 = {

7
heat/engine/clients/os/neutron.py

@ -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,

7
heat/engine/clients/os/nova.py

@ -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,

7
heat/engine/clients/os/sahara.py

@ -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,

5
heat/engine/clients/os/swift.py

@ -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'),

7
heat/engine/clients/os/trove.py

@ -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

7
heat/engine/clients/os/zaqar.py

@ -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…
Cancel
Save