From a4ec907fa4b1907f451f674ad32fa3113afbea58 Mon Sep 17 00:00:00 2001 From: bizhiyuan Date: Thu, 5 Dec 2024 14:12:33 +0800 Subject: [PATCH] Update fields for Get interface of Node --- controllers/node.go | 12 ++++++++++-- models/node.go | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/controllers/node.go b/controllers/node.go index c92210c..e867716 100644 --- a/controllers/node.go +++ b/controllers/node.go @@ -1,6 +1,6 @@ /* * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. - * ha-api licensed under the Mulan Permissive Software License, Version 2. + * ha-api licensed under the Mulan Permissive Software License, Version 2. * See LICENSE file for more details. * Author: yangzhao_kl * Date: Fri Jan 8 20:56:40 2021 +0800 @@ -8,8 +8,11 @@ package controllers import ( - "github.com/beego/beego/v2/server/web" + "strings" + "gitee.com/openeuler/ha-api/models" + "gitee.com/openeuler/ha-api/utils" + "github.com/beego/beego/v2/server/web" ) type NodesController struct { @@ -26,6 +29,11 @@ func (nsc *NodesController) Get() { } else { result["action"] = true result["data"] = retData + if len(retData) > 0 { + currentNode, _ := utils.RunCommand(utils.CmdHostName) + currentNodeStr := strings.ReplaceAll(string(currentNode), "\n", "") + result["localnode"] = currentNodeStr + } } nsc.Data["json"] = &result diff --git a/models/node.go b/models/node.go index 98e111e..4df01b9 100644 --- a/models/node.go +++ b/models/node.go @@ -1,6 +1,6 @@ /* * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. - * ha-api licensed under the Mulan Permissive Software License, Version 2. + * ha-api licensed under the Mulan Permissive Software License, Version 2. * See LICENSE file for more details. * Author: yangzhao_kl * Date: Fri Jan 8 20:56:40 2021 +0800 -- Gitee