Stop overriding the endpoint when it's provided without a token

Add a default clientrc file
This commit is contained in:
Arash Ghoreyshi
2013-06-21 11:24:11 -05:00
parent 99f6d9f367
commit a496993c4f
2 changed files with 17 additions and 4 deletions

View File

@@ -27,7 +27,8 @@ class Connection(object):
token=None, authenticate=None, request=None, fake_env=None,
**kwargs):
"""
Authenticate and connect to the endpoint
Authenticate and connect to the service endpoint, which is usually
received through authentication.
:param auth_endpoint: The auth URL to authenticate against
default: env('OS_AUTH_URL')
@@ -37,6 +38,10 @@ class Connection(object):
default: env('OS_PASSWORD')
:param tenant: The tenant ID
default: env('OS_TENANT_NAME')
:keyword param endpoint: The service endpoint to connect to
default: env('SERVICE_ENDPOINT')
If a token is provided, an endpoint should be as well.
"""
LOG.debug(_("Creating Connection object"))
@@ -52,7 +57,7 @@ class Connection(object):
"n or defined as environment variables.")
self.authenticate = authenticate or auth.authenticate
self.request = request or requests.request
self._endpoint = kwargs.get('endpoint')
self._endpoint = kwargs.get('endpoint') or self.env('SERVICE_ENDPOINT')
self._cacert = kwargs.get('cacert')
self.connect(token=token)
@@ -97,7 +102,7 @@ class Connection(object):
self.auth_token = token
else:
LOG.debug(_("Authenticating token"))
self.endpoint, self.auth_token = self.authenticate(
endpoint, self.auth_token = self.authenticate(
self._auth_endpoint,
self._user,
self._key,
@@ -106,6 +111,8 @@ class Connection(object):
endpoint=self._endpoint,
cacert=self._cacert
)
if self.endpoint is None:
self.endpoint = endpoint
@property
def auth_token(self):
@@ -166,7 +173,7 @@ class Connection(object):
cypher_type=None,
expiration=None):
"""
Creates and returns an Order object with all of its metadata filled in.
Creates and returns a Secret object with all of its metadata filled in.
arguments:
mime_type - The MIME type of the secret

6
clientrc Normal file
View File

@@ -0,0 +1,6 @@
export OS_TENANT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=password
export OS_AUTH_URL="http://keystone-int.cloudkeep.io:5000/v2.0/"
export SERVICE_ENDPOINT="http://api-01-int.cloudkeep.io:9311/v1/"
export SERVICE_TOKEN=''