if getattr(self, 'cloud', None):
img_url = self._custom_url('image') or self._custom_url('plankton')
if img_url:
- token = self._custom_token('image')\
- or self._custom_token('plankton')\
- or self.config.get_cloud(self.cloud, 'token')
+ token = self._custom_token('image') or self._custom_token(
+ 'plankton') or self.config.get_cloud(self.cloud, 'token')
self.client = ImageClient(base_url=img_url, token=token)
return
if getattr(self, 'auth_base', False):
)
def _check_empty(self):
- for term in (
- 'disk_format', 'container_format', 'status', 'properties'):
- if self[term]:
+ for t in ('disk_format', 'container_format', 'status', 'properties'):
+ if self[t]:
return
raiseCLIError(
'Nothing to update, please use arguments (-h for a list)')
arguments = dict(
checksum=ValueArgument('Set image checksum', '--checksum'),
container_format=ValueArgument(
- 'Set container format',
- '--container-format'),
+ 'Set container format', '--container-format'),
disk_format=ValueArgument('Set disk format', '--disk-format'),
owner_name=ValueArgument('Set user uuid by user name', '--owner-name'),
properties=KeyValueArgument(
if getattr(self, 'auth_base', False):
return self.auth_base.term('id', atoken)
else:
- astakos_url = self.config.get('user', 'url')\
- or self.config.get('astakos', 'url')
+ astakos_url = self.config.get('user', 'url') or self.config.get(
+ 'astakos', 'url')
if not astakos_url:
raise CLIBaseUrlError(service='astakos')
user = AstakosClient(astakos_url, atoken)
try:
for k, v in _load_image_meta(pfile).items():
key = k.lower().replace('-', '_')
- if k == 'properties':
+ if key == 'properties':
for pk, pv in v.items():
properties[pk.upper().replace('-', '_')] = pv
elif key == 'name':
meta_path, dumps(r, indent=2),
container_info_cache=self.container_info_cache)
except TypeError:
- print('Failed to dump metafile %s:%s' % (dst_cont, meta_path))
+ self.error(
+ 'Failed to dump metafile %s:%s' % (dst_cont, meta_path))
return
if self['json_output']:
print_json(dict(
metafile_location='%s:%s' % (dst_cont, meta_path),
headers=meta_headers))
else:
- print('Metadata file uploaded as %s:%s (version %s)' % (
+ self.error('Metadata file uploaded as %s:%s (version %s)' % (
dst_cont, meta_path, meta_headers['x-object-version']))
def main(self, name, container___image_path):
arguments = dict(
detail=FlagArgument('show detailed output', ('-l', '--details')),
limit=IntArgument('limit number listed images', ('-n', '--number')),
- more=FlagArgument(
- 'output results in pages (-n to set items per page, default 10)',
- '--more'),
+ more=FlagArgument('handle long lists of results', '--more'),
enum=FlagArgument('Enumerate results', '--enumerate'),
user_id=ValueArgument('filter by user_id', '--user-id'),
user_name=ValueArgument('filter by username', '--user-name'),
self._run(image_id=image_id, key=key)
-#@command(image_cmds)
-#class image_compute_properties_add(_init_cyclades, _optional_json):
-# """Add a property to an image"""
-#
-# @errors.generic.all
-# @errors.cyclades.connection
-# @errors.plankton.id
-# @errors.plankton.metadata
-# def _run(self, image_id, key, val):
-# self._print(
-# self.client.create_image_metadata(image_id, key, val), print_dict)
-#
-# def main(self, image_id, key, val):
-# super(self.__class__, self)._run()
-# self._run(image_id=image_id, key=key, val=val)
-
-
@command(image_cmds)
class image_compute_properties_set(_init_cyclades, _optional_json):
"""Add / update a set of properties for an image
@errors.generic.all
def _run(self, *args):
- print(args)
+ self.writeln(args)
def main(self, *args):
self._run(args)
@errors.generic.all
def _run(self):
from kamaki.cli.utils import print_dict, print_list, print_items
- print('Test simple dict:\n- - -')
+ self.writeln('Test simple dict:\n- - -')
print_dict(self.d1)
- print('- - -\n')
- print('\nTest simple list:\n- - -')
+ self.writeln('- - -\n')
+ self.writeln('\nTest simple list:\n- - -')
print_list(self.l1)
- print('- - -\n')
- print('\nTest 2-level dict:\n- - -')
+ self.writeln('- - -\n')
+ self.writeln('\nTest 2-level dict:\n- - -')
print_dict(self.d2)
- print('- - -\n')
- print('\nTest non-trivial list:\n- - -')
+ self.writeln('- - -\n')
+ self.writeln('\nTest non-trivial list:\n- - -')
print_list(self.l2)
- print('- - -')
- print('\nTest extreme dict:\n- - -')
+ self.writeln('- - -')
+ self.writeln('\nTest extreme dict:\n- - -')
print_dict(self.d3)
- print('- - -\n')
- print('Test simple enumerated dict:\n- - -')
+ self.writeln('- - -\n')
+ self.writeln('Test simple enumerated dict:\n- - -')
print_dict(self.d1, with_enumeration=True)
- print('- - -\n')
- print('\nTest simple enumerated list:\n- - -')
+ self.writeln('- - -\n')
+ self.writeln('\nTest simple enumerated list:\n- - -')
print_list(self.l1, with_enumeration=True)
- print('- - -\n')
- print('Test non-trivial deep-enumerated dict:\n- - -')
+ self.writeln('- - -\n')
+ self.writeln('Test non-trivial deep-enumerated dict:\n- - -')
print_dict(self.d2, with_enumeration=True, recursive_enumeration=True)
- print('- - -\n')
- print('\nTest non-trivial enumerated list:\n- - -')
+ self.writeln('- - -\n')
+ self.writeln('\nTest non-trivial enumerated list:\n- - -')
print_list(self.l2, with_enumeration=True)
- print('- - -\n')
- print('\nTest print_items with id:\n- - -')
+ self.writeln('- - -\n')
+ self.writeln('\nTest print_items with id:\n- - -')
print_items([
{'id': '42', 'title': 'lalakis 1', 'content': self.d1},
{'id': '142', 'title': 'lalakis 2', 'content': self.d2}])
- print('- - -')
- print('\nTest print_items with id and enumeration:\n- - -')
+ self.writeln('- - -')
+ self.writeln('\nTest print_items with id and enumeration:\n- - -')
print_items(
[
{'id': '42', 'title': 'lalakis 1', 'content': self.d1},
{'id': '142', 'title': 'lalakis 2', 'content': self.d2}],
with_enumeration=True)
- print('- - -')
- print('\nTest print_items with id, title and redundancy:\n- - -')
+ self.writeln('- - -')
+ self.writeln('\nTest print_items with id, title, redundancy:\n- - -')
print_items(
[
{'id': '42', 'title': 'lalakis 1', 'content': self.d1},
{'id': '142', 'title': 'lalakis 2', 'content': self.d2}],
title=('id', 'title'),
with_redundancy=True)
- print('- - -')
- print('\nTest print_items with lists- - -')
+ self.writeln('- - -')
+ self.writeln('\nTest print_items with lists- - -')
print_items([['i00', 'i01', 'i02'], [self.l2, 'i11', self.d1], 3])
- print('- - -')
+ self.writeln('- - -')
def main(self):
self._run()
@errors.generic.all
@astakoserror
def _run(self):
- print 'accepted ', self['accept']
- print 'rejected ', self['reject']
+ self.writeln('accepted ', self['accept'])
+ self.writeln('rejected ', self['reject'])
self._print(
self.client.resolve_commissions(
self.token, self['accept'], self['reject']),
def apply_notification(foo):
def wrap(self, *args, **kwargs):
r = foo(self, *args, **kwargs)
- print 'Application is submitted successfully'
+ self.writeln('Application is submitted successfully')
return r
return wrap
@errors.generic.all
@astakoserror
def _run(self, project_id):
- print self.client.join_project(self.token, project_id)
+ self.writeln(self.client.join_project(self.token, project_id))
def main(self, project_id):
super(project_membership_join, self)._run()
@errors.generic.all
@astakoserror
def _run(self, project_id, email):
- print self.client.enroll_member(self.token, project_id, email)
+ self.writeln(self.client.enroll_member(self.token, project_id, email))
def main(self, project_id, email):
super(project_membership_join, self)._run()