Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Ultravisor log collection from Host #582

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/OpTestConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class OpTestConstants():
CLEAR_GARD_CMD = '/gard clear all'
LIST_GARD_CMD = '/gard list'
OPAL_MSG_LOG = "cat /sys/firmware/opal/msglog"
ULTRAVISOR_MSG_LOG = "cat /sys/firmware/ultravisor/msglog"
PROC_CMDLINE = "cat /proc/cmdline"
OPAL_DUMP_NODE = "/proc/device-tree/ibm,opal/dump/"
NVRAM_PRINT_CFG = "nvram --print-config"
Expand Down
66 changes: 46 additions & 20 deletions common/OpTestHost.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,17 @@

import sys
import os
import string
import time
import random
import subprocess
import re
import telnetlib
import socket
import select
import pty
import pexpect
import subprocess

import OpTestConfiguration
from .OpTestConstants import OpTestConstants as BMC_CONST
from .OpTestError import OpTestError
from .OpTestSSH import OpTestSSH
from . import OpTestQemu
from .Exceptions import CommandFailed, NoKernelConfig, KernelModuleNotLoaded, KernelConfigNotSet, ParameterCheck
from .Exceptions import CommandFailed, NoKernelConfig, KernelModuleNotLoaded, KernelConfigNotSet

import logging
import OpTestLogger
log = OpTestLogger.optest_logger_glob.get_logger(__name__)

Expand Down Expand Up @@ -232,6 +223,37 @@ def host_gather_opal_msg_log(self, console=0):
with open(fn, 'w') as f:
f.write(l_data)

def host_gather_uv_msg_log(self, console=0):
'''
Gather Ultravisor logs(from the host) and store in a file
'''
uv_enabled_cmd = '[ -d /sys/firmware/devicetree/base/ibm,ultravisor ] && echo "enabled"'
if "enabled" in self.host_run_command(uv_enabled_cmd, console=console):
try:
l_data = '\n'.join(self.host_run_command(
BMC_CONST.ULTRAVISOR_MSG_LOG, console=console))
except OpTestError:
l_msg = "Failed to gather ULTRAVISOR message logs"
raise OpTestError(l_msg)

if not self.results_dir:
log.debug(l_data)
return

l_res = (time.asctime(time.localtime())).replace(" ", "_")
l_logFile = "Ultravisor_msglog_%s.log" % l_res
fn = os.path.join(self.results_dir, l_logFile)
log.debug(fn)
with open(fn, 'w') as f:
f.write(l_data)

def host_gather_fw_logs(self, console=0):
'''
Wrapper function to gather all firmware related logs
'''
self.host_gather_opal_msg_log(console)
self.host_gather_uv_msg_log(console)

def host_check_command(self, *i_cmd, **kwargs):
'''
Check if one or more binaries are present on host
Expand Down Expand Up @@ -666,7 +688,7 @@ def host_check_pkg_kdump(self, i_oslevel, console=0):

def host_is_kdump_active(self, os_level, console=0):
'''
This function will check whether the kdump service is running/active or not.
This function will check whether the kdump service is running/active or not.
'''
if "Ubuntu" in os_level:
try:
Expand All @@ -683,7 +705,6 @@ def host_is_kdump_active(self, os_level, console=0):
except CommandFailed:
return False


def host_disable_kdump_service(self, os_level, console=0):
'''
This function disables kdump service. Needs the OS version (from `/etc/os-release`) to
Expand Down Expand Up @@ -799,7 +820,7 @@ def host_get_cores(self, console=0):

# Supported on OpenPower and P9 FSP system
def host_prd_supported(self, bmc_type, console=0):
if not "FSP" in bmc_type:
if "FSP" not in bmc_type:
return True

proc_gen = self.host_get_proc_gen(console=console)
Expand Down Expand Up @@ -984,16 +1005,24 @@ class OpTestLPAR(OpTestHost):
Methods not applicable for an LPAR are overridden here
'''

def __init__(self, i_hostip, i_hostuser, i_hostpasswd, i_bmcip, i_results_dir,
scratch_disk="", proxy="", logfile=sys.stdout,
def __init__(self, i_hostip, i_hostuser, i_hostpasswd, i_bmcip,
i_results_dir, scratch_disk="", proxy="", logfile=sys.stdout,
check_ssh_keys=False, known_hosts_file=None, conf=None):
super(OpTestLPAR, self).__init__(i_hostip,
i_hostuser, i_hostpasswd, i_bmcip, i_results_dir, scratch_disk,
proxy, logfile, check_ssh_keys, known_hosts_file, conf)
i_hostuser, i_hostpasswd, i_bmcip,
i_results_dir, scratch_disk, proxy,
logfile, check_ssh_keys,
known_hosts_file, conf)

def host_gather_opal_msg_log(self, *args):
pass

def host_gather_uv_msg_log(self, *args):
pass

def host_gather_fw_logs(self, *args):
pass

def host_pflash_get_partition(self, *args):
pass

Expand Down Expand Up @@ -1042,9 +1071,6 @@ def host_clear_error_logs(self, *args):
def host_clear_all_dumps(self, *args):
pass

def host_get_list_of_chips(self, *args):
pass

def host_prd_supported(self, *args):
pass

Expand Down
2 changes: 1 addition & 1 deletion testcases/InstallUpstreamKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def is_url(path):
if self.conf.args.host_cmd:
con.run_command(self.conf.args.host_cmd,
timeout=self.host_cmd_timeout)
self.cv_HOST.host_gather_opal_msg_log()
self.cv_HOST.host_gather_fw_logs()
self.cv_HOST.host_gather_kernel_log()
finally:
if self.console_thread.isAlive():
Expand Down
2 changes: 2 additions & 0 deletions testcases/RunHostTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@ def runTest(self):
self.host_cmd_resultpath)

def tearDown(self):
self.self.cv_SYSTEM.cv_HOST.host_gather_fw_logs()
self.self.cv_SYSTEM.cv_HOST.host_gather_kernel_log()
self.console_thread.console_terminate()