Revision adc46059 snf-cyclades-app/synnefo/logic/backend_allocator.py
b/snf-cyclades-app/synnefo/logic/backend_allocator.py | ||
---|---|---|
47 | 47 |
importlib.import_module(settings.BACKEND_ALLOCATOR_MODULE) |
48 | 48 |
|
49 | 49 |
def allocate(self, flavor): |
50 |
"""Allocate a vm of the specified flavor to a backend. |
|
51 |
|
|
52 |
Warning!!: An explicit commit is required after calling this function, |
|
53 |
in order to release the locks acquired by the get_available_backends |
|
54 |
function. |
|
55 |
|
|
56 |
""" |
|
50 | 57 |
# Get the size of the vm |
51 | 58 |
disk = flavor_disk(flavor) |
52 | 59 |
ram = flavor.ram |
... | ... | |
81 | 88 |
"""Get available backends from db. |
82 | 89 |
|
83 | 90 |
""" |
84 |
return Backend.objects.filter(drained=False, offline=False) |
|
91 |
return list(Backend.objects.select_for_update().filter(drained=False, |
|
92 |
offline=False)) |
|
85 | 93 |
|
86 | 94 |
|
87 | 95 |
def flavor_disk(flavor): |
Also available in: Unified diff