You are viewing a plain text version of this content. The canonical link for it is here.
Posted to tashi-commits@incubator.apache.org by st...@apache.org on 2012/02/27 21:07:30 UTC

svn commit: r1294327 - in /incubator/tashi/branches/stable: ./ src/tashi/client/ src/tashi/clustermanager/ src/tashi/clustermanager/data/ src/tashi/nodemanager/vmcontrol/

Author: stroucki
Date: Mon Feb 27 21:07:30 2012
New Revision: 1294327

URL: http://svn.apache.org/viewvc?rev=1294327&view=rev
Log:
Merge the following bugfixes into stable:-
1245045 getslots fix
1292488 irpbugs (makefile, checkinstances, getimages) 
1292541 makefile
1292543 makefile
1292895 pickled database corruption
1293348 makefile
1293401 releaseinstance
1294310 mryan print and link follow patch

Modified:
    incubator/tashi/branches/stable/   (props changed)
    incubator/tashi/branches/stable/Makefile
    incubator/tashi/branches/stable/src/tashi/client/tashi-client.py
    incubator/tashi/branches/stable/src/tashi/clustermanager/clustermanagerservice.py
    incubator/tashi/branches/stable/src/tashi/clustermanager/data/datainterface.py
    incubator/tashi/branches/stable/src/tashi/clustermanager/data/ldapoverride.py
    incubator/tashi/branches/stable/src/tashi/clustermanager/data/pickled.py
    incubator/tashi/branches/stable/src/tashi/nodemanager/vmcontrol/qemu.py

Propchange: incubator/tashi/branches/stable/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb 27 21:07:30 2012
@@ -1,5 +1,7 @@
 /incubator/tashi/branches/cmu:1178106-1187632
 /incubator/tashi/branches/stroucki-accounting:1221525-1241770
 /incubator/tashi/branches/stroucki-accounting/branches/stroucki-accounting:1221525-1235607
+/incubator/tashi/branches/stroucki-irpbugs:1245857-1292894
+/incubator/tashi/branches/stroucki-slotsbug:1244839-1245041
 /incubator/tashi/branches/zoni-dev/trunk:1034098-1177646
-/incubator/tashi/trunk:1203846-1241774
+/incubator/tashi/trunk:1203846-1241774,1245045,1292488,1292541,1292543,1292895,1293348,1293401,1294310

Modified: incubator/tashi/branches/stable/Makefile
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stable/Makefile?rev=1294327&r1=1294326&r2=1294327&view=diff
==============================================================================
--- incubator/tashi/branches/stable/Makefile (original)
+++ incubator/tashi/branches/stable/Makefile Mon Feb 27 21:07:30 2012
@@ -33,7 +33,7 @@ package: src DISCLAIMER INSTALL LICENSE 
 	mkdir apache-tashi
 	cp -rp doc etc Makefile src DISCLAIMER INSTALL LICENSE NOTICE README apache-tashi/
 	find apache-tashi -type d -name ".svn"|xargs rm -rf
-	chgrp -R incubator apache-tashi
+	-chgrp -R incubator apache-tashi
 	tar zcf apache-tashi.tar.gz apache-tashi
 	rm -rf apache-tashi
 
@@ -118,7 +118,7 @@ rmdoc:
 #  Zoni 
 bin/zoni-cli:
 	@echo Symlinking in zoni-cli...
-	(cd bin; ln -s ../src/zoni/client/zoni-cli .)
+	(cd bin; ln -s ../src/zoni/client/zoni-cli.py zoni-client)
 # why necessarily put this in /usr/local/bin like nothing else?
 usr/local/bin/zoni:
 	@echo Creating /usr/local/bin/zoni

Modified: incubator/tashi/branches/stable/src/tashi/client/tashi-client.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stable/src/tashi/client/tashi-client.py?rev=1294327&r1=1294326&r2=1294327&view=diff
==============================================================================
--- incubator/tashi/branches/stable/src/tashi/client/tashi-client.py (original)
+++ incubator/tashi/branches/stable/src/tashi/client/tashi-client.py Mon Feb 27 21:07:30 2012
@@ -166,7 +166,7 @@ def getSlots(cores, memory):
 			continue
 		countbycores = int((h.cores - h.usedCores) / cores)
 		countbymemory = int((h.memory - h.usedMemory) / memory)
