4 # The RemoteHost class provides methods to do operations on a remote host
7 from SSHLibrary import SSHLibrary
10 def __init__(self, host, user, password, rootdir):
13 self.password = password
14 self.rootdir = rootdir
16 def exec_cmd(self, command):
17 print "Executing command " + command + " on host " + self.host
19 lib.open_connection(self.host)
20 lib.login(username=self.user,password=self.password)
21 lib.execute_command(command)
22 lib.close_connection()
25 def mkdir(self, dir_name):
26 self.exec_cmd("mkdir -p " + dir_name)
28 def copy_file(self, src, dest):
30 lib.open_connection(self.host)
31 lib.login(username=self.user, password=self.password)
32 print "Copying " + src + " to " + dest + " on " + self.host
33 lib.put_file(src, dest)
34 lib.close_connection()
36 def kill_controller(self):
37 self.exec_cmd("ps axf | grep karaf | grep -v grep | awk '{print \"kill -9 \" $1}' | sh")
39 def start_controller(self, dir_name):
40 self.exec_cmd(dir_name + "/odl/bin/start")