Revision 8283d6c1 snf-cyclades-app/synnefo/api/management/commands/network-list.py
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, UUIDCache,
|
|
37 |
from synnefo.management.common import (format_bool, filter_results, UserCache,
|
|
38 | 38 |
Omit) |
39 | 39 |
from synnefo.db.models import Network |
40 | 40 |
from synnefo.management.common import pprint_table |
... | ... | |
87 | 87 |
if args: |
88 | 88 |
raise CommandError("Command doesn't accept any arguments") |
89 | 89 |
|
90 |
ucache = UUIDCache()
|
|
90 |
ucache = UserCache()
|
|
91 | 91 |
|
92 | 92 |
if options['deleted']: |
93 | 93 |
networks = Network.objects.all() |
... | ... | |
100 | 100 |
user = options['user'] |
101 | 101 |
if user: |
102 | 102 |
if '@' in user: |
103 |
user = ucache.get_user(user)
|
|
103 |
user = ucache.get_uuid(user)
|
|
104 | 104 |
networks = networks.filter(userid=user) |
105 | 105 |
|
106 | 106 |
filter_by = options['filter_by'] |
... | ... | |
128 | 128 |
else: |
129 | 129 |
headers.extend(['IPv4 Subnet', 'IPv4 Gateway']) |
130 | 130 |
|
131 |
uuids = list(set([network.userid for network in networks])) |
|
132 |
ucache.fetch_names(uuids) |
|
133 |
|
|
131 | 134 |
table = [] |
132 | 135 |
for network in networks.order_by("id"): |
133 | 136 |
uuid = network.userid |
134 | 137 |
if displayname: |
135 |
dname = ucache.get_user(uuid)
|
|
138 |
dname = ucache.get_name(uuid)
|
|
136 | 139 |
|
137 | 140 |
fields = filter(lambda x: x is not Omit, |
138 | 141 |
[str(network.id), |
Also available in: Unified diff