incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1231416 - in /incubator/tashi/branches/stroucki-accounting: ./ src/tashi/clustermanager/clustermanagerservice.py src/tashi/dfs/vfs.py src/tashi/nodemanager/nodemanagerservice.py src/tashi/nodemanager/vmcontrol/qemu.py
Date Sat, 14 Jan 2012 00:05:53 GMT
Author: stroucki
Date: Sat Jan 14 00:05:53 2012
New Revision: 1231416

URL: http://svn.apache.org/viewvc?rev=1231416&view=rev
Log:
update from trunk

Modified:
    incubator/tashi/branches/stroucki-accounting/   (props changed)
    incubator/tashi/branches/stroucki-accounting/src/tashi/clustermanager/clustermanagerservice.py
    incubator/tashi/branches/stroucki-accounting/src/tashi/dfs/vfs.py
    incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/nodemanagerservice.py
    incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/vmcontrol/qemu.py

Propchange: incubator/tashi/branches/stroucki-accounting/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jan 14 00:05:53 2012
@@ -1,2 +1,4 @@
 /incubator/tashi/branches/cmu:1178106-1187632
+/incubator/tashi/branches/stroucki-accounting:1221525-1221954
 /incubator/tashi/branches/zoni-dev/trunk:1034098-1177646
+/incubator/tashi/trunk:1221525-1231415

Modified: incubator/tashi/branches/stroucki-accounting/src/tashi/clustermanager/clustermanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-accounting/src/tashi/clustermanager/clustermanagerservice.py?rev=1231416&r1=1231415&r2=1231416&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-accounting/src/tashi/clustermanager/clustermanagerservice.py
(original)
+++ incubator/tashi/branches/stroucki-accounting/src/tashi/clustermanager/clustermanagerservice.py
Sat Jan 14 00:05:53 2012
@@ -55,7 +55,7 @@ class ClusterManagerService(object):
 		self.accountingPort = None
 		try:
 			self.accountingHost = self.config.get('ClusterManagerService', 'accountingHost')
-			self.accountingPort = self.config.get('ClusterManagerService', 'accountingPort')
+			self.accountingPort = self.config.getint('ClusterManagerService', 'accountingPort')
 		except:
 			pass
 
@@ -71,7 +71,6 @@ class ClusterManagerService(object):
 		try:
 			if (self.accountingHost is not None) and \
 				    (self.accountingPort is not None):
-
 				self.accountingClient=rpycservices.client(self.accountingHost, self.accountingPort)
 		except:
 			self.log.exception("Could not init accounting")
@@ -270,6 +269,14 @@ 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
+
 			if (self.instanceLastContactTime[instanceId] < (self.__now() - self.allowDecayed)):
 				try:
 					instance = self.data.acquireInstance(instanceId)

Modified: incubator/tashi/branches/stroucki-accounting/src/tashi/dfs/vfs.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-accounting/src/tashi/dfs/vfs.py?rev=1231416&r1=1231415&r2=1231416&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-accounting/src/tashi/dfs/vfs.py (original)
+++ incubator/tashi/branches/stroucki-accounting/src/tashi/dfs/vfs.py Sat Jan 14 00:05:53
2012
@@ -27,52 +27,67 @@ class Vfs(DfsInterface):
 		DfsInterface.__init__(self, config)
 		self.prefix = self.config.get("Vfs", "prefix")
 
-# why do these three need to be separate?	
+	def __dfsToReal(self, dfspath):
+		realpath = os.path.join(self.prefix, dfspath)
+		return realpath
+
 	def copyTo(self, localSrc, dst):
-		shutil.copy(localSrc, os.path.join(self.prefix, dst))
-# just assuming this works
+		realdest = self.__dfsToReal(dst)
+		shutil.copy(localSrc, realdest)
+		# just assuming this works
 		return None
 	
 	def copyFrom(self, src, localDst):
-		shutil.copy(os.path.join(self.prefix, src), localDst)
-# just assuming this works
+		realsrc = self.__dfsToReal(src)
+		shutil.copy(realsrc, localDst)
+		# just assuming this works
 		return None
 
 	def copy(self, src, dst):
-		shutil.copy(os.path.join(self.prefix, src),
-			    os.path.join(self.prefix, dst))
-# just assuming this works
+		realsrc = self.__dfsToReal(src)
+		realdst = self.__dfsToReal(dst)
+		shutil.copy(realsrc, realdst)
+		# just assuming this works
 		return None
 	
 	def list(self, path):
 		try:
-			return os.listdir(os.path.join(self.prefix, path))
+			realpath = self.__dfsToReal(path)
+			return os.listdir(realpath)
 		except OSError, e:
+			# XXXstroucki error 20 = ENOTDIR
 			if (e.errno == 20):
 				return [path.split('/')[-1]]
 			else:
 				raise
 	
 	def stat(self, path):
-		return os.stat(os.path.join(self.prefix, path))
+		realpath = self.__dfsToReal(path)
+		return os.stat(realpath)
 	
 	def move(self, src, dst):
-		shutil.move(os.path.join(self.prefix, src), 
-			    os.path.join(self.prefix, dst))
-# just assuming this works
+		realsrc = self.__dfsToReal(src)
+		realdst = self.__dfsToReal(dst)
+		shutil.move(realsrc, realdst)
+		# just assuming this works
 		return None
 	
 	def mkdir(self, path):
-		return os.mkdir(os.path.join(self.prefix, path))
+		realpath = self.__dfsToReal(path)
+		return os.mkdir(realpath)
 	
 	def unlink(self, path):
