Implement marconi client plugin

This moves the client creation code out of a Clients subclass into
its own client plugin.

The base package has been renamed to heat_marconi since stevedore
is used for client plugin loading and the base package will be
installed by setuptools, the package marconi might clash with
the actual marconi project.

Change-Id: Ie824d961fcfa9dafd72cc40ccf207d1c1e0501ad
This commit is contained in:
Steve Baker 2014-06-30 17:08:56 +12:00 committed by Randall Burt
parent 1a44187fdf
commit 23893088f1
10 changed files with 19 additions and 22 deletions

View File

@ -11,9 +11,6 @@
# License for the specific language governing permissions and limitations
# under the License.
"""Client Library for Marconi Resources."""
from heat.engine import clients
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)
@ -23,10 +20,12 @@ try:
except ImportError:
marconiclient = None
from heat.engine.clients import client_plugin
class Clients(clients.OpenStackClients):
def _marconi(self, service_type="queuing"):
class MarconiClientPlugin(client_plugin.ClientPlugin):
def _create(self):
con = self.context
if self.auth_token is None:
@ -37,11 +36,13 @@ class Clients(clients.OpenStackClients):
'os_auth_token': con.auth_token,
'os_auth_url': con.auth_url,
'os_project_id': con.tenant,
'os_service_type': service_type,
'os_service_type': 'queuing',
}
auth_opts = {'backend': 'keystone',
'options': opts}
conf = {'auth_opts': auth_opts}
endpoint = self.url_for(service_type=service_type)
endpoint = self.url_for(service_type='queuing')
return marconiclient.Client(url=endpoint, conf=conf)
client = marconiclient.Client(url=endpoint, conf=conf)
return client

View File

@ -13,20 +13,17 @@
from heat.common import exception
from heat.engine import attributes
from heat.engine import clients
from heat.engine import properties
from heat.engine import resource
from .. import clients # noqa
if clients.marconiclient is None:
def resource_mapping():
def resource_mapping():
if not clients.has_client('marconi'):
return {}
else:
def resource_mapping():
return {
'OS::Marconi::Queue': MarconiQueue,
}
return {
'OS::Marconi::Queue': MarconiQueue,
}
class MarconiQueue(resource.Resource):
@ -65,10 +62,6 @@ class MarconiQueue(resource.Resource):
),
}
def __init__(self, name, json_snippet, stack):
super(MarconiQueue, self).__init__(name, json_snippet, stack)
self.clients = clients.Clients(self.context)
def marconi(self):
return self.clients.client('marconi')

View File

@ -17,10 +17,13 @@ classifier =
Programming Language :: Python :: 2.7
Programming Language :: Python :: 2.6
packages =
heat_marconi
[files]
# Copy to /usr/lib/heat for plugin loading
data_files =
lib/heat/marconi = marconi/resources/*
lib/heat/marconi = heat_marconi/resources/*
[global]
setup-hooks =