|
|
09283b |
From 0aacfcf209c473ab4c1fff4de653a673b92484de Mon Sep 17 00:00:00 2001
|
|
|
09283b |
From: Marek 'marx' Grac <mgrac@redhat.com>
|
|
|
09283b |
Date: Wed, 19 Aug 2015 09:55:06 +0200
|
|
|
09283b |
Subject: [PATCH] fence_virsh: Add --missing-as-off option
|
|
|
09283b |
|
|
|
09283b |
Resolves: rhbz#1254821
|
|
|
09283b |
---
|
|
|
09283b |
fence/agents/virsh/fence_virsh.py | 4 +++-
|
|
|
09283b |
tests/data/metadata/fence_virsh.xml | 5 +++++
|
|
|
09283b |
2 files changed, 8 insertions(+), 1 deletion(-)
|
|
|
09283b |
|
|
|
09283b |
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
|
|
|
09283b |
index 0a94136..24d360c 100644
|
|
|
09283b |
--- a/fence/agents/virsh/fence_virsh.py
|
|
|
09283b |
+++ b/fence/agents/virsh/fence_virsh.py
|
|
|
09283b |
@@ -54,6 +54,8 @@ def get_power_status(conn, options):
|
|
|
09283b |
for line in conn.before.splitlines():
|
|
|
09283b |
if line.strip() in ["running", "blocked", "idle", "no state", "paused"]:
|
|
|
09283b |
return "on"
|
|
|
09283b |
+ if "error: failed to get domain" in line.strip() and options.has_key("missing_as_off"):
|
|
|
09283b |
+ return "off"
|
|
|
09283b |
if "error:" in line.strip():
|
|
|
09283b |
fail_usage("Failed: You have to enter existing name/UUID of virtual machine!")
|
|
|
09283b |
|
|
|
09283b |
@@ -68,7 +70,7 @@ def set_power_status(conn, options):
|
|
|
09283b |
time.sleep(int(options["--power-wait"]))
|
|
|
09283b |
|
|
|
09283b |
def main():
|
|
|
09283b |
- device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", "port", "sudo"]
|
|
|
09283b |
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", "port", "sudo", "missing_as_off"]
|
|
|
09283b |
|
|
|
09283b |
atexit.register(atexit_handler)
|
|
|
09283b |
|
|
|
09283b |
diff --git a/tests/data/metadata/fence_virsh.xml b/tests/data/metadata/fence_virsh.xml
|
|
|
09283b |
index 642c72e..d664fc4 100644
|
|
|
09283b |
--- a/tests/data/metadata/fence_virsh.xml
|
|
|
09283b |
+++ b/tests/data/metadata/fence_virsh.xml
|
|
|
09283b |
@@ -105,6 +105,11 @@ By default, virsh needs root account to do properly work. So you must allow ssh
|
|
|
09283b |
<content type="string" default="5" />
|
|
|
09283b |
<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
|
|
|
09283b |
</parameter>
|
|
|
09283b |
+ <parameter name="missing_as_off" unique="0" required="0">
|
|
|
09283b |
+ <getopt mixed="--missing-as-off" />
|
|
|
09283b |
+ <content type="boolean" />
|
|
|
09283b |
+ <shortdesc lang="en">Missing port returns OFF instead of failure</shortdesc>
|
|
|
09283b |
+ </parameter>
|
|
|
09283b |
<parameter name="power_timeout" unique="0" required="0">
|
|
|
09283b |
<getopt mixed="--power-timeout=[seconds]" />
|
|
|
09283b |
<content type="string" default="20" />
|