@errors.cyclades.connection
@errors.cyclades.server_id
def _run(self, server_id):
- self._print(self.client.get_server_details(server_id), print_dict)
+ vm = self.client.get_server_details(server_id)
+ uuids = self._uuids2usernames([vm['user_id'], vm['tenant_id']])
+ vm['user_id'] += ' (%s)' % uuids[vm['user_id']]
+ vm['tenant_id'] += ' (%s)' % uuids[vm['tenant_id']]
+ self._print(vm, print_dict)
def main(self, server_id):
super(self.__class__, self)._run()
def _run(self, name, flavor_id, image_id):
r = self.client.create_server(
name, int(flavor_id), image_id, self['personality'])
+ usernames = self._uuids2usernames([r['user_id'], r['tenant_id']])
+ r['user_id'] += ' (%s)' % usernames[r['user_id']]
+ r['tenant_id'] += ' (%s)' % usernames[r['tenant_id']]
self._print(r, print_dict)
if self['wait']:
self._wait(r['id'], r['status'])
self._run(flavor_id=flavor_id)
+def _add_name(self, net):
+ user_id, tenant_id, uuids = net['user_id'], net['tenant_id'], []
+ if user_id:
+ uuids.append(user_id)
+ if tenant_id:
+ uuids.append(tenant_id)
+ if uuids:
+ usernames = self._uuids2usernames(uuids)
+ if user_id:
+ net['user_id'] += ' (%s)' % usernames[user_id]
+ if tenant_id:
+ net['tenant_id'] += ' (%s)' % usernames[tenant_id]
+
+
@command(network_cmds)
class network_info(_init_cyclades, _optional_json):
"""Detailed information on a network
@errors.cyclades.network_id
def _run(self, network_id):
network = self.client.get_network_details(int(network_id))
+ _add_name(self, network)
self._print(network, print_dict, exclude=('id'))
def main(self, network_id):
gateway=self['gateway'],
dhcp=self['dhcp'],
type=self['type'])
+ _add_name(self, r)
self._print(r, print_dict)
-
if self['wait']:
self._wait(r['id'], 'PENDING')
details=[
'Make sure the image file exists'] + howto_image_file)
raise
+ r['owner'] += '( %s)' % self._uuid2username(r['owner'])
self._print(r, print_dict)
#upload the metadata file
@errors.generic.all
@errors.plankton.connection
def _run(self, member):
- self._print(self.client.list_shared(member), title=('image_id',))
+ r = self.client.list_shared(member)
+ if r:
+ uuid = self._username2uuid(member)
+ r = self.client.list_shared(uuid) if uuid else []
+ self._print(r, title=('image_id',))
- def main(self, member):
+ def main(self, member_id_or_username):
super(self.__class__, self)._run()
- self._run(member)
+ self._run(member_id_or_username)
@command(image_cmds)
@errors.plankton.connection
@errors.plankton.id
def _run(self, image_id):
- self._print(self.client.list_members(image_id), title=('member_id',))
+ members = self.client.list_members(image_id)
+ if not self['json_output']:
+ uuids = [member['member_id'] for member in members]
+ usernames = self._uuids2usernames(uuids)
+ for member in members:
+ member['member_id'] += ' (%s)' % usernames[member['member_id']]
+ self._print(members, title=('member_id',))
def main(self, image_id):
super(self.__class__, self)._run()
def _run(self, image_id=None, member=None):
self._optional_output(self.client.add_member(image_id, member))
- def main(self, image_id, member):
+ def main(self, image_id, member_id):
super(self.__class__, self)._run()
- self._run(image_id=image_id, member=member)
+ self._run(image_id=image_id, member=member_id)
@command(image_cmds)
def _run(self, image_id, members):
self._optional_output(self.client.set_members(image_id, members))
- def main(self, image_id, *members):
+ def main(self, image_id, *member_ids):
super(self.__class__, self)._run()
- self._run(image_id=image_id, members=members)
+ self._run(image_id=image_id, members=member_ids)
# Compute Image Commands
@errors.plankton.id
def _run(self, image_id):
image = self.client.get_image_details(image_id)
+ uuids = [image['user_id'], image['tenant_id']]
+ usernames = self._uuids2usernames(uuids)
+ image['user_id'] += ' (%s)' % usernames[image['user_id']]
+ image['tenant_id'] += ' (%s)' % usernames[image['tenant_id']]
self._print(image, print_dict)
def main(self, image_id):
until=self['until'], delimiter=self['delimiter']))
else:
print('Aborted')
- else:
+ elif self.container:
if self['recursive']:
ask_msg = 'Delete container contents'
else:
until=self['until'], delimiter=self['delimiter']))
else:
print('Aborted')
+ else:
+ raiseCLIError('Nothing to delete, please provide container[:path]')
def main(self, container____path__=None):
super(self.__class__, self)._run(container____path__)
@errors.pithos.connection
def _run(self):
accounts = self.client.get_sharing_accounts(marker=self['marker'])
- uuids = [acc['name'] for acc in accounts]
- try:
- 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(usernames)
- else:
- self._print(r, print_dict)
+ if not self['json_output']:
+ usernames = self._uuids2usernames(
+ [acc['name'] for acc in accounts])
+ for item in accounts:
+ uuid = item['name']
+ item['id'], item['name'] = uuid, usernames[uuid]
+ if not self['detail']:
+ item.pop('last_modified')
+ self._print(accounts)
def main(self):
super(self.__class__, self)._run()