From f52e6ead45ec68108c3d4f7bdd3f7e6f181d1737 Mon Sep 17 00:00:00 2001 From: liupei Date: Tue, 11 Nov 2025 17:01:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=99=BA=E8=83=BD=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E5=8A=9F=E8=83=BD=E4=B8=AD=EF=BC=8C=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=99=BA=E8=83=BD=E8=BF=81=E7=A7=BB=E5=AF=B9=E5=BA=94=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/health.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 models/health.go diff --git a/models/health.go b/models/health.go new file mode 100644 index 0000000..56d31b0 --- /dev/null +++ b/models/health.go @@ -0,0 +1,32 @@ +/* + * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. + * ha-api licensed under the Mulan Permissive Software License, Version 2. + * See LICENSE file for more details. + * Author: liupei + * Date: Fri Jul 04 15:54:28 2025 +0800 + */ + + package models + + import ( + "encoding/json" + "strconv" + "strings" + + "gitee.com/openeuler/ha-api/utils" + "github.com/chai2010/gettext-go" + ) + + // 获取cib文件中智能迁移资源对应的属性的值 +func getIndexValue(resName, indexName string) string { + getIndex := "cibadmin --query --xpath " + "\"//clone[@id='" + resName + "']//primitive//instance_attributes//nvpair[@name='" + indexName + "']\"" + _, err := utils.RunCommand(getIndex) + if err == nil { + value := getIndex + " | awk -F 'value=\"|\"/>' '{print $2}'" + res, _ := utils.RunCommand(value) + // 不加strings.TrimSpace在go的返回有\n + return strings.TrimSpace(string(res)) + } else { + return "" + } +} \ No newline at end of file -- Gitee