from threading import Thread
paramiko.util.log_to_file('/tmp/paramiko.log')
-MSGLEN = 1024
+MSGLEN = 4096
DEBUG = True
class Commander(Thread):
def sendSSHComm(self, hostname, username, port, comm):
try:
- self.sshc.connect(hostname=hostname, username=username, port=port)
+ self.sshc.connect(hostname=hostname,
+ username=username,
+ port=port)
stdin, stdout, stderr = self.sshc.exec_command(comm)
print stdout.readlines()
except Exception, e:
def sendMultipleSSHComm(self, hostname, username, port, comms):
try:
- self.sshc.connect(hostname=hostname, username=username, port=port)
+ self.sshc.connect(hostname=hostname,
+ username=username,
+ port=port)
for c in comms:
stdin, stdout, stderr = self.sshc.exec_command(comm)
except Exception, e:
def startDaemon(self, node):
print node.daemon_dir
- comm = SERVER_TYPE+ " "+SERVER_DIR+ " "+SERVER_FILE+" "+"start"
+ comm = SERVER_TYPE+" "+SERVER_DIR+ " "+SERVER_FILE+" "+"start"
#+ node.public_address + " " + node.listen_port
print comm
#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 getNodeStatus(self, node):
+ msg_data = self.sendComm(node.public_address,
+ int(node.listen_port),
+ GET_CLIENTS,
+ "")
+ print msg_data
+
def applyTC(self, node):
si = self.swarm.getSIByNode(node)
self.tc.config(node.public_address,
#self.printDummyCommand(node.public_address, node.public_port, node.ssh_port, commands)
#sendMultipleSSHComm(node.public_address, node.username, node.ssh_port, commands)
- def sendSIStart(self, si):
+ def startSI(self, si):
node = self.nodes.getNodeBySi(si)
base_path = node.getClientBaseDir(si.btclient)
torrent_file = self.swarm.getTorrentFile()
config_data)
if(msg_type == ACK_MSG):
si.pid = msg_data
+
else:
print msg_data
print "----------------------\n"
- def sendSIStop(self, si):
+ def stopSI(self, si):
#self.printDummyCommand(node.public_address, node.listen_port, START_MSG, config_data)
node = self.nodes.getNodeBySi(si)
msg_type, msg_data = self.sendComm(node.public_address,
else:
"error while shutting down client"
print msg_data
-
- def sendSIStatus(self, si):
- pass
+ def cleanNode(self, node):
+ pass
+
+ def getSIStatus(self, si):
+ pass
def startAll(self):
for node in self.nodes.getNodes():