modified client for testing
authorMarius Sandu-Popa <sandupopamarius@gmail.com>
Fri, 19 Mar 2010 12:52:15 +0000 (14:52 +0200)
committerMarius Sandu-Popa <sandupopamarius@gmail.com>
Fri, 19 Mar 2010 13:38:03 +0000 (15:38 +0200)
bt_comm/client/Client.py
bt_comm/client/SSHCommander.py
bt_comm/xml/nodes.xml
bt_comm/xml/swarm.xml

index 80c5c21..e374a66 100644 (file)
@@ -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():
index 7a06ad1..25bfcac 100644 (file)
@@ -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')
index 3f7c0e9..d388703 100644 (file)
@@ -1,15 +1,15 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <nodes>
     <node id="1">
-       <public_address>141.85.224.201</public_address>
+       <public_address>141.85.224.204</public_address>
        <public_port>10150</public_port>
        <public_iface>eth0</public_iface>
-       <private_address>172.30.10.0</private_address>
-       <private_port>10150</private_port>
-       <private_iface>venet0</private_iface>
-       <ssh_port>10122</ssh_port>
-       <username>gogu</username>
-       <listen_port></listen_port>
+       <private_address>172.16.20.3</private_address>
+       <private_port></private_port>
+       <private_iface>venet0:0</private_iface>
+       <ssh_port>20322</ssh_port>
+       <username>p2p</username>
+       <listen_port>10004</listen_port>
        <clients>
            <client id="tribler">
                <base>/home/p2p/p2p-clients/tribler/</base>
            </client>
         </clients>
     </node>
-    <node id="2">
-       <public_address>141.85.224.202</public_address>
-       <public_port>10250</public_port>
-       <public_iface>eth0</public_iface>
-       <private_address>172.30.20.0</private_address>
-       <private_port>10250</private_port>
-       <private_iface>venet0</private_iface>
-       <ssh_port>10222</ssh_port>
-       <username>gicu</username>
-       <listen_port></listen_port>
-       <clients>
-           <client id="tribler">
-               <base>/home/p2p/p2p-clients/tribler/</base>
-           </client>
-           <client id="libtorrent">
-               <base>/home/p2p/p2p-clients/libtorrent/</base>
-           </client>
-           <client id="transmission">
-               <base>/home/p2p/p2p-clients/transmission/</base>
-           </client>
-       </clients>
-    </node>
 </nodes>
index 3862fbe..4899737 100644 (file)
@@ -1,16 +1,16 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <swarm>
-    <torrent_file>cucu</torrent_file>
+    <torrent_file>/home/p2p/p2p-meta/bbt316.torrent</torrent_file>
     <instance id="1">
        <node>1</node>
        <client>tribler</client>
        <upload_limit>512</upload_limit>
        <download_limit>256</download_limit>
-       <download_dir>/download/dir</download_dir>
-       <log_dir>/log/dir</log_dir>
-       <log_file>log_file</log_file>
-       <output_dir>/output/dir</output_dir>
-       <output_file>output_file</output_file>
+       <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>
+       <output_dir>/home/p2p/p2p-log/tribler</output_dir>
+       <output_file>tribler-bbt316.out</output_file>
        <actions>
            <action type="start" delay="00:05:00" />
            <action type="stop" delay="00:10:00" />
            <action type="start" delay="end" />
        </actions>
     </instance>
-    <instance id="2">
-       <node>2</node>
-       <client>transmission</client>
-       <upload_limit>128</upload_limit>
-       <download_limit>64</download_limit>
-       <download_dir>/download/dir</download_dir>
-       <log_dir>/log/dir</log_dir>
-       <log_file>log_file</log_file>
-       <output_dir>/output/dir</output_dir>
-       <output_file>output_file</output_file>
-       <actions>
-           <action type="start" delay="00:05:00" />
-           <action type="stop" delay="01:00:00" />
-           <action type="start" delay="02:00:00" />
-           <action type="start" delay="end" />
-       </actions>
-    </instance>
 </swarm>