1 Star 0 Fork 16

wubijie/fence-agents

forked from src-openEuler/fence-agents 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001-fix-fail_usage-issue.patch 3.19 KB
一键复制 编辑 原始数据 按行查看 历史
From ed3ce39ac322edc0c764c8347aab79efcd6785ce Mon Sep 17 00:00:00 2001
From: wubijie <wubijie@kylinos.cn>
Date: Tue, 22 Aug 2023 19:08:34 +0800
Subject: [PATCH] fix fail_usage() issue
---
agents/openstack/fence_openstack.py | 11 ++++++-----
tests/data/metadata/fence_openstack.xml | 6 +++---
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/agents/openstack/fence_openstack.py b/agents/openstack/fence_openstack.py
index 5257ec5..1a1218c 100755
--- a/agents/openstack/fence_openstack.py
+++ b/agents/openstack/fence_openstack.py
@@ -114,7 +114,7 @@ def define_new_opts():
"longopt" : "uuid",
"help" : "--uuid=[uuid] Replaced by -n, --plug",
"required" : "0",
- "shortdesc" : "Replaced by port",
+ "shortdesc" : "Replaced by port/-n/--plug",
"order": 1
}
@@ -126,6 +126,7 @@ def main():
"port", "no_port", "uuid" ]
define_new_opts()
+ all_opt["port"]["required"] = "0"
all_opt["port"]["help"] = "-n, --plug=[UUID] UUID of the node to be fenced"
all_opt["port"]["shortdesc"] = "UUID of the node to be fenced."
@@ -138,10 +139,10 @@ def main():
if "--uuid" in options:
options["--plug"] = options["--uuid"]
del options["--uuid"]
- elif options["--action"] in ["off", "on", "reboot", "status"] \
- and "--plug" not in options:
- fail_usage("Failed: You have to enter plug number or machine identification", stop)
-
+ elif "--help" not in options and options["--action"] in ["off", "on", \
+ "reboot", "status", "validate-all"] and "--plug" not in options:
+ stop_after_error = False if options["--action"] == "validate-all" else True
+ fail_usage("Failed: You have to enter plug number or machine identification", stop_after_error)
docs = {}
docs["shortdesc"] = "Fence agent for OpenStack's Nova service"
docs["longdesc"] = "fence_openstack is a Fencing agent \
diff --git a/tests/data/metadata/fence_openstack.xml b/tests/data/metadata/fence_openstack.xml
index a7b2594..3a799f4 100644
--- a/tests/data/metadata/fence_openstack.xml
+++ b/tests/data/metadata/fence_openstack.xml
@@ -43,12 +43,12 @@
<content type="string" />
<shortdesc lang="en">Script to run to retrieve password</shortdesc>
</parameter>
- <parameter name="plug" unique="0" required="1" obsoletes="port">
+ <parameter name="plug" unique="0" required="0" obsoletes="port">
<getopt mixed="-n, --plug=[UUID]" />
<content type="string" />
<shortdesc lang="en">UUID of the node to be fenced.</shortdesc>
</parameter>
- <parameter name="port" unique="0" required="1" deprecated="1">
+ <parameter name="port" unique="0" required="0" deprecated="1">
<getopt mixed="-n, --plug=[UUID]" />
<content type="string" />
<shortdesc lang="en">UUID of the node to be fenced.</shortdesc>
@@ -91,7 +91,7 @@
<parameter name="uuid" unique="0" required="0">
<getopt mixed="--uuid=[uuid]" />
<content type="string" />
- <shortdesc lang="en">Replaced by port</shortdesc>
+ <shortdesc lang="en">Replaced by port/-n/--plig</shortdesc>
</parameter>
<parameter name="quiet" unique="0" required="0">
<getopt mixed="-q, --quiet" />
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wubijie123/fence-agents.git
git@gitee.com:wubijie123/fence-agents.git
wubijie123
fence-agents
fence-agents
master

搜索帮助