Skip to content

Commit

Permalink
Install sosreport package
Browse files Browse the repository at this point in the history
Install the required packages for collecting sosreport

Signed-off-by: Vaishnavi Bhat <[email protected]>
  • Loading branch information
vaishnavibhat committed Oct 8, 2024
1 parent 0296a44 commit 66cc912
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions common/OpTestUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ def setup_term(self, system, pty, ssh_obj=None, block=0):
# Ctrl-L may cause a esc[J (erase) character to appear in the buffer.
# Include this in the patterns that expect $ (end of line)
rc = pty.expect(['login: (\x1b\[J)*$', ".*#(\x1b\[J)*$", ".*# (\x1b\[J)*$", ".*\$(\x1b\[J)*",
"~>(\x1b\[J)", "~ #(\x1b\[J)", ":~(\x1b\[J)*", 'Petitboot', pexpect.TIMEOUT, pexpect.EOF], timeout=30)
"~>(\x1b\[J)", "~ #(\x1b\[J)", ":~(\x1b\[J)", 'Petitboot', pexpect.TIMEOUT, pexpect.EOF], timeout=30)
if rc == 0:
track_obj.PS1_set, track_obj.LOGIN_set = self.get_login(
system_obj.cv_HOST, term_obj, pty, self.build_prompt(system_obj.prompt))
Expand Down Expand Up @@ -1807,7 +1807,7 @@ def handle_password(self, term_obj, pty, command):
raise CommandFailed(command, ''.join(failure_list_output), -1)
return list_output, echo_rc

def run_command(self, term_obj, command, timeout=600, retry=5):
def run_command(self, term_obj, command, timeout=60, retry=0):
# retry=0 will perform one pass
counter = 0
while counter <= retry:
Expand Down Expand Up @@ -2159,6 +2159,8 @@ def gather_os_logs(self, list_of_files=[], list_of_commands=[], collect_sosrepor

def __gather_os_files_logs(self, list_of_files=[], output_dir=None):
host = self.conf.host()
if self.distro_name() == 'rhel':
host.host_run_command("yum install rsyslog -y"
default_files = ['/var/log/messages', '/var/log/boot.log']
list_of_files.extend(default_files)

Expand Down Expand Up @@ -2191,6 +2193,7 @@ def __gather_os_command_logs(self, list_of_commands=[], collect_sosreport=False,

if collect_sosreport:
if 'rhel' in self.distro_name():
host.host_run_command("yum install sos -y")
cmd = 'yes "" | sosreport'
str_msg = "Your sosreport has been generated and saved in:"
elif 'sles' in self.distro_name():
Expand Down Expand Up @@ -2316,10 +2319,7 @@ def get_distro_src(self, package, dest_path, build_option=None, pack_dir=None):

elif self.distro_name() == 'sles':
host.host_run_command("zypper install -y rpm-build")
if package.startswith("kernel"):
s_cmd = f"zypper -n source-install kernel-source;cd /usr/src/packages/SOURCES/;./mkspec;cp {package}.spec ../SPECS/"
else:
s_cmd = f"zypper -n source-install {package};cd /usr/src/packages/SOURCES/;./mkspec;cp {package}.spec ../SPECS/"
s_cmd = f"zypper -n source-install {package};cd /usr/src/packages/SOURCES/;./mkspec;cp {package}.spec ../SPECS/"
if host.host_run_command(s_cmd):

spec_path = f"/usr/src/packages/SPECS/{package}.spec"
Expand Down Expand Up @@ -2574,12 +2574,6 @@ def login(self, username=None, password=None):
self.xAuthHeader['X-Auth-Token'] = match.group(1)
self.jsonHeader.update(self.xAuthHeader)
json_data = json.loads(r.text)
if json_data.get('token'):
json_data={
"data": "User '%s' logged in" %username,
"message": "200 OK",
"status": "ok"
}
log.debug("r.status_code={} json_data['status']={}"
" r.text={} r.headers={} r.request.headers={}"
.format(r.status_code, json_data['status'],
Expand Down

0 comments on commit 66cc912

Please sign in to comment.