Changeset 124
- Timestamp:
- 02/20/08 15:04:59 (10 months ago)
- Files:
-
- projects/AsynCluster/trunk/asyncluster/master/control.py (modified) (1 diff)
- projects/AsynCluster/trunk/asyncluster/master/nodes.py (modified) (3 diffs)
- projects/AsynCluster/trunk/asyncluster/master/test/mock.py (modified) (1 diff)
- projects/AsynCluster/trunk/asyncluster/ndm/client.py (modified) (8 diffs)
- projects/AsynCluster/trunk/asyncluster/ndm/gui.py (modified) (1 diff)
- projects/AsynCluster/trunk/asyncluster/ndm/main.py (deleted)
- projects/AsynCluster/trunk/asyncluster/ndm/node.py (added)
- projects/AsynCluster/trunk/asyncluster/ndm/test/test_client.py (modified) (1 diff)
- projects/AsynCluster/trunk/asyncluster/test/__init__.py (modified) (1 diff)
- projects/AsynCluster/trunk/ndm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
projects/AsynCluster/trunk/asyncluster/master/control.py
r123 r124 42 42 substitution of the message prototype. 43 43 """ 44 msg = " %4s" % nodeID44 msg = "N%04d" % nodeID 45 45 if args: 46 46 msg = "%s (%s): %s" % (msg, args[0], msgProto) projects/AsynCluster/trunk/asyncluster/master/nodes.py
r122 r124 59 59 60 60 def _printableID(self): 61 return "%s% 4d" % ("WN"[self.nodeClient], self.ID)61 return "%s%04d" % ("WN"[self.nodeClient], self.ID) 62 62 63 63 def attached(self, clientRoot): … … 72 72 """ 73 73 def responded(acceptanceCode): 74 if acceptanceCode is None: 75 return (pb.IPerspective, self, lambda _: None) 76 if acceptanceCode is True: 74 print "RESPONDED", acceptanceCode 75 if acceptanceCode == 'node': 77 76 self.nodeClient = True 78 77 d = self.ctl.attachNode(self, clientRoot) 79 el se:78 elif acceptanceCode == 'child': 80 79 self.nodeClient = False 81 80 d = self.ctl.attachWorker(clientRoot) 81 else: 82 return (pb.IPerspective, self, lambda : None) 82 83 clientRoot.notifyOnDisconnect(self.detached) 83 84 return d.addCallback(doneAttaching) … … 87 88 print "%s: Attached" % self._printableID() 88 89 return pb.IPerspective, self, self.detached 89 90 90 91 serverPassword = self.ctl.config['common']['server password'] 91 92 d = clientRoot.callRemote('reverseLogin', serverPassword) projects/AsynCluster/trunk/asyncluster/master/test/mock.py
r123 r124 127 127 if called == 'reverseLogin': 128 128 if args[0] == self.serverPassword: 129 result = True129 result = 'node' 130 130 else: 131 131 result = None projects/AsynCluster/trunk/asyncluster/ndm/client.py
r123 r124 29 29 30 30 import os, signal 31 from twisted.internet import defer, reactor, threads31 from twisted.internet import defer, threads, reactor 32 32 from twisted.cred import credentials 33 33 from twisted.spread import pb … … 36 36 37 37 PYTHON="/usr/bin/python" 38 CONFIG_PATH = "/etc/asyncluster.conf" 38 39 39 40 … … 59 60 60 61 62 class ChildManager(object): 63 """ 64 I manage child worker clients. Construct one instance of me per child 65 worker process. 66 67 @ivar config: A L{configobj} config object loaded from the config file. 68 69 """ 70 def __init__(self): 71 # The config object 72 import configobj 73 self.config = configobj.ConfigObj(CONFIG_PATH) 74 # The session-less client 75 self.client = Client(self) 76 # Go! 77 reactor.callWhenRunning(self.client.connect) 78 reactor.run() 79 80 def shutdown(self): 81 d = self.client.disconnect() 82 d.addCallback(lambda _: reactor.stop()) 83 return d 84 85 61 86 class ChildRoot(jobs.ChildRoot): 62 87 """ … … 66 91 trusted = False 67 92 68 def __init__(self, serverPassword , ID):69 self.serverPassword , self.ID = serverPassword, ID93 def __init__(self, serverPassword): 94 self.serverPassword = serverPassword 70 95 71 96 def remote_reverseLogin(self, password): … … 74 99 itself to the client, in this case a child worker client. 75 100 76 If the server is authenticated, returns my unique integer77 ID. Otherwise, returns C{None}.101 If the server is authenticated, returns the string 'child' to identify 102 me to the server as a child root. Otherwise, returns C{None}. 78 103 """ 79 104 self.trusted = (password == self.serverPassword) 80 105 if self.trusted: 81 return self.ID82 83 84 class SessionRoot(pb.Root):106 return 'child' 107 108 109 class NodeRoot(pb.Root): 85 110 """ 86 111 I am the root resource for one NDM client capable of spawning worker 87 112 clients and managing user sessions. 88 113 """ 89 workerCmd = "from asyncluster.ndm import main; main.BaseManager()"114 workerCmd = "from asyncluster.ndm import client; client.ChildManager()" 90 115 91 116 def __init__(self, serverPassword, main): … … 98 123 itself to the client, in this case a node client. 99 124 100 If the server is authenticated, returns C{True}. Otherwise, returns101 C{None}.125 If the server is authenticated, returns the string 'node' to identify 126 me to the server as a node root. Otherwise, returns C{None}. 102 127 """ 103 128 self.trusted = (password == self.serverPassword) 104 129 if self.trusted: 105 return True130 return 'node' 106 131 107 132 def remote_setTimeLeft(self, hoursLeft): … … 226 251 return answer 227 252 raise ConnectionError("Couldn't authorize connection to server") 228 253 229 254 cc = self.main.config['client'] 230 255 # TCP Connection … … 236 261 serverPassword = self.main.config['common']['server password'] 237 262 if self.session: 238 self.root = SessionRoot(serverPassword, self.main)263 self.root = NodeRoot(serverPassword, self.main) 239 264 else: 240 265 self.root = ChildRoot(serverPassword) projects/AsynCluster/trunk/asyncluster/ndm/gui.py
r115 r124 57 57 # Fixed Size and centered (initial) position 58 58 size = [int(x) for x in self.main.config['display']['size']] 59 center = [getattr(self.main. app.desktop().size(), x)()/259 center = [getattr(self.main.desktop.size(), x)()/2 60 60 for x in ('width', 'height')] 61 61 rect = QtCore.QRect() projects/AsynCluster/trunk/asyncluster/ndm/test/test_client.py
r123 r124 41 41 42 42 43 class Test_ SessionRoot(TestCase):43 class Test_NodeRoot(TestCase): 44 44 def setUp(self): 45 self.root = client. SessionRoot("foo", None)45 self.root = client.NodeRoot("foo", None) 46 46 self.root.trusted = True 47 47 projects/AsynCluster/trunk/asyncluster/test/__init__.py
r16 r124 32 32 packagePath = os.path.dirname(packagePath) 33 33 if packagePath not in sys.path: 34 sys.path.insert(0, packagePath) 34 sys.path.insert(0, packagePath) 35 36 # Ensure that any helper modules in the "real" test package (containing the 37 # target file for any symlinks to this file) can be imported by name only 38 packagePath = os.path.dirname(os.path.realpath(__file__)) 39 if packagePath not in sys.path: 40 sys.path.append(packagePath) projects/AsynCluster/trunk/ndm
r89 r124 39 39 then 40 40 # Starts the Python interpreter as Xinit's sole X client 41 exec python -c \ 42 "from asyncluster.ndm import main; main.GuiManager()" \ 43 2>/dev/null 41 exec python \ 42 -c "from asyncluster.ndm import node; node.Manager()" 2>/dev/null 44 43 45 44 else
