autorun: Commander update
authorMarius Sandu-Popa <sandupopamarius@gmail.com>
Thu, 29 Apr 2010 18:45:29 +0000 (21:45 +0300)
committerMarius Sandu-Popa <sandupopamarius@gmail.com>
Thu, 29 Apr 2010 18:45:46 +0000 (21:45 +0300)
autorun/commander/Commander.py
autorun/commander/CommanderBase.py
autorun/xml/swarm.xml

index b942f74..9fba3b8 100644 (file)
@@ -17,16 +17,17 @@ class Commander(Thread):
                #self.sshc.load_system_host_keys()      
                self.Commander = CommanderBase();       
                self.commands = {
-               'list': [self.simpleC,          'Lists the nodes in xml file.'],
-               'boot':[self.nodeC,             'Bootstrap server. Options: all | x .'],
-               'start': [self.clientC,         'Start clients. Options: all | x | x,y .'],
-               'stop': [self.clientC,          'Stop clients. Options: all | x | x,y .'],
-               'archive': [self.nodeC,                 'Archive output information of clients.'+\
-                                                               'Options: all | x .'],
-               'getclients': [self.nodeC,      'Get running clients. Options: all | x .'],
-               'getoutput': [self.nodeC,       'Get clients output. Options: all | x .'],
-               'help': [self.simpleC,          "Show This Message."],
-               'exit': [self.simpleC,          "Exit Commander."]
+               'list': [self.simpleC,  'Lists the nodes in xml file.'],
+               'boot':[self.nodeC,     'Bootstrap server. Options: all | x .'],
+               'start': [self.clientC, 'Start clients. Options: all | x | x,y .'],
+               'stop': [self.clientC,  'Stop clients. Options: all | x | x,y .'],
+               'status': [self.clientC,        'Status clients. Options: all | x | x,y .'],
+               'archive': [self.nodeC, 'Archive output information of clients.'+\
+                                       'Options: all | x .'],
+               'getclients': [self.nodeC,'Get running clients. Options: all | x .'],
+               'getoutput': [self.nodeC,'Get clients output. Options: all | x .'],
+               'help': [self.simpleC,  "Show This Message."],
+               'exit': [self.simpleC,  "Exit Commander."]
                }
        
        def simpleC(self, comm, argv):
@@ -67,8 +68,9 @@ class Commander(Thread):
        
        def clientC(self, comm, argv):
                argc = len(argv)
-               callbacks = {'start':self.startSI,
-                               'stop':self.stopSI}
+               callbacks = {'start': self.startSI,
+                               'stop': self.stopSI,
+                               'status': self.statusSI}
                if argc == 0:
                        print "Invalid arguments"
                        return
@@ -128,14 +130,18 @@ class Commander(Thread):
                                                        int(node.listen_port), 
                                                        config_data)    
                print ">>>>>>>>", ret
-               if ret:
-                       si.pid = ret
+               if ret: si.pid = ret
        
        def stopSI(self, node, si):     
                return self.Commander.stop(node.public_address, 
                                                        int(node.listen_port), 
                                                        si.pid)
-
+       
+       def statusSI(self, node, si):
+               return self.Commander.status(node.public_address, 
+                                                       int(node.listen_port), 
+                                                       si.pid)
+               
        def getNodeStatus(self, node):  
                return self.Commander.getClients(node.public_address, 
                                        int(node.listen_port)) 
index a6cd43b..f6a0678 100644 (file)
@@ -95,6 +95,17 @@ class CommanderBase():
                else:
                        error("stop_client", msg_data)
        
+       def status(self, public_address, listen_port, client_pid):      
+               msg_type, msg_data = self.sendComm(public_address, 
+                                                                               listen_port, 
+                                                                               GET_STATUS, 
+                                                                               client_pid)
+               if msg_type == ACK_MSG:
+                       return msg_data
+               else:
+                       error("start_client", msg_data)
+       
+       
        def clean(self):
                pass
        
index c9669c5..b1b69dc 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <swarm>
-    <torrent_file>/home/p2p/p2p-meta/bbt316.torrent</torrent_file>
+    <torrent_file>/home/p2p/p2p-meta/himym520.torrent</torrent_file>
      <instance id="1">
        <node>1</node>
        <client>tribler</client>
@@ -8,9 +8,9 @@
        <download_limit>256</download_limit>
        <download_dir>/home/p2p/p2p-dld/tribler</download_dir>
        <log_dir>/home/p2p/p2p-log/tribler</log_dir>
-       <log_file>tribler-bbt316.log</log_file>
+       <log_file>tribler-himym520.log</log_file>
        <output_dir>/home/p2p/p2p-log/tribler</output_dir>
-       <output_file>tribler-bbt316.out</output_file>
+       <output_file>tribler-himym520.out</output_file>
        <actions>
            <action type="start" delay="00:05:00" />
            <action type="stop" delay="00:10:00" />