Commit ba1ef68c authored by Stratos Psomadakis's avatar Stratos Psomadakis
Browse files

Fix bugs in UserCache

Fix an infinite loop bug in UserCache.fetch_names(), and correct the
*-list commands to only call fetch_names(), when invoked with the
--displayname option.
parent 7b922cf7
......@@ -128,8 +128,9 @@ class Command(BaseCommand):
else:
headers.extend(['IPv4 Subnet', 'IPv4 Gateway'])
uuids = list(set([network.userid for network in networks]))
ucache.fetch_names(uuids)
if displayname:
uuids = list(set([network.userid for network in networks]))
ucache.fetch_names(uuids)
table = []
for network in networks.order_by("id"):
......
......@@ -136,8 +136,9 @@ class Command(BaseCommand):
'backend',
])
uuids = list(set([server.userid for server in servers]))
ucache.fetch_names(uuids)
if displayname:
uuids = list(set([server.userid for server in servers]))
ucache.fetch_names(uuids)
table = []
for server in servers.order_by('id'):
......
......@@ -263,11 +263,11 @@ class UserCache(object):
assert(self.split > 0), "split must be positive"
def fetch_names(self, uuid_list):
l = len(uuid_list)
total = len(uuid_list)
split = self.split
start = 0
while start < l:
end = self.split if l > self.split else l
for start in range(0, total, split):
end = start + split
try:
names = \
astakos.get_displaynames(token=ASTAKOS_TOKEN,
......@@ -277,8 +277,6 @@ class UserCache(object):
except Exception as e:
log.error("Failed to fetch names: %s", e)
start = end
def get_uuid(self, name):
if not name in self.users:
try:
......
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