Revision 47d1d754 snf-cyclades-app/synnefo/logic/allocators/default_allocator.py
b/snf-cyclades-app/synnefo/logic/allocators/default_allocator.py | ||
---|---|---|
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 | 34 |
from __future__ import division |
35 |
import logging |
|
35 | 36 |
from synnefo.api.util import backend_public_networks |
36 | 37 |
|
38 |
log = logging.getLogger(__name__) |
|
39 |
|
|
37 | 40 |
|
38 | 41 |
def allocate(backends, vm): |
39 | 42 |
if len(backends) == 1: |
... | ... | |
43 | 46 |
capable_backends = [backend for backend in backends |
44 | 47 |
if vm_fits_in_backend(backend, vm)] |
45 | 48 |
|
49 |
log.debug("Capable backends for VM %s: %s", vm, capable_backends) |
|
50 |
|
|
46 | 51 |
# Since we are conservatively updating backend resources on each |
47 | 52 |
# allocation, a backend may actually be able to host a vm (despite |
48 | 53 |
# the state of the backend in db) |
... | ... | |
53 | 58 |
backend_scores = [(backend, backend_score(backend, vm)) |
54 | 59 |
for backend in capable_backends] |
55 | 60 |
|
61 |
log.debug("Backend scores %s", backend_scores) |
|
62 |
|
|
56 | 63 |
# Pick out the best |
57 | 64 |
result = min(backend_scores, key=lambda (b, b_score): b_score) |
58 | 65 |
backend = result[0] |
Also available in: Unified diff