Commit 9d3cd179 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Show user names in /file sharers

Refs: #4203
parent c3e1ac99
......@@ -1100,7 +1100,7 @@ class file_upload(_file_container_command, _optional_output_cmd):
print('%s is not a regular file' % fpath)
if not path.isfile(lpath):
raiseCLIError(('%s is not aregular file' % lpath) if (
raiseCLIError(('%s is not a regular file' % lpath) if (
path.exists(lpath)) else '%s does not exist' % lpath)
robj = self.client.get_object_info(rpath)
......@@ -2047,10 +2047,19 @@ class file_sharers(_file_account_command, _optional_json):
def _run(self):
accounts = self.client.get_sharing_accounts(marker=self['marker'])
uuids = [acc['name'] for acc in accounts]
astakos_responce = self.auth_base.post_user_catalogs(uuids)
usernames = astakos_responce.json
r = usernames['uuid_catalog']
except Exception as e:
print 'WARNING: failed to call user_catalogs, %s' % e
r = dict(sharer_uuid=uuids)
usernames = accounts
if self['json_output'] or self['detail']:
self._print([acc['name'] for acc in accounts])
self._print(r, print_dict)
def main(self):
super(self.__class__, self)._run()
......@@ -140,7 +140,7 @@ class astakos_user_name(_astakos_init, _optional_json):
self._print(self.client.get_username(self.token, uuids[0]))
self.client.get_username(self.token, uuids), print_dict)
self.client.get_usernames(self.token, uuids), print_dict)
def main(self, uuid, *more_uuids):
super(self.__class__, self)._run()
......@@ -31,8 +31,11 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from kamaki.clients import Client, ClientError
from logging import getLogger
from json import dumps
from kamaki.clients import Client, ClientError
from kamaki.clients.utils import path4url
class AstakosClient(Client):
......@@ -151,3 +154,15 @@ class AstakosClient(Client):
def user_term(self, key, token=None):
"""Get (cached) term, from user credentials"""
return self.user_info(token).get(key, None)
def post_user_catalogs(self, uuids):
"""POST base_url/user_catalogs
:param uuids: (list or tuple) user uuids
:returns: (dict) {uuid1: name1, uuid2: name2, ...}
account_url = self.get_service_endpoints('account')['publicURL']
account = AstakosClient(account_url, self.token)
json_data = dict(uuids=uuids)
return'user_catalogs', json=json_data)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment