updated Commander
authorMarius Sandu-Popa <sandupopamarius@gmail.com>
Fri, 16 Apr 2010 07:38:20 +0000 (10:38 +0300)
committerMarius Sandu-Popa <sandupopamarius@gmail.com>
Fri, 16 Apr 2010 07:38:56 +0000 (10:38 +0300)
autorun/commander/Commander.py

index 70ac5d8..5b47e87 100644 (file)
@@ -8,7 +8,7 @@ from TrafficControl import *
 from threading import Thread
 paramiko.util.log_to_file('/tmp/paramiko.log')
 
-MSGLEN = 1024
+MSGLEN = 4096
 DEBUG = True
 
 class Commander(Thread):
@@ -24,7 +24,9 @@ class Commander(Thread):
                
        def sendSSHComm(self, hostname, username, port, comm):
                try:
-                       self.sshc.connect(hostname=hostname,  username=username, port=port)
+                       self.sshc.connect(hostname=hostname,  
+                                       username=username, 
+                                       port=port)
                        stdin, stdout, stderr = self.sshc.exec_command(comm)
                        print stdout.readlines()
                except Exception, e:
@@ -34,7 +36,9 @@ class Commander(Thread):
        
        def sendMultipleSSHComm(self, hostname, username, port, comms):
                try:
-                       self.sshc.connect(hostname=hostname,  username=username, port=port)
+                       self.sshc.connect(hostname=hostname,  
+                                       username=username, 
+                                       port=port)
                        for c in comms:
                                stdin, stdout, stderr = self.sshc.exec_command(comm)
                except Exception, e:
@@ -73,13 +77,20 @@ class Commander(Thread):
                        
        def startDaemon(self, node):
                print node.daemon_dir
-               comm = SERVER_TYPE+ " "+SERVER_DIR+ " "+SERVER_FILE+" "+"start"   
+               comm = SERVER_TYPE+" "+SERVER_DIR+ " "+SERVER_FILE+" "+"start"   
                        #+ node.public_address + " " + node.listen_port
                print comm
                #self.printDummyCommand(node.public_address, node.public_port, node.ssh_port, comm)
                #self.sendSSHComm(node.public_address, node.username, int(node.ssh_port), comm)
                #self.sendSSHComm(node.public_address, node.username, int(node.ssh_port), "ps -ef | grep Server")
-       
+
+       def getNodeStatus(self, node):  
+               msg_data = self.sendComm(node.public_address, 
+                                       int(node.listen_port), 
+                                       GET_CLIENTS, 
+                                       "")
+               print msg_data          
+               
        def applyTC(self, node):
                si = self.swarm.getSIByNode(node)
                self.tc.config(node.public_address, 
@@ -95,7 +106,7 @@ class Commander(Thread):
                #self.printDummyCommand(node.public_address, node.public_port, node.ssh_port, commands)
                #sendMultipleSSHComm(node.public_address, node.username, node.ssh_port, commands)
        
-       def sendSIStart(self, si):
+       def startSI(self, si):
                node = self.nodes.getNodeBySi(si)
                base_path = node.getClientBaseDir(si.btclient)
                torrent_file = self.swarm.getTorrentFile()
@@ -118,6 +129,7 @@ class Commander(Thread):
                                        config_data)
                if(msg_type == ACK_MSG):
                        si.pid = msg_data
+       
                else:
                        print msg_data          
        
@@ -128,7 +140,7 @@ class Commander(Thread):
                print "----------------------\n"
                
        
-       def sendSIStop(self, si):       
+       def stopSI(self, si):   
                #self.printDummyCommand(node.public_address, node.listen_port, START_MSG, config_data)
                node = self.nodes.getNodeBySi(si)
                msg_type, msg_data = self.sendComm(node.public_address, 
@@ -141,10 +153,12 @@ class Commander(Thread):
                else:
                        "error while shutting down client"
                        print msg_data          
-       
 
-       def sendSIStatus(self, si):
-               pass
+       def cleanNode(self, node):
+               pass    
+
+       def getSIStatus(self, si):
+               pass    
        
        def startAll(self):
                for node in self.nodes.getNodes():