incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1083136 - /incubator/tashi/trunk/src/tashi/agents/primitive.py
Date Sat, 19 Mar 2011 03:10:58 GMT
Author: stroucki
Date: Sat Mar 19 03:10:58 2011
New Revision: 1083136

URL: http://svn.apache.org/viewvc?rev=1083136&view=rev
Log:
unindent huge block by one level using pass and continue

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=1083136&r1=1083135&r2=1083136&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/agents/primitive.py (original)
+++ incubator/tashi/trunk/src/tashi/agents/primitive.py Sat Mar 19 03:10:58 2011
@@ -122,38 +122,45 @@ class Primitive(object):
 							# as to do this.
 							if ((targetHost == None or allowElsewhere) and minMaxHost == None):
 								for h in hosts.values():
-									# if the machine is suitable to host a vm...
+									# if the machine is suitable to host a vm, lets look at it
 									if (h.up == True and h.state == HostState.Normal and len(h.reserved) == 0):
-										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):
-								# found a host
-								if (not inst.hints.get("__resume_source", None)):
-									for hook in self.hooks:
-										hook.preCreate(inst)
-								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]
-								# get rid of its possible entry in muffle if VM is scheduled to a host
-								if (inst.name in muffle):
-									muffle.pop(inst.name)
-							else:
-								# did not find a host
-								if (inst.name not in muffle):
-									self.log.info("Failed to find a suitable place to schedule %s" % (inst.name))
-									muffle[inst.name] = True
+										pass
+									else:
+										# otherwise find another machine
+										continue
+									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):
+												# found a host
+												if (not inst.hints.get("__resume_source", None)):
+													for hook in self.hooks:
+														hook.preCreate(inst)
+														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]
+				# get rid of its possible entry in muffle if VM is scheduled to a host
+														if (inst.name in muffle):
+															muffle.pop(inst.name)
+														else:
+															# did not find a host
+															if (inst.name not in muffle):
+																self.log.info("Failed to find a suitable place to schedule %s" % (inst.name))
+																muffle[inst.name] = True
 						except Exception, e:
 							# XXXstroucki: how can we get here?
 							if (inst.name not in muffle):
 								self.log.exception("Failed to schedule or activate %s" % (inst.name))
 								muffle[inst.name] = True
+				
 
 
 				time.sleep(self.scheduleDelay)
+
+
 			except TashiException, e:
 				self.log.exception("Tashi exception")
 				time.sleep(self.scheduleDelay)



Mime
View raw message