Revision 7fede91e snf-cyclades-app/synnefo/logic/backend_allocator.py
b/snf-cyclades-app/synnefo/logic/backend_allocator.py | ||
---|---|---|
61 | 61 |
|
62 | 62 |
# Find the best backend to host the vm, based on the allocation |
63 | 63 |
# strategy |
64 |
backend_id = self.strategy_mod.allocate(available_backends, vm)
|
|
64 |
backend = self.strategy_mod.allocate(available_backends, vm) |
|
65 | 65 |
|
66 |
backend = Backend.objects.get(id=backend_id) |
|
67 | 66 |
# Reduce the free resources of the selected backend by the size of |
68 | 67 |
# the vm |
69 | 68 |
reduce_backend_resources(backend, vm) |
... | ... | |
75 | 74 |
"""Get available backends from db. |
76 | 75 |
|
77 | 76 |
""" |
78 |
attrs = ['mfree', 'mtotal', 'dfree', 'dtotal', 'pinst_cnt', 'ctotal'] |
|
79 |
backends = {} |
|
80 |
for b in Backend.objects.filter(drained=False, offline=False): |
|
81 |
backend = {} |
|
82 |
for a in attrs: |
|
83 |
backend[a] = getattr(b, a) |
|
84 |
backends[b.id] = backend |
|
85 |
return backends |
|
77 |
return Backend.objects.filter(drained=False, offline=False) |
|
86 | 78 |
|
87 | 79 |
|
88 | 80 |
def flavor_disk(flavor): |
Also available in: Unified diff