Add migration selector via free memory

Closes #152
This commit is contained in:
Joshua Boniface 2022-05-18 03:47:16 -04:00
parent 51ad2058ed
commit f8cdcb30ba
2 changed files with 22 additions and 2 deletions

View File

@ -639,6 +639,8 @@ def findTargetNode(zkhandler, dom_uuid):
# Execute the search # Execute the search
if search_field == "mem": if search_field == "mem":
return findTargetNodeMem(zkhandler, node_limit, dom_uuid) return findTargetNodeMem(zkhandler, node_limit, dom_uuid)
if search_field == "memfree":
return findTargetNodeMemFree(zkhandler, node_limit, dom_uuid)
if search_field == "load": if search_field == "load":
return findTargetNodeLoad(zkhandler, node_limit, dom_uuid) return findTargetNodeLoad(zkhandler, node_limit, dom_uuid)
if search_field == "vcpus": if search_field == "vcpus":
@ -677,7 +679,7 @@ def getNodes(zkhandler, node_limit, dom_uuid):
# #
# via free memory (relative to allocated memory) # via allocated memory
# #
def findTargetNodeMem(zkhandler, node_limit, dom_uuid): def findTargetNodeMem(zkhandler, node_limit, dom_uuid):
most_provfree = 0 most_provfree = 0
@ -698,6 +700,24 @@ def findTargetNodeMem(zkhandler, node_limit, dom_uuid):
return target_node return target_node
#
# via free memory
#
def findTargetNodeMemFree(zkhandler, node_limit, dom_uuid):
most_memfree = 0
target_node = None
node_list = getNodes(zkhandler, node_limit, dom_uuid)
for node in node_list:
memfree = int(zkhandler.read(("node.memory.free", node)))
if memfree > most_memfree:
most_memfree = memfree
target_node = node
return target_node
# #
# via load average # via load average
# #

View File

@ -122,7 +122,7 @@ pvc:
pass: Passw0rd pass: Passw0rd
# migration: Migration option configuration # migration: Migration option configuration
migration: migration:
# target_selector: Criteria to select the ideal migration target, options: mem, load, vcpus, vms # target_selector: Criteria to select the ideal migration target, options: mem, memfree, load, vcpus, vms
target_selector: mem target_selector: mem
# configuration: Local system configurations # configuration: Local system configurations
configuration: configuration: