def test_servicelog_repair_action(self): """ The test checks servicelog_log_repair_action command of servicelog. """ event = "v6_power_error" # Stopping rtas_errd daemon so we can work Manageservice = ServiceManager() Manageservice.stop("rtas_errd") self.log.info("=====0 - Cleaning events from the servicelog " "database =======") self.run_cmd("servicelog_manage --truncate events --force") self.run_cmd("rm -f /var/log/platform") self.run_cmd("rm -f /var/spool/mail/root") self.log.info("===========1 - Injecting event ===" "======") self.run_cmd("/usr/sbin/rtas_errd -d -f %s/%s" % (self.events_path, event)) self.log.info("===========2 - Checking servicelog before the " "repair action =========") self.run_cmd("servicelog --type=ppc64_rtas -v") location = self.run_cmd_out("servicelog --type=ppc64_rtas" " -v | grep Location | cut -d\":\" -f2 | sed 's/^ *//'") """ The log_repair_action command creates an entry in the error log to indicate that the device at the specified location code has been repaired. When viewing a list of platform errors, all errors on the device at the specified location code priorI to the specified date will be considered closed (fixed). """ self.log.info("===========3 - Introducing the repair action " "=========") self.run_cmd("log_repair_action -q -t ppc64_rtas -l %s" % location) self.log.info("===========4 - Checking servicelog after the " "repair action =========") self.run_cmd("servicelog --type=ppc64_rtas -v") # Checking if we have a repair action on servicelog repair_event = self.run_cmd_out("servicelog " "--type=ppc64_rtas | grep \"Repair Action\" | " "cut -d\":\" -f1") if repair_event != "Repair Action": self.is_fail += 1 self.log.debug("Warning: Repair Action not found!") # Checking if the event was repaired indeed repaired = self.run_cmd_out("servicelog " "--type=ppc64_rtas | grep \"Event Repaired\" | cat -b " "| grep 2 | cut -d\":\" -f2 | sed 's/^ *//'") if repaired != "Yes": self.is_fail += 1 self.log.debug("Warning: Event not repaired!") # Start of the service stopped earlier Manageservice.start("rtas_errd") if self.is_fail >= 1: self.fail("%s command(s) failed in servicelog_repair_action" "verification" % self.is_fail)
def test_servicelog_notify(self): """ The test checks servicelog_notify command of servicelog. """ event = "v6_power_error" # Stopping rtas_errd daemon so we can work Manageservice = ServiceManager() Manageservice.stop("rtas_errd") self.log.info("===============1. Creating notification tool ====" "===========") notify_script = self.get_data("notify_script.sh") cmd = "chmod 777 %s" % notify_script process.run(cmd, ignore_status=True, sudo=True, shell=True) self.log.info("=======2 - Adding notification tool to servicelog =" "======") self.run_cmd("servicelog_notify --add --command=%s --type=all " "--repair_action=all --serviceable=all" % notify_script) self.log.info("===========3 - Injecting serviceable event ===" "======") self.run_cmd("/usr/sbin/rtas_errd -d -f %s/%s" % (self.events_path, event)) self.log.info("========4 - Checking registered notification tools ==" "======") self.run_cmd("servicelog_notify --list") self.log.info("=====5 - Check for notify_script.sh registered " "successfully =======") self.run_cmd("servicelog_notify --list | grep notify_script") ids = self.run_cmd_out("servicelog_notify --list --command=%s | " "grep \"Servicelog ID:\" | cut -d\":\" -f2 | sed 's/^ *//'" % notify_script) self.log.info("=====6 - Checking if servicelog_notify --list, " "lists the command just added =======") for id in ids: if id.strip(): self.run_cmd("servicelog_notify --list --id=%s" % id.strip()) self.log.info("=====7 - Checking if servicelog_notify --query, lists " "the command just added =======") self.run_cmd("servicelog_notify --query --command=%s" % notify_script) self.log.info("=====8 - Checking servicelog_notify --remove =======") for id in ids: if id.strip(): self.run_cmd("servicelog_notify --remove --id=%s" % id.strip()) self.log.info("=====9 - Cleaning events from the servicelog " "database =======") self.run_cmd("servicelog_manage --truncate notify --force") self.log.info("=====10 - Checking if the notification tools were " "cleared out =======") process.run("servicelog_notify --list", ignore_status=True) # Start the service stopped earlier Manageservice.start("rtas_errd") if self.is_fail >= 1: self.fail("%s command(s) failed in servicelog_notify " "verification" % self.is_fail)
def test_servicelog_manage(self): """ The test checks servicelog_manage command of servicelog. """ self.is_fail = 0 event = "v6_fru_replacement" tmp_dir = "/var/tmp/ras/" if not os.path.exists(tmp_dir): os.makedirs(tmp_dir) os.path.join(tmp_dir, "notify_script.sh") # Stopping rtas_errd daemon so we can work Manageservice = ServiceManager() Manageservice.stop("rtas_errd") self.log.info("=====0 - Cleaning events from the servicelog " "database =======") self.run_cmd("servicelog_manage --truncate events --force") self.run_cmd("rm -f /var/log/platform") self.run_cmd("rm -f /var/spool/mail/root") self.log.info("===========1 - Injecting serviceable event ===" "======") self.run_cmd("/usr/sbin/rtas_errd -d -f %s/%s" % (self.events_path, event)) self.log.info("===========2 - Checking if the event shows up" " on servicelog_manage =========") self.run_cmd("servicelog --dump") cmd_num_records = "servicelog --dump | grep \"Power Platform (RTAS) Event\" | wc -l" NoofRecords = self.run_cmd_out(cmd_num_records) if int(NoofRecords) == 0: self.is_fail += 1 self.log.info("servicelog --dump does have recored any " "RTAS Event") self.log.info("=====3 - Cleaning events from the servicelog " "database =======") self.run_cmd("servicelog_manage --truncate events --force") NoofRecords = 0 self.log.info("======4 - Checking if the events database was" " really cleaned up=========") NoofRecords = self.run_cmd_out(cmd_num_records) if int(NoofRecords): self.is_fail += 1 self.log.info("servicelog not trucated") # Start of the service stopped earlier Manageservice.start("rtas_errd") if self.is_fail >= 1: self.fail("%s command(s) failed in servicelog_manage" "verification" % self.is_fail)
def test_servicelog_repair_action(self): """ The test checks servicelog_log_repair_action command of servicelog. """ event = "v6_power_error" # Stopping rtas_errd daemon so we can work Manageservice = ServiceManager() Manageservice.stop("rtas_errd") self.log.info("=====0 - Cleaning events from the servicelog " "database =======") self.run_cmd("servicelog_manage --truncate events --force") self.run_cmd("rm -f /var/log/platform") self.run_cmd("rm -f /var/spool/mail/root") self.log.info("===========1 - Injecting event ===" "======") self.run_cmd("/usr/sbin/rtas_errd -d -f %s/%s" % (self.events_path, event)) self.log.info("===========2 - Checking servicelog before the " "repair action =========") self.run_cmd("servicelog --type=ppc64_rtas -v") location = self.run_cmd_out( "servicelog --type=ppc64_rtas" " -v | grep Location | cut -d\":\" -f2 | sed 's/^ *//'") """ The log_repair_action command creates an entry in the error log to indicate that the device at the specified location code has been repaired. When viewing a list of platform errors, all errors on the device at the specified location code priorI to the specified date will be considered closed (fixed). """ self.log.info("===========3 - Introducing the repair action " "=========") self.run_cmd("log_repair_action -q -t ppc64_rtas -l %s" % location) self.log.info("===========4 - Checking servicelog after the " "repair action =========") self.run_cmd("servicelog --type=ppc64_rtas -v") # Checking if we have a repair action on servicelog repair_event = self.run_cmd_out( "servicelog " "--type=ppc64_rtas | grep \"Repair Action\" | " "cut -d\":\" -f1") if repair_event != "Repair Action": self.is_fail += 1 self.log.debug("Warning: Repair Action not found!") # Checking if the event was repaired indeed repaired = self.run_cmd_out( "servicelog " "--type=ppc64_rtas | grep \"Event Repaired\" | cat -b " "| grep 2 | cut -d\":\" -f2 | sed 's/^ *//'") if repaired != "Yes": self.is_fail += 1 self.log.debug("Warning: Event not repaired!") # Start of the service stopped earlier Manageservice.start("rtas_errd") if self.is_fail >= 1: self.fail("%s command(s) failed in servicelog_repair_action" "verification" % self.is_fail)
def test_servicelog_notify(self): """ The test checks servicelog_notify command of servicelog. """ event = "v6_power_error" # Stopping rtas_errd daemon so we can work Manageservice = ServiceManager() Manageservice.stop("rtas_errd") self.log.info("===============1. Creating notification tool ====" "===========") notify_script = self.get_data("notify_script.sh") cmd = "chmod 777 %s" % notify_script process.run(cmd, ignore_status=True, sudo=True, shell=True) self.log.info("=======2 - Adding notification tool to servicelog =" "======") self.run_cmd("servicelog_notify --add --command=%s --type=all " "--repair_action=all --serviceable=all" % notify_script) self.log.info("===========3 - Injecting serviceable event ===" "======") self.run_cmd("/usr/sbin/rtas_errd -d -f %s/%s" % (self.events_path, event)) self.log.info("========4 - Checking registered notification tools ==" "======") self.run_cmd("servicelog_notify --list") self.log.info("=====5 - Check for notify_script.sh registered " "successfully =======") self.run_cmd("servicelog_notify --list | grep notify_script") ids = self.run_cmd_out( "servicelog_notify --list --command=%s | " "grep \"Servicelog ID:\" | cut -d\":\" -f2 | sed 's/^ *//'" % notify_script) ids = ids.split() self.log.info("=====6 - Checking if servicelog_notify --list, " "lists the command just added =======") for id in ids: if id: self.run_cmd("servicelog_notify --list --id=%s" % id) self.log.info("=====7 - Checking if servicelog_notify --query, lists " "the command just added =======") self.run_cmd("servicelog_notify --query --command=%s" % notify_script) self.log.info("=====8 - Checking servicelog_notify --remove =======") for id in ids: if id: self.run_cmd("servicelog_notify --remove --id=%s" % id) self.log.info("=====9 - Cleaning events from the servicelog " "database =======") self.run_cmd("servicelog_manage --truncate notify --force") self.log.info("=====10 - Checking if the notification tools were " "cleared out =======") process.run("servicelog_notify --list", ignore_status=True) # Start the service stopped earlier Manageservice.start("rtas_errd") if self.is_fail >= 1: self.fail("%s command(s) failed in servicelog_notify " "verification" % self.is_fail)