Loading ccserver/election.py +15 −4 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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 Loading Loading @@ -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: Loading @@ -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 Loading Loading
ccserver/election.py +15 −4 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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 Loading Loading @@ -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: Loading @@ -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 Loading