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/05/17 20:37:14 UTC

svn commit: r1339853 - in /incubator/tashi/trunk/src/tashi: agents/instancehook.py agents/mauipacket.py agents/mauiwiki.py agents/primitive_zoni.py agents/pseudoDes.py rpycservices/rpycservices.py utils/pseudoDes.py

Author: stroucki
Date: Thu May 17 20:37:14 2012
New Revision: 1339853

URL: http://svn.apache.org/viewvc?rev=1339853&view=rev
Log:
clean agents directory, add notes on seldom-seen components

Added:
    incubator/tashi/trunk/src/tashi/utils/pseudoDes.py
      - copied, changed from r1339788, incubator/tashi/trunk/src/tashi/agents/pseudoDes.py
Removed:
    incubator/tashi/trunk/src/tashi/agents/mauipacket.py
    incubator/tashi/trunk/src/tashi/agents/pseudoDes.py
Modified:
    incubator/tashi/trunk/src/tashi/agents/instancehook.py
    incubator/tashi/trunk/src/tashi/agents/mauiwiki.py
    incubator/tashi/trunk/src/tashi/agents/primitive_zoni.py
    incubator/tashi/trunk/src/tashi/rpycservices/rpycservices.py

Modified: incubator/tashi/trunk/src/tashi/agents/instancehook.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/agents/instancehook.py?rev=1339853&r1=1339852&r2=1339853&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/agents/instancehook.py (original)
+++ incubator/tashi/trunk/src/tashi/agents/instancehook.py Thu May 17 20:37:14 2012
@@ -1,5 +1,3 @@
-#! /usr/bin/env python
-
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -17,6 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.    
 
+# superclass for instance hooks.
+
 class InstanceHook(object):
 	def __init__(self, config, client, post=False):
 		if (self.__class__ is InstanceHook):

Modified: incubator/tashi/trunk/src/tashi/agents/mauiwiki.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/agents/mauiwiki.py?rev=1339853&r1=1339852&r2=1339853&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/agents/mauiwiki.py (original)
+++ incubator/tashi/trunk/src/tashi/agents/mauiwiki.py Thu May 17 20:37:14 2012
@@ -17,6 +17,113 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# XXXstroucki: wiki is a text based resource manager that maui can
+# use. It also seems to have disappeared from the face of the web.
+# This code is unmaintained.
+
+# XXXstroucki former file mauipacket.py
+import subprocess
+import time
+import tashi.utils.pseudoDes
+
+class MauiPacket:
+	def __init__(self, key=0):
+		self.size = 0
+		self.char = '\n'
+		self.chksum = '0'*16
+		self.timestamp = int(time.time())
+		self.auth = ''
+		self.data = []
+		self.msg = ''
+		self.key=key
+	def readPacket(self, istream):
+		self.msg = ''
+
+		size = istream.read(8)
+		self.msg = self.msg+size
+		self.size = int(size)
+
+		self.char = istream.read(1)
+		self.msg = self.msg + self.char
+
+		packet = istream.read(self.size)
+		self.msg = self.msg + packet
+
+		packet = packet.split()
+		
+		for i in range(len(packet)):
+			item = packet[i].split('=')
+			if item[0] == 'CK':
+				self.chksum = item[1]
+			if item[0] == 'TS':
+				self.timestamp = int(item[1])
+			if item[0] == 'AUTH':
+				self.auth = item[1]
+			if item[0] == 'DT':
+				self.data = packet[i:]
+				self.data=self.data[0].split('=',1)[1:] + self.data[1:]
+
+	def checksumMessage(self, message, key=None):
+		if key == None:
+			key = self.key
+		if type(key) == type(''):
+			key = int(key)
+		chksum = pseudoDes.generateKey(message, key)
+		chksum = '%016x' % chksum
+		return chksum
+	def getChecksum(self):
+		cs = self.msg.partition('TS=')
+		cs = cs[1]+cs[2]
+		chksum = self.checksumMessage(cs)
+		return chksum
+	def verifyChecksum(self):
+		chksum = self.getChecksum()
+		if chksum != self.chksum:
+			print 'verifyChecksum: "%s"\t"%s"'%(chksum, self.chksum)
+			print 'verifyChecksum (types): %s\t%s' %(type(chksum), type(self.chksum))
+			return False
+		return True
+	def set(self, data, auth=None, key=None, timestamp=None):
+		if timestamp==None:
+			timestamp = int(time.time())
+		self.data = data
+		if auth !=None:
+			self.auth = auth
+		if key != None:
+			self.key = key
+		self.timstamp=timestamp
+		self.fixup()
+	def fixup(self):
+		datastring = "TS=%i AUTH=%s DT=%s"%(self.timestamp, self.auth, (' '.join(self.data)))
+		self.chksum = self.checksumMessage(datastring)
+
+		pktstring = 'CK=%s %s'%(self.chksum, datastring)
+		self.size = len(pktstring)
+	def __str__(self):
+		datastring = "TS=%i AUTH=%s DT=%s"%(self.timestamp, self.auth, (' '.join(self.data)))
+		self.chksum = self.checksumMessage(datastring)
+
+		pktstring = 'CK=%s %s'%(self.chksum, datastring)
+		self.msg = ''
+		self.msg = self.msg + '%08i'%len(pktstring)
+		self.msg = self.msg + self.char
+		self.msg = self.msg + pktstring
+
+		return self.msg
+	def prettyString(self):
+		s = '''Maui Packet
+-----------
+size:\t\t%i
+checksum:\t%s
+timestamp:\t%s
+auth:\t\t%s
+data:
+%s
+-----------'''
+		s = s%(self.size, self.chksum, self.timestamp, self.auth, self.data)
+		return s
+
+# XXXstroucki original file mauiwiki.py
 import time
 import hashlib
 import sys
@@ -30,7 +137,7 @@ import logging.config
 from tashi.parallel import synchronizedmethod
 from tashi.services.ttypes import *
 from tashi.util import getConfig, createClient, instantiateImplementation, boolean
-from tashi.agents.mauipacket import MauiPacket
+#from tashi.agents.mauipacket import MauiPacket
 import tashi.util
 
 def jobnameToId(jobname):

Modified: incubator/tashi/trunk/src/tashi/agents/primitive_zoni.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/agents/primitive_zoni.py?rev=1339853&r1=1339852&r2=1339853&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/agents/primitive_zoni.py (original)
+++ incubator/tashi/trunk/src/tashi/agents/primitive_zoni.py Thu May 17 20:37:14 2012
@@ -17,6 +17,11 @@
 # specific language governing permissions and limitations
 # under the License.    
 
+# XXXstroucki: this apparently originated from a copy of the primitive
+# scheduler code sometime in 2010. It aims to keep a pool of tashi servers
+# available, and other servers shut down. Could this be better suited for
+# a hook function of the scheduler?
+
 from socket import gethostname
 import os
 import socket

Modified: incubator/tashi/trunk/src/tashi/rpycservices/rpycservices.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/rpycservices/rpycservices.py?rev=1339853&r1=1339852&r2=1339853&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/rpycservices/rpycservices.py (original)
+++ incubator/tashi/trunk/src/tashi/rpycservices/rpycservices.py Thu May 17 20:37:14 2012
@@ -65,6 +65,9 @@ class client:
 		if name not in clusterManagerRPCs and name not in nodeManagerRPCs and name not in accountingRPCs:
 			return None
 		def connectWrap(*args):
+			# XXXstroucki: why not talk directly, instead
+			# of using rpyc? We're already using pickle to move
+			# args.
 			args = cPickle.dumps(clean(args))
 			try:
 				res = getattr(self.conn.root, name)(args)

Copied: incubator/tashi/trunk/src/tashi/utils/pseudoDes.py (from r1339788, incubator/tashi/trunk/src/tashi/agents/pseudoDes.py)
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/utils/pseudoDes.py?p2=incubator/tashi/trunk/src/tashi/utils/pseudoDes.py&p1=incubator/tashi/trunk/src/tashi/agents/pseudoDes.py&r1=1339788&r2=1339853&rev=1339853&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/agents/pseudoDes.py (original)
+++ incubator/tashi/trunk/src/tashi/utils/pseudoDes.py Thu May 17 20:37:14 2012
@@ -1,5 +1,4 @@
-#! /usr/bin/env python
-
+#!/usr/bin/python
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -17,6 +16,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# XXXstroucki: why pseudo?
+
 values = {1:(0xcba4e531, 0x12be4590),
           2:(0x537158eb, 0xab54ce58),
           3:(0x145cdc3c, 0x6954c7a6),