diff --git a/etc/heat/heat.conf.sample b/etc/heat/heat.conf.sample index d1d3973289..fe95700798 100644 --- a/etc/heat/heat.conf.sample +++ b/etc/heat/heat.conf.sample @@ -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= + +# Optional PEM-formatted certificate chain file. (string +# value) +#cert_file= + +# Optional PEM-formatted file that contains the private key. +# (string value) +#key_file= + +# If set, then the server's certificate will not be verified. +# (boolean value) +#insecure=false + + [clients_nova] # diff --git a/heat/engine/clients.py b/heat/engine/clients.py index 72aebceeb4..bc9d069746 100644 --- a/heat/engine/clients.py +++ b/heat/engine/clients.py @@ -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 diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 00fe10241a..9e937b605d 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -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 diff --git a/requirements.txt b/requirements.txt index 2616ba7412..0aa5d356c2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/test-requirements.txt b/test-requirements.txt index 507a51c815..2d611a987a 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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