Implement trove client plugin
This moves the client creation code out of Clients._trove() into its own client plugin. Trove is an integrated project, and python-troveclient is a dependency, so the import is now mandatory. Change-Id: I89d290f6a38488779e77ff11bdfdd64c159a57e8
This commit is contained in:
parent
ce65e9bdb2
commit
e247c291ed
@ -15,7 +15,6 @@ from ceilometerclient import client as ceilometerclient
|
|||||||
from heatclient import client as heatclient
|
from heatclient import client as heatclient
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from stevedore import extension
|
from stevedore import extension
|
||||||
from troveclient import client as troveclient
|
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from heat.common import heat_keystoneclient as hkc
|
from heat.common import heat_keystoneclient as hkc
|
||||||
@ -120,29 +119,6 @@ class OpenStackClients(object):
|
|||||||
'Replace with calls to client("trove")')
|
'Replace with calls to client("trove")')
|
||||||
return self.client('trove')
|
return self.client('trove')
|
||||||
|
|
||||||
def _trove(self):
|
|
||||||
|
|
||||||
con = self.context
|
|
||||||
endpoint_type = self._get_client_option('trove', 'endpoint_type')
|
|
||||||
args = {
|
|
||||||
'service_type': 'database',
|
|
||||||
'auth_url': con.auth_url,
|
|
||||||
'proxy_token': con.auth_token,
|
|
||||||
'username': None,
|
|
||||||
'password': None,
|
|
||||||
'cacert': self._get_client_option('trove', 'ca_file'),
|
|
||||||
'insecure': self._get_client_option('trove', 'insecure'),
|
|
||||||
'endpoint_type': endpoint_type
|
|
||||||
}
|
|
||||||
|
|
||||||
client = troveclient.Client('1.0', **args)
|
|
||||||
management_url = self.url_for(service_type='database',
|
|
||||||
endpoint_type=endpoint_type)
|
|
||||||
client.client.auth_token = con.auth_token
|
|
||||||
client.client.management_url = management_url
|
|
||||||
|
|
||||||
return client
|
|
||||||
|
|
||||||
def ceilometer(self):
|
def ceilometer(self):
|
||||||
warnings.warn('ceilometer() is deprecated. '
|
warnings.warn('ceilometer() is deprecated. '
|
||||||
'Replace with calls to client("ceilometer")')
|
'Replace with calls to client("ceilometer")')
|
||||||
|
42
heat/engine/clients/os/trove.py
Normal file
42
heat/engine/clients/os/trove.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from troveclient import client as tc
|
||||||
|
|
||||||
|
from heat.engine.clients import client_plugin
|
||||||
|
|
||||||
|
|
||||||
|
class TroveClientPlugin(client_plugin.ClientPlugin):
|
||||||
|
|
||||||
|
def _create(self):
|
||||||
|
|
||||||
|
con = self.context
|
||||||
|
endpoint_type = self._get_client_option('trove', 'endpoint_type')
|
||||||
|
args = {
|
||||||
|
'service_type': 'database',
|
||||||
|
'auth_url': con.auth_url,
|
||||||
|
'proxy_token': con.auth_token,
|
||||||
|
'username': None,
|
||||||
|
'password': None,
|
||||||
|
'cacert': self._get_client_option('trove', 'ca_file'),
|
||||||
|
'insecure': self._get_client_option('trove', 'insecure'),
|
||||||
|
'endpoint_type': endpoint_type
|
||||||
|
}
|
||||||
|
|
||||||
|
client = tc.Client('1.0', **args)
|
||||||
|
management_url = self.url_for(service_type='database',
|
||||||
|
endpoint_type=endpoint_type)
|
||||||
|
client.client.auth_token = con.auth_token
|
||||||
|
client.client.management_url = management_url
|
||||||
|
|
||||||
|
return client
|
@ -15,7 +15,6 @@ from troveclient.openstack.common.apiclient import exceptions as troveexc
|
|||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.engine import attributes
|
from heat.engine import attributes
|
||||||
from heat.engine.clients import troveclient
|
|
||||||
from heat.engine import constraints
|
from heat.engine import constraints
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
from heat.engine import resource
|
from heat.engine import resource
|
||||||
@ -265,7 +264,7 @@ class OSDBInstance(resource.Resource):
|
|||||||
def _refresh_instance(self, instance):
|
def _refresh_instance(self, instance):
|
||||||
try:
|
try:
|
||||||
instance.get()
|
instance.get()
|
||||||
except troveclient.exceptions.RequestEntityTooLarge as exc:
|
except troveexc.RequestEntityTooLarge as exc:
|
||||||
msg = _("Stack %(name)s (%(id)s) received an OverLimit "
|
msg = _("Stack %(name)s (%(id)s) received an OverLimit "
|
||||||
"response during instance.get(): %(exception)s")
|
"response during instance.get(): %(exception)s")
|
||||||
LOG.warning(msg % {'name': self.stack.name,
|
LOG.warning(msg % {'name': self.stack.name,
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from troveclient.openstack.common.apiclient import exceptions as troveexc
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
from heat.engine.clients import troveclient
|
|
||||||
from heat.engine import parser
|
from heat.engine import parser
|
||||||
from heat.engine.resources import os_database
|
from heat.engine.resources import os_database
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
@ -181,7 +181,7 @@ class OSDBInstanceTest(HeatTestCase):
|
|||||||
# Simulate an OverLimit exception
|
# Simulate an OverLimit exception
|
||||||
self.m.StubOutWithMock(fake_dbinstance, 'get')
|
self.m.StubOutWithMock(fake_dbinstance, 'get')
|
||||||
fake_dbinstance.get().AndRaise(
|
fake_dbinstance.get().AndRaise(
|
||||||
troveclient.exceptions.RequestEntityTooLarge)
|
troveexc.RequestEntityTooLarge)
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ class OSDBInstanceTest(HeatTestCase):
|
|||||||
fake_dbinstance.delete().AndReturn(None)
|
fake_dbinstance.delete().AndReturn(None)
|
||||||
self.m.StubOutWithMock(fake_dbinstance, 'get')
|
self.m.StubOutWithMock(fake_dbinstance, 'get')
|
||||||
fake_dbinstance.get().AndReturn(None)
|
fake_dbinstance.get().AndReturn(None)
|
||||||
fake_dbinstance.get().AndRaise(troveclient.exceptions.NotFound(404))
|
fake_dbinstance.get().AndRaise(troveexc.NotFound(404))
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
scheduler.TaskRunner(instance.delete)()
|
scheduler.TaskRunner(instance.delete)()
|
||||||
@ -232,9 +232,9 @@ class OSDBInstanceTest(HeatTestCase):
|
|||||||
# Simulate an OverLimit exception
|
# Simulate an OverLimit exception
|
||||||
self.m.StubOutWithMock(fake_dbinstance, 'get')
|
self.m.StubOutWithMock(fake_dbinstance, 'get')
|
||||||
fake_dbinstance.get().AndRaise(
|
fake_dbinstance.get().AndRaise(
|
||||||
troveclient.exceptions.RequestEntityTooLarge)
|
troveexc.RequestEntityTooLarge)
|
||||||
fake_dbinstance.get().AndReturn(None)
|
fake_dbinstance.get().AndReturn(None)
|
||||||
fake_dbinstance.get().AndRaise(troveclient.exceptions.NotFound(404))
|
fake_dbinstance.get().AndRaise(troveexc.NotFound(404))
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
scheduler.TaskRunner(instance.delete)()
|
scheduler.TaskRunner(instance.delete)()
|
||||||
@ -262,7 +262,7 @@ class OSDBInstanceTest(HeatTestCase):
|
|||||||
scheduler.TaskRunner(instance.create)()
|
scheduler.TaskRunner(instance.create)()
|
||||||
self.m.StubOutWithMock(self.fc.instances, 'get')
|
self.m.StubOutWithMock(self.fc.instances, 'get')
|
||||||
self.fc.instances.get(12345).AndRaise(
|
self.fc.instances.get(12345).AndRaise(
|
||||||
troveclient.exceptions.NotFound(404))
|
troveexc.NotFound(404))
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
scheduler.TaskRunner(instance.delete)()
|
scheduler.TaskRunner(instance.delete)()
|
||||||
|
@ -43,6 +43,7 @@ heat.clients =
|
|||||||
nova = heat.engine.clients.os.nova:NovaClientPlugin
|
nova = heat.engine.clients.os.nova:NovaClientPlugin
|
||||||
neutron = heat.engine.clients.os.neutron:NeutronClientPlugin
|
neutron = heat.engine.clients.os.neutron:NeutronClientPlugin
|
||||||
swift = heat.engine.clients.os.swift:SwiftClientPlugin
|
swift = heat.engine.clients.os.swift:SwiftClientPlugin
|
||||||
|
trove = heat.engine.clients.os.trove:TroveClientPlugin
|
||||||
|
|
||||||
heat.constraints =
|
heat.constraints =
|
||||||
nova.flavor = heat.engine.resources.server:FlavorConstraint
|
nova.flavor = heat.engine.resources.server:FlavorConstraint
|
||||||
|
Loading…
Reference in New Issue
Block a user