Revision c51f3a08
b/snf-cyclades-app/synnefo/api/management/commands/network-list.py | ||
---|---|---|
34 | 34 |
from optparse import make_option |
35 | 35 |
|
36 | 36 |
from django.core.management.base import BaseCommand, CommandError |
37 |
from synnefo.management.common import format_bool, filter_results |
|
37 |
from synnefo.management.common import format_bool, filter_results, UUIDCache
|
|
38 | 38 |
from synnefo.db.models import Network |
39 | 39 |
from synnefo.management.common import pprint_table |
40 | 40 |
|
... | ... | |
70 | 70 |
help="Filter results. Comma seperated list of key 'cond' val pairs" |
71 | 71 |
" that displayed entries must satisfy. e.g." |
72 | 72 |
" --filter-by \"name=Network-1,link!=prv0\"." |
73 |
" Available keys are: %s" % ", ".join(FIELDS)) |
|
74 |
|
|
73 |
" Available keys are: %s" % ", ".join(FIELDS)), |
|
74 |
make_option('--uuids', |
|
75 |
action='store_true', |
|
76 |
dest='use_uuids', |
|
77 |
default=False, |
|
78 |
help="Display UUIDs instead of user emails"), |
|
75 | 79 |
) |
76 | 80 |
|
77 | 81 |
def handle(self, *args, **options): |
... | ... | |
98 | 102 |
else: |
99 | 103 |
headers.extend(['IPv4 Subnet', 'IPv4 Gateway']) |
100 | 104 |
|
105 |
if options['use_uuids'] is False: |
|
106 |
ucache = UUIDCache() |
|
107 |
|
|
101 | 108 |
table = [] |
102 | 109 |
for network in networks.order_by("id"): |
110 |
user = network.userid |
|
111 |
if options['use_uuids'] is False: |
|
112 |
user = ucache.get_user(network.userid) |
|
113 |
|
|
103 | 114 |
fields = [str(network.id), |
104 | 115 |
network.name, |
105 | 116 |
network.flavor, |
106 |
network.userid or '',
|
|
117 |
user or '',
|
|
107 | 118 |
network.mac_prefix or '', |
108 | 119 |
str(network.dhcp), |
109 | 120 |
network.state, |
b/snf-cyclades-app/synnefo/api/management/commands/server-inspect.py | ||
---|---|---|
56 | 56 |
args = "<server ID>" |
57 | 57 |
|
58 | 58 |
option_list = BaseCommand.option_list + ( |
59 |
make_option('--jobs', action='store_true', |
|
60 |
dest='jobs', default=False, |
|
61 |
help="Show non-archived jobs concerning server." |
|
62 |
), |
|
59 |
make_option('--jobs', |
|
60 |
action='store_true', |
|
61 |
dest='jobs', |
|
62 |
default=False, |
|
63 |
help="Show non-archived jobs concerning server."), |
|
64 |
make_option('--uuids', |
|
65 |
action='store_true', |
|
66 |
dest='use_uuids', |
|
67 |
default=False, |
|
68 |
help="Display UUIDs instead of user emails"), |
|
63 | 69 |
) |
64 | 70 |
|
65 | 71 |
def handle(self, *args, **options): |
... | ... | |
77 | 83 |
labels = ('name', 'owner', 'flavor', 'image', 'state', 'backend', |
78 | 84 |
'deleted', 'action', 'backendjobid', 'backendopcode', |
79 | 85 |
'backendjobstatus', 'backend_time') |
80 |
fields = (vm.name, vm.userid, vm.flavor.name, image, |
|
86 |
|
|
87 |
user = vm.userid |
|
88 |
if options['use_uuids'] is False: |
|
89 |
ucache = common.UUIDCache() |
|
90 |
user = ucache.get_user(vm.userid) |
|
91 |
|
|
92 |
fields = (vm.name, user, vm.flavor.name, image, |
|
81 | 93 |
common.format_vm_state(vm), str(vm.backend), |
82 | 94 |
str(vm.deleted), str(vm.action), str(vm.backendjobid), |
83 | 95 |
str(vm.backendopcode), str(vm.backendjobstatus), |
b/snf-cyclades-app/synnefo/api/management/commands/server-list.py | ||
---|---|---|
109 | 109 |
servers = filter_results(servers, filter_by) |
110 | 110 |
|
111 | 111 |
cache = ImageCache() |
112 |
ucache = UUIDCache() |
|
112 |
if options['use_uuids'] is False: |
|
113 |
ucache = UUIDCache() |
|
113 | 114 |
|
114 | 115 |
headers = ('id', 'name', 'owner', 'flavor', 'image', 'state', |
115 | 116 |
'backend') |
... | ... | |
131 | 132 |
state = format_vm_state(server) |
132 | 133 |
|
133 | 134 |
user = server.userid |
134 |
if not options['use_uuids']:
|
|
135 |
if options['use_uuids'] is False:
|
|
135 | 136 |
user = ucache.get_user(server.userid) |
136 | 137 |
|
137 | 138 |
fields = (str(server.id), name, user, flavor, image, |
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