From f6ee8ca0eb94ce430f700aa397e257beeabd2172 Mon Sep 17 00:00:00 2001 From: Moiz Raja Date: Thu, 4 Jun 2015 18:02:06 -0700 Subject: [PATCH] Fix issue with kill_controller not working in certain environments Move the kill functionality to a separate shell script which is copied over to the destination system before invoking it Change-Id: If9c01746263448e4dcb8920ebd962fe745275c8b Signed-off-by: Moiz Raja --- .../clustering/cluster-deployer/deploy.py | 22 +++++++++++++------ .../cluster-deployer/kill_controller.sh | 1 + .../cluster-deployer/remote_host.py | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100755 test/tools/clustering/cluster-deployer/kill_controller.sh diff --git a/test/tools/clustering/cluster-deployer/deploy.py b/test/tools/clustering/cluster-deployer/deploy.py index ccc69e4a36..f9927cc0a1 100755 --- a/test/tools/clustering/cluster-deployer/deploy.py +++ b/test/tools/clustering/cluster-deployer/deploy.py @@ -67,7 +67,10 @@ class TemplateRenderer: self.cwd = os.getcwd() self.template_root = self.cwd + "/templates/" + template + "/" - def render(self, template_path, output_path, variables={}): + def render(self, template_path, output_path, variables=None): + if variables is None: + variables = {} + with open(self.template_root + template_path, "r") as myfile: data = myfile.read() @@ -90,8 +93,8 @@ def array_str(arr): for x in range(0, len(arr)): s = s + '"' + arr[x] + '"' if x < (len(arr) - 1): - s = s + "," - s = s + "]" + s += "," + s += "]" return s @@ -115,6 +118,10 @@ class Deployer: self.rpc_seed_nodes = rpc_seed_nodes self.replicas = replicas + def kill_controller(self, remote): + remote.copy_file("kill_controller.sh", self.rootdir + "/") + remote.exec_cmd(self.rootdir + "/kill_controller.sh") + def deploy(self): # Determine distribution version distribution_name = os.path.splitext(os.path.basename(self.distribution))[0] @@ -147,17 +154,19 @@ class Deployer: # Connect to the remote host and start doing operations remote = RemoteHost(self.host, self.user, self.password, self.rootdir) - remote.mkdir(self.dir_name) # Delete all the sub-directories under the deploy directory if the --clean flag is used - if(self.clean is True): + if self.clean is True: remote.exec_cmd("rm -rf " + self.rootdir + "/deploy/*") + # Create the deployment directory + remote.mkdir(self.dir_name) + # Clean the m2 repository remote.exec_cmd("rm -rf " + self.rootdir + "/.m2/repository") # Kill the controller if it's running - remote.kill_controller() + self.kill_controller(remote) # Copy the distribution to the host and unzip it odl_file_path = self.dir_name + "/odl.zip" @@ -196,7 +205,6 @@ def main(): hosts = args.hosts.split(",") time_stamp = time.time() dir_name = args.rootdir + "/deploy/" + str(time_stamp) - distribution_name = os.path.splitext(os.path.basename(args.distribution))[0] # noqa ds_seed_nodes = [] rpc_seed_nodes = [] diff --git a/test/tools/clustering/cluster-deployer/kill_controller.sh b/test/tools/clustering/cluster-deployer/kill_controller.sh new file mode 100755 index 0000000000..68de138544 --- /dev/null +++ b/test/tools/clustering/cluster-deployer/kill_controller.sh @@ -0,0 +1 @@ +ps axf | grep karaf | grep -v grep | awk '{print "kill -9 " $1}' | sudo sh diff --git a/test/tools/clustering/cluster-deployer/remote_host.py b/test/tools/clustering/cluster-deployer/remote_host.py index 5da74b77a8..34c9f1f065 100644 --- a/test/tools/clustering/cluster-deployer/remote_host.py +++ b/test/tools/clustering/cluster-deployer/remote_host.py @@ -36,7 +36,7 @@ class RemoteHost: lib.close_connection() def kill_controller(self): - self.exec_cmd("ps axf | grep karaf | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + self.exec_cmd("sudo ps axf | grep karaf | grep -v grep | awk '{print \"kill -9 \" $1}' | sudo sh") def start_controller(self, dir_name): self.exec_cmd(dir_name + "/odl/bin/start") -- 2.36.6