ret = self.Commander.start(node.public_address,
int(node.listen_port),
config_data)
- #print ">>>>>>>>", ret
- if ret: si.pid = ret
+ if ret: si.pid = ret; si.running = True
def stopSI(self, node, si):
ret = self.Commander.stop(node.public_address,
int(node.listen_port),
si.pid)
+ if ret: si.pid = -1; si.running = False
-
- #{'download_size': 183509218, 'num_peers': 2, 'eta': 0, 'timestamp': datetime.datetime(2010, 4, 30, 9, 6, 27), 'upload_speed': 0, 'download_speed': 0, 'dht': 0}
def statusSI(self, node, si):
ret = self.Commander.status(node.public_address,
int(node.listen_port),
#~ node.ssh_port,
#~ commands)
+ def update(self):
+ for node in self.nodes.getNodes():
+ ret = self.Commander.getClients(node.public_address,
+ int(node.listen_port))
+ if ret:
+ for l in ret:
+ si = self.swarm.getSIByNode(node)
+ if si.btclient != l[0] or self.swarm.torrent_file !=l[2]:
+ print "[Error] Commander and Server are not in sync!"
+ sys.exit()
+ si.pid = l[1]
+ si.running = True
+
def run(self):
self.about()
+ self.update()
while True:
try:
input = raw_input("commander> ")
" KB/s" + ", Up:" +si.upload_limit + " KB/s" + ')'
def about(self):
- print "Commander version 1.1"
- print "Enter \"help\" for instructions"
+ print "Commander version 1.2\nEnter \"help\" for instructions\n"
if __name__ == "__main__":
c = Commander("../xml/nodes.xml", "../xml/swarm.xml")
def __init__(self, id, list):
self.id = id;
self.pid = -1;
- #~ self.running = False;
+ self.running = False;
self.node_id = list[0];
self.btclient = list[1];
self.upload_limit = list[2];
class Node:
def __init__(self, id, list):
self.id = id;
- #~ self.running = False;
self.public_address = list[0];
self.public_port = list[1];
self.public_iface = list[2];
<?xml version="1.0" encoding="ISO-8859-1"?>
<nodes>
<node id="1">
- <public_address>141.85.224.201</public_address>
- <public_port>50700</public_port>
- <public_iface>eth0</public_iface>
- <private_address>172.16.10.7</private_address>
- <private_port></private_port>
- <private_iface>venet0:0</private_iface>
- <ssh_port>10722</ssh_port>
- <username>p2p</username>
- <listen_port>10740</listen_port>
- <daemon_dir>/home/p2p/cs-p2p-next/autorun/server/</daemon_dir>
- <daemon_file>Server.py</daemon_file>
- <clients>
- <client id="tribler">
- <base>/home/p2p/p2p-clients/tribler</base>
- </client>
- <client id="hrktorrent">
- <base>/home/p2p/p2p-clients/hrktorrent</base>
- </client>
- <client id="transmission">
- <base>/home/p2p/p2p-clients/transmission/cli</base>
- </client>
- </clients>
- </node>
- <node id="2">
<public_address>141.85.224.201</public_address>
<public_port>50800</public_port>
<public_iface>eth0</public_iface>
<action type="start" delay="end" />
</actions>
</instance>
- <instance id="2">
- <node>2</node>
- <client>tribler</client>
- <upload_limit>512</upload_limit>
- <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-himym520.log</log_file>
- <output_dir>/home/p2p/p2p-log/tribler</output_dir>
- <output_file>tribler-himym520.out</output_file>
- <actions>
- <action type="start" delay="00:05:00" />
- <action type="stop" delay="00:10:00" />
- <action type="start" delay="00:15:00" />
- <action type="stop" delay="00:20:00" />
- <action type="start" delay="00:25:00" />
- <action type="start" delay="end" />
- </actions>
- </instance>
</swarm>