Merge "Account for differences in Rackspace Cloud Glance"

This commit is contained in:
Jenkins 2014-06-26 21:05:59 +00:00 committed by Gerrit Code Review
commit 089f7f0b9d
1 changed files with 31 additions and 0 deletions

View File

@ -13,6 +13,8 @@
"""Client Libraries for Rackspace Resources."""
import urlparse
from oslo.config import cfg
from heat.common import exception
@ -20,6 +22,8 @@ from heat.engine import clients
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
from glanceclient import client as glanceclient
LOG = logging.getLogger(__name__)
try:
@ -119,6 +123,33 @@ class Clients(clients.OpenStackClients):
# unwrap here and things just work
return self._get_client("object_store").connection
def glance(self):
if "image" not in self._clients:
con = self.context
endpoint_type = self._get_client_option('glance', 'endpoint_type')
endpoint = self.url_for(service_type='image',
endpoint_type=endpoint_type,
region_name=cfg.CONF.region_name)
# Rackspace service catalog includes a tenant scoped glance
# endpoint so we have to munge the url a bit
glance_url = urlparse.urlparse(endpoint)
# remove the tenant and following from the url
endpoint = "%s://%s" % (glance_url.scheme, glance_url.hostname)
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')
}
client = glanceclient.Client('2', endpoint, **args)
self._clients["image"] = client
return self._clients["image"]
def __authenticate(self):
"""Create an authenticated client context."""
self.pyrax = pyrax.create_context("rackspace")