-		count += min(countbycores, countbymemory)
+		count += max(0, min(countbycores, countbymemory))
 
 	print "%d" % (count),
 	print (lambda:"instances", lambda:"instance")[count == 1](),
@@ -575,6 +575,8 @@ def main():
 			try:
 				if (type(res) == types.ListType):
 					makeTable(res, keys)
+				elif (type(res) == types.StringType):
+					print res
 				else:
 					makeTable([res], keys)
 					

Modified: incubator/tashi/branches/stable/src/tashi/clustermanager/clustermanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stable/src/tashi/clustermanager/clustermanagerservice.py?rev=1294327&r1=1294326&r2=1294327&view=diff
==============================================================================
--- incubator/tashi/branches/stable/src/tashi/clustermanager/clustermanagerservice.py (original)
+++ incubator/tashi/branches/stable/src/tashi/clustermanager/clustermanagerservice.py Mon Feb 27 21:07:30 2012
@@ -269,18 +269,19 @@ class ClusterManagerService(object):
 		
 		# iterate through all VMs I believe are active
 		for instanceId in self.instanceLastContactTime.keys():
-			# Don't query non-running VMs. eg. if a VM
-			# is suspended, and has no host, then there's
-			# no one to ask
-			if instance.state != InstanceState.Running and \
-			   instance.state != InstanceState.Activating and \
-			   instance.state != InstanceState.Orphaned:
-				continue
 
 			# XXXstroucki should lock instance here?
 			if (self.instanceLastContactTime[instanceId] < (self.__now() - self.allowDecayed)):
 				try:
 					instance = self.data.acquireInstance(instanceId)
+					# Don't query non-running VMs. eg. if a VM
+					# is suspended, and has no host, then there's
+					# no one to ask
+					if instance.state != InstanceState.Running and \
+					   instance.state != InstanceState.Activating and \
+					   instance.state != InstanceState.Orphaned:
+						self.data.releaseInstance(instance)
+						continue
 				except:
 					continue
 

Modified: incubator/tashi/branches/stable/src/tashi/clustermanager/data/datainterface.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stable/src/tashi/clustermanager/data/datainterface.py?rev=1294327&r1=1294326&r2=1294327&view=diff
==============================================================================
--- incubator/tashi/branches/stable/src/tashi/clustermanager/data/datainterface.py (original)
+++ incubator/tashi/branches/stable/src/tashi/clustermanager/data/datainterface.py Mon Feb 27 21:07:30 2012
@@ -45,6 +45,9 @@ class DataInterface(object):
 	
 	def getHost(self, id):
 		raise NotImplementedError
+
+	def getImages(self):
+		raise NotImplementedError
 	
 	def getInstances(self):
 		raise NotImplementedError

Modified: incubator/tashi/branches/stable/src/tashi/clustermanager/data/ldapoverride.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stable/src/tashi/clustermanager/data/ldapoverride.py?rev=1294327&r1=1294326&r2=1294327&view=diff
==============================================================================
--- incubator/tashi/branches/stable/src/tashi/clustermanager/data/ldapoverride.py (original)
+++ incubator/tashi/branches/stable/src/tashi/clustermanager/data/ldapoverride.py Mon Feb 27 21:07:30 2012
@@ -17,9 +17,12 @@
 
 import subprocess
 import time
+#XXXstroucki getImages requires os?
+import os
+from tashi.rpycservices.rpyctypes import Errors, Network, Host, User, Instance, TashiException, LocalImages, DiskConfiguration, NetworkConfiguration
+from tashi.util import stringPartition, boolean, instantiateImplementation, humanReadable
 from tashi.rpycservices.rpyctypes import User
 from tashi.clustermanager.data import DataInterface
-from tashi.util import instantiateImplementation
 
 class LdapOverride(DataInterface):
 	def __init__(self, config):
@@ -31,6 +34,7 @@ class LdapOverride(DataInterface):
 		self.nameKey = config.get("LdapOverride", "nameKey")
 		self.idKey = config.get("LdapOverride", "idKey")
 		self.ldapCommand = config.get("LdapOverride", "ldapCommand")
