incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1368680 - in /incubator/tashi/trunk/src/tashi: client/tashi-admin.py clustermanager/clustermanagerservice.py clustermanager/data/fromconfig.py clustermanager/data/sql.py rpycservices/rpycservices.py
Date Thu, 02 Aug 2012 20:05:33 GMT
Author: stroucki
Date: Thu Aug  2 20:05:32 2012
New Revision: 1368680

URL: http://svn.apache.org/viewvc?rev=1368680&view=rev
Log:
Merge branch 'adminhostcmds'

Modified:
    incubator/tashi/trunk/src/tashi/client/tashi-admin.py
    incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py
    incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py
    incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py
    incubator/tashi/trunk/src/tashi/rpycservices/rpycservices.py

Modified: incubator/tashi/trunk/src/tashi/client/tashi-admin.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/client/tashi-admin.py?rev=1368680&r1=1368679&r2=1368680&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/client/tashi-admin.py (original)
+++ incubator/tashi/trunk/src/tashi/client/tashi-admin.py Thu Aug  2 20:05:32 2012
@@ -82,6 +82,42 @@ def setHostNotes(args):
 	print rv
 	return 0
 
+def addHost(args):
+	global scriptname
+	parser = optparse.OptionParser()
+	parser.set_usage("%s addHost [options]" % scriptname)
+	parser.add_option("--host", help="Add this host to the cluster (mandatory)", action="store",
type="string", dest="hostname")
+	(options, arguments) = parser.parse_args(args)
+	if options.hostname is None:
+		print "A mandatory option is missing\n"
+		parser.print_help()
+		sys.exit(-1)
+
+	# let the NM on the new host fill this in on its regular checkins
+	memory = 0
+	cores = 0
+	version = "new"
+
+	rv = remoteCommand("registerHost", options.hostname, memory, cores, version)
+	print rv
+	return 0
+
+def delHost(args):
+	global scriptname
+	parser = optparse.OptionParser()
+	parser.set_usage("%s delHost [options]" % scriptname)
+	parser.add_option("--host", help="Remove this host from the cluster (mandatory)", action="store",
type="string", dest="hostname")
+	(options, arguments) = parser.parse_args(args)
+	if options.hostname is None:
+		print "A mandatory option is missing\n"
+		parser.print_help()
+		sys.exit(-1)
+
+	hostId = checkHid(options.hostname)
+	rv = remoteCommand("unregisterHost", hostId)
+	print rv
+	return 0
+
 def help(args):
 	global scriptname
 	print "Available commands:"
