Commit 6c93495f authored by Antoine Millet's avatar Antoine Millet

Enhanced elector to allow elections for hot migration.

Note: Memory filter is currently hard-disabled because node needs a better
method to provide this value.
parent a53d2594
......@@ -34,10 +34,21 @@ class Elector(object):
('has_alloc', 'filter allocatable hv'),
('duplicate_name', 'filter vm duplicate names'),
('enough_disk', 'filter hv with not enough disk'),),
'hot': (('is_hv', 'filter r=hv'),
('not_source_hv', 'filter source hv'),
('is_connected', 'filter connected hv'),
('vm_htype_eq_hv', 'filter bad hv types'),
('has_rights', 'filter rights'),
('has_alloc', 'filter allocatable hv'),
('duplicate_name', 'filter vm duplicate names'),
#('enough_ram', 'filter hv with not enough ram'),
('enough_disk', 'filter hv with not enough disk'),),
}
# Available algos for each types:
ALGO_BY_TYPES = {'cold': ('fair', )}
ALGO_BY_TYPES = {'cold': ('fair', ),
'hot': ('fair', )}
def __init__(self, server, query_vm, query_dest, login):
# The server instance for this election:
......@@ -78,7 +89,7 @@ class Elector(object):
candidates = self._get_candidates(self.FILTERS[mtype])
# Distributes VMs to each candidate:
migration_plan = distribute(candidates)
migration_plan = distribute(mtype, candidates)
# Return the migration plan:
return migration_plan
......@@ -118,7 +129,7 @@ class Elector(object):
##### Distribution algorithm methods:
#####
def _algo_fair(self, candidates):
def _algo_fair(self, mtype, candidates):
migration_plan = []
# Sort vm by number of destination hv:
......@@ -140,7 +151,7 @@ class Elector(object):
hv = min(hvs, key=lambda x: hv_alloc[x['id']])
migration_plan.append({'sid': vm['id'], 'did': hv['id'],
'type': 'cold'})
'type': mtype})
hv_alloc[hv['id']] = hv_alloc.get(hv['id'], 0) + 1
return migration_plan
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment