diff --git a/ha-api.mo b/ha-api.mo index 68fc369be9eee61965c304c1de06e12b6f2504a9..6385b1d74f4853db17a345ed442e3029325e59b7 100644 Binary files a/ha-api.mo and b/ha-api.mo differ diff --git a/resource.py b/resource.py index 46b5d390af6111bb8497ff698df513e2b7a1a200..1ef1a53fe9dc0660b10d71e27cfbe5febe3cfce6 100644 --- a/resource.py +++ b/resource.py @@ -992,9 +992,25 @@ def resource_action(rsc_id, action, data): rsc_id ) + " --set-parameter target-role --meta --parameter-value started" status, output = common_utils.run_cmd(cmd_str) + cmd_target_role = "crm_resource --resource " + str(rsc_id) + " --query-xml" + status, output = common_utils.run_cmd(cmd_target_role) # 输出为xml格式 + xml_data = output.split(":\n") + xml = xml_data[1] + doc = xmltodict.parse(xml) + for i in doc: + if i == "clone": + value = doc["clone"]["primitive"]["meta_attributes"]["nvpair"]["@value"] + elif i == "group": + value = doc["group"]["meta_attributes"]["nvpair"]["@value"] + else: + value = doc["primitive"]["meta_attributes"]["nvpair"]["@value"] + if value == "stopped": + return {'action': False, 'error': _("The resource failed to start because of a problem")} if status != 0: return {'action': False, 'error': _(output)} - return {"action": True, "info": _("Action on resource success")} + else: + return {"action": True, "info": _("Action on resource success")} + if str(action) == "stop": cmd_str = cmd + str( rsc_id @@ -1427,7 +1443,7 @@ def create_resource(data): if rsc_id is resource_id['id'] or rsc_id == resource_id['id']: return { 'action': False, - 'error': " %s Resources already exist" % (str(rsc_id)) + 'error': "id: %s " "资源已经存在" % str(rsc_id) } if "provider" in data: provider = " provider=\"" + str(data["provider"]) + "\"" @@ -1489,7 +1505,7 @@ def create_resource(data): if rsc_id is resource_id['id'] or rsc_id == resource_id['id']: return { 'action': False, - 'error': " %s Resources already exist" % (str(rsc_id)) + 'error': "id: %s " "组资源已经存在" % str(rsc_id) } for r in rscs: cmd_str = cmd_str + " " + str(r) @@ -1774,6 +1790,7 @@ def get_resource_info_by_rsc_id(rsc_id): def get_meta_and_inst(rsc_id): cmd_str = "crm_resource --resource " + str(rsc_id) + " --query-xml" status, output = common_utils.run_cmd(cmd_str) # 输出为xml格式 + print(output) if status != 0: return {'action': False, 'error': _(output)} # format diff --git a/zh_CN.po b/zh_CN.po index a6e66afd7f8794f58949887353436fcf70b76fd2..46eb1789caedb48a9ea2e56aff37944b4c21a126 100644 --- a/zh_CN.po +++ b/zh_CN.po @@ -3172,7 +3172,7 @@ msgid "Then Action" msgstr "然后操作" msgid "There are running resources in the cluster, please close first" -msgstr "集群中有运行的资源,请先关闭" +msgstr "请先停止集群中运行的节点" msgid "Change cluster success" msgstr "改变集群成功" @@ -3183,6 +3183,12 @@ msgstr "更改节点状态成功" msgid "Change node status Failed" msgstr "更改节点状态失败" +msgid "Resources already exist" +msgstr "资源已经存在" + +msgid "The resource failed to start because of a problem" +msgstr "资源存在问题 启动失败" + msgid "error info" msgstr "更改节点信息错误"