From a496993c4f96e2d010f58b9e3e314cf516384982 Mon Sep 17 00:00:00 2001 From: Arash Ghoreyshi Date: Fri, 21 Jun 2013 11:24:11 -0500 Subject: [PATCH] Stop overriding the endpoint when it's provided without a token Add a default clientrc file --- barbicanclient/client.py | 15 +++++++++++---- clientrc | 6 ++++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 clientrc diff --git a/barbicanclient/client.py b/barbicanclient/client.py index 7f6fb752..17b32c93 100644 --- a/barbicanclient/client.py +++ b/barbicanclient/client.py @@ -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 diff --git a/clientrc b/clientrc new file mode 100644 index 00000000..e953c919 --- /dev/null +++ b/clientrc @@ -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=''