summaryrefslogtreecommitdiff
path: root/swiftclient/client.py
diff options
context:
space:
mode:
authorDonagh McCabe <donagh.mccabe@hp.com>2012-09-05 15:55:53 +0100
committerDonagh McCabe <donagh.mccabe@hp.com>2012-09-11 09:26:12 +0100
commit68d1550f15a6ec6f51973af2e27f3a6943b6305f (patch)
tree6feabf40aac7571cf8e9522842fa01f4df41420d /swiftclient/client.py
parent4b4fbf0dc0d2e918b88c1e387f462faca7e98ffd (diff)
downloadpython-swiftclient-1.2.0.tar.gz
Add region_name support1.2.0
Add --os-region-name (and OS_REGION_NAME env) to bin/swift Add region_name to the os_options in Connection class. bug 1019832 Change-Id: Id8515d97e5351638dce10581c7368f61518e1fa7
Diffstat (limited to 'swiftclient/client.py')
-rw-r--r--swiftclient/client.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index 5425312..65a721e 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -236,6 +236,7 @@ def get_keystoneclient_2_0(auth_url, user, key, os_options):
We are using the keystoneclient library for our 2.0 authentication.
"""
from keystoneclient.v2_0 import client as ksclient
+ from keystoneclient import exceptions
_ksclient = ksclient.Client(username=user,
password=key,
tenant_name=os_options.get('tenant_name'),
@@ -243,9 +244,15 @@ def get_keystoneclient_2_0(auth_url, user, key, os_options):
auth_url=auth_url)
service_type = os_options.get('service_type') or 'object-store'
endpoint_type = os_options.get('endpoint_type') or 'publicURL'
- endpoint = _ksclient.service_catalog.url_for(
- service_type=service_type,
- endpoint_type=endpoint_type)
+ try:
+ endpoint = _ksclient.service_catalog.url_for(
+ attr='region',
+ filter_value=os_options.get('region_name'),
+ service_type=service_type,
+ endpoint_type=endpoint_type)
+ except exceptions.EndpointNotFound:
+ raise ClientException('Endpoint for %s not found - '
+ 'have you specified a region?' % service_type)
return (endpoint, _ksclient.auth_token)
@@ -924,7 +931,7 @@ class Connection(object):
to a auth 2.0 system.
:param os_options: The OpenStack options which can have tenant_id,
auth_token, service_type, endpoint_type,
- tenant_name, object_storage_url
+ tenant_name, object_storage_url, region_name
"""
self.authurl = authurl
self.user = user