+		self.dfs = instantiateImplementation(config.get("ClusterManager", "dfs"), config)
 	
 	def registerInstance(self, instance):
 		return self.baseDataObject.registerInstance(instance)
@@ -68,6 +72,17 @@ class LdapOverride(DataInterface):
 	def getNetwork(self, id):
 		return self.baseDataObject.getNetwork(id)
 
+        def getImages(self):
+                count = 0
+                myList = []
+                for i in self.dfs.list("images"):
+                        myFile = self.dfs.getLocalHandle("images/" + i)
+                        if os.path.isfile(myFile):
+                                image = LocalImages(d={'id':count, 'imageName':i, 'imageSize':humanReadable(self.dfs.stat(myFile)[6])})
+                                myList.append(image)
+                                count += 1
+                return myList
+
 	def fetchFromLdap(self):
 		now = time.time()
 		if (now - self.lastUserUpdate > self.fetchThreshold):

Modified: incubator/tashi/branches/stable/src/tashi/clustermanager/data/pickled.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stable/src/tashi/clustermanager/data/pickled.py?rev=1294327&r1=1294326&r2=1294327&view=diff
==============================================================================
--- incubator/tashi/branches/stable/src/tashi/clustermanager/data/pickled.py (original)
+++ incubator/tashi/branches/stable/src/tashi/clustermanager/data/pickled.py Mon Feb 27 21:07:30 2012
@@ -39,22 +39,27 @@ class Pickled(FromConfig):
 	
 	def cleanInstances(self):
 		ci = {}
-		for i in self.instances.itervalues():
+		for ignore, i in self.instances.items():
 			i2 = Instance(d=i.__dict__)
 			ci[i2.id] = i2
 		return ci
 	
 	def cleanHosts(self):
 		ch = {}
-		for h in self.hosts.itervalues():
+		for ignore, h in self.hosts.items():
 			h2 = Host(d=h.__dict__)
 			ch[h2.id] = h2
 		return ch
 	
 	def save(self):
-		file = open(self.file, "w")
+		filename = self.file
+		# XXXstroucki could be better
+		tempfile = "%s.new" % filename
+
+		file = open(tempfile, "w")
 		cPickle.dump((self.cleanHosts(), self.cleanInstances(), self.networks, self.users), file)
 		file.close()
+		os.rename(tempfile, filename)
 
 	def load(self):
 		if (os.access(self.file, os.F_OK)):
@@ -67,11 +72,11 @@ class Pickled(FromConfig):
 		self.instances = instances
 		self.networks = networks
 		self.users = users
-		for i in self.instances.itervalues():
+		for ignore, i in self.instances.items():
 			if (i.id >= self.maxInstanceId):
 				self.maxInstanceId = i.id + 1
 			i._lock = threading.Lock()
 			self.lockNames[i._lock] = "i%d" % (i.id)
-		for h in self.hosts.itervalues():
+		for ignore, h in self.hosts.items():
 			h._lock = threading.Lock()
 			self.lockNames[h._lock] = "h%d" % (h.id)

Modified: incubator/tashi/branches/stable/src/tashi/nodemanager/vmcontrol/qemu.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stable/src/tashi/nodemanager/vmcontrol/qemu.py?rev=1294327&r1=1294326&r2=1294327&view=diff
==============================================================================
--- incubator/tashi/branches/stable/src/tashi/nodemanager/vmcontrol/qemu.py (original)
+++ incubator/tashi/branches/stable/src/tashi/nodemanager/vmcontrol/qemu.py Mon Feb 27 21:07:30 2012
@@ -132,10 +132,11 @@ class Qemu(VmControlInterface):
 	def __getHostPids(self):
 		"""Utility function to get a list of system PIDs that match the QEMU_BIN specified (/proc/nnn/exe)"""
 		pids = []
+		real_bin = os.readlink(self.QEMU_BIN)
 		for f in os.listdir("/proc"):
 			try:
 				bin = os.readlink("/proc/%s/exe" % (f))
-				if (bin.find(self.QEMU_BIN) != -1):
+				if (bin.find(real_bin) != -1):
 					pids.append(int(f))
 			except Exception:
 				pass