Revision 90b67503 snf-cyclades-app/synnefo/api/management/commands/flavor-list.py
b/snf-cyclades-app/synnefo/api/management/commands/flavor-list.py | ||
---|---|---|
42 | 42 |
|
43 | 43 |
class Command(BaseCommand): |
44 | 44 |
help = "List flavors" |
45 |
|
|
45 |
|
|
46 | 46 |
option_list = BaseCommand.option_list + ( |
47 | 47 |
make_option('-c', |
48 | 48 |
action='store_true', |
... | ... | |
50 | 50 |
default=False, |
51 | 51 |
help="Use pipes to separate values"), |
52 | 52 |
) |
53 |
|
|
53 |
|
|
54 | 54 |
def handle(self, *args, **options): |
55 | 55 |
if args: |
56 | 56 |
raise CommandError("Command doesn't accept any arguments") |
57 |
|
|
57 |
|
|
58 | 58 |
labels = ('id', 'name', 'cpus', 'ram', 'disk', 'template', 'deleted') |
59 | 59 |
columns = (3, 12, 6, 6, 6, 10, 7) |
60 |
|
|
60 |
|
|
61 | 61 |
if not options['csv']: |
62 | 62 |
line = ' '.join(l.rjust(w) for l, w in zip(labels, columns)) |
63 | 63 |
self.stdout.write(line + '\n') |
64 | 64 |
sep = '-' * len(line) |
65 | 65 |
self.stdout.write(sep + '\n') |
66 |
|
|
67 |
for flavor in Flavor.objects.all(): |
|
66 |
|
|
67 |
for flavor in Flavor.objects.all().order_by('id'):
|
|
68 | 68 |
id = str(flavor.id) |
69 | 69 |
cpu = str(flavor.cpu) |
70 | 70 |
ram = str(flavor.ram) |
... | ... | |
72 | 72 |
deleted = format_bool(flavor.deleted) |
73 | 73 |
fields = (id, flavor.name, cpu, ram, disk, flavor.disk_template, |
74 | 74 |
deleted) |
75 |
|
|
75 |
|
|
76 | 76 |
if options['csv']: |
77 | 77 |
line = '|'.join(fields) |
78 | 78 |
else: |
79 | 79 |
line = ' '.join(f.rjust(w) for f, w in zip(fields, columns)) |
80 |
|
|
80 |
|
|
81 | 81 |
self.stdout.write(line.encode('utf8') + '\n') |
Also available in: Unified diff