incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mry...@apache.org
Subject svn commit: r754987 - /incubator/tashi/trunk/src/tashi/agents/primitive.py
Date Mon, 16 Mar 2009 19:25:26 GMT
Author: mryan3
Date: Mon Mar 16 19:25:26 2009
New Revision: 754987

URL: http://svn.apache.org/viewvc?rev=754987&view=rev
Log:
Patch to add the ability to specify a target host for VM placement.
This also includes the ability to specify whether the scheduler should fail to place the VM
if the target host is full.


Modified:
    incubator/tashi/trunk/src/tashi/agents/primitive.py

Modified: incubator/tashi/trunk/src/tashi/agents/primitive.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/agents/primitive.py?rev=754987&r1=754986&r2=754987&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/agents/primitive.py (original)
+++ incubator/tashi/trunk/src/tashi/agents/primitive.py Mon Mar 16 19:25:26 2009
@@ -26,7 +26,7 @@
 import logging.config
 
 from tashi.services.ttypes import *
-from tashi.util import getConfig, createClient, instantiateImplementation
+from tashi.util import getConfig, createClient, instantiateImplementation, boolean
 
 class Primitive(object):
 	def __init__(self, config, client, transport):
@@ -78,13 +78,27 @@
 						try:
 							min = None
 							minHost = None
-							for h in hosts.values():
-								if ((min is None or len(load[h.id]) < min) and h.up == True and h.state == HostState.Normal):
-									memUsage = reduce(lambda x, y: x + instances[y].memory, load[h.id], inst.memory)
-									coreUsage = reduce(lambda x, y: x + instances[y].cores, load[h.id], inst.cores)
-									if (memUsage <= h.memory and coreUsage <= h.cores):
-										min = len(load[h.id])
-										minHost = h
+							targetHost = inst.hints.get("targetHost", None)
+							try:
+								allowElsewhere = boolean(inst.hints.get("allowElsewhere", "False"))
+							except Exception, e:
+								allowElsewhere = False
+							if (targetHost != None):
+								for h in hosts.values():
+									if ((str(h.id) == targetHost or h.name == targetHost) and h.up == True and h.state
== HostState.Normal):
+										memUsage = reduce(lambda x, y: x + instances[y].memory, load[h.id], inst.memory)
+										coreUsage = reduce(lambda x, y: x + instances[y].cores, load[h.id], inst.cores)
+										if (memUsage <= h.memory and coreUsage <= h.cores):
+											min = len(load[h.id])
+											minHost = h
+							if ((targetHost == None or allowElsewhere) and minHost == None):
+								for h in hosts.values():
+									if ((min is None or len(load[h.id]) < min) and h.up == True and h.state == HostState.Normal):
+										memUsage = reduce(lambda x, y: x + instances[y].memory, load[h.id], inst.memory)
+										coreUsage = reduce(lambda x, y: x + instances[y].cores, load[h.id], inst.cores)
+										if (memUsage <= h.memory and coreUsage <= h.cores):
+											min = len(load[h.id])
+											minHost = h
 							if (minHost):
 								for hook in self.hooks:
 									hook.preCreate(inst)



Mime
View raw message