pep8 fixes
This commit is contained in:
@@ -23,7 +23,8 @@ class Connection(object):
|
||||
self._user = user
|
||||
self._key = key
|
||||
self._tenant = tenant
|
||||
self._endpoint = kwargs.get('endpoint') or 'https://barbican.api.rackspacecloud.com/v1/'
|
||||
self._endpoint = (kwargs.get('endpoint')
|
||||
or 'https://barbican.api.rackspacecloud.com/v1/')
|
||||
self._cacert = kwargs.get('cacert')
|
||||
|
||||
self.connect()
|
||||
@@ -64,9 +65,14 @@ class Connection(object):
|
||||
if token:
|
||||
self.auth_token = token
|
||||
else:
|
||||
(self._endpoint,
|
||||
self.auth_token) = authenticate(self._auth_endpoint, self._user, self._key, self._tenant,
|
||||
endpoint=self._endpoint, cacert=self._cacert)
|
||||
self._endpoint, self.auth_token = authenticate(
|
||||
self._auth_endpoint,
|
||||
self._user,
|
||||
self._key,
|
||||
self._tenant,
|
||||
endpoint=self._endpoint,
|
||||
cacert=self._cacert
|
||||
)
|
||||
|
||||
@property
|
||||
def auth_token(self):
|
||||
@@ -174,9 +180,10 @@ class Connection(object):
|
||||
|
||||
# Check if the status code is 2xx class
|
||||
if not response.ok:
|
||||
raise ClientException(href=href, method=method, http_status=response.status_code,
|
||||
raise ClientException(href=href, method=method,
|
||||
http_status=response.status_code,
|
||||
http_response_content=response.content)
|
||||
|
||||
resp_body = json.loads(response.content) if response.content else ''
|
||||
|
||||
return response.headers, resp_body
|
||||
return response.headers, resp_body
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class ClientException(Exception):
|
||||
"""Exception for wrapping up Marconi client errors"""
|
||||
"""Exception for wrapping up Barbican client errors"""
|
||||
def __init__(self, href='', http_status=0,
|
||||
method='', http_response_content=''):
|
||||
|
||||
@@ -9,4 +9,4 @@ class ClientException(Exception):
|
||||
self.http_response_content = http_response_content
|
||||
|
||||
msg = "%s %s returned %d" % (self.method, self.href, self.http_status)
|
||||
Exception.__init__(self, msg)
|
||||
Exception.__init__(self, msg)
|
||||
|
||||
@@ -8,7 +8,8 @@ class Secret(object):
|
||||
"""
|
||||
def __init__(self, connection, dict):
|
||||
"""
|
||||
Builds a secret object from a json representation. Includes the connection object for subtasks.
|
||||
Builds a secret object from a json representation. Includes the
|
||||
connection object for subtasks.
|
||||
"""
|
||||
self._connection = connection
|
||||
self._href = dict['secret_ref']
|
||||
|
||||
@@ -7,7 +7,11 @@ ENDPOINT = 'https://barbican.api.rackspacecloud.com/v1/'
|
||||
|
||||
|
||||
def list_secrets(username, password, tenant, endpoint):
|
||||
connection = client.Connection(IDENTITY, username, password, tenant, endpoint=endpoint)
|
||||
connection = client.Connection(IDENTITY,
|
||||
username,
|
||||
password,
|
||||
tenant,
|
||||
endpoint=endpoint)
|
||||
secrets = connection.list_secrets()
|
||||
|
||||
print 'Current Secrets (%d):' % (len(secrets))
|
||||
@@ -16,14 +20,31 @@ def list_secrets(username, password, tenant, endpoint):
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description='Testing code for barbican secrets api resource.')
|
||||
parser.add_argument('--username', help='The keystone username used for for authentication')
|
||||
parser.add_argument('--password', help='The keystone password used for for authentication')
|
||||
parser.add_argument('--tenant', help='The keystone tenant used for for authentication')
|
||||
parser.add_argument('--keystone', default=IDENTITY,
|
||||
help='The keystone endpoint used for for authentication')
|
||||
parser.add_argument('--endpoint', default=ENDPOINT,
|
||||
help='The barbican endpoint to test against')
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Testing code for barbican secrets api resource.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--username',
|
||||
help='The keystone username used for for authentication'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--password',
|
||||
help='The keystone password used for for authentication'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--tenant',
|
||||
help='The keystone tenant used for for authentication'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--keystone',
|
||||
default=IDENTITY,
|
||||
help='The keystone endpoint used for for authentication'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--endpoint',
|
||||
default=ENDPOINT,
|
||||
help='The barbican endpoint to test against'
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
@@ -31,4 +52,4 @@ def parse_args():
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = parse_args()
|
||||
list_secrets(args.username, args.password, args.tenant, args.endpoint)
|
||||
list_secrets(args.username, args.password, args.tenant, args.endpoint)
|
||||
|
||||
Reference in New Issue
Block a user