From: Marius Sandu-Popa Date: Thu, 29 Apr 2010 18:45:29 +0000 (+0300) Subject: autorun: Commander update X-Git-Tag: getopt_long~43 X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=de8d94363d1f1dfa51a4c80fa8e12bcdef79489f;p=cs-p2p-next.git autorun: Commander update --- diff --git a/autorun/commander/Commander.py b/autorun/commander/Commander.py index b942f74..9fba3b8 100644 --- a/autorun/commander/Commander.py +++ b/autorun/commander/Commander.py @@ -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)) diff --git a/autorun/commander/CommanderBase.py b/autorun/commander/CommanderBase.py index a6cd43b..f6a0678 100644 --- a/autorun/commander/CommanderBase.py +++ b/autorun/commander/CommanderBase.py @@ -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 diff --git a/autorun/xml/swarm.xml b/autorun/xml/swarm.xml index c9669c5..b1b69dc 100644 --- a/autorun/xml/swarm.xml +++ b/autorun/xml/swarm.xml @@ -1,6 +1,6 @@ - /home/p2p/p2p-meta/bbt316.torrent + /home/p2p/p2p-meta/himym520.torrent 1 tribler @@ -8,9 +8,9 @@ 256 /home/p2p/p2p-dld/tribler /home/p2p/p2p-log/tribler - tribler-bbt316.log + tribler-himym520.log /home/p2p/p2p-log/tribler - tribler-bbt316.out + tribler-himym520.out