incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mry...@apache.org
Subject svn commit: r743886 - in /incubator/tashi/trunk/src/tashi: client/tashi-client.py clustermanager/clustermanagerservice.py nodemanager/nodemanagerservice.py nodemanager/vmcontrol/qemu.py thrift/services.thrift
Date Thu, 12 Feb 2009 21:20:06 GMT
Author: mryan3
Date: Thu Feb 12 21:20:03 2009
New Revision: 743886

URL: http://svn.apache.org/viewvc?rev=743886&view=rev
Log:
A mechanism for making VMM-specific calls was added.

This is used to provide VNC access to KVM/Qemu VMs at the moment.


Modified:
    incubator/tashi/trunk/src/tashi/client/tashi-client.py
    incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py
    incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py
    incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py
    incubator/tashi/trunk/src/tashi/thrift/services.thrift

Modified: incubator/tashi/trunk/src/tashi/client/tashi-client.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/client/tashi-client.py?rev=743886&r1=743885&r2=743886&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/client/tashi-client.py (original)
+++ incubator/tashi/trunk/src/tashi/client/tashi-client.py Thu Feb 12 21:20:03 2009
@@ -195,6 +195,7 @@
 'getInstances': [],
 'getMyInstances': [],
 'getVmLayout': [],
+'vmmSpecificCall': [('instance', checkIid, lambda: requiredArg('instance'), True), ('arg',
str, lambda: requiredArg('arg'), True)],
 }
 
 # Used to convert the dictionary built from the arguments into an object that can be used
by thrift
@@ -209,6 +210,7 @@
 'migrateVm': '[instance, targetHostId]',
 'pauseVm': '[instance]',
 'unpauseVm': '[instance]',
+'vmmSpecificCall': '[instance, arg]',
 }
 
 # Example use strings
@@ -229,6 +231,7 @@
 'getInstances': [''],
 'getMyInstances': [''],
 'getVmLayout': [''],
+'vmmSpecificCall': ['--instance 12345 --arg startVnc', '--instance foobar --arg stopVnc']
 }
 
 show_hide = []

Modified: incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py?rev=743886&r1=743885&r2=743886&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py Thu Feb 12 21:20:03
2009
@@ -325,6 +325,17 @@
 				instance.userObj = None
 		return instances
 	
+	@RPC
+	def vmmSpecificCall(self, instanceId, arg):
+		instance = self.data.getInstance(instanceId)
+		hostname = self.data.getHost(instance.hostId).name
+		try:
+			res = self.proxy[hostname].vmmSpecificCall(instance.vmId, arg)
+		except Exception:
+			self.log.exception('vmmSpecificCall failed on host %s with vmId %d' % (hostname, instance.vmId))
+			raise
+		return res
+	
 #	@timed
 	@RPC
 	def registerNodeManager(self, host, instances):

Modified: incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py?rev=743886&r1=743885&r2=743886&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py Thu Feb 12 21:20:03
2009
@@ -277,6 +277,10 @@
 		return instance
 	
 	@RPC
+	def vmmSpecificCall(self, vmId, arg):
+		return self.vmm.vmmSpecificCall(vmId, arg)
+	
+	@RPC
 	def listVms(self):
 		return self.instances.keys()
 	

Modified: incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py?rev=743886&r1=743885&r2=743886&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py Thu Feb 12 21:20:03 2009
@@ -92,6 +92,8 @@
 		self.controlledVMs = {}
 		self.usedPorts = []
 		self.usedPortsLock = threading.Lock()
+		self.vncPort = 1
+		self.vncPortLock = threading.Lock()
 		self.migrationSemaphore = threading.Semaphore(int(self.config.get("Qemu", "maxParallelMigrations")))
 		try:
 			os.mkdir(self.INFO_DIR)
@@ -153,6 +155,10 @@
 		for vmId in controlledVMs:
 			try:
 				child = self.loadChildInfo(vmId)
+				self.vncPortLock.acquire()
+				if (child.vncPort >= self.vncPort):
+					self.vncPort = child.vncPort + 1
+				self.vncPortLock.release()
 				child.monitorFd = os.open(child.ptyFile, os.O_RDWR | os.O_NOCTTY)
 				child.monitor = os.fdopen(child.monitorFd)
 				self.controlledVMs[child.pid] = child
@@ -257,10 +263,16 @@
 		child.opts = opts
 		child.pid = pid
 		child.ptyFile = ptyFile
-		child.monitorHistory = []
-		child.OSchild = False
-		child.errorBit = False
-		child.migratingOut = False
+		if ('monitorHistory' not in child.__dict__):
+			child.monitorHistory = []
+		if ('OSchild' not in child.__dict__):
+			child.OSchild = False
+		if ('errorBit' not in child.__dict__):
+			child.errorBit = False
+		if ('migratingOut' not in child.__dict__):
+			child.migratingOut = False
+		if ('vncPort' not in child.__dict__):
+			child.vncPort = -1
 		return child
 	
 	def saveChildInfo(self, child):
@@ -303,6 +315,7 @@
 		os.close(pipe_w)
 		child = self.anonClass(pid=pid, image=image, macAddr=macAddr, memory=memory, cores=cores,
opts=opts, stderr=os.fdopen(pipe_r, 'r'), migratingOut = False, monitorHistory=[], errorBit
= False, OSchild = True)
 		child.ptyFile = None
+		child.vncPort = -1
 		self.saveChildInfo(child)
 		self.controlledVMs[child.pid] = child
 		log.info("Adding vmId %d" % (child.pid))
@@ -488,5 +501,29 @@
 		# XXX: the child could have exited between these two points, but I don't know how to fix
that since it might not be our child process
 		os.kill(child.pid, signal.SIGKILL)
 	
+	def vmmSpecificCall(self, vmId, arg):
+		arg = arg.lower()
+		if (arg == "startvnc"):
+			child = self.getChildFromPid(vmId)
+			hostname = socket.gethostname()
+			if (child.vncPort == -1):
+				self.vncPortLock.acquire()
+				port = self.vncPort
+				self.vncPort = self.vncPort + 1
+				self.vncPortLock.release()
+				self.enterCommand(child, "change vnc :%d" % (port))
+				child.vncPort = port
+				self.saveChildInfo(child)
+			port = child.vncPort
+			return "%s:%d" % (hostname, port)
+		elif (arg == "stopvnc"):
+			child = self.getChildFromPid(vmId)
+			self.enterCommand(child, "change vnc none")
+			child.vncPort = -1
+			self.saveChildInfo(child)
+			return "None"
+		else:
+			return "Unknown arg %s" % (arg)
+	
 	def listVms(self):
 		return self.controlledVMs.keys()

Modified: incubator/tashi/trunk/src/tashi/thrift/services.thrift
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/thrift/services.thrift?rev=743886&r1=743885&r2=743886&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/thrift/services.thrift (original)
+++ incubator/tashi/trunk/src/tashi/thrift/services.thrift Thu Feb 12 21:20:03 2009
@@ -135,6 +135,8 @@
 
 	list<Instance> getInstances() throws (1:TashiException e)
 	
+	string vmmSpecificCall(1:i32 instanceId, 2:string arg) throws (1:TashiException e)
+	
 	// NodeManager-facing RPCs
 	i32 registerNodeManager(1:Host host, 2:list<Instance> instances) throws (1:TashiException
e)
 	void vmUpdate(1:i32 instanceId, 2:Instance instance, 3:InstanceState old) throws (1:TashiException
e)
@@ -168,6 +170,8 @@
 
 	Instance getVmInfo(1:i32 vmId) throws (1:TashiException e)
 	list<i32> listVms() throws (1:TashiException e)
-
+	
+	string vmmSpecificCall(1:i32 vmId, 2:string arg) throws (1:TashiException e)
+	
 	// Host getHostInfo() throws (1:TashiException e)
 }



Mime
View raw message