Add glanceclient to heat

To enable implementation of a glance image resource, we first need to add
access to glanceclient in heat.

Change-Id: Ie0623e0307f6d3163ae584ceab89453f71f48053
Implements: blueprint glance-image
This commit is contained in:
huangtianhua 2014-04-26 17:30:03 +08:00
parent 0b25affb9c
commit 4b57d14559
5 changed files with 63 additions and 1 deletions

View File

@ -698,6 +698,33 @@
#insecure=false
[clients_glance]
#
# Options defined in heat.common.config
#
# Type of endpoint in Identity service catalog to use for
# communication with the OpenStack service. (string value)
#endpoint_type=publicURL
# Optional CA cert file to use in SSL connections. (string
# value)
#ca_file=<None>
# Optional PEM-formatted certificate chain file. (string
# value)
#cert_file=<None>
# Optional PEM-formatted file that contains the private key.
# (string value)
#key_file=<None>
# If set, then the server's certificate will not be verified.
# (boolean value)
#insecure=false
[clients_nova]
#

View File

@ -52,6 +52,12 @@ except ImportError:
ceilometerclient = None
logger.info(_('ceilometerclient not available'))
try:
from glanceclient import client as glanceclient
except ImportError:
glanceclient = None
logger.info(_('glanceclient not available'))
_default_backend = "heat.engine.clients.OpenStackClients"
cloud_opts = [
@ -76,6 +82,7 @@ class OpenStackClients(object):
self._trove = None
self._ceilometer = None
self._heat = None
self._glance = None
@property
def auth_token(self):
@ -148,6 +155,31 @@ class OpenStackClients(object):
self._swift = swiftclient.Connection(**args)
return self._swift
def glance(self):
if glanceclient is None:
return None
if self._glance:
return self._glance
con = self.context
endpoint_type = self._get_client_option('glance', 'endpoint_type')
endpoint = self.url_for(service_type='image',
endpoint_type=endpoint_type)
args = {
'auth_url': con.auth_url,
'service_type': 'image',
'project_id': con.tenant,
'token': self.auth_token,
'endpoint_type': endpoint_type,
'ca_file': self._get_client_option('glance', 'ca_file'),
'cert_file': self._get_client_option('glance', 'cert_file'),
'key_file': self._get_client_option('glance', 'key_file'),
'insecure': self._get_client_option('glance', 'insecure')
}
self._glance = glanceclient.Client('1', endpoint, **args)
return self._glance
def neutron(self):
if neutronclient is None:
return None

View File

@ -358,6 +358,9 @@ class Resource(object):
def heat(self):
return self.stack.clients.heat()
def glance(self):
return self.stack.clients.glance()
def _do_action(self, action, pre_func=None, resource_data=None):
'''
Perform a transition to a new state via a specified action

View File

@ -14,6 +14,7 @@ posix_ipc
pycrypto>=2.6
python-ceilometerclient>=1.0.6
python-cinderclient>=1.0.6
python-glanceclient>=0.9.0
python-heatclient>=0.2.3
python-keystoneclient>=0.7.0
python-neutronclient>=2.3.4,<3

View File

@ -7,7 +7,6 @@ mock>=1.0
mox>=0.5.3
oslosphinx
oslotest
python-glanceclient>=0.9.0
sphinx>=1.1.2,<1.2
testrepository>=0.0.18
testscenarios>=0.4