incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1294845 - in /incubator/tashi/branches/stroucki-dropthrift: ./ src/tashi/client/ src/tashi/clustermanager/ src/tashi/clustermanager/data/ src/tashi/nodemanager/vmcontrol/
Date Tue, 28 Feb 2012 21:34:37 GMT
Author: stroucki
Date: Tue Feb 28 21:34:37 2012
New Revision: 1294845

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

Modified:
    incubator/tashi/branches/stroucki-dropthrift/   (props changed)
    incubator/tashi/branches/stroucki-dropthrift/Makefile
    incubator/tashi/branches/stroucki-dropthrift/src/tashi/client/tashi-client.py
    incubator/tashi/branches/stroucki-dropthrift/src/tashi/clustermanager/clustermanagerservice.py
    incubator/tashi/branches/stroucki-dropthrift/src/tashi/clustermanager/data/pickled.py
    incubator/tashi/branches/stroucki-dropthrift/src/tashi/nodemanager/vmcontrol/qemu.py
    incubator/tashi/branches/stroucki-dropthrift/src/tashi/nodemanager/vmcontrol/xenpv.py

Propchange: incubator/tashi/branches/stroucki-dropthrift/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 28 21:34:37 2012
@@ -3,6 +3,10 @@
 /incubator/tashi/branches/stablefix:1203848-1241770
 /incubator/tashi/branches/stroucki-accounting:1221525-1241770
 /incubator/tashi/branches/stroucki-accounting/branches/stroucki-accounting:1221525-1235607
-/incubator/tashi/branches/stroucki-irpbugs:1245857-1292484
+/incubator/tashi/branches/stroucki-irpbugs:1245857-1292894
 /incubator/tashi/branches/stroucki-slotsbug:1244839-1245041
+/incubator/tashi/branches/stroucki-tashi10:1294393-1294727
+/incubator/tashi/branches/stroucki-tashi11:1294393-1294415
+/incubator/tashi/branches/stroucki-tashi8:1294393-1294427
 /incubator/tashi/branches/zoni-dev/trunk:1034098-1177646
+/incubator/tashi/trunk:1292492-1294842

Modified: incubator/tashi/branches/stroucki-dropthrift/Makefile
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-dropthrift/Makefile?rev=1294845&r1=1294844&r2=1294845&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-dropthrift/Makefile (original)
+++ incubator/tashi/branches/stroucki-dropthrift/Makefile Tue Feb 28 21:34:37 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/stroucki-dropthrift/src/tashi/client/tashi-client.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-dropthrift/src/tashi/client/tashi-client.py?rev=1294845&r1=1294844&r2=1294845&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-dropthrift/src/tashi/client/tashi-client.py (original)
+++ incubator/tashi/branches/stroucki-dropthrift/src/tashi/client/tashi-client.py Tue Feb
28 21:34:37 2012
@@ -186,12 +186,26 @@ def createMany(instance, count):
 		instances.append(client.createVm(instance))
 	return instances
 
+def shutdownMany(basename):
+	return __shutdownOrDestroyMany("shutdown", basename)
+
 def destroyMany(basename):
+	return __shutdownOrDestroyMany("destroy", basename)
+
+def __shutdownOrDestroyMany(method, basename):
 	instances = client.getInstances()
 	count = 0
 	for i in instances:
 		if (i.name.startswith(basename + "-") and i.name[len(basename)+1].isdigit()):
-			client.destroyVm(i.id)
+			if method == "shutdown":
+				client.shutdownVm(i.id)
+
+			elif method == "destroy":
+				client.destroyVm(i.id)
+
+			else:
+				raise ValueError("Unknown method")
+
 			count = count + 1
 	if (count == 0):
 		raise ValueError("That is an unused basename")
