Commit 287c45c2 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Update resource-list management command

parent 4e8083bd
......@@ -31,42 +31,21 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from optparse import make_option
from import NoArgsCommand
from import Resource
from import ListCommand
class Command(NoArgsCommand):
class Command(ListCommand):
help = "List resources"
option_list = NoArgsCommand.option_list + (
help="Use pipes to separate values"),
def handle_noargs(self, **options):
resources = Resource.objects.select_related().all()
labels = ('id', 'service', 'name')
columns = (3, 40, 40)
if not options['csv']:
line = ' '.join(l.rjust(w) for l, w in zip(labels, columns))
self.stdout.write(line + '\n')
sep = '-' * len(line)
self.stdout.write(sep + '\n')
for r in resources:
fields = (str(,,
if options['csv']:
line = '|'.join(fields)
line = ' '.join(f.rjust(w) for f, w in zip(fields, columns))
self.stdout.write(line + '\n')
object_class = Resource
"id": ("id", "ID"),
"name": ("name", "Resource Name"),
"service": ("service", "Service"),
"unit": ("unit", "Unit"),
"limit": ("uplimit", "Base Quota"),
"description": ("desc", "Description"),
fields = ["id", "name", "service", "unit", "limit", "description"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment