+ if self.is_qemu():
+ self.start_qemu()
+ else:
+ utils.header("TestNode.qemu_start : %s model %s taken as real node"%(self.name(),model))
+ return True
+
+ def qemu_timestamp (self):
+ "all nodes: start the qemu instance (also runs qemu-bridge-init start)"
+ test_box = self.test_box()
+ test_box.run_in_buildname("mkdir -p %s"%self.nodedir(), dry_run=self.dry_run())
+ now=int(time.time())
+ return test_box.run_in_buildname("echo %d > %s/timestamp"%(now,self.nodedir()), dry_run=self.dry_run())==0
+
+ def start_qemu (self):
+ test_box = self.test_box()
+ utils.header("Starting qemu node %s on %s"%(self.name(),test_box.hostname()))
+
+ test_box.run_in_buildname("%s/qemu-bridge-init start >> %s/log.txt"%(self.nodedir(),self.nodedir()),
+ dry_run=self.dry_run())
+ # kick it off in background, as it would otherwise hang
+ test_box.run_in_buildname("%s/qemu-start-node 2>&1 >> %s/log.txt"%(self.nodedir(),self.nodedir()))
+
+ def list_qemu (self):
+ utils.header("Listing qemu for host %s on box %s"%(self.name(),self.test_box().hostname()))
+ command="%s/qemu-kill-node -l %s"%(self.nodedir(),self.name())
+ self.test_box().run_in_buildname(command, dry_run=self.dry_run())
+ return True
+
+ def kill_qemu (self):
+ #Prepare the log file before killing the nodes
+ test_box = self.test_box()
+ # kill the right processes
+ utils.header("Stopping qemu for node %s on box %s"%(self.name(),self.test_box().hostname()))
+ command="%s/qemu-kill-node %s"%(self.nodedir(),self.name())
+ self.test_box().run_in_buildname(command, dry_run=self.dry_run())
+ return True
+
+ def gather_qemu_logs (self):
+ if not self.is_qemu():
+ return True
+ remote_log="%s/log.txt"%self.nodedir()
+ local_log="logs/node.qemu.%s.txt"%self.name()
+ self.test_box().test_ssh.fetch(remote_log,local_log,dry_run=self.dry_run())
+
+ def keys_clear_known_hosts (self):
+ "remove test nodes entries from the local known_hosts file"
+ TestSsh(self.name()).clear_known_hosts()
+ return True
+
+ def create_test_ssh(self):
+ # get the plc's keys for entering the node
+ vservername=self.test_plc.vservername
+### # assuming we've run testplc.fetch_keys()
+### key = "keys/%(vservername)s.rsa"%locals()
+ # fetch_keys doesn't grab the root key anymore
+ key = "keys/key_admin.rsa"
+ return TestSsh(self.name(), buildname=self.buildname(), key=key)
+
+ def check_hooks (self):
+ extensions = [ 'py','pl','sh' ]
+ path='hooks/node'
+ scripts=utils.locate_hooks_scripts ('node '+self.name(), path,extensions)
+ overall = True
+ for script in scripts:
+ if not self.check_hooks_script (script):
+ overall = False
+ return overall
+
+ def check_hooks_script (self,local_script):
+ # push the script on the node's root context
+ script_name=os.path.basename(local_script)
+ utils.header ("NODE hook %s (%s)"%(script_name,self.name()))
+ test_ssh=self.create_test_ssh()
+ test_ssh.copy_home(local_script)
+ if test_ssh.run("./"+script_name) != 0:
+ utils.header ("WARNING: node hooks check script %s FAILED (ignored)"%script_name)
+ #return False
+ return True