@@ -106,12 +142,16 @@ description = (
 cmdsdesc = (
 ("setHostState", "Sets host state"),
 ("setHostNotes", "Annotates a host"),
+("addHost", "Add a host to the cluster"),
+("delHost", "Remove a host from the cluster"),
 ("help", "Get list of available commands"),
 )
 
 cmds = {
 'setHostState': setHostState,
 'setHostNotes': setHostNotes,
+'addHost': addHost,
+'delHost': delHost,
 'help': help,
 }
 

Modified: incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py?rev=1368680&r1=1368679&r2=1368680&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py Thu Aug  2 20:05:32
2012
@@ -846,10 +846,14 @@ class ClusterManagerService(object):
 		except:
 			self.log.warning("Failed to lookup host %s" % hostId)
 
-		return hostId
+		return "Registered host %s with hostId %s" % (host.name, host.id)
 
 	# extern
 	def unregisterHost(self, hostId):
+		# what about VMs that may be running on the host?
+		# what about VMs attempted to be scheduled here once
+		# we've removed it?
+
 		try:
 			host = self.data.getHost(hostId)
 			self.__ACCOUNT("CM HOST UNREGISTER", host=host)
@@ -857,6 +861,9 @@ class ClusterManagerService(object):
 			self.log.warning("Failed to lookup host %s" % hostId)
 			return
 
+		self.log.info("Aborting non-implemented host unregistration for host %s" % host.name)
+		return "Host removal for host %s not implemented yet" % host.name
+
 		self.data.unregisterHost(hostId)
 		self.log.info("Host %s was unregistered" % hostId)
 		return

Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py?rev=1368680&r1=1368679&r2=1368680&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py Thu Aug  2 20:05:32
2012
@@ -205,6 +205,8 @@ class FromConfig(DataInterface):
 				self.save()
 				self.hostLock.release()
 				return _id, True
+
+		# this is a new host
 		_id = self.getNewId("hosts")
 		self.hosts[_id] = Host(d={'id':_id,'name':hostname,'state':HostState.Normal,'memory':memory,'cores':cores,'version':version})
 		self.save()
@@ -212,6 +214,7 @@ class FromConfig(DataInterface):
 		return _id, False
 		
 	def unregisterHost(self, hostId):
+		# what about VMs that may run on this host?
 		self.hostLock.acquire()
 		del self.hosts[hostId]
 		self.save()

Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py?rev=1368680&r1=1368679&r2=1368680&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py Thu Aug  2 20:05:32 2012
@@ -338,6 +338,7 @@ class SQL(DataInterface):
 		
 	def registerHost(self, hostname, memory, cores, version):
 		self.hostLock.acquire()
+		# does this have to be so general?
 		cur = self.executeStatement("SELECT * from hosts")
 		res = cur.fetchall()
 		for r in res:
@@ -354,6 +355,8 @@ class SQL(DataInterface):
 				self.executeStatement("UPDATE hosts SET %s WHERE id = %d" % (s, _id))
 				self.hostLock.release()
 				return r[0], True
+
+		# this is a new host
 		_id = self.getNewId("hosts")
 		host = Host(d={'id': _id, 'up': 0, 'decayed': 0, 'state': 1, 'name': hostname, 'memory':memory,
'cores': cores, 'version':version, 'notes':'', 'reserved':[]})
 		l = self.makeHostList(host)
@@ -363,7 +366,9 @@ class SQL(DataInterface):
 		return _id, False
 	
 	def unregisterHost(self, hostId):
+		# what about VMs that may run on this host?
 		self.hostLock.acquire()
+		# does this have to be so general?
 		cur = self.executeStatement("SELECT * from hosts")
 		res = cur.fetchall()
 		for r in res:

Modified: incubator/tashi/trunk/src/tashi/rpycservices/rpycservices.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/rpycservices/rpycservices.py?rev=1368680&r1=1368679&r2=1368680&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/rpycservices/rpycservices.py (original)
+++ incubator/tashi/trunk/src/tashi/rpycservices/rpycservices.py Thu Aug  2 20:05:32 2012
@@ -19,7 +19,7 @@ import rpyc
 from tashi.rpycservices.rpyctypes import Instance, Host, User
 import cPickle
 
-clusterManagerRPCs = ['createVm', 'shutdownVm', 'destroyVm', 'suspendVm', 'resumeVm', 'migrateVm',
'pauseVm', 'unpauseVm', 'getHosts', 'getNetworks', 'getUsers', 'getInstances', 'vmmSpecificCall',
'registerNodeManager', 'vmUpdate', 'activateVm', 'registerHost', 'getImages', 'copyImage',
'setHostState', 'setHostNotes']
+clusterManagerRPCs = ['createVm', 'shutdownVm', 'destroyVm', 'suspendVm', 'resumeVm', 'migrateVm',
'pauseVm', 'unpauseVm', 'getHosts', 'getNetworks', 'getUsers', 'getInstances', 'vmmSpecificCall',
'registerNodeManager', 'vmUpdate', 'activateVm', 'registerHost', 'unregisterHost', 'getImages',
'copyImage', 'setHostState', 'setHostNotes']
 nodeManagerRPCs = ['instantiateVm', 'shutdownVm', 'destroyVm', 'suspendVm', 'resumeVm', 'prepReceiveVm',
'prepSourceVm', 'migrateVm', 'receiveVm', 'pauseVm', 'unpauseVm', 'getVmInfo', 'listVms',
'vmmSpecificCall', 'getHostInfo', 'liveCheck']
 accountingRPCs = ['record']
 



Mime
View raw message