Revision ed9af02c
b/Changelog | ||
---|---|---|
27 | 27 |
- Implement purging a non-empty container [#3662] |
28 | 28 |
- Add a -l option to upload, for listing uploaded objects details [#3730] |
29 | 29 |
- Add option to cache container info for upload_object [#3707] |
30 |
- Add enumeration to all listing commands, make it optional [#3739] |
|
30 | 31 |
|
b/kamaki/cli/commands/cyclades.py | ||
---|---|---|
93 | 93 |
limit=IntArgument('limit number of listed VMs', ('-n', '--number')), |
94 | 94 |
more=FlagArgument( |
95 | 95 |
'output results in pages (-n to set items per page, default 10)', |
96 |
'--more') |
|
96 |
'--more'), |
|
97 |
enum=FlagArgument('Enumerate results', '--enumerate') |
|
97 | 98 |
) |
98 | 99 |
|
99 | 100 |
def _make_results_pretty(self, servers): |
... | ... | |
122 | 123 |
if self['more']: |
123 | 124 |
print_items( |
124 | 125 |
servers, |
125 |
page_size=self['limit'] if self['limit'] else 10) |
|
126 |
page_size=self['limit'] if self['limit'] else 10, |
|
127 |
with_enumeration=self['enum']) |
|
126 | 128 |
else: |
127 | 129 |
print_items( |
128 |
servers[:self['limit'] if self['limit'] else len(servers)]) |
|
130 |
servers[:self['limit'] if self['limit'] else len(servers)], |
|
131 |
with_enumeration=self['enum']) |
|
129 | 132 |
|
130 | 133 |
def main(self): |
131 | 134 |
super(self.__class__, self)._run() |
... | ... | |
495 | 498 |
limit=IntArgument('limit # of listed flavors', ('-n', '--number')), |
496 | 499 |
more=FlagArgument( |
497 | 500 |
'output results in pages (-n to set items per page, default 10)', |
498 |
'--more') |
|
501 |
'--more'), |
|
502 |
enum=FlagArgument('Enumerate results', '--enumerate') |
|
499 | 503 |
) |
500 | 504 |
|
501 | 505 |
@errors.generic.all |
... | ... | |
503 | 507 |
def _run(self): |
504 | 508 |
flavors = self.client.list_flavors(self['detail']) |
505 | 509 |
pg_size = 10 if self['more'] and not self['limit'] else self['limit'] |
506 |
print_items(flavors, with_redundancy=self['detail'], page_size=pg_size) |
|
510 |
print_items( |
|
511 |
flavors, |
|
512 |
with_redundancy=self['detail'], |
|
513 |
page_size=pg_size, |
|
514 |
with_enumeration=self['enum']) |
|
507 | 515 |
|
508 | 516 |
def main(self): |
509 | 517 |
super(self.__class__, self)._run() |
... | ... | |
563 | 571 |
limit=IntArgument('limit # of listed networks', ('-n', '--number')), |
564 | 572 |
more=FlagArgument( |
565 | 573 |
'output results in pages (-n to set items per page, default 10)', |
566 |
'--more') |
|
574 |
'--more'), |
|
575 |
enum=FlagArgument('Enumerate results', '--enumerate') |
|
567 | 576 |
) |
568 | 577 |
|
569 | 578 |
def _make_results_pretty(self, nets): |
... | ... | |
577 | 586 |
if self['detail']: |
578 | 587 |
self._make_results_pretty(networks) |
579 | 588 |
if self['more']: |
580 |
print_items(networks, page_size=self['limit'] or 10) |
|
589 |
print_items( |
|
590 |
networks, |
|
591 |
page_size=self['limit'] or 10, with_enumeration=self['enum']) |
|
581 | 592 |
elif self['limit']: |
582 |
print_items(networks[:self['limit']]) |
|
593 |
print_items( |
|
594 |
networks[:self['limit']], |
|
595 |
with_enumeration=self['enum']) |
|
583 | 596 |
else: |
584 |
print_items(networks) |
|
597 |
print_items(networks, with_enumeration=self['enum'])
|
|
585 | 598 |
|
586 | 599 |
def main(self): |
587 | 600 |
super(self.__class__, self)._run() |
b/kamaki/cli/commands/image.py | ||
---|---|---|
103 | 103 |
limit=IntArgument('limit number of listed images', ('-n', '--number')), |
104 | 104 |
more=FlagArgument( |
105 | 105 |
'output results in pages (-n to set items per page, default 10)', |
106 |
'--more') |
|
106 |
'--more'), |
|
107 |
enum=FlagArgument('Enumerate results', '--enumerate') |
|
107 | 108 |
) |
108 | 109 |
|
109 | 110 |
def _filtered_by_owner(self, detail, *list_params): |
... | ... | |
150 | 151 |
if self['more']: |
151 | 152 |
print_items( |
152 | 153 |
images, |
153 |
title=('name',), |
|
154 |
with_enumeration=True, |
|
155 |
page_size=self['limit'] or 10) |
|
154 |
with_enumeration=self['enum'], page_size=self['limit'] or 10) |
|
156 | 155 |
elif self['limit']: |
157 |
print_items( |
|
158 |
images[:self['limit']], |
|
159 |
title=('name',), |
|
160 |
with_enumeration=True) |
|
156 |
print_items(images[:self['limit']], with_enumeration=self['enum']) |
|
161 | 157 |
else: |
162 |
print_items(images, title=('name',), with_enumeration=True)
|
|
158 |
print_items(images, with_enumeration=self['enum'])
|
|
163 | 159 |
|
164 | 160 |
def main(self): |
165 | 161 |
super(self.__class__, self)._run() |
... | ... | |
355 | 351 |
limit=IntArgument('limit number listed images', ('-n', '--number')), |
356 | 352 |
more=FlagArgument( |
357 | 353 |
'output results in pages (-n to set items per page, default 10)', |
358 |
'--more') |
|
354 |
'--more'), |
|
355 |
enum=FlagArgument('Enumerate results', '--enumerate') |
|
359 | 356 |
) |
360 | 357 |
|
361 | 358 |
def _make_results_pretty(self, images): |
... | ... | |
370 | 367 |
if self['detail']: |
371 | 368 |
self._make_results_pretty(images) |
372 | 369 |
if self['more']: |
373 |
print_items(images, page_size=self['limit'] or 10) |
|
370 |
print_items( |
|
371 |
images, |
|
372 |
page_size=self['limit'] or 10, with_enumeration=self['enum']) |
|
374 | 373 |
else: |
375 |
print_items(images[:self['limit']]) |
|
374 |
print_items(images[:self['limit']], with_enumeration=self['enum'])
|
|
376 | 375 |
|
377 | 376 |
def main(self): |
378 | 377 |
super(self.__class__, self)._run() |
b/kamaki/cli/commands/pithos.py | ||
---|---|---|
328 | 328 |
'--more'), |
329 | 329 |
exact_match=FlagArgument( |
330 | 330 |
'Show only objects that match exactly with path', |
331 |
'--exact-match') |
|
331 |
'--exact-match'), |
|
332 |
enum=FlagArgument('Enumerate results', '--enumerate') |
|
332 | 333 |
) |
333 | 334 |
|
334 | 335 |
def print_objects(self, object_list): |
... | ... | |
348 | 349 |
size = format_size(obj['bytes']) |
349 | 350 |
pretty_obj['bytes'] = '%s (%s)' % (obj['bytes'], size) |
350 | 351 |
oname = bold(obj['name']) |
352 |
prfx = ('%s%s. ' % (empty_space, index)) if self['enum'] else '' |
|
351 | 353 |
if self['detail']: |
352 |
print('%s%s. %s' % (empty_space, index, oname))
|
|
354 |
print('%s%s' % (prfx, oname))
|
|
353 | 355 |
print_dict(pretty_keys(pretty_obj), exclude=('name')) |
354 | 356 |
|
355 | 357 |
else: |
356 |
oname = '%s%s. %6s %s' % (empty_space, index, size, oname)
|
|
358 |
oname = '%s%9s %s' % (prfx, size, oname)
|
|
357 | 359 |
oname += '/' if isDir else '' |
358 | 360 |
print(oname) |
359 | 361 |
if self['more']: |
... | ... | |
365 | 367 |
for index, container in enumerate(container_list): |
366 | 368 |
if 'bytes' in container: |
367 | 369 |
size = format_size(container['bytes']) |
368 |
cname = '%s. %s' % (index + 1, bold(container['name'])) |
|
370 |
prfx = ('%s. ' % (index + 1)) if self['enum'] else '' |
|
371 |
cname = '%s%s' % (prfx, bold(container['name'])) |
|
369 | 372 |
if self['detail']: |
370 | 373 |
print(cname) |
371 | 374 |
pretty_c = container.copy() |
Also available in: Unified diff