+
+ 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
+ else:
+ utils.header ("SUCCESS: node hook %s OK"%script_name)
+ return True
+
+ def has_libvirt (self):
+ test_ssh=self.create_test_ssh()
+ return test_ssh.run ("rpm -q --quiet libvirt-client")==0
+
+ def _check_system_slice (self, slicename,dry_run=False):
+ sitename=self.test_plc.plc_spec['settings']['PLC_SLICE_PREFIX']
+ vservername="%s_%s"%(sitename,slicename)
+ test_ssh=self.create_test_ssh()
+ if self.has_libvirt():
+ utils.header("Checking system slice %s using virsh"%slicename)
+ return test_ssh.run("virsh --connect lxc:// list | grep -q ' %s '"%vservername,
+ dry_run=dry_run)==0
+ else:
+ (retcod,output)=utils.output_of(test_ssh.actual_command("cat /vservers/%s/etc/slicefamily 2> /dev/null")%vservername)
+ # get last line only as ssh pollutes the output
+ slicefamily=output.split("\n")[-1]
+ utils.header("Found slicefamily '%s'for slice %s"%(slicefamily,slicename))
+ if retcod != 0:
+ return False
+ utils.header("Checking system slice %s using vserver-stat"%slicename)
+ return test_ssh.run("vserver-stat | grep %s"%vservername,dry_run=dry_run)==0
+
+