Modify alloc memory check to just look at alloc
This commit is contained in:
parent
59219c4e97
commit
d69cb72439
|
@ -22,8 +22,11 @@
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
import lxml
|
import lxml
|
||||||
|
import math
|
||||||
import kazoo.client
|
import kazoo.client
|
||||||
|
|
||||||
|
import client_lib.zkhandler as zkhandler
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Supplemental functions
|
# Supplemental functions
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -224,33 +227,29 @@ def findTargetNode(zk_conn, search_field, dom_uuid):
|
||||||
return findTargetNodeVMs(zk_conn, dom_uuid)
|
return findTargetNodeVMs(zk_conn, dom_uuid)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# via free memory (relative to allocated memory)
|
# via allocated memory
|
||||||
def findTargetNodeMem(zk_conn, dom_uuid):
|
def findTargetNodeMem(zk_conn, dom_uuid):
|
||||||
most_allocfree = 0
|
least_alloc = math.inf
|
||||||
target_node = None
|
target_node = None
|
||||||
|
|
||||||
node_list = getNodes(zk_conn, dom_uuid)
|
node_list = getNodes(zk_conn, dom_uuid)
|
||||||
for node in node_list:
|
for node in node_list:
|
||||||
memalloc = int(zk_conn.get('/nodes/{}/memalloc'.format(node))[0].decode('ascii'))
|
alloc = float(zkhandler.readdata(zk_conn, '/nodes/{}/memalloc'.format(node)))
|
||||||
memused = int(zk_conn.get('/nodes/{}/memused'.format(node))[0].decode('ascii'))
|
|
||||||
memfree = int(zk_conn.get('/nodes/{}/memfree'.format(node))[0].decode('ascii'))
|
|
||||||
memtotal = memused + memfree
|
|
||||||
allocfree = memtotal - memalloc
|
|
||||||
|
|
||||||
if allocfree > most_allocfree:
|
if alloc < least_alloc:
|
||||||
most_allocfree = allocfree
|
least_alloc = alloc
|
||||||
target_node = node
|
target_node = node
|
||||||
|
|
||||||
return target_node
|
return target_node
|
||||||
|
|
||||||
# via load average
|
# via load average
|
||||||
def findTargetNodeLoad(zk_conn, dom_uuid):
|
def findTargetNodeLoad(zk_conn, dom_uuid):
|
||||||
least_load = 9999
|
least_load = math.inf
|
||||||
target_node = None
|
target_node = None
|
||||||
|
|
||||||
node_list = getNodes(zk_conn, dom_uuid)
|
node_list = getNodes(zk_conn, dom_uuid)
|
||||||
for node in node_list:
|
for node in node_list:
|
||||||
load = float(zk_conn.get('/nodes/{}/cpuload'.format(node))[0].decode('ascii'))
|
load = float(zkhandler.readdata(zk_conn, '/nodes/{}/cpuload'.format(node)))
|
||||||
|
|
||||||
if load < least_load:
|
if load < least_load:
|
||||||
least_load = load
|
least_load = load
|
||||||
|
@ -260,12 +259,12 @@ def findTargetNodeLoad(zk_conn, dom_uuid):
|
||||||
|
|
||||||
# via total vCPUs
|
# via total vCPUs
|
||||||
def findTargetNodeVCPUs(zk_conn, dom_uuid):
|
def findTargetNodeVCPUs(zk_conn, dom_uuid):
|
||||||
least_vcpus = 9999
|
least_vcpus = math.inf
|
||||||
target_node = None
|
target_node = None
|
||||||
|
|
||||||
node_list = getNodes(zk_conn, dom_uuid)
|
node_list = getNodes(zk_conn, dom_uuid)
|
||||||
for node in node_list:
|
for node in node_list:
|
||||||
vcpus = int(zk_conn.get('/nodes/{}/vcpualloc'.format(node))[0].decode('ascii'))
|
vcpus = float(zkhandler.readdata(zk_conn, '/nodes/{}/vcpualloc'.format(node)))
|
||||||
|
|
||||||
if vcpus < least_vcpus:
|
if vcpus < least_vcpus:
|
||||||
least_vcpus = vcpus
|
least_vcpus = vcpus
|
||||||
|
@ -275,12 +274,12 @@ def findTargetNodeVCPUs(zk_conn, dom_uuid):
|
||||||
|
|
||||||
# via total VMs
|
# via total VMs
|
||||||
def findTargetNodeVMs(zk_conn, dom_uuid):
|
def findTargetNodeVMs(zk_conn, dom_uuid):
|
||||||
least_vms = 9999
|
least_vms = math.inf
|
||||||
target_node = None
|
target_node = None
|
||||||
|
|
||||||
node_list = getNodes(zk_conn, dom_uuid)
|
node_list = getNodes(zk_conn, dom_uuid)
|
||||||
for node in node_list:
|
for node in node_list:
|
||||||
vms = int(zk_conn.get('/nodes/{}/domainscount'.format(node))[0].decode('ascii'))
|
vms = float(zkhandler.readdata(zk_conn, '/nodes/{}/domainscount'.format(node)))
|
||||||
|
|
||||||
if vms < least_vms:
|
if vms < least_vms:
|
||||||
least_vms = vms
|
least_vms = vms
|
||||||
|
|
Loading…
Reference in New Issue