Commit 998d7e25 authored by Stavros Sachtouris's avatar Stavros Sachtouris

Rename base_url,auth_base to endpoint_url,astakos

Refs #9

This change affects both the kamaki.cli and kamaki.clients hierarchies
It is of semantic significance only
Backwards compatibility is preserved in kamaki.clients, so that
old code using base_url instead of endpoint_url will still work.
parent 6ea9601e
......@@ -24,4 +24,5 @@ Features:
- Resources can be reassigned to projects
- Update account API commands to reflect changes in synnefo 0.16
- Implement a get_endpoint_url method and use it
- Rename kamaki.clients.Client.base_url --> endpoint_url, keep BW compatibility [#9]
......@@ -285,19 +285,19 @@ def init_cached_authenticator(config_argument, cloud, logger):
_cnf = config_argument.value
url = _cnf.get_cloud(cloud, 'url')
tokens = _cnf.get_cloud(cloud, 'token').split()
auth_base, failed = None, []
astakos, failed = None, []
for token in tokens:
try:
if auth_base:
auth_base.authenticate(token)
if astakos:
astakos.authenticate(token)
else:
tmp_base = CachedAstakosClient(url, token)
from kamaki.cli.cmds import CommandInit
fake_cmd = CommandInit(dict(config=config_argument))
fake_cmd.client = auth_base
fake_cmd.client = astakos
fake_cmd._set_log_params()
tmp_base.authenticate(token)
auth_base = tmp_base
astakos = tmp_base
except ClientError as ce:
if ce.status in (401, ):
logger.warning(
......@@ -314,7 +314,7 @@ def init_cached_authenticator(config_argument, cloud, logger):
_cnf.set_cloud(cloud, 'token', ' '.join(tokens))
_cnf.write()
if tokens:
return auth_base
return astakos
logger.warning('WARNING: cloud.%s.token is now empty' % cloud)
except AssertionError as ae:
logger.warning('WARNING: Failed to load authenticator [%s]' % ae)
......@@ -538,16 +538,15 @@ def run_shell(exe, parser):
cloud = _init_session(parser.arguments)
global kloger
_cnf = parser.arguments['config']
auth_base = init_cached_authenticator(_cnf, cloud, kloger)
astakos = init_cached_authenticator(_cnf, cloud, kloger)
try:
username, userid = (
auth_base.user_term('name'), auth_base.user_term('id'))
username, userid = (astakos.user_term('name'), astakos.user_term('id'))
except Exception:
username, userid = '', ''
from kamaki.cli.shell import init_shell
shell = init_shell(exe, parser, username, userid)
_load_all_commands(shell.cmd_tree, parser.arguments)
shell.run(auth_base, cloud, parser)
shell.run(astakos, cloud, parser)
@main
......
......@@ -91,7 +91,7 @@ class CommandInit(object):
def __init__(
self,
arguments={}, auth_base=None, cloud=None,
arguments={}, astakos=None, cloud=None,
_in=None, _out=None, _err=None):
self._in, self._out, self._err = (
_in or stdin, _out or stdout, _err or stderr)
......@@ -113,14 +113,14 @@ class CommandInit(object):
self.config = self['config']
except KeyError:
pass
self.auth_base = auth_base or getattr(self, 'auth_base', None)
self.astakos = astakos or getattr(self, 'astakos', None)
self.cloud = cloud or getattr(self, 'cloud', None)
def get_client(self, cls, service):
self.cloud = getattr(self, 'cloud', 'default')
URL, TOKEN = self._custom_url(service), self._custom_token(service)
if not all([URL, TOKEN]):
astakos = getattr(self, 'auth_base', None)
astakos = getattr(self, 'astakos', None)
if astakos:
URL = URL or astakos.get_endpoint_url(
self._custom_type(service) or cls.service_type,
......@@ -180,10 +180,10 @@ class CommandInit(object):
return self.config.get_cloud(self.cloud, '%s_version' % service)
def _uuids2usernames(self, uuids):
return self.auth_base.post_user_catalogs(uuids)
return self.astakos.post_user_catalogs(uuids)
def _usernames2uuids(self, username):
return self.auth_base.post_user_catalogs(displaynames=username)
return self.astakos.post_user_catalogs(displaynames=username)
def _uuid2username(self, uuid):
return self._uuids2usernames([uuid]).get(uuid, None)
......
......@@ -90,23 +90,22 @@ def with_temp_token(func):
class _AstakosInit(CommandInit):
@errors.Generic.all
@errors.Astakos.load
@errors.Astakos.astakosclient
@client_log
def _run(self):
if getattr(self, 'cloud', None):
base_url = self._custom_url('astakos')
if base_url:
endpoint_url = self._custom_url('astakos')
if endpoint_url:
token = self._custom_token(
'astakos') or self.config.get_cloud(
self.cloud, 'token')
token = token.split()[0] if ' ' in token else token
self.client = LoggedAstakosClient(base_url, token)
self.client = LoggedAstakosClient(endpoint_url, token)
return
else:
self.cloud = 'default'
if getattr(self, 'auth_base', None):
self.client = self.auth_base.get_client()
if getattr(self, 'astakos', None):
self.client = self.astakos.get_client()
return
raise CLIBaseUrlError(service='astakos')
......@@ -238,7 +237,7 @@ class user_info(_AstakosInit, OptionalOutput):
uuid = self['uuid'] or (self._username2uuid(self['name']) if (
self['name']) else None)
try:
token = self.auth_base.get_token(uuid) if uuid else None
token = self.astakos.get_token(uuid) if uuid else None
except KeyError:
msg = ('id %s' % self['uuid']) if (
self['uuid']) else 'username %s' % self['name']
......@@ -248,7 +247,7 @@ class user_info(_AstakosInit, OptionalOutput):
' /user list',
'To authenticate and add a new user in the session list',
' /user add <new token>'])
self.print_(self.auth_base.user_info(token), self.print_dict)
self.print_(self.astakos.user_info(token), self.print_dict)
@command(user_cmds)
......@@ -258,16 +257,16 @@ class user_add(_AstakosInit, OptionalOutput):
@errors.Generic.all
@errors.Astakos.astakosclient
def _run(self, token=None):
ask = token and token not in self.auth_base._uuids
self.print_(self.auth_base.authenticate(token), self.print_dict)
ask = token and token not in self.astakos._uuids
self.print_(self.astakos.authenticate(token), self.print_dict)
if ask and self.ask_user(
'Token is temporarily stored in memory. If it is stored in'
' kamaki configuration file, it will be available in later'
' sessions. Do you want to permanently store this token?'):
tokens = self.auth_base._uuids.keys()
tokens.remove(self.auth_base.token)
tokens = self.astakos._uuids.keys()
tokens.remove(self.astakos.token)
self['config'].set_cloud(
self.cloud, 'token', ' '.join([self.auth_base.token] + tokens))
self.cloud, 'token', ' '.join([self.astakos.token] + tokens))
self['config'].write()
def main(self, new_token=None):
......@@ -287,7 +286,7 @@ class user_list(_AstakosInit, OptionalOutput):
@errors.Astakos.astakosclient
def _run(self):
self.print_([u if self['detail'] else (dict(
id=u['id'], name=u['name'])) for u in self.auth_base.list_users()])
id=u['id'], name=u['name'])) for u in self.astakos.list_users()])
def main(self):
super(self.__class__, self)._run()
......@@ -302,7 +301,7 @@ class user_select(_AstakosInit):
@errors.Astakos.astakosclient
def _run(self, uuid):
try:
first_token = self.auth_base.get_token(uuid)
first_token = self.astakos.get_token(uuid)
except KeyError:
raise CLIError(
'No user with uuid %s in the cached session list' % uuid,
......@@ -311,14 +310,14 @@ class user_select(_AstakosInit):
' /user list',
'To authenticate and add a new user in the session list',
' /user add <new token>'])
if self.auth_base.token != first_token:
self.auth_base.token = first_token
if self.astakos.token != first_token:
self.astakos.token = first_token
msg = 'User with id %s is now the current session user.\n' % uuid
msg += 'Do you want future sessions to also start with this user?'
if self.ask_user(msg):
tokens = self.auth_base._uuids.keys()
tokens.remove(self.auth_base.token)
tokens.insert(0, self.auth_base.token)
tokens = self.astakos._uuids.keys()
tokens.remove(self.astakos.token)
tokens.insert(0, self.astakos.token)
self['config'].set_cloud(
self.cloud, 'token', ' '.join(tokens))
self['config'].write()
......@@ -340,7 +339,7 @@ class user_delete(_AstakosInit):
@errors.Generic.all
@errors.Astakos.astakosclient
def _run(self, uuid):
if uuid == self.auth_base.user_term('id'):
if uuid == self.astakos.user_term('id'):
raise CLIError('Cannot remove current session user', details=[
'To see all cached session users',
' /user list',
......@@ -349,7 +348,7 @@ class user_delete(_AstakosInit):
'To select a different session user',
' /user select <user uuid>'])
try:
self.auth_base.remove_user(uuid)
self.astakos.remove_user(uuid)
except KeyError:
raise CLIError('No user with uuid %s in session list' % uuid,
details=[
......@@ -361,7 +360,7 @@ class user_delete(_AstakosInit):
'User is removed from current session, but will be restored in'
' the next session. Remove the user from future sessions?'):
self['config'].set_cloud(
self.cloud, 'token', ' '.join(self.auth_base._uuids.keys()))
self.cloud, 'token', ' '.join(self.astakos._uuids.keys()))
self['config'].write()
def main(self, user_uuid):
......
......@@ -92,7 +92,7 @@ class Generic(object):
client = getattr(self, 'client', None)
if not client:
raise
url = getattr(client, 'base_url', '<empty>')
url = getattr(client, 'endpoint_url', '<empty>')
raise CLIError('Invalid service URL %s' % url, details=[
'%s' % ce,
'Check if authentication URL is correct',
......@@ -123,30 +123,6 @@ class Astakos(object):
return r
return _raise
@classmethod
def load(this, func):
def _raise(self, *args, **kwargs):
r = func(self, *args, **kwargs)
try:
client = getattr(self, 'client')
except AttributeError as ae:
raise CLIError('Client setup failure', importance=3, details=[
'%s' % ae])
if not getattr(client, 'token', False):
log.warning(
'No permanent token (try:'
' kamaki config set cloud.default.token <tkn>)')
if not getattr(client, 'astakos_base_url', False):
msg = 'Missing synnefo authentication URL'
raise CLIError(msg, importance=3, details=[
'Check if authentication URL is correct',
' # check current URL:',
' $ kamaki config get cloud.default.url',
' # set new auth. URL:',
' $ kamaki config set cloud.default.url'] + CLOUDNAME)
return r
return _raise
@classmethod
def authenticate(this, func):
def _raise(self, *args, **kwargs):
......
......@@ -543,7 +543,7 @@ class image_register(_ImageInit, OptionalOutput):
def main(self):
super(self.__class__, self)._run()
locator, pithos = self.arguments['pithos_location'], None
locator.setdefault('uuid', self.auth_base.user_term('id'))
locator.setdefault('uuid', self.astakos.user_term('id'))
locator.path = locator.path or path.basename(
self['local_image_path'] or '')
if not locator.path:
......@@ -561,7 +561,7 @@ class image_register(_ImageInit, OptionalOutput):
self.arguments['local_image_path'].lvalue)
])
self.arguments['pithos_location'].setdefault(
'uuid', self.auth_base.user_term('id'))
'uuid', self.astakos.user_term('id'))
self._run(self['name'], locator)
......
......@@ -77,7 +77,7 @@ class _PithosInit(CommandInit):
self.account = self._custom_uuid()
if self.account:
return
astakos = getattr(self, 'auth_base', None)
astakos = getattr(self, 'astakos', None)
if astakos:
self.account = astakos.user_term('id', self.token)
else:
......@@ -87,7 +87,8 @@ class _PithosInit(CommandInit):
@client_log
def _run(self):
self.client = self.get_client(PithosClient, 'pithos')
self.base_url, self.token = self.client.base_url, self.client.token
self.endpoint_url = self.client.endpoint_url
self.token = self.client.token
self._set_account()
self.client.account = self.account
self.container = self._custom_container() or 'pithos'
......@@ -100,11 +101,11 @@ class _PithosInit(CommandInit):
class _PithosAccount(_PithosInit):
"""Setup account"""
def __init__(self, arguments={}, auth_base=None, cloud=None):
super(_PithosAccount, self).__init__(arguments, auth_base, cloud)
def __init__(self, arguments={}, astakos=None, cloud=None):
super(_PithosAccount, self).__init__(arguments, astakos, cloud)
self['account'] = UserAccountArgument(
'A user UUID or name', ('-A', '--account'))
self.arguments['account'].account_client = auth_base
self.arguments['account'].account_client = astakos
def print_objects(self, object_list):
for index, obj in enumerate(object_list):
......@@ -143,8 +144,8 @@ class _PithosAccount(_PithosInit):
class _PithosContainer(_PithosAccount):
"""Setup container"""
def __init__(self, arguments={}, auth_base=None, cloud=None):
super(_PithosContainer, self).__init__(arguments, auth_base, cloud)
def __init__(self, arguments={}, astakos=None, cloud=None):
super(_PithosContainer, self).__init__(arguments, astakos, cloud)
self['container'] = ValueArgument(
'Use this container (default: pithos)', ('-C', '--container'))
......@@ -515,12 +516,12 @@ class _PithosFromTo(_PithosContainer):
'The version of the source object', '--source-version')
)
def __init__(self, arguments={}, auth_base=None, cloud=None):
def __init__(self, arguments={}, astakos=None, cloud=None):
self.arguments.update(arguments)
self.arguments.update(self.sd_arguments)
super(_PithosFromTo, self).__init__(
self.arguments, auth_base, cloud)
self.arguments['destination_user'].account_client = self.auth_base
self.arguments, astakos, cloud)
self.arguments['destination_user'].account_client = self.astakos
def _report_transfer(self, src, dst, transfer_name):
if not dst:
......@@ -650,7 +651,7 @@ class _PithosFromTo(_PithosContainer):
dst_acc, dst_con, dst_path = self.resolve_pithos_url(
destination_path_or_url)
self.dst_client = PithosClient(
base_url=self.client.base_url, token=self.client.token,
endpoint_url=self.client.endpoint_url, token=self.client.token,
container=self[
'destination_container'] or dst_con or self.client.container,
account=self['destination_user'] or dst_acc or self.account)
......@@ -1683,7 +1684,7 @@ class sharer_info(_PithosAccount, OptionalOutput):
super(self.__class__, self)._run()
if account_uuid_or_name:
arg = UserAccountArgument('Check', ' ')
arg.account_client = self.auth_base
arg.account_client = self.astakos
arg.value = account_uuid_or_name
self.client.account, self.account = arg.value, arg.value
self._run()
......
......@@ -97,9 +97,9 @@ def run(cloud, parser):
exit(0)
cls = cmd.cmd_class
auth_base = init_cached_authenticator(_cnf, cloud, kloger) if (
astakos = init_cached_authenticator(_cnf, cloud, kloger) if (
cloud) else None
executable = cls(parser.arguments, auth_base, cloud)
executable = cls(parser.arguments, astakos, cloud)
parser.required = getattr(cls, 'required', None)
parser.update_arguments(executable.arguments)
for term in _best_match:
......
......@@ -68,7 +68,7 @@ class Shell(Cmd):
_context_stack = []
_prompt_stack = []
_parser = None
auth_base = None
astakos = None
cloud = None
undoc_header = 'interactive shell commands:'
......@@ -204,12 +204,12 @@ class Shell(Cmd):
ldescr = getattr(cls, 'long_description', '')
if subcmd.path == 'history_run':
instance = cls(
dict(cmd_parser.arguments), self.auth_base,
dict(cmd_parser.arguments), self.astakos,
cmd_tree=self.cmd_tree)
else:
instance = cls(
dict(cmd_parser.arguments),
self.auth_base, self.cloud)
self.astakos, self.cloud)
cmd_parser.update_arguments(instance.arguments)
cmd_parser.arguments = instance.arguments
subpath = subcmd.path.split('_')[
......@@ -303,8 +303,8 @@ class Shell(Cmd):
hdr = tmp_partition[0].strip()
return '%s commands:' % hdr
def run(self, auth_base, cloud, parser, path=''):
self.auth_base = auth_base
def run(self, astakos, cloud, parser, path=''):
self.astakos = astakos
self.cloud = cloud
self._parser = parser
cnf = parser.arguments['config']
......
......@@ -388,9 +388,11 @@ class Client(Logged):
DATE_FORMATS = ['%a %b %d %H:%M:%S %Y', ]
CONNECTION_RETRY_LIMIT = 0
def __init__(self, base_url, token):
assert base_url, 'No base_url for client %s' % self
self.base_url = base_url
def __init__(self, endpoint_url, token, base_url=None):
# BW compatibility - keep base_url for some time
endpoint_url = endpoint_url or base_url
assert endpoint_url, 'No endpoint_url for client %s' % self
self.endpoint_url, self.base_url = endpoint_url, endpoint_url
self.token = token
self.headers, self.params = dict(), dict()
self.poolsize = None
......@@ -493,7 +495,7 @@ class Client(Logged):
self, method, path,
async_headers=dict(), async_params=dict(),
**kwargs):
"""Commit an HTTP request to base_url/path
"""Commit an HTTP request to endpoint_url/path
Requests are commited to and performed by Request/ResponseManager
These classes perform a lazy http request. Present method, by default,
enforces them to perform the http call. Hint: call present method with
......@@ -516,9 +518,9 @@ class Client(Logged):
if data:
headers.setdefault('Content-Length', '%s' % len(data))
plog = ('\t[%s]' % self) if self.LOG_PID else ''
sendlog.debug('\n\nCMT %s@%s%s', method, self.base_url, plog)
sendlog.debug('\n\nCMT %s@%s%s', method, self.endpoint_url, plog)
req = RequestManager(
method, self.base_url, path,
method, self.endpoint_url, path,
data=data, headers=headers, params=params)
req.headers_to_quote = self.request_headers_to_quote
req.header_prefices = self.request_header_prefices_to_quote
......
......@@ -61,8 +61,9 @@ class AstakosClient(OriginalAstakosClient):
url = args.pop(0)
token = args.pop(0) if args else kwargs.pop('token', None)
args = tuple([token, url] + args)
elif 'base_url' in kwargs:
kwargs['auth_url'] = kwargs.get('auth_url', kwargs['base_url'])
else:
kwargs['auth_url'] = kwargs.get('auth_url', kwargs.get(
'endpoint_url', kwargs['base_url']))
super(AstakosClient, self).__init__(*args, **kwargs)
def get_service_endpoints(self, service_type, version=None):
......@@ -116,7 +117,7 @@ class LoggedAstakosClient(AstakosClient):
if log_request:
req = RequestManager(
method=log_request['method'],
url='%s://%s' % (self.scheme, self.astakos_base_url),
url='%s://%s' % (self.scheme, self.astakos_endpoint_url),
path=log_request['path'],
data=log_request.get('body', None),
headers=log_request.get('headers', dict()))
......@@ -140,8 +141,8 @@ class CachedAstakosClient(Client):
service_type = 'identity'
@_astakos_error
def __init__(self, base_url, token=None):
super(CachedAstakosClient, self).__init__(base_url, token)
def __init__(self, endpoint_url, token=None):
super(CachedAstakosClient, self).__init__(endpoint_url, token)
self._astakos = dict()
self._uuids = dict()
self._cache = dict()
......@@ -175,7 +176,7 @@ class CachedAstakosClient(Client):
"""
token = self._resolve_token(token)
astakos = LoggedAstakosClient(
self.base_url, token, logger=getLogger('astakosclient'))
self.endpoint_url, token, logger=getLogger('astakosclient'))
astakos.LOG_TOKEN = getattr(self, 'LOG_TOKEN', False)
astakos.LOG_DATA = getattr(self, 'LOG_DATA', False)
r = astakos.authenticate()
......@@ -285,7 +286,7 @@ class CachedAstakosClient(Client):
return self.user_info(token).get(key, None)
def post_user_catalogs(self, uuids=None, displaynames=None, token=None):
"""POST base_url/user_catalogs
"""POST endpoint_url/user_catalogs
:param uuids: (list or tuple) user uuids
......
......@@ -41,7 +41,7 @@ class ComputeRestClient(Client):
# NON-cyclades
def limits_get(self, success=200, **kwargs):
"""GET base_url/limits
"""GET endpoint_url/limits
:param success: success code or list or tupple of accepted success
codes. if server response code is not in this list, a ClientError
......@@ -65,7 +65,7 @@ class ComputeRestClient(Client):
host=None,
success=200,
**kwargs):
"""GET base_url/servers/['detail' | <server_id>]
"""GET endpoint_url/servers/['detail' | <server_id>]
:param server_id: (int or int str) ignored if detail
......@@ -111,7 +111,7 @@ class ComputeRestClient(Client):
json_data=None,
success=202,
**kwargs):
"""POST base_url/servers
"""POST endpoint_url/servers
:param json_data: a json-formated dict that will be send as data
......@@ -142,7 +142,7 @@ class ComputeRestClient(Client):
self,
server_id, server_name=None, json_data=None, success=204,
**kwargs):
"""PUT base_url/servers/<server_id>
"""PUT endpoint_url/servers/<server_id>
:param json_data: a json-formated dict that will be send as data
......@@ -162,7 +162,7 @@ class ComputeRestClient(Client):
return self.put(path, data=json_data, success=success, **kwargs)
def servers_delete(self, server_id, success=204, **kwargs):
"""DEL ETE base_url/servers/<server_id>
"""DEL ETE endpoint_url/servers/<server_id>
:param json_data: a json-formated dict that will be send as data
......@@ -176,7 +176,7 @@ class ComputeRestClient(Client):
return self.delete(path, success=success, **kwargs)
def servers_metadata_get(self, server_id, key=None, success=200, **kwargs):
"""GET base_url/servers/<server_id>/metadata[/key]
"""GET endpoint_url/servers/<server_id>/metadata[/key]
:returns: request response
"""
......@@ -185,7 +185,7 @@ class ComputeRestClient(Client):
def servers_metadata_post(
self, server_id, json_data=None, success=202, **kwargs):
"""POST base_url/servers/<server_id>/metadata
"""POST endpoint_url/servers/<server_id>/metadata
:returns: request response
"""
......@@ -198,7 +198,7 @@ class ComputeRestClient(Client):
def servers_metadata_put(
self, server_id, key=None, json_data=None, success=204, **kwargs):
"""PUT base_url/servers/<server_id>/metadata[/key]
"""PUT endpoint_url/servers/<server_id>/metadata[/key]
:returns: request response
"""
......@@ -210,7 +210,7 @@ class ComputeRestClient(Client):
return self.put(path, data=json_data, success=success, **kwargs)
def servers_metadata_delete(self, server_id, key, success=204, **kwargs):
"""DEL ETE base_url/servers/<server_id>/metadata[/key]
"""DEL ETE endpoint_url/servers/<server_id>/metadata[/key]
:returns: request response
"""
......@@ -219,7 +219,7 @@ class ComputeRestClient(Client):
def servers_action_post(
self, server_id, json_data=None, success=202, **kwargs):
"""POST base_url/servers/<server_id>/action
"""POST endpoint_url/servers/<server_id>/action
:returns: request response
"""
......@@ -234,7 +234,7 @@ class ComputeRestClient(Client):
self, server_id,
network_id=None, changes_since=None, success=(304, 200),
**kwargs):
"""GET base_url/servers/<server_id>/ips[/network_id]
"""GET endpoint_url/servers/<server_id>/ips[/network_id]
:param changes_since: time/date stamp in UNIX/epoch time. Checks for
changes since a previous request.
......@@ -258,7 +258,7 @@ class ComputeRestClient(Client):
type=None,
success=200,
**kwargs):
"""GET base_url[/image_id][/command]
"""GET endpoint_url[/image_id][/command]
:param image_id: (str) ignored if detail
......@@ -294,7 +294,7 @@ class ComputeRestClient(Client):
return self.get(path, success=success, **kwargs)
def images_delete(self, image_id='', success=204, **kwargs):
"""DEL ETE base_url/images/<image_id>
"""DEL ETE endpoint_url/images/<image_id>
:returns: request response
"""
......@@ -302,7 +302,7 @@ class ComputeRestClient(Client):
return self.delete(path, success=success, **kwargs)
def images_metadata_get(self, image_id, key=None, success=200, **kwargs):
"""GET base_url/<image_id>/metadata[/key]
"""GET endpoint_url/<image_id>/metadata[/key]
:returns: request response
"""
......@@ -311,7 +311,7 @@ class ComputeRestClient(Client):
def images_metadata_post(
self, image_id, json_data=None, success=201, **kwargs):
"""POST base_url/images/<image_id>/metadata
"""POST endpoint_url/images/<image_id>/metadata
:returns: request response
"""
......@@ -325,7 +325,7 @@ class ComputeRestClient(Client):
def images_metadata_put(
self, image_id, key=None, json_data=None, success=201, **kwargs):
"""PUT base_url/images/<image_id>/metadata
"""PUT endpoint_url/images/<image_id>/metadata
:returns: request response
"""
......@@ -338,7 +338,7 @@ class ComputeRestClient(Client):
return self.put(path, data=json_data, success=success, **kwargs)
def images_metadata_delete(self, image_id, key, success=204, **kwargs):
"""DEL ETE base_url/images/<image_id>/metadata/key
"""DEL ETE endpoint_url/images/<image_id>/metadata/key
:returns: request response
"""
......@@ -356,7 +356,7 @@ class ComputeRestClient(Client):
limit=None,
success=200,
**kwargs):
"""GET base_url[/flavor_id][/command]
"""GET endpoint_url[/flavor_id][/command]
:param flavor_id: ignored if detail
......
......@@ -204,7 +204,7 @@ class CycladesNetworkClient(NetworkClient):
return r.json['network']
def reassign_network(self, network_id, project, **kwargs):
"""POST base_url/networks/<network_id>/action
"""POST endpoint_url/networks/<network_id>/action
:returns: request response
"""
......
......@@ -39,12 +39,12 @@ class CycladesComputeRestClient(ComputeClient):
"""Synnefo Cyclades REST API Client"""
def servers_stats_get(self, server_id, **kwargs):
"""GET base_url/servers/<server_id>/stats"""
"""GET endpoint_url/servers/<server_id>/stats"""
path = path4url('servers', server_id, 'stats')
return self.get(path, success=200, **kwargs)
def servers_diagnostics_get(self, server_id, **kwargs):
"""GET base_url/servers/<server_id>/diagnostics"""
"""GET endpoint_url/servers/<server_id>/diagnostics"""
path = path4url('servers', server_id, 'diagnostics')
return self.get(path, success=200, **kwargs)
......
......@@ -55,8 +55,8 @@ class ImageClient(Client):
"""Synnefo Plankton API client"""
service_type = 'image'
def __init__(self, base_url, token):
super(ImageClient, self).__init__(base_url, token)
def __init__(self, endpoint_url, token):
super(ImageClient, self).__init__(endpoint_url, token)
self.request_headers_to_quote = ['X-Image-Meta-Name', ]
self.request_header_prefices_to_quote = ['X-Image-Meta-Property-', ]
self.response_headers = [
......
......@@ -102,8 +102,9 @@ def _range_up(start, end, max_value, a_range):
class PithosClient(PithosRestClient):
"""Synnefo Pithos+ API client"""
def __init__(self, base_url, token, account=None, container=None):
super(PithosClient, self).__init__(base_url, token, account, container)
def __init__(self, endpoint_url, token, account=None, container=None):
super(PithosClient, self).__init__(
endpoint_url, token, account, container)
def create_container(
self,
......@@ -1213,7 +1214,7 @@ class PithosClient(PithosRestClient):
self.object_post(obj, update=True, public=True)
info = self.get_object_info(obj)
return info['x-object-public']
pref, sep, rest = self.base_url.partition('//')
pref, sep, rest = self.endpoint_url.partition('//')
base = rest.split('/')[0]
return '%s%s%s/%s' % (pref, sep, base, info['x-object-public'])
......
......@@ -38,8 +38,8 @@ from kamaki.clients.utils import filter_in, filter_out, path4url
class StorageClient(Client):