diff --git a/models/cluster.go b/models/cluster.go index d154c0248f2bedd3a71cc3d82880553c42baa446..f764e9afb1ae4dcdf5544f2f52397eed8429e447 100644 --- a/models/cluster.go +++ b/models/cluster.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 @@ -366,6 +366,12 @@ func getClusterPropertyFromXml(e *etree.Element) map[string]interface{} { func OperationClusterAction(action string) map[string]interface{} { result := map[string]interface{}{} + if action == "" { + result["action"] = false + result["error"] = gettext.Gettext("Action on node failed") + return result + } + if action == "start" { utils.RunCommand(utils.CmdStartCluster) } @@ -376,15 +382,10 @@ func OperationClusterAction(action string) map[string]interface{} { utils.RunCommand(utils.CmdStopClusterLocal) utils.RunCommand(utils.CmdStartCluster) } - if action == "" { - result["action"] = false - result["error"] = gettext.Gettext("Action on node failed") - return result - } else { - result["action"] = true - result["info"] = gettext.Gettext("Action on node success") - return result - } + + result["action"] = true + result["info"] = gettext.Gettext("Action on node success") + return result } func getResourceStickiness() int { diff --git a/models/heartbeat.go b/models/heartbeat.go index 845522d8b2b17bff19a3ee282ef333764d1c796c..b91685883fe4af3b1a949d5f0c9c26eb0d19cf2c 100644 --- a/models/heartbeat.go +++ b/models/heartbeat.go @@ -194,6 +194,13 @@ func AddLink(linkIds string) error { return err } +func EditLinks(hbInfo map[string]string, linkId string) error { + hbInfoStr := GenerateLinkStr(hbInfo) + cmd := fmt.Sprintf(utils.CmdUpdateLinkForce, hbInfoStr, linkId) + _, err := utils.RunCommand(cmd) + return err +} + func GenerateLinkStr(data map[string]string) string { var linkStr strings.Builder for k, v := range data { diff --git a/utils/command.go b/utils/command.go index 858f37d4bc6bd3a17fb810e215616861e30bbb80..2d0ac6e95e8bf1c218e6ca09df0abd7e58b21165 100644 --- a/utils/command.go +++ b/utils/command.go @@ -95,6 +95,8 @@ const ( CmdAddLinkForce = "pcs cluster link add %s --force" CmdAddLinksWithLinkNum = "pcs cluster link add %s options linknumber=%s --force" CmdHbStatus = "corosync-cfgtool -n" + CmdUpdateLink = "pcs cluster link update %s %s" + CmdUpdateLinkForce = CmdUpdateLink + " --force" ) // RunCommand runs the command and get the result