Revision cf2241c4
b/snf-cyclades-app/setup.py | ||
---|---|---|
78 | 78 |
'astakosclient', |
79 | 79 |
'snf-django-lib', |
80 | 80 |
'snf-branding', |
81 |
'snf-webproject' |
|
81 |
'snf-webproject', |
|
82 |
'multiprocessing', |
|
82 | 83 |
] |
83 | 84 |
|
84 | 85 |
EXTRAS_REQUIRES = { |
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 | 34 |
import json |
35 |
import multiprocessing |
|
36 |
import itertools |
|
35 | 37 |
|
36 | 38 |
from django.conf import settings |
37 | 39 |
from django.db import transaction |
... | ... | |
641 | 643 |
os_name=os_name) |
642 | 644 |
|
643 | 645 |
|
646 |
def get_instances(backend, bulk, queue): |
|
647 |
with pooled_rapi_client(backend) as client: |
|
648 |
instances = client.GetInstances(bulk=bulk) |
|
649 |
queue.put(instances) |
|
650 |
|
|
651 |
|
|
644 | 652 |
def get_ganeti_instances(backend=None, bulk=False): |
645 | 653 |
instances = [] |
646 |
for backend in get_backends(backend): |
|
647 |
with pooled_rapi_client(backend) as client: |
|
648 |
instances.append(client.GetInstances(bulk=bulk)) |
|
649 |
|
|
650 |
return reduce(list.__add__, instances, []) |
|
654 |
backends = get_backends(backend) |
|
655 |
queue = multiprocessing.Queue() |
|
656 |
processes = [] |
|
657 |
for backend in backends: |
|
658 |
p = multiprocessing.Process(target=get_instances, |
|
659 |
args=(backend, bulk, queue)) |
|
660 |
processes.append(p) |
|
661 |
p.start() |
|
662 |
[p.join() for p in processes] |
|
663 |
[instances.extend(queue.get()) for p in processes] |
|
664 |
return instances |
|
651 | 665 |
|
652 | 666 |
|
653 | 667 |
def get_ganeti_nodes(backend=None, bulk=False): |
Also available in: Unified diff