-		return os.unlink(os.path.join(self.prefix, path))
+		realpath = self.__dfsToReal(path)
+		return os.unlink(realpath)
 	
 	def rmdir(self, path):
-		return os.rmdir(os.path.join(self.prefix, path))
+		realpath = self.__dfsToReal(path)
+		return os.rmdir(realpath)
 	
 	def open(self, path, perm):
-		return open(os.path.join(self.prefix, path), perm)
+		realpath = self.__dfsToReal(path)
+		return open(realpath, perm)
 	
 	def getLocalHandle(self, path):
-		return os.path.join(self.prefix, path)
+		realpath = self.__dfsToReal(path)
+		return realpath

Modified: incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/nodemanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/nodemanagerservice.py?rev=1231416&r1=1231415&r2=1231416&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/nodemanagerservice.py
(original)
+++ incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/nodemanagerservice.py
Sat Jan 14 00:05:53 2012
@@ -60,7 +60,7 @@ class NodeManagerService(object):
 		self.accountingPort = None
 		try:
 			self.accountingHost = self.config.get('NodeManagerService', 'accountingHost')
-			self.accountingPort = self.config.get('NodeManagerService', 'accountingPort')
+			self.accountingPort = self.config.getint('NodeManagerService', 'accountingPort')
 		except:
 			pass
 
@@ -132,9 +132,9 @@ class NodeManagerService(object):
 		except Exception, e:
 			self.log.exception('Failed to send data to the CM')
 
-		toSleep = start - time.time() + self.registerFrequency
-		if (toSleep > 0):
-			time.sleep(toSleep)
+		#toSleep = start - time.time() + self.registerFrequency
+		#if (toSleep > 0):
+			#time.sleep(toSleep)
 
         def __ACCOUNTFLUSH(self):
 		try:
@@ -311,7 +311,7 @@ class NodeManagerService(object):
 		try:
 			instance.vmId = self.vmm.resumeVm(instance, name)
 			self.instances[instance.vmId] = instance
-			threading.Thread(target=self.resumeVmHelper, args=(instance, name)).start()
+			threading.Thread(target=self.__resumeVmHelper, args=(instance, name)).start()
 		except:
 			self.log.exception('resumeVm failed')
 			raise TashiException(d={'errno':Errors.UnableToResume,'msg':"resumeVm failed on the node
manager"})

Modified: incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/vmcontrol/qemu.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/vmcontrol/qemu.py?rev=1231416&r1=1231415&r2=1231416&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/vmcontrol/qemu.py (original)
+++ incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/vmcontrol/qemu.py Sat
Jan 14 00:05:53 2012
@@ -26,6 +26,7 @@ import socket
 import subprocess
 import sys
 import time
+import shlex
 
 #from tashi.rpycservices.rpyctypes import *
 from tashi.rpycservices.rpyctypes import InstanceState, Host
@@ -153,7 +154,8 @@ class Qemu(VmControlInterface):
 
 		for vmId in vmIds:
 			child = controlledVMs[vmId]
-			name = child.instance.name
+			instance = child.instance
+			name = instance.name
 
 			if vmId not in pids:
 				# VM is no longer running, but is still
@@ -217,9 +219,11 @@ class Qemu(VmControlInterface):
 			else:
 				# VM is still running
 				try:
+					
 					if (child.migratingOut):
 						self.nm.vmStateChange(vmId, None, InstanceState.MigrateTrans)
-					else:
+					elif (instance.state == InstanceState.Orphaned) or \
+						(instance.state == InstanceState.Activating):
 						self.nm.vmStateChange(vmId, None, InstanceState.Running)
 				except:
 					log.exception("vmStateChange failed for VM %s" % (name))
@@ -508,8 +512,9 @@ class Qemu(VmControlInterface):
 		#  Construct the qemu command
 		strCmd = "%s %s %s -clock %s %s %s -m %d -smp %d -serial null -vnc none -monitor pty" %
(self.QEMU_BIN, noAcpiString, cpuString, clockString, diskString, nicString, instance.memory,
instance.cores)
 		if (source):
-			strCmd = "%s -incoming %s" % (strCmd, source)
-		cmd = strCmd.split()
+			strCmd = '%s -incoming "%s"' % (strCmd, source)
+		# XXXstroucki perhaps we're doing it backwards
+		cmd = shlex.split(strCmd)
 
 		log.info("Executing command: %s" % (strCmd))
 		(pipe_r, pipe_w) = os.pipe()
@@ -587,14 +592,16 @@ class Qemu(VmControlInterface):
 				# trying to restart the migration by running
 				# the command again (when qemu is ready to
 				# listen again) is probably not helpful
+				success = False
 				res = self.__enterCommand(child, "migrate -i %s" % (target), timeout=self.migrateTimeout)
 				retry = retry - 1
 				if (res.find("migration failed") == -1):
+					success = True
 					retry = 0
 					break
 				else:
 					log.error("Migration (transiently) failed: %s\n", res)
-			if (retry == 0):
+			if (retry == 0) and (success is False):
 				log.error("Migration failed: %s\n", res)
 				child.errorBit = True
 				raise RuntimeError
@@ -628,6 +635,7 @@ class Qemu(VmControlInterface):
 		# XXX: Use fifo to improve performance
 		vmId = self.__stopVm(vmId, "\"exec:gzip -c > %s\"" % (tmpTarget), True)
 		self.dfs.copyTo(tmpTarget, target)
+		os.unlink(tmpTarget)
 		return vmId
 	
 	# extern



Mime
View raw message