diff --git a/plugins/ascend-driver-manager/config.yaml b/plugins/ascend-driver-manager/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2937a213d3cb5eb8cc6904aca085f80e50b19077 --- /dev/null +++ b/plugins/ascend-driver-manager/config.yaml @@ -0,0 +1,22 @@ +all: + hosts: + target-host: + ansible_host: 127.0.0.1 # 目标主机IP + ansible_port: 22 # SSH端口号 + ansible_user: root # 必须使用root用户 + ansible_password: "" # root用户密码 + vars: + ansible_ssh_common_args: '-o StrictHostKeyChecking=no' + + # Ascend硬件配置 + chip_type: 310p # 硬件型号,支持: 310p, 910b + version: 25.2.0 # 版本号,310p支持: 25.0.rc1.1/25.2.0, 910b支持: 25.0.rc1.1/25.2.0/25.3.rc1 + + # 文件服务器配置 + file_server_url: https://repo.oepkgs.net/openEuler/rpm/openEuler-24.03-LTS/contrib/oedp/files/Ascend/ + + # 下载配置 + download_path: /tmp/ascend # 下载文件存储路径 + download_checksum: false # 是否启用SHA256校验(需要文件服务器支持) + download_timeout: 600 # 下载超时时间(秒) + download_retry: 3 # 下载重试次数 diff --git a/plugins/ascend-driver-manager/doc/readme.md b/plugins/ascend-driver-manager/doc/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..af0c82f9cc03c15a3b0c86b75dc58ee91cfde9e3 --- /dev/null +++ b/plugins/ascend-driver-manager/doc/readme.md @@ -0,0 +1,135 @@ +# Ascend Driver Manager + +## 插件简介 + +Ascend Driver Manager 是一个用于管理昇腾NPU驱动和固件的oeDeploy插件。该插件支持310p和910b芯片的驱动和固件的自动化安装、卸载和状态查询。 + +## 支持的硬件和版本 + +### 310p芯片 +- 25.0.rc1.1 +- 25.2.0 + +### 910b芯片 +- 25.0.rc1.1 +- 25.2.0 +- 25.3.rc1 + +## 功能特性 + +- **自动化安装**: 自动下载并安装指定版本的驱动和固件 +- **智能检测**: 自动检测系统架构(x86-64/aarch64)和虚拟化环境 +- **版本验证**: 验证用户配置的硬件型号和版本号的合法性 +- **状态查询**: 提供详细的驱动、固件和NPU状态信息 +- **完整卸载**: 支持驱动、固件的完整卸载和环境清理 + +## 使用方法 + +### 1. 配置参数 + +编辑 `config.yaml` 文件,配置以下参数: + +```yaml +all: + hosts: + target-host: + ansible_host: 127.0.0.1 # 目标主机IP + ansible_port: 22 # SSH端口号 + ansible_user: root # 必须使用root用户 + ansible_password: "" # root用户密码 + vars: + chip_type: 310p # 硬件型号: 310p 或 910b + version: 25.2.0 # 版本号 + file_server_url: https://repo.oepkgs.net/openEuler/rpm/openEuler-24.03-LTS/contrib/oedp/files/Ascend/ + download_path: /tmp/ascend # 下载路径 + download_checksum: false # 是否启用SHA256校验(需要文件服务器支持) + download_timeout: 600 # 下载超时时间(秒) + download_retry: 3 # 下载重试次数 +``` + +### 2. 安装驱动和固件 + +```bash +oedp run install +``` + +安装过程包括: +1. 验证配置参数 +2. 安装依赖软件包 +3. 创建用户和组 +4. 下载并安装驱动 +5. 检测物理机环境并安装固件(虚拟机跳过) + +### 3. 卸载驱动和固件 + +```bash +oedp run uninstall +``` + +卸载过程包括: +1. 卸载固件 +2. 卸载驱动 +3. 清理用户、组和临时文件 + +### 4. 查询状态 + +```bash +oedp run status +``` + +状态查询包括: +- 驱动和固件安装状态 +- 用户和组存在状态 +- DKMS状态信息 +- NPU-SMI设备信息 + +## 配置说明 + +### 必需配置 + +- `chip_type`: 硬件型号,支持 `310p` 和 `910b` +- `version`: 版本号,不同芯片支持的版本不同 +- `ansible_host`: 目标主机IP地址 +- `ansible_user`: 必须为 `root` +- `ansible_password`: root用户密码 + +### 可选配置 + +- `file_server_url`: 文件服务器地址,默认为华为云镜像源 +- `download_path`: 下载文件存储路径,默认为 `/tmp/ascend` +- `download_checksum`: 是否启用SHA256校验,默认为 `false`,开启需要文件服务器支持 +- `download_timeout`: 下载超时时间,默认为 600 秒 +- `download_retry`: 下载重试次数,默认为 3 次 + +### 系统用户和组 + +插件会自动创建和管理以下系统用户和组: +- **用户**: `HwHiAiUser` +- **组**: `HwHiAiUser` +- **用户主目录**: `/home/HwHiAiUser` + +这些配置已在代码中固定,无需用户配置。 + +## 注意事项 + +1. **用户权限**: 必须使用root用户执行,因为需要安装系统软件包和内核模块 +2. **网络连接**: 需要能够访问文件服务器下载run包 +3. **虚拟机环境**: 在虚拟机中会自动跳过固件安装,这是正常行为 +4. **重复安装**: 插件会自动检测已安装的组件,避免重复安装 + +## 故障排除 + +### 下载失败 +- 检查网络连接 +- 验证文件服务器地址是否正确 +- 增加重试次数或延长超时时间 + +### 安装失败 +- 确保使用root用户 +- 检查系统是否安装了必需的依赖包 +- 查看安装日志中的错误信息 + +### 状态查询异常 +- 确保驱动已正确安装 +- 检查NPU设备是否正常识别 +- 验证DKMS模块状态 diff --git a/plugins/ascend-driver-manager/main.yaml b/plugins/ascend-driver-manager/main.yaml new file mode 100644 index 0000000000000000000000000000000000000000..aff6cd794f835c68c0a9670985d240efdebd1afd --- /dev/null +++ b/plugins/ascend-driver-manager/main.yaml @@ -0,0 +1,38 @@ +name: ascend-driver-manager +version: 1.0.0 +description: Ascend NPU driver and firmware management plugin +description_zh: 昇腾NPU驱动和固件管理插件,支持310p和910b芯片的驱动和固件安装、卸载及状态查询 +description_en: Ascend NPU driver and firmware management plugin, supports installation, uninstallation and status query for 310p and 910b chips +type: app +localhost_available: true +action: + install: + description: Install Ascend NPU driver and firmware + tasks: + - name: Validate configuration and prepare environment + playbook: prepare.yaml + scope: all + - name: Install Ascend NPU driver + playbook: install-driver.yaml + scope: all + - name: Install Ascend NPU firmware + playbook: install-firmware.yaml + scope: all + uninstall: + description: Uninstall Ascend NPU driver and firmware + tasks: + - name: Uninstall Ascend NPU firmware + playbook: uninstall-firmware.yaml + scope: all + - name: Uninstall Ascend NPU driver + playbook: uninstall-driver.yaml + scope: all + - name: Clean up environment + playbook: cleanup.yaml + scope: all + status: + description: Check Ascend NPU driver and firmware status + tasks: + - name: Check driver and firmware status + playbook: status.yaml + scope: all diff --git a/plugins/ascend-driver-manager/workspace/cleanup.yaml b/plugins/ascend-driver-manager/workspace/cleanup.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c2325113fa5dceba7745b64a813d07690d153677 --- /dev/null +++ b/plugins/ascend-driver-manager/workspace/cleanup.yaml @@ -0,0 +1,57 @@ +--- +- hosts: all + become: yes + gather_facts: yes + tasks: + - name: Check if HwHiAiUser user exists + getent: + database: passwd + key: HwHiAiUser + register: user_exists + ignore_errors: yes + + - name: Check if HwHiAiUser group exists + getent: + database: group + key: HwHiAiUser + register: group_exists + ignore_errors: yes + + - name: Remove HwHiAiUser user + user: + name: HwHiAiUser + state: absent + remove: yes + when: user_exists is succeeded + register: user_removal + + - name: Remove HwHiAiUser group + group: + name: HwHiAiUser + state: absent + when: group_exists is succeeded + register: group_removal + + - name: Display cleanup result + debug: + msg: + - "==========================================" + - "环境清理结果" + - "==========================================" + - "用户 HwHiAiUser: {{ '已删除' if (user_exists is succeeded and user_removal is succeeded) else '不存在或删除失败' }}" + - "组 HwHiAiUser: {{ '已删除' if (group_exists is succeeded and group_removal is succeeded) else '不存在或删除失败' }}" + - "==========================================" + + - name: Clean up download directory + file: + path: "{{ download_path }}" + state: absent + ignore_errors: yes + + - name: Display final cleanup status + debug: + msg: + - "==========================================" + - "清理完成" + - "下载目录 {{ download_path }} 已清理" + - "==========================================" diff --git a/plugins/ascend-driver-manager/workspace/download.sh b/plugins/ascend-driver-manager/workspace/download.sh new file mode 100755 index 0000000000000000000000000000000000000000..712f46f64d180c0ce599877a11a691b0dd0e5985 --- /dev/null +++ b/plugins/ascend-driver-manager/workspace/download.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +download_url=$1 +store_path=$2 +check=$3 +timeout=$4 +retry=$5 + +download_file=$(basename "$download_url") + +download_file_with_retry() { + local url=$1 + local dest=$2 + local retries=$3 + local timeout=$4 + local attempt=0 + + while [ $attempt -lt $retries ]; do + echo "Attempt $(($attempt + 1)) to download $url..." + curl -fL -C - --max-time "$timeout" -o "$dest" "$url" + if [ $? -eq 0 ]; then + return 0 + fi + attempt=$(($attempt + 1)) + done + + return 1 +} + +# 关闭sha256校验 +if [ "$check" -eq 0 ]; then + download_file_with_retry "$download_url" "$store_path/$download_file" "$retry" "$timeout" + if [ $? -eq 0 ]; then + echo "Download succeeded." + exit 0 + else + echo "Download failed." + exit 1 + fi +fi + +# 打开sha256校验 +if [ "$check" -eq 1 ]; then + sha256sum_url="${download_url}.sha256sum" + sha256sum_file="$store_path/${download_file}.sha256sum" + curl -sfL --max-time 60 -o "$sha256sum_file" "$sha256sum_url" + if [ $? -ne 0 ]; then + echo "Failed to download SHA256 checksum file." + exit 1 + fi + + remote_sum=$(cat "$sha256sum_file" | awk '{print $1}') + + local_file="$store_path/$download_file" + if [ -f "$local_file" ]; then + local_sum=$(sha256sum "$local_file" | awk '{print $1}') + if [ "$local_sum" == "$remote_sum" ]; then + echo "Local file checksum matches remote checksum." + exit 0 + fi + fi + + attempt=0 + while [ $attempt -lt $retry ]; do + echo "Attempt $(($attempt + 1)) to download $download_url and verify checksum..." + download_file_with_retry "$download_url" "$local_file" 1 "$timeout" + if [ $? -ne 0 ]; then + echo "Download failed." + attempt=$(($attempt + 1)) + continue + fi + + local_sum=$(sha256sum "$local_file" | awk '{print $1}') + if [ "$local_sum" == "$remote_sum" ]; then + echo "Checksum matches. Download succeeded." + exit 0 + fi + + attempt=$(($attempt + 1)) + done + + echo "Checksum verification failed after $retry attempts." + exit 1 +fi + +echo "Invalid check parameter. Must be 0 or 1." +exit 1 \ No newline at end of file diff --git a/plugins/ascend-driver-manager/workspace/install-driver.yaml b/plugins/ascend-driver-manager/workspace/install-driver.yaml new file mode 100644 index 0000000000000000000000000000000000000000..df4cf2b4ff26c3654dbbd0cd2a63374dbeb7882f --- /dev/null +++ b/plugins/ascend-driver-manager/workspace/install-driver.yaml @@ -0,0 +1,86 @@ +--- +- hosts: all + become: yes + gather_facts: yes + tasks: + - name: Load version mapping configuration + include_vars: version_mapping.yaml + + - name: Get system architecture + set_fact: + system_arch: "{{ 'x86-64' if ansible_architecture == 'x86_64' else 'aarch64' }}" + + - name: Set driver package name + set_fact: + driver_package: "{{ version_mapping[chip_type][version]['driver'][system_arch] }}" + + - name: Check if driver is already installed + stat: + path: /usr/local/Ascend/driver/script/uninstall.sh + register: driver_installed + + - name: Skip driver installation if already installed + debug: + msg: + - "==========================================" + - "Ascend 驱动已经安装,跳过安装步骤" + - "==========================================" + when: driver_installed.stat.exists + + - name: Install Ascend driver + block: + - name: Download driver package + script: > + download.sh + "{{ file_server_url }}{{ driver_package }}" + "{{ download_path }}" + "{{ download_checksum | int }}" + "{{ download_timeout }}" + "{{ download_retry }}" + register: download_result + + - name: Display download result + debug: + msg: "{{ download_result.stdout_lines }}" + + - name: Fail if download failed + fail: + msg: "Failed to download driver package" + when: download_result.rc != 0 + + - name: Make driver package executable + file: + path: "{{ download_path }}/{{ driver_package }}" + mode: '0755' + + - name: Install Ascend driver + shell: | + cd {{ download_path }} + ./{{ driver_package }} --full --install-for-all + register: install_result + ignore_errors: yes + + - name: Display driver installation result + debug: + msg: + - "==========================================" + - "Ascend 驱动安装结果" + - "==========================================" + - "{{ install_result.stdout_lines | default([]) }}" + - "{{ install_result.stderr_lines | default([]) }}" + - "返回码: {{ install_result.rc }}" + - "==========================================" + + - name: Check driver installation status + stat: + path: /usr/local/Ascend/driver/script/uninstall.sh + register: driver_check + + - name: Driver installation status + debug: + msg: + - "==========================================" + - "驱动安装状态: {{ '成功' if driver_check.stat.exists else '失败' }}" + - "==========================================" + + when: not driver_installed.stat.exists diff --git a/plugins/ascend-driver-manager/workspace/install-firmware.yaml b/plugins/ascend-driver-manager/workspace/install-firmware.yaml new file mode 100644 index 0000000000000000000000000000000000000000..80d0c4818af04f22ef1174b0f5dc2c1df9938aa6 --- /dev/null +++ b/plugins/ascend-driver-manager/workspace/install-firmware.yaml @@ -0,0 +1,119 @@ +--- +- hosts: all + become: yes + gather_facts: yes + tasks: + - name: Load version mapping configuration + include_vars: version_mapping.yaml + + - name: Set firmware package name + set_fact: + firmware_package: "{{ version_mapping[chip_type][version]['firmware'] }}" + + - name: Check if running on physical machine + shell: | + if [ -d /sys/firmware/efi ] || [ -d /sys/firmware/acpi ]; then + # Check for virtualization + if command -v systemd-detect-virt >/dev/null 2>&1; then + if systemd-detect-virt -q; then + echo "virtual" + else + echo "physical" + fi + elif [ -f /proc/cpuinfo ]; then + if grep -q "hypervisor\|QEMU\|VMware\|VirtualBox\|Xen" /proc/cpuinfo; then + echo "virtual" + else + echo "physical" + fi + else + echo "physical" + fi + else + echo "physical" + fi + register: machine_type + changed_when: false + + - name: Skip firmware installation on virtual machine + debug: + msg: + - "==========================================" + - "检测到虚拟机环境,跳过固件安装" + - "==========================================" + when: machine_type.stdout == "virtual" + + - name: Install firmware on physical machine + block: + - name: Check if firmware is already installed + stat: + path: /usr/local/Ascend/firmware/script/uninstall.sh + register: firmware_installed + + - name: Skip firmware installation if already installed + debug: + msg: + - "==========================================" + - "Ascend 固件已经安装,跳过安装步骤" + - "==========================================" + when: firmware_installed.stat.exists + + - name: Install Ascend firmware + block: + - name: Download firmware package + script: > + download.sh + "{{ file_server_url }}{{ firmware_package }}" + "{{ download_path }}" + "{{ download_checksum | int }}" + "{{ download_timeout }}" + "{{ download_retry }}" + register: download_result + + - name: Display download result + debug: + msg: "{{ download_result.stdout_lines }}" + + - name: Fail if download failed + fail: + msg: "Failed to download firmware package" + when: download_result.rc != 0 + + - name: Make firmware package executable + file: + path: "{{ download_path }}/{{ firmware_package }}" + mode: '0755' + + - name: Install Ascend firmware + shell: | + cd {{ download_path }} + ./{{ firmware_package }} --full + register: install_result + ignore_errors: yes + + - name: Display firmware installation result + debug: + msg: + - "==========================================" + - "Ascend 固件安装结果" + - "==========================================" + - "{{ install_result.stdout_lines | default([]) }}" + - "{{ install_result.stderr_lines | default([]) }}" + - "返回码: {{ install_result.rc }}" + - "==========================================" + + - name: Check firmware installation status + stat: + path: /usr/local/Ascend/firmware/script/uninstall.sh + register: firmware_check + + - name: Firmware installation status + debug: + msg: + - "==========================================" + - "固件安装状态: {{ '成功' if firmware_check.stat.exists else '失败' }}" + - "==========================================" + + when: not firmware_installed.stat.exists + + when: machine_type.stdout == "physical" diff --git a/plugins/ascend-driver-manager/workspace/prepare.yaml b/plugins/ascend-driver-manager/workspace/prepare.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9eed2ef6643cbc7b06cb7bda9d039ac1a4b09cf6 --- /dev/null +++ b/plugins/ascend-driver-manager/workspace/prepare.yaml @@ -0,0 +1,73 @@ +--- +- hosts: all + become: yes + gather_facts: yes + tasks: + - name: Load version mapping configuration + include_vars: version_mapping.yaml + + - name: Validate chip type + fail: + msg: "Unsupported chip type: {{ chip_type }}. Supported types: 310p, 910b" + when: chip_type not in version_mapping + + - name: Validate version for chip type + fail: + msg: "Unsupported version {{ version }} for chip type {{ chip_type }}. Supported versions: {{ version_mapping[chip_type].keys() | list }}" + when: version not in version_mapping[chip_type] + + - name: Get system architecture + set_fact: + system_arch: "{{ 'x86-64' if ansible_architecture == 'x86_64' else 'aarch64' }}" + + - name: Set driver and firmware package names + set_fact: + driver_package: "{{ version_mapping[chip_type][version]['driver'][system_arch] }}" + firmware_package: "{{ version_mapping[chip_type][version]['firmware'] }}" + + - name: Display configuration information + debug: + msg: + - "==========================================" + - "Ascend Driver Manager 配置信息" + - "==========================================" + - "硬件型号: {{ chip_type }}" + - "版本号: {{ version }}" + - "系统架构: {{ system_arch }}" + - "驱动包: {{ driver_package }}" + - "固件包: {{ firmware_package }}" + - "文件服务器: {{ file_server_url }}" + - "下载路径: {{ download_path }}" + - "==========================================" + + - name: Install required packages + yum: + name: + - make + - dkms + - gcc + - "kernel-headers-{{ ansible_kernel }}" + - "kernel-devel-{{ ansible_kernel }}" + - net-tools + - python3-libselinux + state: present + + - name: Create download directory + file: + path: "{{ download_path }}" + state: directory + mode: '0755' + + - name: Check if HwHiAiUser group exists + group: + name: HwHiAiUser + state: present + + - name: Check if HwHiAiUser user exists + user: + name: HwHiAiUser + group: HwHiAiUser + home: /home/HwHiAiUser + shell: /bin/bash + create_home: yes + state: present diff --git a/plugins/ascend-driver-manager/workspace/status.yaml b/plugins/ascend-driver-manager/workspace/status.yaml new file mode 100644 index 0000000000000000000000000000000000000000..54016c8e8e750706c8e742349137de78843d81de --- /dev/null +++ b/plugins/ascend-driver-manager/workspace/status.yaml @@ -0,0 +1,85 @@ +--- +- hosts: all + become: yes + gather_facts: yes + tasks: + - name: Check DKMS status + shell: dkms status + register: dkms_status + ignore_errors: yes + changed_when: false + + - name: Check NPU-SMI info + shell: npu-smi info + register: npu_smi_info + ignore_errors: yes + changed_when: false + + - name: Check driver installation status + stat: + path: /usr/local/Ascend/driver/script/uninstall.sh + register: driver_installed + + - name: Check firmware installation status + stat: + path: /usr/local/Ascend/firmware/script/uninstall.sh + register: firmware_installed + + - name: Check Ascend user and group + block: + - name: Check if HwHiAiUser user exists + getent: + database: passwd + key: HwHiAiUser + register: user_exists + ignore_errors: yes + + - name: Check if HwHiAiUser group exists + getent: + database: group + key: HwHiAiUser + register: group_exists + ignore_errors: yes + + - name: Display comprehensive status + debug: + msg: + - "==========================================" + - "Ascend NPU 状态信息" + - "==========================================" + - "驱动状态: {{ '已安装' if driver_installed.stat.exists else '未安装' }}" + - "固件状态: {{ '已安装' if firmware_installed.stat.exists else '未安装' }}" + - "用户 HwHiAiUser: {{ '存在' if user_exists is succeeded else '不存在' }}" + - "组 HwHiAiUser: {{ '存在' if group_exists is succeeded else '不存在' }}" + - "==========================================" + + - name: Display DKMS status + debug: + msg: + - "==========================================" + - "DKMS 状态" + - "==========================================" + - "{{ dkms_status.stdout_lines | default(['DKMS命令执行失败']) }}" + - "返回码: {{ dkms_status.rc }}" + - "==========================================" + + - name: Display NPU-SMI info + debug: + msg: + - "==========================================" + - "NPU-SMI 信息" + - "==========================================" + - "{{ npu_smi_info.stdout_lines | default(['NPU-SMI命令执行失败']) }}" + - "返回码: {{ npu_smi_info.rc }}" + - "==========================================" + + - name: Display error information if commands failed + debug: + msg: + - "==========================================" + - "错误信息" + - "==========================================" + - "DKMS错误: {{ dkms_status.stderr_lines | default(['无']) }}" + - "NPU-SMI错误: {{ npu_smi_info.stderr_lines | default(['无']) }}" + - "==========================================" + when: dkms_status.rc != 0 or npu_smi_info.rc != 0 diff --git a/plugins/ascend-driver-manager/workspace/uninstall-driver.yaml b/plugins/ascend-driver-manager/workspace/uninstall-driver.yaml new file mode 100644 index 0000000000000000000000000000000000000000..60b16d8e56fe767893bf3002fa5f094fae43525e --- /dev/null +++ b/plugins/ascend-driver-manager/workspace/uninstall-driver.yaml @@ -0,0 +1,49 @@ +--- +- hosts: all + become: yes + gather_facts: yes + tasks: + - name: Check if driver is installed + stat: + path: /usr/local/Ascend/driver/script/uninstall.sh + register: driver_installed + + - name: Skip driver uninstallation if not installed + debug: + msg: + - "==========================================" + - "Ascend 驱动未安装,跳过卸载步骤" + - "==========================================" + when: not driver_installed.stat.exists + + - name: Uninstall Ascend driver + block: + - name: Execute driver uninstall script + shell: /usr/local/Ascend/driver/script/uninstall.sh + register: uninstall_result + ignore_errors: yes + + - name: Display driver uninstallation result + debug: + msg: + - "==========================================" + - "Ascend 驱动卸载结果" + - "==========================================" + - "{{ uninstall_result.stdout_lines | default([]) }}" + - "{{ uninstall_result.stderr_lines | default([]) }}" + - "返回码: {{ uninstall_result.rc }}" + - "==========================================" + + - name: Check driver uninstallation status + stat: + path: /usr/local/Ascend/driver/script/uninstall.sh + register: driver_check + + - name: Driver uninstallation status + debug: + msg: + - "==========================================" + - "驱动卸载状态: {{ '成功' if not driver_check.stat.exists else '失败' }}" + - "==========================================" + + when: driver_installed.stat.exists diff --git a/plugins/ascend-driver-manager/workspace/uninstall-firmware.yaml b/plugins/ascend-driver-manager/workspace/uninstall-firmware.yaml new file mode 100644 index 0000000000000000000000000000000000000000..988b9bbaa4cd3b15c9b738f8a66d12456e4cfd13 --- /dev/null +++ b/plugins/ascend-driver-manager/workspace/uninstall-firmware.yaml @@ -0,0 +1,49 @@ +--- +- hosts: all + become: yes + gather_facts: yes + tasks: + - name: Check if firmware is installed + stat: + path: /usr/local/Ascend/firmware/script/uninstall.sh + register: firmware_installed + + - name: Skip firmware uninstallation if not installed + debug: + msg: + - "==========================================" + - "Ascend 固件未安装,跳过卸载步骤" + - "==========================================" + when: not firmware_installed.stat.exists + + - name: Uninstall Ascend firmware + block: + - name: Execute firmware uninstall script + shell: /usr/local/Ascend/firmware/script/uninstall.sh + register: uninstall_result + ignore_errors: yes + + - name: Display firmware uninstallation result + debug: + msg: + - "==========================================" + - "Ascend 固件卸载结果" + - "==========================================" + - "{{ uninstall_result.stdout_lines | default([]) }}" + - "{{ uninstall_result.stderr_lines | default([]) }}" + - "返回码: {{ uninstall_result.rc }}" + - "==========================================" + + - name: Check firmware uninstallation status + stat: + path: /usr/local/Ascend/firmware/script/uninstall.sh + register: firmware_check + + - name: Firmware uninstallation status + debug: + msg: + - "==========================================" + - "固件卸载状态: {{ '成功' if not firmware_check.stat.exists else '失败' }}" + - "==========================================" + + when: firmware_installed.stat.exists diff --git a/plugins/ascend-driver-manager/workspace/version_mapping.yaml b/plugins/ascend-driver-manager/workspace/version_mapping.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ab1585b9d8bb4e96838323d6cac7d0918dc623e4 --- /dev/null +++ b/plugins/ascend-driver-manager/workspace/version_mapping.yaml @@ -0,0 +1,31 @@ +# Ascend硬件型号、版本号与run包对应关系配置文件 +# 用于管理不同硬件型号和版本的驱动、固件包名称 + +version_mapping: + 310p: + 25.0.rc1.1: + driver: + aarch64: Ascend-hdk-310p-npu-driver_25.0.rc1.1_linux-aarch64.run + x86-64: Ascend-hdk-310p-npu-driver_25.0.rc1.1_linux-x86-64.run + firmware: Ascend-hdk-310p-npu-firmware_7.7.0.1.231.run + 25.2.0: + driver: + aarch64: Ascend-hdk-310p-npu-driver_25.2.0_linux-aarch64.run + x86-64: Ascend-hdk-310p-npu-driver_25.2.0_linux-x86-64.run + firmware: Ascend-hdk-310p-npu-firmware_7.7.0.6.236.run + 910b: + 25.0.rc1.1: + driver: + aarch64: Ascend-hdk-910b-npu-driver_25.0.rc1.1_linux-aarch64.run + x86-64: Ascend-hdk-910b-npu-driver_25.0.rc1.1_linux-x86-64.run + firmware: Ascend-hdk-910b-npu-firmware_7.7.0.1.231.run + 25.2.0: + driver: + aarch64: Ascend-hdk-910b-npu-driver_25.2.0_linux-aarch64.run + x86-64: Ascend-hdk-910b-npu-driver_25.2.0_linux-x86-64.run + firmware: Ascend-hdk-910b-npu-firmware_7.7.0.6.236.run + 25.3.rc1: + driver: + aarch64: Ascend-hdk-910b-npu-driver_25.3.rc1_linux-aarch64.run + x86-64: Ascend-hdk-910b-npu-driver_25.3.rc1_linux-x86-64.run + firmware: Ascend-hdk-910b-npu-firmware_7.8.0.2.212.run