Commit f22773bc authored by Stratos Psomadakis's avatar Stratos Psomadakis Committed by Christos Stavrakakis
Browse files

Add --uuids option to snf-manage cmds

parent 9931bc62
......@@ -34,7 +34,7 @@
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from synnefo.management.common import format_bool, filter_results
from synnefo.management.common import format_bool, filter_results, UUIDCache
from synnefo.db.models import Network
from synnefo.management.common import pprint_table
......@@ -70,8 +70,12 @@ class Command(BaseCommand):
help="Filter results. Comma seperated list of key 'cond' val pairs"
" that displayed entries must satisfy. e.g."
" --filter-by \"name=Network-1,link!=prv0\"."
" Available keys are: %s" % ", ".join(FIELDS))
" Available keys are: %s" % ", ".join(FIELDS)),
make_option('--uuids',
action='store_true',
dest='use_uuids',
default=False,
help="Display UUIDs instead of user emails"),
)
def handle(self, *args, **options):
......@@ -98,12 +102,19 @@ class Command(BaseCommand):
else:
headers.extend(['IPv4 Subnet', 'IPv4 Gateway'])
if options['use_uuids'] is False:
ucache = UUIDCache()
table = []
for network in networks.order_by("id"):
user = network.userid
if options['use_uuids'] is False:
user = ucache.get_user(network.userid)
fields = [str(network.id),
network.name,
network.flavor,
network.userid or '',
user or '',
network.mac_prefix or '',
str(network.dhcp),
network.state,
......
......@@ -56,10 +56,16 @@ class Command(BaseCommand):
args = "<server ID>"
option_list = BaseCommand.option_list + (
make_option('--jobs', action='store_true',
dest='jobs', default=False,
help="Show non-archived jobs concerning server."
),
make_option('--jobs',
action='store_true',
dest='jobs',
default=False,
help="Show non-archived jobs concerning server."),
make_option('--uuids',
action='store_true',
dest='use_uuids',
default=False,
help="Display UUIDs instead of user emails"),
)
def handle(self, *args, **options):
......@@ -77,7 +83,13 @@ class Command(BaseCommand):
labels = ('name', 'owner', 'flavor', 'image', 'state', 'backend',
'deleted', 'action', 'backendjobid', 'backendopcode',
'backendjobstatus', 'backend_time')
fields = (vm.name, vm.userid, vm.flavor.name, image,
user = vm.userid
if options['use_uuids'] is False:
ucache = common.UUIDCache()
user = ucache.get_user(vm.userid)
fields = (vm.name, user, vm.flavor.name, image,
common.format_vm_state(vm), str(vm.backend),
str(vm.deleted), str(vm.action), str(vm.backendjobid),
str(vm.backendopcode), str(vm.backendjobstatus),
......
......@@ -109,7 +109,8 @@ class Command(BaseCommand):
servers = filter_results(servers, filter_by)
cache = ImageCache()
ucache = UUIDCache()
if options['use_uuids'] is False:
ucache = UUIDCache()
headers = ('id', 'name', 'owner', 'flavor', 'image', 'state',
'backend')
......@@ -131,7 +132,7 @@ class Command(BaseCommand):
state = format_vm_state(server)
user = server.userid
if not options['use_uuids']:
if options['use_uuids'] is False:
user = ucache.get_user(server.userid)
fields = (str(server.id), name, user, flavor, image,
......
......@@ -33,8 +33,10 @@
import json
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from synnefo.management.common import get_network
from synnefo.management.common import get_network, UUIDCache
from synnefo.db.models import (Backend, BackendNetwork,
pooled_rapi_client)
......@@ -45,6 +47,14 @@ from util import pool_map_chunks
class Command(BaseCommand):
help = "Inspect a network on DB and Ganeti."
option_list = BaseCommand.option_list + (
make_option('--uuids',
action='store_true',
dest='use_uuids',
default=False,
help="Display UUIDs instead of user emails"),
)
def handle(self, *args, **options):
write = self.stdout.write
if len(args) != 1:
......@@ -56,7 +66,13 @@ class Command(BaseCommand):
labels = ('name', 'backend-name', 'state', 'owner', 'subnet',
'gateway', 'mac_prefix', 'link', 'public', 'dhcp', 'flavor',
'deleted', 'action', 'pool')
fields = (net.name, net.backend_id, net.state, str(net.userid),
user = net.userid
if options['use_uuids'] is False:
ucache = UUIDCache()
user = ucache.get_user(net.userid)
fields = (net.name, net.backend_id, net.state, user or '',
str(net.subnet), str(net.gateway), str(net.mac_prefix),
str(net.link), str(net.public), str(net.dhcp),
str(net.flavor), str(net.deleted), str(net.action),
......
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