Revision f1e5b343
b/kamaki/cli/commands/__init__.py | ||
---|---|---|
94 | 94 |
def _custom_version(self, service): |
95 | 95 |
return self.config.get_cloud(self.cloud, '%s_version' % service) |
96 | 96 |
|
97 |
def _uuids2usernames(self, uuids): |
|
98 |
return self.auth_base.post_user_catalogs(uuids).json['uuid_catalog'] |
|
99 |
|
|
100 |
def _usernames2uuids(self, username): |
|
101 |
return self.auth_base.post_user_catalogs( |
|
102 |
displaynames=username).json['displayname_catalog'] |
|
103 |
|
|
97 | 104 |
def _uuid2username(self, uuid): |
98 |
r = self.auth_base.post_user_catalogs([uuid]) |
|
99 |
uuids = r.json['uuid_catalog'] |
|
100 |
return uuids.get(uuid, None) |
|
105 |
return self._uuids2usernames([uuid]).get(uuid, None) |
|
101 | 106 |
|
102 | 107 |
def _username2uuid(self, username): |
103 |
r = self.auth_base.post_user_catalogs(displaynames=[username]) |
|
104 |
names = r.json['displayname_catalog'] |
|
105 |
return names.get(username, None) |
|
108 |
return self._usernames2uuids([username]).get(username, None) |
|
106 | 109 |
|
107 | 110 |
def _set_log_params(self): |
108 | 111 |
try: |
b/kamaki/cli/commands/image.py | ||
---|---|---|
227 | 227 |
|
228 | 228 |
def _filtered_by_name(self, images): |
229 | 229 |
np, ns, nl = self['name_pref'], self['name_suff'], self['name_like'] |
230 |
uuids = {} |
|
230 | 231 |
|
231 |
def augment_owner(img): |
|
232 |
uuid = img.get('owner', None) |
|
233 |
if uuid and not self['json_output']: |
|
234 |
img['owner'] = '%s (%s)' % (uuid, self._uuid2username(uuid)) |
|
232 |
def fish_uuids(img): |
|
233 |
if self['detail'] and not self['json_output']: |
|
234 |
uuids[img['owner']] = '' |
|
235 | 235 |
return img |
236 | 236 |
|
237 |
return [augment_owner(img) for img in images if (
|
|
237 |
r = [fish_uuids(img) for img in images if (
|
|
238 | 238 |
(not np) or img['name'].lower().startswith(np.lower())) and ( |
239 | 239 |
(not ns) or img['name'].lower().endswith(ns.lower())) and ( |
240 | 240 |
(not nl) or nl.lower() in img['name'].lower())] |
241 | 241 |
|
242 |
if self['detail'] and not self['json_output']: |
|
243 |
uuids = self._uuids2usernames(uuids.keys()) |
|
244 |
for img in r: |
|
245 |
img['owner'] += ' (%s)' % uuids[img['owner']] |
|
246 |
|
|
247 |
return r |
|
248 |
|
|
242 | 249 |
def _filtered_by_properties(self, images): |
243 | 250 |
new_images = [] |
244 | 251 |
for img in images: |
Also available in: Unified diff