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/23 05:30:03 UTC

svn commit: r1292653 - in /incubator/tashi/branches/stroucki-registration/src/tashi: client/tashi-client.py clustermanager/clustermanagerservice.py

Author: stroucki
Date: Thu Feb 23 05:30:03 2012
New Revision: 1292653

URL: http://svn.apache.org/viewvc?rev=1292653&view=rev
Log:
First hackup of cmAdmin command

Modified:
    incubator/tashi/branches/stroucki-registration/src/tashi/client/tashi-client.py
    incubator/tashi/branches/stroucki-registration/src/tashi/clustermanager/clustermanagerservice.py

Modified: incubator/tashi/branches/stroucki-registration/src/tashi/client/tashi-client.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-registration/src/tashi/client/tashi-client.py?rev=1292653&r1=1292652&r2=1292653&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-registration/src/tashi/client/tashi-client.py (original)
+++ incubator/tashi/branches/stroucki-registration/src/tashi/client/tashi-client.py Thu Feb 23 05:30:03 2012
@@ -173,7 +173,7 @@ def getSlots(cores, memory):
 	print "with %d" % (cores),
 	print (lambda:"cores", lambda:"core")[cores == 1](),
 	print "and %d MB memory could be created." % (memory)
-	
+
 def createMany(instance, count):
 	# will create instances from 0 to count-1
 	l = len(str(count - 1))
@@ -216,10 +216,12 @@ extraViews = {
 'destroyMany': (destroyMany, None),
 'getVmLayout': (getVmLayout, ['id', 'name', 'state', 'instances', 'usedMemory', 'memory', 'usedCores', 'cores']),
 'getInstances': (None, ['id', 'hostId', 'name', 'user', 'state', 'disk', 'memory', 'cores']),
-'getMyInstances': (getMyInstances, ['id', 'hostId', 'name', 'user', 'state', 'disk', 'memory', 'cores'])
+'getMyInstances': (getMyInstances, ['id', 'hostId', 'name', 'user', 'state', 'disk', 'memory', 'cores']),
 }
 
 # Used to specify what args are excepted for a function, what to use to convert the string to a value, what to use as a default value if it's missing, and whether the argument was required or not
+# XXXstroucki add checkHId for host id checking?
+
 argLists = {
 'createVm': [('userId', int, getUser, False), ('name', str, lambda: requiredArg('name'), 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)],
 '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)],
@@ -241,6 +243,7 @@ argLists = {
 'getMyInstances': [],
 'getVmLayout': [],
 'vmmSpecificCall': [('instance', checkIid, lambda: requiredArg('instance'), True), ('arg', str, lambda: requiredArg('arg'), True)],
+'cmAdmin': [('arg', str, lambda: requiredArg('arg'), True), ('instance', checkIid, lambda: {}, False), ('state', str, lambda: {}, False), ('hostname', str, lambda: {}, False), ('host', str, lambda: {}, False), ('netid', str, lambda: {}, False), ('netname', str, lambda: {}, False), ('userid', str, lambda: {}, False), ('username', str, lambda: {}, False)],
 'unregisterHost': [('hostId', int, lambda: requiredArg('hostId'), True)],
 }
 
@@ -257,6 +260,7 @@ convertArgs = {
 'pauseVm': '[instance]',
 'unpauseVm': '[instance]',
 'vmmSpecificCall': '[instance, arg]',
+'cmAdmin': '{"arg":arg, "instance":instance, "state":state, "hostname":hostname, "host":host, "netid":netid, "netname":netname, "userid":userid, "username":username}'
 'unregisterHost' : '[hostId]',
 'getSlots' : '[cores, memory]',
 'copyImage' : '[src, dst]',
@@ -282,6 +286,7 @@ description = {
 'getMyInstances': 'Utility function that only lists VMs owned by the current user',
 'getVmLayout': 'Utility function that displays what VMs are placed on what hosts',
 'vmmSpecificCall': 'Direct access to VM manager specific functionality',
+'cmAdmin': 'Direct access to CM specific functionality',
 'unregisterHost' : 'Unregisters host. Registration happens when starting node manager',
 'getImages' : 'Gets a list of available VM images',
 'copyImage' : 'Copies a VM image',
@@ -309,6 +314,7 @@ examples = {
 'getImages': [''],
 'copyImage': ['--src src.qcow2 --dst dst.qcow2'],
 'vmmSpecificCall': ['--instance 12345 --arg startVnc', '--instance foobar --arg stopVnc'],
+'cmAdmin': ['(see hints)'],
 'unregisterHost' : ['--hostId 2'],
 }
 

Modified: incubator/tashi/branches/stroucki-registration/src/tashi/clustermanager/clustermanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-registration/src/tashi/clustermanager/clustermanagerservice.py?rev=1292653&r1=1292652&r2=1292653&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-registration/src/tashi/clustermanager/clustermanagerservice.py (original)
+++ incubator/tashi/branches/stroucki-registration/src/tashi/clustermanager/clustermanagerservice.py Thu Feb 23 05:30:03 2012
@@ -526,7 +526,84 @@ class ClusterManagerService(object):
 			self.log.exception('vmmSpecificCall failed on host %s with vmId %d' % (hostname, instance.vmId))
 			raise
 		return res
-	
+
+	def cmAdmin(self, args):
+
+		host = args.get("host")
+		hostname = args.get("hostname")
+
+		userid = args.get("userid")
+		username = args.get("username")
+
+		netid = args.get("netid")
+		netname = args.get("netname")
+
+		instanceId = args.get("instance")
+		statestr = args.get("state")
+
+		cmd = args.get("arg")
+		if cmd is None:
+			return
+
+		cmd = cmd.lower()
+
+		try:
+			if cmd == "addhost":
+				if hostname is None:
+					return "Specify hostname to add"
+
+				return "Not implemented yet"
+
+			elif cmd == "delhost":
+				if host is not None:
+					return "Not implemented yet"
+
+				if hostname is not None:
+					return "Not implemented yet"
+
+				return "Specify host to delete"
+
+			elif cmd == "adduser":
+				if username is None:
+					return "Specify username to add"
+
+				return "Not implemented yet"
+
+			elif cmd == "deluser":
+				if userid is not None:
+					return "Not implemented yet"
+
+				if username is not None:
+					return "Not implemented yet"
+
+				return "Specify user to delete"
+
+			elif cmd == "addnet":
+				if netid is None or \
+					    netname is None:
+					return "Specify net ID and name to add"
+
+				return "Not implemented yet"
+
+			elif cmd == "delnet":
+				if netid is not None:
+					return "Not implemented yet"
+
+				if netname is not None:
+					return "Not implemented yet"
+
+				return "Specify network to delete"
+
+			elif cmd == "setstate":
+				return "Not implemented yet"
+
+			else:
+				return "Unknown command"
+
+		except:
+			self.log.exception('cmAdmin failed')
+			raise
+
 #	@timed
 	def registerNodeManager(self, host, instances):
 		"""Called by the NM every so often as a keep-alive/state polling -- state changes here are NOT AUTHORITATIVE"""