From 1e2613fd13d31bda9598585e31407596348dd267 Mon Sep 17 00:00:00 2001 From: Lili Deng Date: Wed, 14 Dec 2022 21:44:55 +0800 Subject: [PATCH] download /var/log/waagent.log and files under /var/log/azure/ if they exist --- lisa/operating_system.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lisa/operating_system.py b/lisa/operating_system.py index 402ec9752..68d13fd51 100644 --- a/lisa/operating_system.py +++ b/lisa/operating_system.py @@ -5,7 +5,7 @@ import time from dataclasses import dataclass from enum import Enum from functools import partial -from pathlib import Path +from pathlib import Path, PurePosixPath from typing import ( TYPE_CHECKING, Any, @@ -381,13 +381,24 @@ class Posix(OperatingSystem, BaseClassMixin): self._node.execute("modinfo hv_netvsc").save_stdout_to_file( saved_path / "modinfo-hv_netvsc.txt" ) - try: - self._node.shell.copy_back( - self._node.get_pure_path("/etc/os-release"), - saved_path / "os-release.txt", - ) - except FileNotFoundError: - self._log.debug("File /etc/os-release doesn't exist.") + from lisa.tools import Chmod, Find + + find_tool = self._node.tools[Find] + file_list = find_tool.find_files( + PurePosixPath("/var/log/azure/"), type="f", sudo=True + ) + self._node.tools[Chmod].update_folder("/var/log/azure/", "a+rwX", sudo=True) + file_list.append("/etc/os-release") + file_list.append("/var/log/waagent.log") + for file in file_list: + try: + file_name = file.split("/")[-1] + self._node.shell.copy_back( + self._node.get_pure_path(file), + saved_path / f"{file_name}.txt", + ) + except FileNotFoundError: + self._log.debug(f"File {file} doesn't exist.") def get_package_information( self, package_name: str, use_cached: bool = True