Revision 47d1d754

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]
b/snf-cyclades-app/synnefo/logic/backend_allocator.py
27 27
# those of the authors and should not be interpreted as representing official
28 28
# policies, either expressed or implied, of GRNET S.A.
29 29

  
30
import logging
30 31
import datetime
31 32
from django.utils import importlib
32 33

  
......
34 35
from synnefo.db.models import Backend
35 36
from synnefo.logic.backend import update_resources
36 37

  
38
log = logging.getLogger(__name__)
39

  
37 40

  
38 41
class BackendAllocator():
39 42
    """Wrapper class for instance allocation.
......
50 53
        cpu = flavor.cpu
51 54
        vm = {'ram': ram, 'disk': disk, 'cpu': cpu}
52 55

  
56
        log.debug("Allocating VM: %r", vm)
57

  
53 58
        # Refresh backends, if needed
54 59
        refresh_backends_stats()
55 60

  
......
63 68
        # strategy
64 69
        backend = self.strategy_mod.allocate(available_backends, vm)
65 70

  
71
        log.info("Allocated VM %r, in backend %s", vm, backend)
72

  
66 73
        # Reduce the free resources of the selected backend by the size of
67 74
        # the vm
68 75
        reduce_backend_resources(backend, vm)
......
116 123
    delta = datetime.timedelta(minutes=settings.BACKEND_REFRESH_MIN)
117 124
    for b in Backend.objects.filter(drained=False, offline=False):
118 125
        if now > b.updated + delta:
126
            log.debug("Updating resources of backend %r", b)
119 127
            update_resources(b)

Also available in: Unified diff