incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mry...@apache.org
Subject svn commit: r778478 - in /incubator/tashi/trunk: etc/TashiDefaults.cfg src/tashi/agents/primitive.py
Date Mon, 25 May 2009 19:33:05 GMT
Author: mryan3
Date: Mon May 25 19:33:05 2009
New Revision: 778478

URL: http://svn.apache.org/viewvc?rev=778478&view=rev
Log:
Added the ability for the basic scheduler to pack VMs in instead of spacing them out


Modified:
    incubator/tashi/trunk/etc/TashiDefaults.cfg
    incubator/tashi/trunk/src/tashi/agents/primitive.py

Modified: incubator/tashi/trunk/etc/TashiDefaults.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/etc/TashiDefaults.cfg?rev=778478&r1=778477&r2=778478&view=diff
==============================================================================
--- incubator/tashi/trunk/etc/TashiDefaults.cfg (original)
+++ incubator/tashi/trunk/etc/TashiDefaults.cfg Mon May 25 19:33:05 2009
@@ -113,6 +113,7 @@
 [Primitive]
 hook1 = tashi.agents.DhcpDns
 scheduleDelay = 2.0
+densePack = False
 
 [DhcpDns]
 dnsKeyFile = /location/of/private/key/for/dns

Modified: incubator/tashi/trunk/src/tashi/agents/primitive.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/agents/primitive.py?rev=778478&r1=778477&r2=778478&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/agents/primitive.py (original)
+++ incubator/tashi/trunk/src/tashi/agents/primitive.py Mon May 25 19:33:05 2009
@@ -36,6 +36,7 @@
 		self.hooks = []
 		self.log = logging.getLogger(__file__)
 		self.scheduleDelay = float(self.config.get("Primitive", "scheduleDelay"))
+		self.densePack = boolean(self.config.get("Primitive", "densePack"))
 		items = self.config.items("Primitive")
 		items.sort()
 		for item in items:
@@ -79,8 +80,8 @@
 					for i in load[None]:
 						inst = instances[i]
 						try:
-							min = None
-							minHost = None
+							minMax = None
+							minMaxHost = None
 							targetHost = inst.hints.get("targetHost", None)
 							try:
 								allowElsewhere = boolean(inst.hints.get("allowElsewhere", "False"))
@@ -88,27 +89,29 @@
 								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):
+									if ((str(h.id) == targetHost or h.name == targetHost)):
+										if (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):
+												minMax = len(load[h.id])
+												minMaxHost = h
+							if ((targetHost == None or allowElsewhere) and minMaxHost == 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):
+									if (h.up == True and h.state == HostState.Normal):
+										if (minMax is None or (self.densePack and len(load[h.id]) > minMax) or (not
self.densePack and len(load[h.id]) < minMax)):
+											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):
+												minMax = len(load[h.id])
+												minMaxHost = h
+							if (minMaxHost):
 								if (not inst.hints.get("__resume_source", None)):
 									for hook in self.hooks:
 										hook.preCreate(inst)
-								self.log.info("Scheduling instance %s on host %s" % (inst.name, minHost.name))	
-								self.client.activateVm(i, minHost)
-								load[minHost.id] = load[minHost.id] + [i]
+								self.log.info("Scheduling instance %s (%d mem, %d cores, %d uid) on host %s" % (inst.name,
inst.memory, inst.cores, inst.userId, minMaxHost.name))	
+								self.client.activateVm(i, minMaxHost)
+								load[minMaxHost.id] = load[minMaxHost.id] + [i]
 							else:
 								self.log.info("Failed to find a suitable place to schedule %s" % (inst.name))
 						except Exception, e:



Mime
View raw message