@@ -213,6 +227,7 @@ extraViews = {
 'copyImage': (None, None), 
 'createVm': (None, ['id', 'hostId', 'name', 'user', 'state', 'disk', 'memory', 'cores']),
 'createMany': (createMany, ['id', 'hostId', 'name', 'user', 'state', 'disk', 'memory', 'cores']),
+'shutdownMany': (shutdownMany, None),
 'destroyMany': (destroyMany, None),
 'getVmLayout': (getVmLayout, ['id', 'name', 'state', 'instances', 'usedMemory', 'memory',
'usedCores', 'cores']),
 'getInstances': (None, ['id', 'hostId', 'name', 'user', 'state', 'disk', 'memory', 'cores']),
@@ -225,6 +240,7 @@ argLists = {
 'createMany': [('userId', int, getUser, False), ('basename', str, lambda: requiredArg('basename'),
True), ('cores', int, lambda: 1, False), ('memory', int, lambda: 128, False), ('disks', parseDisks,
lambda: requiredArg('disks'), True), ('nics', parseNics, randomNetwork, False), ('hints',
parseHints, lambda: {}, False), ('count', int, lambda: requiredArg('count'), True)],
 'shutdownVm': [('instance', checkIid, lambda: requiredArg('instance'), True)],
 'destroyVm': [('instance', checkIid, lambda: requiredArg('instance'), True)],
+'shutdownMany': [('basename', str, lambda: requiredArg('basename'), True)],
 'destroyMany': [('basename', str, lambda: requiredArg('basename'), True)],
 'suspendVm': [('instance', checkIid, lambda: requiredArg('instance'), True)],
 'resumeVm': [('instance', checkIid, lambda: requiredArg('instance'), True)],
@@ -250,6 +266,7 @@ convertArgs = {
 'createMany': '[Instance(d={"userId":userId,"name":basename,"cores":cores,"memory":memory,"disks":disks,"nics":nics,"hints":hints}),
count]',
 'shutdownVm': '[instance]',
 'destroyVm': '[instance]',
+'shutdownMany': '[basename]',
 'destroyMany': '[basename]',
 'suspendVm': '[instance]',
 'resumeVm': '[instance]',
@@ -268,6 +285,7 @@ description = {
 'createMany': 'Utility function that creates many VMs with the same set of parameters',
 'shutdownVm': 'Attempts to shutdown a VM nicely',
 'destroyVm': 'Immediately destroys a VM -- it is the same as unplugging a physical machine
and should be used for non-persistent VMs or when all else fails',
+'shutdownMany': 'Attempts to gracefully shut down a group of VMs created with createMany',
 'destroyMany': 'Destroys a group of VMs created with createMany',
 'suspendVm': 'Suspends a running VM to disk',
 'resumeVm': 'Resumes a suspended VM from disk',
@@ -293,6 +311,7 @@ examples = {
 'createMany': ['--basename foobar --disks i386-hardy.qcow2 --count 4'],
 'shutdownVm': ['--instance 12345', '--instance foobar'],
 'destroyVm': ['--instance 12345', '--instance foobar'],
+'shutdownMany': ['--basename foobar'],
 'destroyMany': ['--basename foobar'],
 'suspendVm': ['--instance 12345', '--instance foobar'],
 'resumeVm': ['--instance 12345', '--instance foobar'],
@@ -563,18 +582,26 @@ def main():
 		
 		f = getattr(client, function, None)
 
-		if (f is None):
-			f = extraViews[function][0]
-		if (function in convertArgs):
-			fargs = eval(convertArgs[function], globals(), vals)
-		else:
-			fargs = []
+		try:
+			if (f is None):
+				f = extraViews[function][0]
+			if (function in convertArgs):
+				fargs = eval(convertArgs[function], globals(), vals)
+			else:
+				fargs = []
+		except NameError, e:
+			print e
+			print "Please run tashi-client --examples for syntax information"
+			sys.exit(-1)
+
 		res = f(*fargs)
 		if (res != None):
 			keys = extraViews.get(function, (None, None))[1]
 			try:
 				if (type(res) == types.ListType):
 					makeTable(res, keys)
+				elif (type(res) == types.StringType):
+					print res
 				else:
 					makeTable([res], keys)
 					

Modified: incubator/tashi/branches/stroucki-dropthrift/src/tashi/clustermanager/clustermanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-dropthrift/src/tashi/clustermanager/clustermanagerservice.py?rev=1294845&r1=1294844&r2=1294845&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-dropthrift/src/tashi/clustermanager/clustermanagerservice.py
(original)
+++ incubator/tashi/branches/stroucki-dropthrift/src/tashi/clustermanager/clustermanagerservice.py
Tue Feb 28 21:34:37 2012
@@ -280,7 +280,7 @@ class ClusterManagerService(object):
 					if instance.state != InstanceState.Running and \
 					   instance.state != InstanceState.Activating and \
 					   instance.state != InstanceState.Orphaned:
-						self.data.releaseInstance(instanceId)
+						self.data.releaseInstance(instance)
 						continue
 				except:
 					continue

Modified: incubator/tashi/branches/stroucki-dropthrift/src/tashi/clustermanager/data/pickled.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-dropthrift/src/tashi/clustermanager/data/pickled.py?rev=1294845&r1=1294844&r2=1294845&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-dropthrift/src/tashi/clustermanager/data/pickled.py
(original)
+++ incubator/tashi/branches/stroucki-dropthrift/src/tashi/clustermanager/data/pickled.py
Tue Feb 28 21:34:37 2012
@@ -52,9 +52,14 @@ class Pickled(FromConfig):
 		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)):

Modified: incubator/tashi/branches/stroucki-dropthrift/src/tashi/nodemanager/vmcontrol/qemu.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-dropthrift/src/tashi/nodemanager/vmcontrol/qemu.py?rev=1294845&r1=1294844&r2=1294845&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-dropthrift/src/tashi/nodemanager/vmcontrol/qemu.py (original)
+++ incubator/tashi/branches/stroucki-dropthrift/src/tashi/nodemanager/vmcontrol/qemu.py Tue
Feb 28 21:34:37 2012
@@ -132,10 +132,14 @@ 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 = self.QEMU_BIN
+		while os.path.islink(real_bin):
+			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
@@ -500,8 +504,14 @@ class Qemu(VmControlInterface):
 		nicModel = self.__stripSpace(nicModel)
 
 		nicString = ""
+		nicNetworks = {}
 		for i in range(0, len(instance.nics)):
+			# Don't allow more than one interface per vlan
 			nic = instance.nics[i]
+			if nicNetworks.has_key(nic.network):
+				continue
+			nicNetworks[nic.network] = True
+
 			nicString = nicString + "-net nic,macaddr=%s,model=%s,vlan=%d -net tap,ifname=%s%d.%d,vlan=%d,script=/etc/qemu-ifup.%d
" % (nic.mac, nicModel, nic.network, self.ifPrefix, instance.id, i, nic.network, nic.network)
 
 		#  ACPI

Modified: incubator/tashi/branches/stroucki-dropthrift/src/tashi/nodemanager/vmcontrol/xenpv.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-dropthrift/src/tashi/nodemanager/vmcontrol/xenpv.py?rev=1294845&r1=1294844&r2=1294845&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-dropthrift/src/tashi/nodemanager/vmcontrol/xenpv.py
(original)
+++ incubator/tashi/branches/stroucki-dropthrift/src/tashi/nodemanager/vmcontrol/xenpv.py
Tue Feb 28 21:34:37 2012
@@ -346,6 +346,8 @@ extra='xencons=tty'
 				instance.disks[i].local = newdisk
 
 
+		# XXXstroucki if ever supporting multiple nics,
+		# ensure more than one isn't put on the same network.
 		fn = self.createXenConfig(name, 
 					  instance.disks[0].local, 
 					  instance.nics[0].mac, 



Mime
View raw message