Commit c3a3661f authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Speed up reconciliation

Speed up reconciliation by using mulitprocessing to get in parallel
the instances from all Ganeti backends.
parent ac04235f
......@@ -78,7 +78,8 @@ INSTALL_REQUIRES = [
......@@ -32,6 +32,8 @@
# or implied, of GRNET S.A.
import json
import multiprocessing
import itertools
from django.conf import settings
from django.db import transaction
......@@ -641,13 +643,25 @@ def set_firewall_profile(vm, profile):
def get_instances(backend, bulk, queue):
with pooled_rapi_client(backend) as client:
instances = client.GetInstances(bulk=bulk)
def get_ganeti_instances(backend=None, bulk=False):
instances = []
for backend in get_backends(backend):
with pooled_rapi_client(backend) as client:
return reduce(list.__add__, instances, [])
backends = get_backends(backend)
queue = multiprocessing.Queue()
processes = []
for backend in backends:
p = multiprocessing.Process(target=get_instances,
args=(backend, bulk, queue))
[p.join() for p in processes]
[instances.extend(queue.get()) for p in processes]
return instances
def get_ganeti_nodes(backend=None, bulk=False):
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