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:
parent
1a44187fdf
commit
23893088f1
@ -11,9 +11,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""Client Library for Marconi Resources."""
|
|
||||||
|
|
||||||
from heat.engine import clients
|
|
||||||
from heat.openstack.common import log as logging
|
from heat.openstack.common import log as logging
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -23,10 +20,12 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
marconiclient = None
|
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
|
con = self.context
|
||||||
if self.auth_token is None:
|
if self.auth_token is None:
|
||||||
@ -37,11 +36,13 @@ class Clients(clients.OpenStackClients):
|
|||||||
'os_auth_token': con.auth_token,
|
'os_auth_token': con.auth_token,
|
||||||
'os_auth_url': con.auth_url,
|
'os_auth_url': con.auth_url,
|
||||||
'os_project_id': con.tenant,
|
'os_project_id': con.tenant,
|
||||||
'os_service_type': service_type,
|
'os_service_type': 'queuing',
|
||||||
}
|
}
|
||||||
auth_opts = {'backend': 'keystone',
|
auth_opts = {'backend': 'keystone',
|
||||||
'options': opts}
|
'options': opts}
|
||||||
conf = {'auth_opts': auth_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
|
@ -13,20 +13,17 @@
|
|||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.engine import attributes
|
from heat.engine import attributes
|
||||||
|
from heat.engine import clients
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
from heat.engine import resource
|
from heat.engine import resource
|
||||||
|
|
||||||
from .. import clients # noqa
|
|
||||||
|
|
||||||
|
def resource_mapping():
|
||||||
if clients.marconiclient is None:
|
if not clients.has_client('marconi'):
|
||||||
def resource_mapping():
|
|
||||||
return {}
|
return {}
|
||||||
else:
|
return {
|
||||||
def resource_mapping():
|
'OS::Marconi::Queue': MarconiQueue,
|
||||||
return {
|
}
|
||||||
'OS::Marconi::Queue': MarconiQueue,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class MarconiQueue(resource.Resource):
|
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):
|
def marconi(self):
|
||||||
return self.clients.client('marconi')
|
return self.clients.client('marconi')
|
||||||
|
|
@ -17,10 +17,13 @@ classifier =
|
|||||||
Programming Language :: Python :: 2.7
|
Programming Language :: Python :: 2.7
|
||||||
Programming Language :: Python :: 2.6
|
Programming Language :: Python :: 2.6
|
||||||
|
|
||||||
|
packages =
|
||||||
|
heat_marconi
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
# Copy to /usr/lib/heat for plugin loading
|
# Copy to /usr/lib/heat for plugin loading
|
||||||
data_files =
|
data_files =
|
||||||
lib/heat/marconi = marconi/resources/*
|
lib/heat/marconi = heat_marconi/resources/*
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
setup-hooks =
|
setup-hooks =
|
Loading…
Reference in New Issue
Block a user