Revision c51f3a08 snf-cyclades-app/synnefo/logic/management/commands/network-inspect.py
b/snf-cyclades-app/synnefo/logic/management/commands/network-inspect.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
import json |
35 | 35 |
|
36 |
from optparse import make_option |
|
37 |
|
|
36 | 38 |
from django.core.management.base import BaseCommand, CommandError |
37 |
from synnefo.management.common import get_network |
|
39 |
from synnefo.management.common import get_network, UUIDCache
|
|
38 | 40 |
|
39 | 41 |
from synnefo.db.models import (Backend, BackendNetwork, |
40 | 42 |
pooled_rapi_client) |
... | ... | |
45 | 47 |
class Command(BaseCommand): |
46 | 48 |
help = "Inspect a network on DB and Ganeti." |
47 | 49 |
|
50 |
option_list = BaseCommand.option_list + ( |
|
51 |
make_option('--uuids', |
|
52 |
action='store_true', |
|
53 |
dest='use_uuids', |
|
54 |
default=False, |
|
55 |
help="Display UUIDs instead of user emails"), |
|
56 |
) |
|
57 |
|
|
48 | 58 |
def handle(self, *args, **options): |
49 | 59 |
write = self.stdout.write |
50 | 60 |
if len(args) != 1: |
... | ... | |
56 | 66 |
labels = ('name', 'backend-name', 'state', 'owner', 'subnet', |
57 | 67 |
'gateway', 'mac_prefix', 'link', 'public', 'dhcp', 'flavor', |
58 | 68 |
'deleted', 'action', 'pool') |
59 |
fields = (net.name, net.backend_id, net.state, str(net.userid), |
|
69 |
|
|
70 |
user = net.userid |
|
71 |
if options['use_uuids'] is False: |
|
72 |
ucache = UUIDCache() |
|
73 |
user = ucache.get_user(net.userid) |
|
74 |
|
|
75 |
fields = (net.name, net.backend_id, net.state, user or '', |
|
60 | 76 |
str(net.subnet), str(net.gateway), str(net.mac_prefix), |
61 | 77 |
str(net.link), str(net.public), str(net.dhcp), |
62 | 78 |
str(net.flavor), str(net.deleted), str(net.action), |
Also available in: Unified diff