From: Marius Sandu-Popa Date: Fri, 19 Mar 2010 12:52:15 +0000 (+0200) Subject: modified client for testing X-Git-Tag: getopt_long~131 X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=c29e6d5391634ab2f8c4fee9e745901d3e6d6dc7;p=cs-p2p-next.git modified client for testing --- diff --git a/bt_comm/client/Client.py b/bt_comm/client/Client.py index 80c5c21..e374a66 100644 --- a/bt_comm/client/Client.py +++ b/bt_comm/client/Client.py @@ -18,6 +18,7 @@ class Commander(Thread): self.swarm = Swarm(swarm_xml); self.tc = TrafficControl("openvz"); self.sshc = paramiko.SSHClient() + self.sshc.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.sshc.load_system_host_keys() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -25,6 +26,7 @@ class Commander(Thread): try: self.sshc.connect(hostname=hostname, username=username, port=port) stdin, stdout, stderr = self.sshc.exec_command(comm) + print stdout.readlines() except Exception as e: print e finally: @@ -48,8 +50,7 @@ class Commander(Thread): if response == ACK_MSG: self.sendMsg(pickle.dumps(config_data)) response = self.recv_msg() - if (DEBUG): - print response + print "->>>>>>>>>>>>>>>>>>>>>>>>>", response except Exception as e: print e finally: @@ -73,9 +74,11 @@ class Commander(Thread): return msg def startDaemon(self, node): - comm = "python StartMeUpBaby"; - self.printDummyCommand(node.public_address, node.public_port, node.ssh_port, comm) - #sendSSHComm(node.public_address, node.username, node.ssh_port, comm) + comm = "PYTHONPATH=/home/p2p/cs-p2p-next/bt_comm:/home/p2p/cs-p2p-next/bt_comm/start-clients/ python /home/p2p/cs-p2p-next/bt_comm/server/Server.py start" + + #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 applyTC(self, node): si = self.swarm.getSIByNode(node) @@ -106,7 +109,7 @@ class Commander(Thread): } self.printDummyCommand(node.public_address, node.listen_port, START_MSG, config_data) - #sendComm(node.public_address, node.public_port, START_MSG, config_data) + self.sendComm(node.public_address, int(node.listen_port), START_MSG, config_data) def printDummyCommand(self, public_address, public_port, option1, data): print "----------------------" @@ -123,7 +126,7 @@ class Commander(Thread): def startAll(self): for node in self.nodes.getNodes(): - self.applyTC(node) + #self.applyTC(node) self.startDaemon(node) for si in self.swarm.getSIs(): diff --git a/bt_comm/client/SSHCommander.py b/bt_comm/client/SSHCommander.py index 7a06ad1..25bfcac 100644 --- a/bt_comm/client/SSHCommander.py +++ b/bt_comm/client/SSHCommander.py @@ -3,12 +3,21 @@ import os paramiko.util.log_to_file('/tmp/paramiko.log') class SSHCommander: - def __init__(self, hostname, username, password): + def __init__(self, hostname, username, port): + #self.sshclient = paramiko.Transport((hostname, port)) self.sshclient = paramiko.SSHClient() + self.sshclient.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.sshclient.load_system_host_keys() + #~ transport = paramiko.Transport((host, port)) + #pkey_file = os.path.expanduser('~/.ssh/id_rsa') + #self.pkey = paramiko.RSAKey.from_private_key_file(pkey_file) + self.hostname = hostname + self.username = username + self.port = port def connect(self): - self.sshclient.connect(hostname=hostname, username=username, password=password) + self.sshclient.connect(hostname=self.hostname, username=self.username, port=self.port) + #self.sshclient.connect(username=self.username, pkey=self.pkey) def emitCommand(self, comm): stdin, stdout, stderr = self.sshclient.exec_command(comm) @@ -18,9 +27,10 @@ class SSHCommander: self.sshclient.close() -sshc = SSHCommander("141.85.37.93", "marius", "marius") -sshc.emitCommand("transmissioncli -D -U \[isoHunt\]\ ubuntu-9.10-desktop-i386.iso.torrent &> out.log") -#sshc.closeConnection() +sshc = SSHCommander("141.85.224.204", "p2p", 20322) +sshc.connect() +sshc.emitCommand("ls -lh") +sshc.closeConnection() #~ #client.connect(hostname='p2p-next-07.grid.pub.ro', username='p2p') #~ stdin, stdout, stderr = client.exec_command('touch gugu dudu') diff --git a/bt_comm/xml/nodes.xml b/bt_comm/xml/nodes.xml index 3f7c0e9..d388703 100644 --- a/bt_comm/xml/nodes.xml +++ b/bt_comm/xml/nodes.xml @@ -1,15 +1,15 @@ - 141.85.224.201 + 141.85.224.204 10150 eth0 - 172.30.10.0 - 10150 - venet0 - 10122 - gogu - + 172.16.20.3 + + venet0:0 + 20322 + p2p + 10004 /home/p2p/p2p-clients/tribler/ @@ -22,26 +22,4 @@ - - 141.85.224.202 - 10250 - eth0 - 172.30.20.0 - 10250 - venet0 - 10222 - gicu - - - - /home/p2p/p2p-clients/tribler/ - - - /home/p2p/p2p-clients/libtorrent/ - - - /home/p2p/p2p-clients/transmission/ - - - diff --git a/bt_comm/xml/swarm.xml b/bt_comm/xml/swarm.xml index 3862fbe..4899737 100644 --- a/bt_comm/xml/swarm.xml +++ b/bt_comm/xml/swarm.xml @@ -1,16 +1,16 @@ - cucu + /home/p2p/p2p-meta/bbt316.torrent 1 tribler 512 256 - /download/dir - /log/dir - log_file - /output/dir - output_file + /home/p2p/p2p-dld/tribler + /home/p2p/p2p-log/tribler + tribler-bbt316.log + /home/p2p/p2p-log/tribler + tribler-bbt316.out @@ -20,21 +20,4 @@ - - 2 - transmission - 128 - 64 - /download/dir - /log/dir - log_file - /output/dir - output_file - - - - - - -