From b9a45db4c41fd153c4fc2aceb211ff5264e0af60 Mon Sep 17 00:00:00 2001 From: cc <18856836718@163.com> Date: Fri, 29 Mar 2024 19:29:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devkit_installer/devkit_machine.py | 2 +- .../installer_command_line.py | 2 +- tools/install_dependency/src/constant.py | 5 ++-- .../src/download/download_config.py | 5 ++++ .../src/download/download_utils.py | 1 + .../install_dependency/src/machine/machine.py | 27 +++++++++++++++++++ tools/install_dependency/src/utils.py | 1 + 7 files changed, 39 insertions(+), 4 deletions(-) diff --git a/component/DevKitWeb/devkit_installer/devkit_machine.py b/component/DevKitWeb/devkit_installer/devkit_machine.py index 0ff751d..2480079 100644 --- a/component/DevKitWeb/devkit_installer/devkit_machine.py +++ b/component/DevKitWeb/devkit_installer/devkit_machine.py @@ -110,7 +110,7 @@ class DevKitMachine: else: plugin_param = f"--plugin={plugin}" - cmd = (f"cd {self.install_dir} && yes | head -1 | ./{self.install_file} {plugin_param} -d={install_path} " + cmd = (f"cd {self.install_dir} && yes | head -1 | sudo bash {self.install_file} {plugin_param} -d={install_path} " f"--ip={server_ip} --map_ip={server_ip} -p={server_port} --http_port={http_port} " f"--rpc_ip={server_ip} --rpc_port={rpc_port} --normal-install=1") LOGGER.info(f"cmd: {cmd}") diff --git a/component/DevKitWeb/devkit_installer/installer_command_line.py b/component/DevKitWeb/devkit_installer/installer_command_line.py index 9ea38bc..0c73f93 100644 --- a/component/DevKitWeb/devkit_installer/installer_command_line.py +++ b/component/DevKitWeb/devkit_installer/installer_command_line.py @@ -1,6 +1,6 @@ import argparse -PACKAGE_NAME = "DevKit-All-24.0.RC1-Linux-Kunpeng.tar.gz" +PACKAGE_NAME = "DevKit-All-23.0.T30-Linux-Kunpeng.tar.gz" class CommandLine: diff --git a/tools/install_dependency/src/constant.py b/tools/install_dependency/src/constant.py index 46a2883..f403763 100644 --- a/tools/install_dependency/src/constant.py +++ b/tools/install_dependency/src/constant.py @@ -16,10 +16,11 @@ ROLE_COMPONENT = { SCANNER: ["BiShengJDK17"], C_BUIDLER: ["GCCforOpenEuler", "BiShengCompiler", "BiShengJDK17", "A-FOT", "NonInvasiveSwitching"], JAVA_BUILDER: ["BiShengJDK17", "BiShengJDK8"], - EXECUTOR: ["BiShengJDK17", "LkpTests"] + EXECUTOR: ["BiShengJDK17", "LkpTests"], + DEVKIT: ["DevKitWeb"] } -ROLE_LIST = [SCANNER, C_BUIDLER, JAVA_BUILDER, EXECUTOR] +ROLE_LIST = [SCANNER, C_BUIDLER, JAVA_BUILDER, EXECUTOR, DEVKIT] FILE = "file" SHA256 = "sha256" diff --git a/tools/install_dependency/src/download/download_config.py b/tools/install_dependency/src/download/download_config.py index 1bc885d..bd7b2a8 100644 --- a/tools/install_dependency/src/download/download_config.py +++ b/tools/install_dependency/src/download/download_config.py @@ -31,6 +31,11 @@ CompatibilityTesting = { "file": "https://gitee.com/openeuler/devkit-pipeline/releases/download/v0.2/compatibility_testing.tar.gz", } +DevKitWeb = { + "component_name": "DevKitWeb", + "file": "https://kunpeng-repo.obs.cn-north-4.myhuaweicloud.com/Porting%20Advisor/Porting%20Advisor%2023.0.T30/DevKit-All-23.0.T30-Linux-Kunpeng.tar.gz", + "sha256": "https://kunpeng-repo.obs.cn-north-4.myhuaweicloud.com/Porting%20Advisor/Porting%20Advisor%2023.0.T30/DevKit-All-23.0.T30-Linux-Kunpeng.tar.gz.asc", +} OpenEuler_2003_LTS = { "component_name": "openEuler_2003_LTS", diff --git a/tools/install_dependency/src/download/download_utils.py b/tools/install_dependency/src/download/download_utils.py index d9960e7..4a310d4 100644 --- a/tools/install_dependency/src/download/download_utils.py +++ b/tools/install_dependency/src/download/download_utils.py @@ -42,6 +42,7 @@ component_collection_map = { download_config.GCCforOpenEuler, download_config.BiShengJDK8, download_config.BiShengJDK17, + download_config.DevKitWeb, ) } diff --git a/tools/install_dependency/src/machine/machine.py b/tools/install_dependency/src/machine/machine.py index 9779112..7162a10 100644 --- a/tools/install_dependency/src/machine/machine.py +++ b/tools/install_dependency/src/machine/machine.py @@ -137,6 +137,7 @@ class Machine: "BiShengJDK8": self.default_install_component_handle, "LkpTests": self.lkptest_install_component_handle, "NonInvasiveSwitching": self.nis_install_component_handle, + "DevKitWeb": self.devkitweb_install_component_handle, "OpenEulerMirrorISO": self.deploy_iso_handle, "UnOpenEulerMirrorISO": self.undeploy_iso_handle, "A-FOT": self.install_a_fot, @@ -145,6 +146,32 @@ class Machine: self._remote_exec_command(CHECK_TMP_SPACE_SUFFICIENT_FOR_PACKAGE, ssh_client) return component_name_to_func_dict.get(component_name)(component_name, sftp_client, ssh_client) + def devkitweb_install_component_handle(self, component_name, sftp_client, ssh_client): + # 上传 tar.gz 文件 + LOGGER.info(f"Install component in remote machine {self.ip}: {component_name}") + remote_file_list = [] + shell_dict = component_collection_map.get(component_name) + + url_and_save_path = shell_dict.get("download file") + local_file = url_and_save_path.get("save_path") + remote_file = os.path.abspath(os.path.join('/opt', local_file.split('/')[-1])) + LOGGER.debug(f"Transport local_file: {local_file} to remote machine {self.ip} " + f"remote_file: {remote_file}") + remote_file_list.append(remote_file) + sftp_client.put(localpath=f"{local_file}", remotepath=f"{remote_file}") + + stdin, stdout, stderr = ssh_client.exec_command( + f"{os.path.join(base_path('component'), component_name, 'devkit_installer')} " + f"-i {self.ip} -u {self.user} -p {self.pkey}") + exit_status = stdout.channel.recv_exit_status() + if exit_status == 0: + LOGGER.debug(f"Remote machine {self.ip} exec 'devkit_installer' success.") + else: + LOGGER.error(f"Remote machine {self.ip} exec 'devkit_installer' failed.") + + # 清理tmp临时文件 + self.clear_tmp_file_at_remote_machine(ssh_client, remote_file_list) + def install_a_fot(self, component_name, sftp_client, ssh_client): saved_path = os.path.join(constant.DEFAULT_PATH, "a-fot.tar.gz") remote_file = os.path.abspath(os.path.join('/tmp', saved_path)) diff --git a/tools/install_dependency/src/utils.py b/tools/install_dependency/src/utils.py index b16c3ac..b4b7908 100644 --- a/tools/install_dependency/src/utils.py +++ b/tools/install_dependency/src/utils.py @@ -45,6 +45,7 @@ def read_yaml_file(yaml_path): sys.exit(1) return yaml_dict + def generate_component_list(yaml_dict): component_list = list() for role in ROLE_LIST: -- Gitee From d769a8f317b0c1ecec726dcb8caebe691d63d3a6 Mon Sep 17 00:00:00 2001 From: cc <18856836718@163.com> Date: Sat, 30 Mar 2024 10:15:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?devkit=5Finstaller=20=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=99=A8=20=E6=9E=84=E5=BB=BA=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/DevKitWeb/build_devkit_installer.sh | 20 ++ component/build_component.sh | 5 + .../src/handler/connect_check.py | 12 +- .../src/machine/local_machine.py | 303 ------------------ 4 files changed, 27 insertions(+), 313 deletions(-) create mode 100644 component/DevKitWeb/build_devkit_installer.sh delete mode 100644 tools/install_dependency/src/machine/local_machine.py diff --git a/component/DevKitWeb/build_devkit_installer.sh b/component/DevKitWeb/build_devkit_installer.sh new file mode 100644 index 0000000..be01ab9 --- /dev/null +++ b/component/DevKitWeb/build_devkit_installer.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# SourceCode build script +# Copyright: Copyright (c) Huawei Technologies Co., Ltd. All rights reserved. + +set -e +current_dir=$(cd $(dirname "$0"); pwd) +project_dir=$(dirname $(dirname "${current_dir}")) + +umask 077 + +build_dir=${project_dir}/build/devkit_installer +rm -rf "${build_dir}" +mkdir -p "${build_dir}" + +cd "${build_dir}" + +pyinstaller -F "${current_dir}"/devkit_installer/devkit_installer.py -p "${current_dir}"/devkit_installer --name "devkit_installer" + +mkdir -p "${project_dir}"/build/component/DevKitWeb +cp "${build_dir}"/dist/devkit_installer "${project_dir}"/build/component/DevKitWeb diff --git a/component/build_component.sh b/component/build_component.sh index ddb166c..2be9d33 100644 --- a/component/build_component.sh +++ b/component/build_component.sh @@ -22,6 +22,10 @@ function build_devkit_distribute() { bash "${current_dir}"/DevkitDistribute/build_devkit_distribute.sh } +function build_devkit_installer() { + bash "${current_dir}"/DevKitWeb/build_devkit_installer.sh +} + function main() { if [[ -d ${final_component_dir} ]]; then rm -rf "${final_component_dir}" @@ -38,6 +42,7 @@ function main() { build_lkp_tests build_devkit_distribute + build_devkit_installer } main "$@" diff --git a/tools/install_dependency/src/handler/connect_check.py b/tools/install_dependency/src/handler/connect_check.py index 02cf7c5..3392771 100644 --- a/tools/install_dependency/src/handler/connect_check.py +++ b/tools/install_dependency/src/handler/connect_check.py @@ -3,7 +3,6 @@ import socket import constant from handler.handler_and_node import Handler -from machine.local_machine import LocalMachine from machine.machine import Machine from exception.connect_exception import ConnectException from constant import ROLE_COMPONENT, ROLE_LIST @@ -14,23 +13,16 @@ LOGGER = logging.getLogger("install_dependency") class ConnectCheck(Handler): def handle(self, data) -> bool: LOGGER.debug("ConnectCheck start!") - local_ip = ConnectCheck.get_local_ip() data[constant.MACHINE] = dict() ret = True for role in (ROLE_LIST & data.keys()): - ret = ret and ConnectCheck.machine_role_check(data, role, local_ip) + ret = ret and ConnectCheck.machine_role_check(data, role) return ret @staticmethod - def machine_role_check(data, role, local_ip): + def machine_role_check(data, role): builder_list = data.get(role) for ip in builder_list: - if ip == local_ip or ip == "127.0.0.1": - ip = "127.0.0.1" - machine_instance = data[constant.MACHINE].get(ip, LocalMachine(ip)) - machine_instance.add_component(ROLE_COMPONENT[role]) - data[constant.MACHINE][ip] = machine_instance - continue try: machine_instance = data[constant.MACHINE].get(ip, Machine(ip, data[constant.USER], data[constant.PKEY], data.get(constant.PASSWORD, None))) diff --git a/tools/install_dependency/src/machine/local_machine.py b/tools/install_dependency/src/machine/local_machine.py deleted file mode 100644 index fece548..0000000 --- a/tools/install_dependency/src/machine/local_machine.py +++ /dev/null @@ -1,303 +0,0 @@ -import os -import logging -import subprocess - -import constant -from deploy.command_line import CommandLine -from exception.connect_exception import NotMatchedMachineTypeException -from download.download_utils import component_collection_map -from deploy.lkp_collect_map import lkp_collection_map -from utils import (base_path, MKDIR_TMP_DEVKITDEPENDENCIES_CMD, YUM_INSTALL_LKP_DEPENDENCIES_CMD, - CHECK_MIRROR_INSTALL_STATUS, PROMPT_MAP) - -LOGGER = logging.getLogger("install_dependency") -SHELL_FILE_LIST = ["install.sh", "check_install_result.sh"] - - -class LocalMachine: - def __init__(self, ip): - self.ip = ip - self.check_is_aarch64() - self.component_list = [] - self.mirrors = False - - def set_mirror(self): - self.mirrors = True - - def add_component(self, component): - self.component_list.extend(component) - self.component_list = list(set(self.component_list)) - - def get_components(self): - return self.component_list.copy() - - def install_components(self): - if self.mirrors: - self.install_component("OpenEulerMirrorISO") - for component in self.component_list: - self.install_component(component) - if self.mirrors: - self.install_component("UnOpenEulerMirrorISO") - - self.clear_tmp_file_at_local_machine([os.path.join("/tmp/", constant.DEPENDENCY_DIR)]) - - def check_is_aarch64(self): - machine_type = os.uname().machine.lower() - LOGGER.info(f"{self.ip} machine type: {machine_type}") - if machine_type != "aarch64": - LOGGER.error(f"Machine type of {self.ip} is {machine_type}, not aarch64. Please replace this machine.") - raise NotMatchedMachineTypeException() - - def install_component(self, component_name): - try: - self.install_component_handler(component_name) - except (FileNotFoundError, PermissionError, NotADirectoryError, OSError, IOError) as e: - LOGGER.error(f"Local machine {self.ip} occur Error: {str(e)}") - - def install_component_handler(self, component_name): - component_name_to_func_dict = { - "GCCforOpenEuler": self.default_install_component_handle, - "BiShengCompiler": self.default_install_component_handle, - "BiShengJDK17": self.default_install_component_handle, - "BiShengJDK8": self.default_install_component_handle, - "LkpTests": self.lkptest_install_component_handle, - "NonInvasiveSwitching": self.nis_install_component_handle, - "OpenEulerMirrorISO": self.deploy_iso_handle, - "UnOpenEulerMirrorISO": self.undeploy_iso_handle, - "A-FOT": self.install_a_fot, - } - self._local_exec_command(MKDIR_TMP_DEVKITDEPENDENCIES_CMD) - self._local_exec_command(YUM_INSTALL_LKP_DEPENDENCIES_CMD) - return component_name_to_func_dict.get(component_name)(component_name) - - def install_a_fot(self, component_name): - saved_path = os.path.join(constant.DEFAULT_PATH, "a-fot.tar.gz") - remote_file = os.path.abspath(os.path.join('/tmp', saved_path)) - LOGGER.debug(f"Copy local_file: {saved_path} to local machine {self.ip} remote_file: {remote_file}") - self._local_exec_command(f"/bin/cp -f {saved_path} {remote_file}") - self.nis_install_component_handle(component_name) - self.clear_tmp_file_at_local_machine([remote_file]) - - def nis_install_component_handle(self, component_name): - remote_file_list = [] - # 上传并执行 安装脚本, 校验安装结果脚本 - install_result = "" - for shell_file in SHELL_FILE_LIST: - sh_file_local_path = os.path.join(base_path("component"), component_name, shell_file) - sh_file_remote_path = os.path.join("/tmp/", constant.DEPENDENCY_DIR, component_name + shell_file) - sh_cmd = f"bash {sh_file_remote_path}" - execute_output = ( - self.transport_shell_file_and_execute( - sh_file_local_path=sh_file_local_path, - sh_file_remote_path=sh_file_remote_path, - sh_cmd=sh_cmd - )) - remote_file_list.append(sh_file_remote_path) - if shell_file == SHELL_FILE_LIST[1]: - install_result = execute_output - - if install_result == "true": - LOGGER.info(f"Local machine {self.ip} install {component_name} success.") - else: - LOGGER.error(f"Local machine {self.ip} install {component_name} failed.") - # 清理tmp临时文件 - self.clear_tmp_file_at_local_machine(remote_file_list) - - def lkptest_install_component_handle(self, component_name): - self._local_exec_command(MKDIR_TMP_DEVKITDEPENDENCIES_CMD) - self._local_exec_command(YUM_INSTALL_LKP_DEPENDENCIES_CMD) - - # 复制 tar.gz 文件 - LOGGER.info(f"Install component in local machine {self.ip}: {component_name}") - remote_file_list = [] - shell_dict = lkp_collection_map.get(component_name) - for shell_cmd in shell_dict: - url_and_save_path = shell_dict.get(shell_cmd) - local_file = url_and_save_path.get("save_path") - remote_file = os.path.abspath(os.path.join('/tmp', constant.DEPENDENCY_DIR, local_file.split('/')[-1])) - LOGGER.debug(f"Copy local_file: {local_file} to local machine {self.ip} remote_file: {remote_file}") - remote_file_list.append(remote_file) - self._local_exec_command(f"/bin/cp -f {local_file} {remote_file}") - # 上传并执行 安装脚本, 校验安装结果脚本 - install_result = "" - for shell_file in SHELL_FILE_LIST: - sh_file_local_path = os.path.join(base_path("component"), component_name, shell_file) - sh_file_remote_path = os.path.join("/tmp/", constant.DEPENDENCY_DIR, component_name + shell_file) - sh_cmd = f"bash {sh_file_remote_path} {remote_file_list[0]} {remote_file_list[1]}" - execute_output = ( - self.transport_shell_file_and_execute( - sh_file_local_path=sh_file_local_path, - sh_file_remote_path=sh_file_remote_path, - sh_cmd=sh_cmd - )) - remote_file_list.append(sh_file_remote_path) - if shell_file == SHELL_FILE_LIST[1]: - install_result = execute_output - - if install_result == "true": - LOGGER.info(f"Local machine {self.ip} install {component_name} success.") - else: - LOGGER.error(f"Local machine {self.ip} install {component_name} failed.") - # 清理tmp临时文件 - self.clear_tmp_file_at_local_machine(remote_file_list) - self.__install_component_on_lkptest("CompatibilityTesting") - self.__install_component_on_lkptest("DevkitDistribute") - - def __install_component_on_lkptest(self, component_name): - # 复制 tar.gz 文件 - LOGGER.info(f"Install component in local machine {self.ip}: {component_name}") - remote_file_list = [] - shell_dict = lkp_collection_map.get(component_name) - for shell_cmd in shell_dict: - url_and_save_path = shell_dict.get(shell_cmd) - local_file = url_and_save_path.get("save_path") - remote_file = os.path.abspath(os.path.join('/tmp', constant.DEPENDENCY_DIR, local_file.split('/')[-1])) - LOGGER.debug(f"Copy local_file: {local_file} to local machine {self.ip} remote_file: {remote_file}") - remote_file_list.append(remote_file) - self._local_exec_command(f"/bin/cp -f {local_file} {remote_file}") - # 上传并执行 安装脚本, 校验安装结果脚本 - install_result = "" - for shell_file in SHELL_FILE_LIST: - sh_file_local_path = os.path.join(base_path("component"), component_name, shell_file) - sh_file_remote_path = os.path.join("/tmp/", constant.DEPENDENCY_DIR, component_name + shell_file) - sh_cmd = f"bash {sh_file_remote_path} {remote_file_list[0]}" - execute_output = ( - self.transport_shell_file_and_execute( - sh_file_local_path=sh_file_local_path, - sh_file_remote_path=sh_file_remote_path, - sh_cmd=sh_cmd - )) - remote_file_list.append(sh_file_remote_path) - if shell_file == SHELL_FILE_LIST[1]: - install_result = execute_output - - if install_result == "true": - LOGGER.info(f"Local machine {self.ip} install {component_name} success.") - else: - LOGGER.error(f"Local machine {self.ip} install {component_name} failed.") - # 清理tmp临时文件 - self.clear_tmp_file_at_local_machine(remote_file_list) - - def deploy_iso_handle(self, component_name): - # 复制镜像文件 - LOGGER.info(f"Deploy component in local machine {self.ip}: {component_name}") - local_path = os.path.abspath(CommandLine.iso_path) - - # 执行 安装脚本, 校验安装结果脚本 - install_result = "" - for shell_file in SHELL_FILE_LIST: - sh_file_local_path = os.path.join(base_path("component"), component_name, shell_file) - sh_cmd = f"bash {sh_file_local_path} {local_path}" - if not os.path.exists(sh_file_local_path): - LOGGER.error(f"{sh_file_local_path} not exists.") - raise FileNotFoundError(f"local file {sh_file_local_path} not exists.") - - result = subprocess.run(f"{sh_cmd}".split(' '), - capture_output=True, shell=False) - output = result.stdout.decode().strip() - LOGGER.info(f"Local machine {self.ip} exec '{sh_cmd}' output: {output}") - if shell_file == SHELL_FILE_LIST[1]: - install_result = output - - if install_result == "true": - LOGGER.info(f"Remote machine {self.ip} deploy {component_name} success.") - else: - LOGGER.info(f"Remote machine {self.ip} deploy {component_name} failed.") - - def default_install_component_handle(self, component_name): - self._local_exec_command(MKDIR_TMP_DEVKITDEPENDENCIES_CMD) - - # 上传 组件压缩包和校验文件 - LOGGER.info(f"Install component in local machine {self.ip}: {component_name}") - remote_file_list = [] - shell_dict = component_collection_map.get(component_name) - for shell_cmd in shell_dict: - url_and_save_path = shell_dict.get(shell_cmd) - local_file = url_and_save_path.get("save_path") - remote_file = os.path.abspath(os.path.join('/tmp', local_file)) - LOGGER.debug(f"Copy local_file: {local_file} to local machine {self.ip} remote_file: {remote_file}") - remote_file_list.append(remote_file) - self._local_exec_command(f"/bin/cp -f {local_file} {remote_file}") - # 上传并执行 安装脚本, 校验安装结果脚本 - install_result = "" - for shell_file in SHELL_FILE_LIST: - sh_file_local_path = os.path.join(base_path("component"), component_name, shell_file) - sh_file_remote_path = os.path.join("/tmp/", constant.DEPENDENCY_DIR, component_name + shell_file) - sh_cmd = f"bash {sh_file_remote_path}" - execute_output = ( - self.transport_shell_file_and_execute( - sh_file_local_path=sh_file_local_path, - sh_file_remote_path=sh_file_remote_path, - sh_cmd=sh_cmd - )) - remote_file_list.append(sh_file_remote_path) - if shell_file == SHELL_FILE_LIST[1]: - install_result = execute_output - - if install_result == "true": - LOGGER.info(f"Local machine {self.ip} install {component_name} success.") - else: - LOGGER.error(f"Local machine {self.ip} install {component_name} failed.") - # 清理tmp临时文件 - self.clear_tmp_file_at_local_machine(remote_file_list) - - def _local_exec_command(self, cmd): - result = subprocess.run(cmd.split(' '), - capture_output=False, shell=False, stderr=subprocess.STDOUT) - if result.returncode == 0: - LOGGER.debug(f"Local machine {self.ip} exec '{cmd}' success.") - else: - LOGGER.error(f"Local machine {self.ip} exec '{cmd}' failed.") - raise OSError(PROMPT_MAP.get(cmd, f"Local machine {self.ip} exec '{cmd}' failed.")) - - def transport_shell_file_and_execute(self, sh_file_local_path, sh_file_remote_path, sh_cmd): - if not os.path.exists(sh_file_local_path): - LOGGER.error(f"{sh_file_local_path} not exists.") - raise FileNotFoundError(f"local file {sh_file_local_path} not exists.") - - LOGGER.debug(f"Copy local_file: {sh_file_local_path} to local machine {self.ip} " - f"remote_file: {sh_file_remote_path}") - subprocess.run(f"/bin/cp -f {sh_file_local_path} {sh_file_remote_path}".split(' '), - capture_output=False, shell=False, stderr=subprocess.STDOUT) - - result = subprocess.run(f"{sh_cmd}".split(' '), - capture_output=True, shell=False) - output = result.stdout.decode().strip() - LOGGER.info(f"Local machine {self.ip} exec '{sh_cmd}' output: {output}") - return output - - def clear_tmp_file_at_local_machine(self, remote_file_list): - LOGGER.debug(f"Clear tmp file at local machine {self.ip}") - for remote_file in remote_file_list: - try: - remote_file = os.path.realpath(remote_file) - if not remote_file.startswith(os.path.join("/tmp", constant.DEPENDENCY_DIR)): - continue - LOGGER.debug(f"Delete tmp file at local machine {self.ip}: {remote_file}") - subprocess.run(f"rm -fr {remote_file}".split(' '), - capture_output=False, shell=False, stderr=subprocess.STDOUT) - except Exception as e: - LOGGER.debug(str(e)) - - def do_nothing(self, component_name, sftp_client, ssh_client): - return - - def undeploy_iso_handle(self, component_name): - # 需要检查本地镜像是否安装成功 - self._local_exec_command(CHECK_MIRROR_INSTALL_STATUS) - - component_name = component_name.replace("Un", "") - LOGGER.info(f"Umount component in local machine {self.ip}: {component_name}") - - # 执行 卸载脚本 - for shell_file in ["uninstall.sh"]: - sh_file_local_path = os.path.join(base_path("component"), component_name, shell_file) - sh_cmd = f"bash {sh_file_local_path}" - if not os.path.exists(sh_file_local_path): - LOGGER.error(f"{sh_file_local_path} not exists.") - raise FileNotFoundError(f"local file {sh_file_local_path} not exists.") - - result = subprocess.run(f"{sh_cmd}".split(' '), - capture_output=True, shell=False) - output = result.stdout.decode().strip() - LOGGER.info(f"Local machine {self.ip} exec '{sh_cmd}' output: {output}") -- Gitee From 14e6385e76ecb2d5e9aad05534ae9e20a7c86919 Mon Sep 17 00:00:00 2001 From: cc <18856836718@163.com> Date: Sat, 30 Mar 2024 14:18:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20DevKitWeb=20=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=99=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/DevKitWeb/devkit_installer/devkit_machine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component/DevKitWeb/devkit_installer/devkit_machine.py b/component/DevKitWeb/devkit_installer/devkit_machine.py index 2480079..c8000de 100644 --- a/component/DevKitWeb/devkit_installer/devkit_machine.py +++ b/component/DevKitWeb/devkit_installer/devkit_machine.py @@ -82,7 +82,7 @@ class DevKitMachine: LOGGER.error(f"DevKit install package not exists: {package_file}") return False - cmd = f"cd {package_dir} && tar -zxf {package_name}" + cmd = f"cd {package_dir} && sudo tar -zxf {package_name}" stdin, stdout, stderr = ssh_client.exec_command(cmd) exit_status = stdout.channel.recv_exit_status() if exit_status == 0: -- Gitee