fence-agents: master - fence agents: Transfer non-SNMP fence agents to long-opts
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=a5a8c1...
Commit: a5a8c1fae0a55ef6d4558e83bffd4c9c04fcd559
Parent: 880e1373d607f863692e2a0667cf24c74fbd0a2c
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon Nov 5 16:23:06 2012 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Nov 8 10:20:20 2012 +0100
fence agents: Transfer non-SNMP fence agents to long-opts
---
fence/agents/alom/fence_alom.py | 8 ++--
fence/agents/apc/fence_apc.py | 70 ++++++++++++------------
fence/agents/bladecenter/fence_bladecenter.py | 30 +++++-----
fence/agents/cisco_ucs/fence_cisco_ucs.py | 18 +++---
fence/agents/drac5/fence_drac5.py | 14 +++---
fence/agents/hpblade/fence_hpblade.py | 18 +++---
fence/agents/ilo/fence_ilo.py | 34 ++++++------
fence/agents/ilo_mp/fence_ilo_mp.py | 6 +-
fence/agents/ldom/fence_ldom.py | 16 +++---
fence/agents/lpar/fence_lpar.py | 56 ++++++++++----------
fence/agents/rhevm/fence_rhevm.py | 4 +-
fence/agents/rsa/fence_rsa.py | 6 +-
fence/agents/rsb/fence_rsb.py | 18 +++---
fence/agents/sanbox2/fence_sanbox2.py | 18 +++---
fence/agents/virsh/fence_virsh.py | 10 ++--
fence/agents/vmware/fence_vmware.py | 70 ++++++++++++------------
fence/agents/vmware_soap/fence_vmware_soap.py | 26 +++++-----
fence/agents/wti/fence_wti.py | 40 +++++++-------
18 files changed, 231 insertions(+), 231 deletions(-)
diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py
index 3f39b2d..abe0a1a 100644
--- a/fence/agents/alom/fence_alom.py
+++ b/fence/agents/alom/fence_alom.py
@@ -17,18 +17,18 @@ BUILD_DATE=""
def get_power_status(conn, options):
conn.send_eol("showplatform")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
status = re.search("standby", conn.before.lower())
result = (status != None and "off" or "on")
return result
def set_power_status(conn, options):
- cmd_line = (options["-o"] == "on" and "poweron" or "poweroff -f -y")
+ cmd_line = (options["--action"] == "on" and "poweron" or "poweroff -f -y")
conn.send_eol(cmd_line)
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
# Get the machine some time between poweron and poweroff
- time.sleep(int(options["-g"]))
+ time.sleep(int(options["--power-timeout"]))
def main():
device_opt = [ "ipaddr", "login", "passwd", "passwd_script", "cmd_prompt", "secure",
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index 743627a..9236a30 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -29,7 +29,7 @@ def get_power_status(conn, options):
outlets = {}
conn.send_eol("1")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
version = 0
admin = 0
@@ -38,11 +38,11 @@ def get_power_status(conn, options):
if (None != re.compile('.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before)):
switch = 1
if (None != re.compile('.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before)):
- if (0 == options.has_key("-s")):
+ if (0 == options.has_key("--switch")):
fail_usage("Failed: You have to enter physical switch number")
else:
- if (0 == options.has_key("-s")):
- options["-s"] = "1"
+ if (0 == options.has_key("--switch")):
+ options["--switch"] = "1"
if (None == re.compile('.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before)):
version = 2
@@ -62,13 +62,13 @@ def get_power_status(conn, options):
conn.send_eol("3")
else:
conn.send_eol("2")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
conn.send_eol("1")
else:
- conn.send_eol(options["-s"])
+ conn.send_eol(options["--switch"])
while True:
- exp_result = conn.log_expect(options, [ options["-c"], "Press <ENTER>" ], int(options["-Y"]))
+ exp_result = conn.log_expect(options, [ options["--command-prompt"], "Press <ENTER>" ], int(options["--shell-timeout"]))
lines = conn.before.split("\n")
show_re = re.compile('(^|\x0D)\s*(\d+)- (.*?)\s+(ON|OFF)\s*')
for x in lines:
@@ -79,14 +79,14 @@ def get_power_status(conn, options):
if exp_result == 0:
break
conn.send(chr(03))
- conn.log_expect(options, "- Logout", int(options["-Y"]))
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, "- Logout", int(options["--shell-timeout"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
- if ["list", "monitor"].count(options["-o"]) == 1:
+ if ["list", "monitor"].count(options["--action"]) == 1:
return outlets
else:
try:
- (_, status) = outlets[options["-n"]]
+ (_, status) = outlets[options["--plug"]]
return status.lower().strip()
except KeyError:
fail(EC_STATUS)
@@ -95,10 +95,10 @@ def set_power_status(conn, options):
action = {
'on' : "1",
'off': "2"
- }[options["-o"]]
+ }[options["--action"]]
conn.send_eol("1")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
version = 0
admin2 = 0
@@ -111,13 +111,13 @@ def set_power_status(conn, options):
action = {
'on' : "1",
'off': "3"
- }[options["-o"]]
+ }[options["--action"]]
if (None != re.compile('.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before)):
- if (0 == options.has_key("-s")):
+ if (0 == options.has_key("--switch")):
fail_usage("Failed: You have to enter physical switch number")
else:
- if (0 == options.has_key("-s")):
- options["-s"] = 1
+ if (0 == options.has_key("--switch")):
+ options["--switch"] = 1
if (None == re.compile('.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before)):
version = 2
@@ -137,41 +137,41 @@ def set_power_status(conn, options):
conn.send_eol("3")
else:
conn.send_eol("2")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
if (None == re.compile('.*2- Outlet Restriction.*', re.IGNORECASE | re.S).match(conn.before)):
admin3 = 0
else:
admin3 = 1
conn.send_eol("1")
else:
- conn.send_eol(options["-s"])
+ conn.send_eol(options["--switch"])
- while 1 == conn.log_expect(options, [ options["-c"], "Press <ENTER>" ], int(options["-Y"])):
+ while 1 == conn.log_expect(options, [ options["--command-prompt"], "Press <ENTER>" ], int(options["--shell-timeout"])):
conn.send_eol("")
- conn.send_eol(options["-n"]+"")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.send_eol(options["--plug"]+"")
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
if switch == 0:
if admin2 == 1:
conn.send_eol("1")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
if admin3 == 1:
conn.send_eol("1")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
else:
conn.send_eol("1")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
conn.send_eol(action)
- conn.log_expect(options, "Enter 'YES' to continue or <ENTER> to cancel :", int(options["-Y"]))
+ conn.log_expect(options, "Enter 'YES' to continue or <ENTER> to cancel :", int(options["--shell-timeout"]))
conn.send_eol("YES")
- conn.log_expect(options, "Press <ENTER> to continue...", int(options["-Y"]))
+ conn.log_expect(options, "Press <ENTER> to continue...", int(options["--shell-timeout"]))
conn.send_eol("")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
conn.send(chr(03))
- conn.log_expect(options, "- Logout", int(options["-Y"]))
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, "- Logout", int(options["--shell-timeout"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
def main():
device_opt = [ "ipaddr", "login", "passwd", "passwd_script", "cmd_prompt",
@@ -195,11 +195,11 @@ will block any necessary fencing actions."
docs["vendorurl"] = "http://www.apc.com"
show_docs(options, docs)
- ## Support for -n [switch]:[plug] notation that was used before
- if (options.has_key("-n") == 1) and (-1 != options["-n"].find(":")):
- (switch, plug) = options["-n"].split(":", 1)
- options["-s"] = switch
- options["-n"] = plug
+ ## Support for --plug [switch]:[plug] notation that was used before
+ if (options.has_key("--plug") == 1) and (-1 != options["--plug"].find(":")):
+ (switch, plug) = options["--plug"].split(":", 1)
+ options["--switch"] = switch
+ options["--plug"] = plug
##
## Operate the fencing device
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index 726a15f..cf38e10 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -23,40 +23,40 @@ BUILD_DATE="March, 2008"
#END_VERSION_GENERATION
def get_power_status(conn, options):
- node_cmd = "system:blade\[" + options["-n"] + "\]>"
+ node_cmd = "system:blade\[" + options["--plug"] + "\]>"
- conn.send_eol("env -T system:blade[" + options["-n"] + "]")
- i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["-Y"]))
+ conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
+ i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["--shell-timeout"]))
if i == 1:
## Given blade number does not exist
- if options.has_key("-M"):
+ if options.has_key("--missing-as-off"):
return "off"
else:
fail(EC_STATUS)
conn.send_eol("power -state")
- conn.log_expect(options, node_cmd, int(options["-Y"]))
+ conn.log_expect(options, node_cmd, int(options["--shell-timeout"]))
status = conn.before.splitlines()[-1]
conn.send_eol("env -T system")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
return status.lower().strip()
def set_power_status(conn, options):
- node_cmd = "system:blade\[" + options["-n"] + "\]>"
+ node_cmd = "system:blade\[" + options["--plug"] + "\]>"
- conn.send_eol("env -T system:blade[" + options["-n"] + "]")
- i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["-Y"]))
+ conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
+ i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["--shell-timeout"]))
if i == 1:
## Given blade number does not exist
- if options.has_key("-M"):
+ if options.has_key("--missing-as-off"):
return
else:
fail(EC_GENERIC_ERROR)
- conn.send_eol("power -"+options["-o"])
- conn.log_expect(options, node_cmd, int(options["-Y"]))
+ conn.send_eol("power -"+options["--action"])
+ conn.log_expect(options, node_cmd, int(options["--shell-timeout"]))
conn.send_eol("env -T system")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
def get_blades_list(conn, options):
outlets = { }
@@ -64,9 +64,9 @@ def get_blades_list(conn, options):
node_cmd = "system>"
conn.send_eol("env -T system")
- conn.log_expect(options, node_cmd, int(options["-Y"]))
+ conn.log_expect(options, node_cmd, int(options["--shell-timeout"]))
conn.send_eol("list -l 2")
- conn.log_expect(options, node_cmd, int(options["-Y"]))
+ conn.log_expect(options, node_cmd, int(options["--shell-timeout"]))
lines = conn.before.split("\r\n")
filter_re = re.compile("^\s*blade\[(\d+)\]\s+(.*?)\s*$")
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index 5ed2c35..2a81c68 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -19,8 +19,8 @@ RE_GET_DESC = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
def get_power_status(conn, options):
res = send_command(options, \
"<configResolveDn cookie=\"" + options["cookie"] + "\" inHierarchical=\"false\" dn=\"org-root" + options["-s"] + \
- "/ls-" + options["-n"] + "/power\"/>", \
- int(options["-Y"]))
+ "/ls-" + options["--plug"] + "/power\"/>", \
+ int(options["--shell-timeout"]))
result = RE_STATUS.search(res)
if (result == None):
@@ -37,14 +37,14 @@ def set_power_status(conn, options):
action = {
'on' : "up",
'off' : "down"
- }[options["-o"]]
+ }[options["--action"]]
res = send_command(options, \
"<configConfMos cookie=\"" + options["cookie"] + "\" inHierarchical=\"no\">" + \
- "<inConfigs><pair key=\"org-root" + options["-s"] + "/ls-" + options["-n"] + "/power\">" + \
- "<lsPower dn=\"org-root/ls-" + options["-n"] + "/power\" state=\"" + action + "\" status=\"modified\" />" + \
+ "<inConfigs><pair key=\"org-root" + options["-s"] + "/ls-" + options["--plug"] + "/power\">" + \
+ "<lsPower dn=\"org-root/ls-" + options["--plug"] + "/power\" state=\"" + action + "\" status=\"modified\" />" + \
"</pair></inConfigs></configConfMos>", \
- int(options["-Y"]))
+ int(options["--shell-timeout"]))
return
@@ -54,7 +54,7 @@ def get_list(conn, options):
try:
res = send_command(options, \
"<configResolveClass cookie=\"" + options["cookie"] + "\" inHierarchical=\"false\" classId=\"lsServer\"/>", \
- int(options["-Y"]))
+ int(options["--shell-timeout"]))
lines = res.split("<lsServer ")
for i in range(1, len(lines)):
@@ -113,7 +113,7 @@ used with Cisco UCS to fence machines."
show_docs(options, docs)
### Login
- res = send_command(options, "<aaaLogin inName=\"" + options["-l"] + "\" inPassword=\"" + options["-p"] + "\" />", int(options["-y"]))
+ res = send_command(options, "<aaaLogin inName=\"" + options["--username"] + "\" inPassword=\"" + options["--password"] + "\" />", int(options["--login-timeout"]))
result = RE_COOKIE.search(res)
if (result == None):
## Cookie is absenting in response
@@ -135,7 +135,7 @@ used with Cisco UCS to fence machines."
result = fence_action(None, options, set_power_status, get_power_status, get_list)
### Logout; we do not care about result as we will end in any case
- send_command(options, "<aaaLogout inCookie=\"" + options["cookie"] + "\" />", int(options["-Y"]))
+ send_command(options, "<aaaLogout inCookie=\"" + options["cookie"] + "\" />", int(options["--shell-timeout"]))
sys.exit(result)
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index f8c129d..bce8cef 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -24,11 +24,11 @@ BUILD_DATE="March, 2008"
def get_power_status(conn, options):
if options["model"] == "DRAC CMC":
- conn.send_eol("racadm serveraction powerstatus -m " + options["-m"])
+ conn.send_eol("racadm serveraction powerstatus -m " + options["--module-name"])
elif options["model"] == "DRAC 5":
conn.send_eol("racadm serveraction powerstatus")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
status = re.compile("(^|: )(ON|OFF|Powering ON|Powering OFF)\s*$", re.IGNORECASE | re.MULTILINE).search(conn.before).group(2)
if status.lower().strip() in ["on", "powering on", "powering off"]:
@@ -40,13 +40,13 @@ def set_power_status(conn, options):
action = {
'on' : "powerup",
'off': "powerdown"
- }[options["-o"]]
+ }[options["--action"]]
if options["model"] == "DRAC CMC":
- conn.send_eol("racadm serveraction " + action + " -m " + options["-m"])
+ conn.send_eol("racadm serveraction " + action + " -m " + options["--module-name"])
elif options["model"] == "DRAC 5":
conn.send_eol("racadm serveraction " + action)
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
def get_list_devices(conn, options):
outlets = { }
@@ -55,7 +55,7 @@ def get_list_devices(conn, options):
conn.send_eol("getmodinfo")
list_re = re.compile("^([^\s]*?)\s+Present\s*(ON|OFF)\s*.*$")
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
for line in conn.before.splitlines():
if (list_re.search(line)):
outlets[list_re.search(line).group(1)] = ("", list_re.search(line).group(2))
@@ -95,7 +95,7 @@ By default, the telnet interface is not enabled."
conn = fence_login(options)
if conn.before.find("CMC") >= 0:
- if 0 == options.has_key("-m") and 0 == ["monitor", "list"].count(options["-o"].lower()):
+ if 0 == options.has_key("--module-name") and 0 == ["monitor", "list"].count(options["--action"].lower()):
fail_usage("Failed: You have to enter module name (-m)")
options["model"] = "DRAC CMC"
diff --git a/fence/agents/hpblade/fence_hpblade.py b/fence/agents/hpblade/fence_hpblade.py
index c4f045e..6532065 100644
--- a/fence/agents/hpblade/fence_hpblade.py
+++ b/fence/agents/hpblade/fence_hpblade.py
@@ -17,8 +17,8 @@ BUILD_DATE="March, 2008"
#END_VERSION_GENERATION
def get_power_status(conn, options):
- conn.send_eol("show server status " + options["-n"])
- conn.log_expect(options, options["-c"] , int(options["-Y"]))
+ conn.send_eol("show server status " + options["--plug"])
+ conn.log_expect(options, options["--command-prompt"] , int(options["--shell-timeout"]))
power_re = re.compile("^\s*Power: (.*?)\s*$")
status = "unknown"
@@ -28,7 +28,7 @@ def get_power_status(conn, options):
status = res.group(1)
if status == "unknown":
- if options.has_key("-M"):
+ if options.has_key("--missing-as-off"):
return "off"
else:
fail(EC_STATUS)
@@ -36,17 +36,17 @@ def get_power_status(conn, options):
return status.lower().strip()
def set_power_status(conn, options):
- if options["-o"] == "on":
- conn.send_eol("poweron server " + options["-n"])
- elif options["-o"] == "off":
- conn.send_eol("poweroff server " + options["-n"] + " force")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ if options["--action"] == "on":
+ conn.send_eol("poweron server " + options["--plug"])
+ elif options["--action"] == "off":
+ conn.send_eol("poweroff server " + options["--plug"] + " force")
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
def get_blades_list(conn, options):
outlets = { }
conn.send_eol("show server list" )
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
list_re = re.compile("^\s*(.*?)\s+(.*?)\s+(.*?)\s+OK\s+(.*?)\s+(.*?)\s*$")
for line in conn.before.splitlines():
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index 66472aa..c85a063 100644
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -22,18 +22,18 @@ BUILD_DATE="March, 2008"
#END_VERSION_GENERATION
def get_power_status(conn, options):
- conn.send("<LOGIN USER_LOGIN = \"" + options["-l"] + "\"" + \
- " PASSWORD = \"" + options["-p"] + "\">\r\n")
+ conn.send("<LOGIN USER_LOGIN = \"" + options["--username"] + "\"" + \
+ " PASSWORD = \"" + options["--password"] + "\">\r\n")
conn.send("<SERVER_INFO MODE = \"read\"><GET_HOST_POWER_STATUS/>\r\n")
conn.send("</SERVER_INFO></LOGIN>\r\n")
- conn.log_expect(options, "HOST_POWER=\"(.*?)\"", int(options["-g"]))
+ conn.log_expect(options, "HOST_POWER=\"(.*?)\"", int(options["--power-timeout"]))
status = conn.match.group(1)
return status.lower().strip()
def set_power_status(conn, options):
- conn.send("<LOGIN USER_LOGIN = \"" + options["-l"] + "\"" + \
- " PASSWORD = \"" + options["-p"] + "\">\r\n")
+ conn.send("<LOGIN USER_LOGIN = \"" + options["--username"] + "\"" + \
+ " PASSWORD = \"" + options["--password"] + "\">\r\n")
conn.send("<SERVER_INFO MODE = \"write\">")
if options.has_key("fw_processor") and options["fw_processor"] == "iLO2":
@@ -41,10 +41,10 @@ def set_power_status(conn, options):
conn.send("<HOLD_PWR_BTN TOGGLE=\"yes\" />\r\n")
else:
conn.send("<HOLD_PWR_BTN />\r\n")
- elif options["-r"] < 2.21:
- conn.send("<SET_HOST_POWER HOST_POWER = \"" + options["-o"] + "\" />\r\n")
+ elif options["--ribcl-version"] < 2.21:
+ conn.send("<SET_HOST_POWER HOST_POWER = \"" + options["--action"] + "\" />\r\n")
else:
- if options["-o"] == "off":
+ if options["--action"] == "off":
conn.send("<HOLD_PWR_BTN/>\r\n")
else:
conn.send("<PRESS_PWR_BTN/>\r\n")
@@ -81,23 +81,23 @@ the iLO card through an XML stream."
conn = fence_login(options)
try:
conn.send("<?xml version=\"1.0\"?>\r\n")
- conn.log_expect(options, [ "</RIBCL>", "<END_RIBCL/>" ], int(options["-y"]))
+ conn.log_expect(options, [ "</RIBCL>", "<END_RIBCL/>" ], int(options["--login-timeout"]))
version = re.compile("<RIBCL VERSION=\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
- if options.has_key("-r") == 0:
- options["-r"] = float(version)
+ if options.has_key("--ribcl-version") == 0:
+ options["--ribcl-version"] = float(version)
- if options["-r"] >= 2:
+ if options["--ribcl-version"] >= 2:
conn.send("<RIBCL VERSION=\"2.0\">\r\n")
else:
conn.send("<RIBCL VERSION=\"1.2\">\r\n")
- conn.send("<LOGIN USER_LOGIN = \"" + options["-l"] + "\"" + \
- " PASSWORD = \"" + options["-p"] + "\">\r\n")
- if options["-r"] >= 2:
+ conn.send("<LOGIN USER_LOGIN = \"" + options["--username"] + "\"" + \
+ " PASSWORD = \"" + options["--password"] + "\">\r\n")
+ if options["--ribcl-version"] >= 2:
conn.send("<RIB_INFO MODE=\"read\"><GET_FW_VERSION />\r\n")
conn.send("</RIB_INFO>\r\n")
- conn.log_expect(options, "<GET_FW_VERSION\s*\n", int(options["-Y"]))
- conn.log_expect(options, "/>", int(options["-Y"]))
+ conn.log_expect(options, "<GET_FW_VERSION\s*\n", int(options["--shell-timeout"]))
+ conn.log_expect(options, "/>", int(options["--shell-timeout"]))
options["fw_version"] = float(re.compile("FIRMWARE_VERSION\s*=\s*\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1))
options["fw_processor"] = re.compile("MANAGEMENT_PROCESSOR\s*=\s*\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
conn.send("</LOGIN>\r\n")
diff --git a/fence/agents/ilo_mp/fence_ilo_mp.py b/fence/agents/ilo_mp/fence_ilo_mp.py
index 7cf068a..85764c6 100644
--- a/fence/agents/ilo_mp/fence_ilo_mp.py
+++ b/fence/agents/ilo_mp/fence_ilo_mp.py
@@ -14,7 +14,7 @@ def get_power_status(conn, options):
conn.send_eol("show /system1")
re_state = re.compile('EnabledState=(.*)', re.IGNORECASE)
- conn.log_expect(options, re_state, int(options["-Y"]))
+ conn.log_expect(options, re_state, int(options["--shell-timeout"]))
status = conn.match.group(1).lower()
@@ -24,12 +24,12 @@ def get_power_status(conn, options):
return "off"
def set_power_status(conn, options):
- if options["-o"] == "on":
+ if options["--action"] == "on":
conn.send_eol("start /system1")
else:
conn.send_eol("stop -f /system1")
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
return
diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py
index 0d67e3f..0f41d75 100644
--- a/fence/agents/ldom/fence_ldom.py
+++ b/fence/agents/ldom/fence_ldom.py
@@ -23,11 +23,11 @@ COMMAND_PROMPT_NEW = "[PEXPECT]"
# Start comunicating after login. Prepare good environment.
def start_communication(conn, options):
conn.send_eol ("PS1='"+COMMAND_PROMPT_NEW+"'")
- res = conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG], int(options["-Y"]))
+ res = conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG], int(options["--shell-timeout"]))
if res == 0:
#CSH stuff
conn.send_eol("set prompt='"+COMMAND_PROMPT_NEW+"'")
- conn.log_expect(options, COMMAND_PROMPT_REG, int(options["-Y"]))
+ conn.log_expect(options, COMMAND_PROMPT_REG, int(options["--shell-timeout"]))
def get_power_status(conn, options):
@@ -35,7 +35,7 @@ def get_power_status(conn, options):
conn.send_eol("ldm ls")
- conn.log_expect(options, COMMAND_PROMPT_REG, int(options["-Y"]))
+ conn.log_expect(options, COMMAND_PROMPT_REG, int(options["--shell-timeout"]))
result = {}
@@ -51,22 +51,22 @@ def get_power_status(conn, options):
elif (fa_status==1):
result[domain.group(1)] = ("", (domain.group(2).lower()=="bound" and "off" or "on"))
- if (not (options["-o"] in ['monitor','list'])):
- if (not (options["-n"] in result)):
+ if (not (options["--action"] in ['monitor','list'])):
+ if (not (options["--plug"] in result)):
fail_usage("Failed: You have to enter existing logical domain!")
else:
- return result[options["-n"]][1]
+ return result[options["--plug"]][1]
else:
return result
def set_power_status(conn, options):
start_communication(conn, options)
- cmd_line = "ldm "+(options["-o"]=="on" and "start" or "stop -f")+" \""+options["-n"]+"\""
+ cmd_line = "ldm "+(options["--action"]=="on" and "start" or "stop -f")+" \""+options["--plug"]+"\""
conn.send_eol(cmd_line)
- conn.log_expect(options, COMMAND_PROMPT_REG, int(options["-g"]))
+ conn.log_expect(options, COMMAND_PROMPT_REG, int(options["--power-timeout"]))
def main():
device_opt = [ "ipaddr", "login", "passwd", "passwd_script",
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index 4522dfd..0bae359 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -21,17 +21,17 @@ BUILD_DATE=""
#END_VERSION_GENERATION
def get_power_status(conn, options):
- if options["-H"] == "3":
- conn.send("lssyscfg -r lpar -m " + options["-s"] + " -n " + options["-n"] + " -F name,state\n")
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ if options["--hmc-version"] == "3":
+ conn.send("lssyscfg -r lpar -m " + options["--managed"] + " -n " + options["--plug"] + " -F name,state\n")
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
try:
- status = re.compile("^" + options["-n"] + ",(.*?),.*$", re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
+ status = re.compile("^" + options["--plug"] + ",(.*?),.*$", re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
except AttributeError:
fail(EC_STATUS_HMC)
- elif options["-H"] == "4":
- conn.send("lssyscfg -r lpar -m "+ options["-s"] +" --filter 'lpar_names=" + options["-n"] + "'\n")
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ elif options["--hmc-version"] == "4":
+ conn.send("lssyscfg -r lpar -m "+ options["--managed"] +" --filter 'lpar_names=" + options["--plug"] + "'\n")
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
try:
status = re.compile(",state=(.*?),", re.IGNORECASE).search(conn.before).group(1)
@@ -48,27 +48,27 @@ def get_power_status(conn, options):
return status
def set_power_status(conn, options):
- if options["-H"] == "3":
- conn.send("chsysstate -o " + options["-o"] + " -r lpar -m " + options["-s"]
- + " -n " + options["-n"] + "\n")
- conn.log_expect(options, options["-c"], int(options["-g"]))
- elif options["-H"] == "4":
- if options["-o"] == "on":
- conn.send("chsysstate -o on -r lpar -m " + options["-s"] +
- " -n " + options["-n"] +
+ if options["--hmc-version"] == "3":
+ conn.send("chsysstate -o " + options["--action"] + " -r lpar -m " + options["--managed"]
+ + " -n " + options["--plug"] + "\n")
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
+ elif options["--hmc-version"] == "4":
+ if options["--action"] == "on":
+ conn.send("chsysstate -o on -r lpar -m " + options["--managed"] +
+ " -n " + options["--plug"] +
" -f `lssyscfg -r lpar -F curr_profile " +
- " -m " + options["-s"] +
- " --filter \"lpar_names="+ options["-n"] +"\"`\n" )
+ " -m " + options["--managed"] +
+ " --filter \"lpar_names="+ options["--plug"] +"\"`\n" )
else:
conn.send("chsysstate -o shutdown -r lpar --immed" +
- " -m " + options["-s"] + " -n " + options["-n"] + "\n")
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ " -m " + options["--managed"] + " -n " + options["--plug"] + "\n")
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
def get_lpar_list(conn, options):
outlets = { }
- if options["-H"] == "3":
- conn.send("query_partition_names -m " + options["-s"] + "\n")
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ if options["--hmc-version"] == "3":
+ conn.send("query_partition_names -m " + options["--managed"] + "\n")
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
## We have to remove first 3 lines (command + header) and last line (part of new prompt)
####
@@ -80,10 +80,10 @@ def get_lpar_list(conn, options):
lines = res.group(2).split("\n")
for outlet_line in lines:
outlets[outlet_line.rstrip()] = ("", "")
- elif options["-H"] == "4":
- conn.send("lssyscfg -r lpar -m " + options["-s"] +
+ elif options["--hmc-version"] == "4":
+ conn.send("lssyscfg -r lpar -m " + options["--managed"] +
" -F name:state\n")
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
## We have to remove first line (command) and last line (part of new prompt)
####
@@ -117,13 +117,13 @@ def main():
docs["longdesc"] = ""
show_docs(options, docs)
- if 0 == options.has_key("-s"):
+ if 0 == options.has_key("--managed"):
fail_usage("Failed: You have to enter name of managed system")
- if (0 == ["list", "monitor"].count(options["-o"].lower())) and (0 == options.has_key("-n")):
+ if (0 == ["list", "monitor"].count(options["--action"].lower())) and (0 == options.has_key("--plug")):
fail_usage("Failed: You have to enter name of the partition")
- if 1 == options.has_key("-H") and (options["-H"] != "3" and options["-H"] != "4"):
+ if 1 == options.has_key("--hmc-version") and (options["--hmc-version"] != "3" and options["--hmc-version"] != "4"):
fail_usage("Failed: You have to enter valid version number: 3 or 4")
##
diff --git a/fence/agents/rhevm/fence_rhevm.py b/fence/agents/rhevm/fence_rhevm.py
index 7f5abde..fb97d51 100644
--- a/fence/agents/rhevm/fence_rhevm.py
+++ b/fence/agents/rhevm/fence_rhevm.py
@@ -18,7 +18,7 @@ RE_GET_NAME = re.compile("<name>(.*?)</name>", re.IGNORECASE)
def get_power_status(conn, options):
### Obtain real ID from name
- res = send_command(options, "vms/?search=name%3D" + options["-n"])
+ res = send_command(options, "vms/?search=name%3D" + options["--plug"])
result = RE_GET_ID.search(res)
if (result == None):
@@ -45,7 +45,7 @@ def set_power_status(conn, options):
action = {
'on' : "start",
'off' : "stop"
- }[options["-o"]]
+ }[options["--action"]]
url = "vms/" + options["id"] + "/" + action
res = send_command(options, url, "POST")
diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py
index 75cf1f7..e1e303f 100644
--- a/fence/agents/rsa/fence_rsa.py
+++ b/fence/agents/rsa/fence_rsa.py
@@ -19,7 +19,7 @@ BUILD_DATE=""
def get_power_status(conn, options):
conn.send_eol("power state")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
match = re.compile("Power: (.*)", re.IGNORECASE).search(conn.before)
if (match != None):
@@ -30,8 +30,8 @@ def get_power_status(conn, options):
return status.lower().strip()
def set_power_status(conn, options):
- conn.send_eol("power " + options["-o"])
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ conn.send_eol("power " + options["--action"])
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
def main():
device_opt = [ "ipaddr", "login", "passwd", "passwd_script",
diff --git a/fence/agents/rsb/fence_rsb.py b/fence/agents/rsb/fence_rsb.py
index 40c922e..395a844 100755
--- a/fence/agents/rsb/fence_rsb.py
+++ b/fence/agents/rsb/fence_rsb.py
@@ -12,10 +12,10 @@ BUILD_DATE=""
def get_power_status(conn, options):
conn.send("2")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
status = re.compile("Power Status : (on|off)", re.IGNORECASE).search(conn.before).group(1)
conn.send("0")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
return (status.lower().strip())
@@ -23,18 +23,18 @@ def set_power_status(conn, options):
action = {
'on' : "4",
'off': "1"
- }[options["-o"]]
+ }[options["--action"]]
conn.send("2")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
conn.send_eol(action)
- conn.log_expect(options, ["want to power off", "'yes' or 'no'"], int(options["-Y"]))
+ conn.log_expect(options, ["want to power off", "'yes' or 'no'"], int(options["--shell-timeout"]))
conn.send_eol("yes")
- conn.log_expect(options, "any key to continue", int(options["-g"]))
+ conn.log_expect(options, "any key to continue", int(options["--power-timeout"]))
conn.send_eol("")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
conn.send_eol("0")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
def main():
device_opt = [ "ipaddr", "login", "passwd", "passwd_script",
@@ -59,7 +59,7 @@ def main():
# set default port for telnet only
if 0 == opt.has_key("-x") and 0 == opt.has_key("-u"):
- opt["-u"] = 3172
+ opt["--ipport"] = 3172
options = check_input(device_opt, opt)
docs = { }
diff --git a/fence/agents/sanbox2/fence_sanbox2.py b/fence/agents/sanbox2/fence_sanbox2.py
index 173c819..ccbfd8e 100644
--- a/fence/agents/sanbox2/fence_sanbox2.py
+++ b/fence/agents/sanbox2/fence_sanbox2.py
@@ -24,8 +24,8 @@ def get_power_status(conn, options):
'offline' : "off"
}
try:
- conn.send_eol("show port " + options["-n"])
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.send_eol("show port " + options["--plug"])
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
except pexpect.TIMEOUT:
try:
conn.send_eol("admin end")
@@ -46,11 +46,11 @@ def set_power_status(conn, options):
action = {
'on' : "online",
'off' : "offline"
- }[options["-o"]]
+ }[options["--action"]]
try:
- conn.send_eol("set port " + options["-n"] + " state " + action)
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ conn.send_eol("set port " + options["--plug"] + " state " + action)
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
except pexpect.TIMEOUT:
try:
conn.send_eol("admin end")
@@ -61,8 +61,8 @@ def set_power_status(conn, options):
fail(EC_TIMED_OUT)
try:
- conn.send_eol("set port " + options["-n"] + " state " + action)
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ conn.send_eol("set port " + options["--plug"] + " state " + action)
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
except pexpect.TIMEOUT:
try:
conn.send_eol("admin end")
@@ -77,7 +77,7 @@ def get_list_devices(conn, options):
try:
conn.send_eol("show port")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
list_re = re.compile("^\s+(\d+?)\s+(Online|Offline)\s+", re.IGNORECASE)
for line in conn.before.splitlines():
@@ -125,7 +125,7 @@ because the connection will block any necessary fencing actions."
conn = fence_login(options)
conn.send_eol("admin start")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
if (re.search("\(admin\)", conn.before, re.MULTILINE) == None):
## Someone else is in admin section, we can't enable/disable
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index c8c49a4..b157385 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -22,7 +22,7 @@ def get_outlets_status(conn, options):
prefix = ""
conn.sendline(prefix + "virsh list --all")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
result = {}
@@ -42,10 +42,10 @@ def get_outlets_status(conn, options):
def get_power_status(conn, options):
outlets = get_outlets_status(conn, options)
- if (not (options["-n"] in outlets)):
+ if (not (options["--plug"] in outlets)):
fail_usage("Failed: You have to enter existing name of virtual machine!")
else:
- return outlets[options["-n"]][1]
+ return outlets[options["--plug"]][1]
def set_power_status(conn, options):
if options.has_key("-d"):
@@ -53,9 +53,9 @@ def set_power_status(conn, options):
else:
prefix = ""
- conn.sendline(prefix + "virsh %s "%(options["-o"] == "on" and "start" or "destroy")+options["-n"])
+ conn.sendline(prefix + "virsh %s "%(options["--action"] == "on" and "start" or "destroy")+options["--plug"])
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
time.sleep(1)
def main():
diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py
index 6e3f394..8524480 100644
--- a/fence/agents/vmware/fence_vmware.py
+++ b/fence/agents/vmware/fence_vmware.py
@@ -106,28 +106,28 @@ def quote_for_run(str):
# Return string with command and additional parameters (something like vmrun -h 'host'
def vmware_prepare_command(options, add_login_params, additional_params):
- res = options["-e"]
+ res = options["--exec"]
if (add_login_params):
if (vmware_internal_type==VMWARE_TYPE_ESX):
- res += " --server '%s' --username '%s' --password '%s' "% (quote_for_run(options["-a"]),
- quote_for_run(options["-l"]),
- quote_for_run(options["-p"]))
+ res += " --server '%s' --username '%s' --password '%s' "% (quote_for_run(options["--ip"]),
+ quote_for_run(options["--username"]),
+ quote_for_run(options["--password"]))
elif (vmware_internal_type==VMWARE_TYPE_SERVER2):
- res += " -h 'https://%s/sdk' -u '%s' -p '%s' -T server "% (quote_for_run(options["-a"]),
- quote_for_run(options["-l"]),
- quote_for_run(options["-p"]))
+ res += " -h 'https://%s/sdk' -u '%s' -p '%s' -T server "% (quote_for_run(options["--ip"]),
+ quote_for_run(options["--username"]),
+ quote_for_run(options["--password"]))
elif (vmware_internal_type==VMWARE_TYPE_SERVER1):
- host_name_array = options["-a"].split(':')
+ host_name_array = options["--ip"].split(':')
res += " -h '%s' -u '%s' -p '%s' -T server1 "% (quote_for_run(host_name_array[0]),
- quote_for_run(options["-l"]),
- quote_for_run(options["-p"]))
+ quote_for_run(options["--username"]),
+ quote_for_run(options["--password"]))
if (len(host_name_array)>1):
res += "-P '%s' "% (quote_for_run(host_name_array[1]))
- if ((options.has_key("-s")) and (vmware_internal_type==VMWARE_TYPE_ESX)):
- res += "--datacenter '%s' "% (quote_for_run(options["-s"]))
+ if ((options.has_key("--vmware-datacenter")) and (vmware_internal_type==VMWARE_TYPE_ESX)):
+ res += "--datacenter '%s' "% (quote_for_run(options["--vmware-datacenter"]))
if (additional_params != ""):
res += additional_params
@@ -148,18 +148,18 @@ def vmware_run_command(options, add_login_params, additional_params, additional_
try:
vmware_log(options, command)
- (res_output, res_code) = pexpect.run(command, int(options["-Y"])+int(options["-y"])+additional_timeout, True)
+ (res_output, res_code) = pexpect.run(command, int(options["--shell-timeout"])+int(options["--login-timeout"])+additional_timeout, True)
if (res_code==None):
fail(EC_TIMED_OUT)
if ((res_code!=0) and (add_login_params)):
vmware_log(options, res_output)
- fail_usage("%s returned %s"% (options["-e"], res_output))
+ fail_usage("%s returned %s"% (options["--exec"], res_output))
else:
vmware_log(options, res_output)
except pexpect.ExceptionPexpect:
- fail_usage("Cannot run command %s"% (options["-e"]))
+ fail_usage("Cannot run command %s"% (options["--exec"]))
return res_output
@@ -169,9 +169,9 @@ def vmware_get_outlets_vi(conn, options, add_vm_name):
outlets = {}
if (add_vm_name):
- all_machines = vmware_run_command(options, True, ("--operation status --vmname '%s'"% (quote_for_run(options["-n"]))), 0)
+ all_machines = vmware_run_command(options, True, ("--operation status --vmname '%s'"% (quote_for_run(options["--plug"]))), 0)
else:
- all_machines = vmware_run_command(options, True, "--operation list", int(options["-g"]))
+ all_machines = vmware_run_command(options, True, "--operation list", int(options["--power-timeout"]))
all_machines_array = all_machines.splitlines()
@@ -222,22 +222,22 @@ def get_power_status(conn, options):
outlets = get_outlets_status(conn, options)
if ((vmware_internal_type==VMWARE_TYPE_SERVER2) or (vmware_internal_type==VMWARE_TYPE_ESX)):
- if (not (options["-n"] in outlets)):
+ if (not (options["--plug"] in outlets)):
fail_usage("Failed: You have to enter existing name of virtual machine!")
else:
- return outlets[options["-n"]][1]
+ return outlets[options["--plug"]][1]
elif (vmware_internal_type==VMWARE_TYPE_SERVER1):
- return ((options["-n"] in outlets) and "on" or "off")
+ return ((options["--plug"] in outlets) and "on" or "off")
def set_power_status(conn, options):
if (vmware_internal_type==VMWARE_TYPE_ESX):
- additional_params = "--operation %s --vmname '%s'"% ((options["-o"]=="on" and "on" or "off"), quote_for_run(options["-n"]))
+ additional_params = "--operation %s --vmname '%s'"% ((options["--action"]=="on" and "on" or "off"), quote_for_run(options["--plug"]))
elif ((vmware_internal_type==VMWARE_TYPE_SERVER1) or (vmware_internal_type==VMWARE_TYPE_SERVER2)):
- additional_params = "%s '%s'"% ((options["-o"]=="on" and "start" or "stop"), quote_for_run(options["-n"]))
- if (options["-o"]=="off"):
+ additional_params = "%s '%s'"% ((options["--action"]=="on" and "start" or "stop"), quote_for_run(options["--plug"]))
+ if (options["--action"]=="off"):
additional_params += " hard"
- vmware_run_command(options, True, additional_params, int(options["-g"]))
+ vmware_run_command(options, True, additional_params, int(options["--power-timeout"]))
# Returns True, if user uses supported vmrun version (currently >=2.0.0) otherwise False.
def vmware_is_supported_vmrun_version(options):
@@ -257,24 +257,24 @@ def vmware_is_supported_vmrun_version(options):
return True
# Check vmware type, set vmware_internal_type to one of VMWARE_TYPE_ value and
-# options["-e"] to path (if not specified)
+# options["--exec"] to path (if not specified)
def vmware_check_vmware_type(options):
global vmware_internal_type
- options["-d"] = options["-d"].lower()
+ options["--vmware-type"] = options["--vmware-type"].lower()
- if (options["-d"]=="esx"):
+ if (options["--vmware-type"]=="esx"):
vmware_internal_type = VMWARE_TYPE_ESX
- if (not options.has_key("-e")):
- options["-e"] = VMHELPER_COMMAND
- elif (options["-d"]=="server2"):
+ if (not options.has_key("--exec")):
+ options["--exec"] = VMHELPER_COMMAND
+ elif (options["--vmware-type"]=="server2"):
vmware_internal_type = VMWARE_TYPE_SERVER2
- if (not options.has_key("-e")):
- options["-e"] = VMRUN_COMMAND
- elif (options["-d"]=="server1"):
+ if (not options.has_key("--exec")):
+ options["--exec"] = VMRUN_COMMAND
+ elif (options["--vmware-type"]=="server1"):
vmware_internal_type = VMWARE_TYPE_SERVER1
- if (not options.has_key("-e")):
- options["-e"] = VMRUN_COMMAND
+ if (not options.has_key("--exec")):
+ options["--exec"] = VMRUN_COMMAND
else:
fail_usage("vmware_type can be esx,server2 or server1!")
diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
index 2710603..4ef03f0 100644
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
@@ -14,12 +14,12 @@ BUILD_DATE="April, 2011"
#END_VERSION_GENERATION
def soap_login(options):
- if options.has_key("-z"):
+ if options.has_key("--ssl"):
url = "https://"
else:
url = "http://"
- url += options["-a"] + ":" + str(options["-u"]) + "/sdk"
+ url += options["--ip"] + ":" + str(options["-u"]) + "/sdk"
conn = Client(url + "/vimService.wsdl")
conn.set_options(location = url)
@@ -30,7 +30,7 @@ def soap_login(options):
mo_SessionManager._type = 'SessionManager'
try:
- SessionManager = conn.service.Login(mo_SessionManager, options["-l"], options["-p"])
+ SessionManager = conn.service.Login(mo_SessionManager, options["--username"], options["--password"])
except Exception, ex:
fail(EC_LOGIN_DENIED)
@@ -104,22 +104,22 @@ def get_power_status(conn, options):
uuid.update(more_uuid)
mappingToUUID.update(more_mappingToUUID)
# Do not run unnecessary SOAP requests
- if options.has_key("-U") and options["-U"] in uuid:
+ if options.has_key("--uuid") and options["--uuid"] in uuid:
break
- if ["list", "monitor"].count(options["-o"]) == 1:
+ if ["list", "monitor"].count(options["--action"]) == 1:
return machines
else:
- if options.has_key("-U") == False:
- if options["-n"].startswith('/'):
+ if options.has_key("--uuid") == False:
+ if options["--plug"].startswith('/'):
## Transform InventoryPath to UUID
mo_SearchIndex = Property(options["ServiceContent"].searchIndex.value)
mo_SearchIndex._type = "SearchIndex"
- vm = conn.service.FindByInventoryPath(mo_SearchIndex, options["-n"])
+ vm = conn.service.FindByInventoryPath(mo_SearchIndex, options["--plug"])
try:
- options["-U"] = mappingToUUID[vm.value]
+ options["--uuid"] = mappingToUUID[vm.value]
except KeyError, ex:
fail(EC_STATUS)
except AttributeError, ex:
@@ -128,14 +128,14 @@ def get_power_status(conn, options):
## Name of virtual machine instead of path
## warning: if you have same names of machines this won't work correctly
try:
- (options["-U"], _) = machines[options["-n"]]
+ (options["--uuid"], _) = machines[options["--plug"]]
except KeyError, ex:
fail(EC_STATUS)
except AttributeError, ex:
fail(EC_STATUS)
try:
- if uuid[options["-U"]] == "poweredOn":
+ if uuid[options["--uuid"]] == "poweredOn":
return "on"
else:
return "off"
@@ -145,12 +145,12 @@ def get_power_status(conn, options):
def set_power_status(conn, options):
mo_SearchIndex = Property(options["ServiceContent"].searchIndex.value)
mo_SearchIndex._type = "SearchIndex"
- vm = conn.service.FindByUuid(mo_SearchIndex, vmSearch = 1, uuid = options["-U"])
+ vm = conn.service.FindByUuid(mo_SearchIndex, vmSearch = 1, uuid = options["--uuid"])
mo_machine = Property(vm.value)
mo_machine._type = "VirtualMachine"
- if options["-o"] == "on":
+ if options["--action"] == "on":
conn.service.PowerOnVM_Task(mo_machine)
else:
conn.service.PowerOffVM_Task(mo_machine)
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 2337e10..80b5e96 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -26,18 +26,18 @@ def get_power_status(conn, options):
conn.send("/S"+"\r\n")
- if isinstance(options["-c"], list):
- re_all = list(options["-c"])
+ if isinstance(options["--command-prompt"], list):
+ re_all = list(options["--command-prompt"])
else:
- re_all = [options["-c"]]
+ re_all = [options["--command-prompt"]]
re_next = re.compile("Enter: ", re.IGNORECASE)
re_all.append(re_next)
- result = conn.log_expect(options, re_all, int(options["-Y"]))
+ result = conn.log_expect(options, re_all, int(options["--shell-timeout"]))
listing = conn.before
if result == (len(re_all) - 1):
conn.send("\r\n")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
listing += conn.before
plug_section = 0
@@ -52,7 +52,7 @@ def get_power_status(conn, options):
plug_line = [x.strip().lower() for x in line.split("|")]
if len(plug_line) < len(plug_header):
plug_section = -1
- if ["list", "monitor"].count(options["-o"]) == 0 and options["-n"].lower() == plug_line[plug_index]:
+ if ["list", "monitor"].count(options["--action"]) == 0 and options["--plug"].lower() == plug_line[plug_index]:
return plug_line[status_index]
else:
## We already believe that first column contains plug number
@@ -67,7 +67,7 @@ def get_power_status(conn, options):
name_index = plug_header.index("name")
status_index = plug_header.index("status")
- if ["list", "monitor"].count(options["-o"]) == 1:
+ if ["list", "monitor"].count(options["--action"]) == 1:
return outlets
else:
return "PROBLEM"
@@ -76,10 +76,10 @@ def set_power_status(conn, options):
action = {
'on' : "/on",
'off': "/off"
- }[options["-o"]]
+ }[options["--action"]]
- conn.send(action + " " + options["-n"] + ",y\r\n")
- conn.log_expect(options, options["-c"], int(options["-g"]))
+ conn.send(action + " " + options["--plug"] + ",y\r\n")
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
def main():
device_opt = [ "ipaddr", "login", "passwd", "passwd_script",
@@ -107,12 +107,12 @@ is running because the connection will block any necessary fencing actions."
##
## @note: if it possible that this device does not need either login, password or both of them
#####
- if 0 == options.has_key("-x"):
+ if 0 == options.has_key("--ssh"):
try:
try:
conn = fspawn(options, TELNET_PATH)
conn.send("set binary\n")
- conn.send("open %s -%s\n"%(options["-a"], options["-u"]))
+ conn.send("open %s -%s\n"%(options["--ip"], options["-u"]))
except pexpect.ExceptionPexpect, ex:
sys.stderr.write(str(ex) + "\n")
sys.stderr.write("Due to limitations, binary dependencies on fence agents "
@@ -120,20 +120,20 @@ is running because the connection will block any necessary fencing actions."
sys.exit(EC_GENERIC_ERROR)
re_login = re.compile("(login: )|(Login Name: )|(username: )|(User Name :)", re.IGNORECASE)
- re_prompt = re.compile("|".join(map (lambda x: "(" + x + ")", options["-c"])), re.IGNORECASE)
+ re_prompt = re.compile("|".join(map (lambda x: "(" + x + ")", options["--command-prompt"])), re.IGNORECASE)
- result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["-Y"]))
+ result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["--shell-timeout"]))
if result == 0:
- if options.has_key("-l"):
- conn.send(options["-l"]+"\r\n")
- result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["-Y"]))
+ if options.has_key("--username"):
+ conn.send(options["--username"]+"\r\n")
+ result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["--shell-timeout"]))
else:
fail_usage("Failed: You have to set login name")
if result == 1:
- if options.has_key("-p"):
- conn.send(options["-p"]+"\r\n")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ if options.has_key("--password"):
+ conn.send(options["--password"]+"\r\n")
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
else:
fail_usage("Failed: You have to enter password or password script")
except pexpect.EOF:
11 years, 5 months
fence-agents: master - fencing: Add support for usage of longopt keys in options
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=880e13...
Commit: 880e1373d607f863692e2a0667cf24c74fbd0a2c
Parent: a2b07ebb3b2050bf04b4d31a7a613efccf1096ff
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon Nov 5 15:32:42 2012 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Nov 8 10:20:10 2012 +0100
fencing: Add support for usage of longopt keys in options
This way we can make code more readable options["--power-timeout"] instead options["-g"].
This code was created manually to support both short and long options but fence agents will
be moved to long-options automatically.
---
fence/agents/lib/fencing.py.py | 196 +++++++++++++++++++++-------------------
1 files changed, 102 insertions(+), 94 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 9612b40..0041846 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -129,7 +129,7 @@ all_opt = {
"order" : 1 },
"passwd_script" : {
"getopt" : "S:",
- "longopt" : "password-script=",
+ "longopt" : "password-script",
"help" : "-S, --password-script=<script> Script to run to retrieve password",
"required" : "0",
"shortdesc" : "Script to retrieve password",
@@ -578,16 +578,21 @@ def process_input(avail_opt):
for x in all_opt.keys():
if all_opt[x].has_key("longopt") and "--" + all_opt[x]["longopt"] == o:
opt["-" + all_opt[x]["getopt"].rstrip(":")] = dict(old_opt)[o]
+ opt["--" + all_opt[x]["longopt"]] = dict(old_opt)[o]
else:
+ for x in all_opt.keys():
+ if all_opt[x].has_key("getopt") and all_opt[x].has_key("longopt") and \
+ ("-" + all_opt[x]["getopt"] == o or "-" + all_opt[x]["getopt"].rstrip(":") == o):
+ opt["--" + all_opt[x]["longopt"]] = dict(old_opt)[o]
opt[o] = dict(old_opt)[o]
## Compatibility Layer
#####
z = dict(opt)
if z.has_key("-T") == 1:
- z["-o"] = "status"
- if z.has_key("-n") == 1:
- z["-m"] = z["-n"]
+ z["--action"] = "status"
+ if z.has_key("--plug") == 1:
+ z["-m"] = z["--plug"]
opt = z
##
@@ -653,7 +658,7 @@ def check_input(device_opt, opt):
## In special cases (show help, metadata or version) we don't need to check anything
#####
- if options.has_key("-h") or options.has_key("-V") or (options.has_key("-o") and options["-o"].lower() == "metadata"):
+ if options.has_key("-h") or options.has_key("-V") or (options.has_key("--action") and options["--action"].lower() == "metadata"):
return options
## Set default values
@@ -661,12 +666,16 @@ def check_input(device_opt, opt):
for opt in device_opt:
if all_opt[opt].has_key("default"):
getopt_short = "-" + all_opt[opt]["getopt"].rstrip(":")
+ getopt_long = "--" + all_opt[opt]["longopt"]
if 0 == options.has_key(getopt_short):
options[getopt_short] = all_opt[opt]["default"]
+ if 0 == options.has_key(getopt_long):
+ options[getopt_long] = all_opt[opt]["default"]
+ options["--action"] = options["--action"].lower()
options["-o"] = options["-o"].lower()
- if options.has_key("-v"):
+ if options.has_key("--verbose"):
options["log"] = LOG_MODE_VERBOSE
else:
options["log"] = LOG_MODE_QUIET
@@ -679,71 +688,71 @@ def check_input(device_opt, opt):
else:
acceptable_actions.extend(["reboot"])
- if 0 == acceptable_actions.count(options["-o"]):
- fail_usage("Failed: Unrecognised action '" + options["-o"] + "'")
+ if 0 == acceptable_actions.count(options["--action"]):
+ fail_usage("Failed: Unrecognised action '" + options["--action"] + "'")
## Compatibility layer
#####
- if options["-o"] == "enable":
- options["-o"] = "on"
- if options["-o"] == "disable":
- options["-o"] = "off"
+ if options["--action"] == "enable":
+ options["--action"] = "on"
+ if options["--action"] == "disable":
+ options["--action"] = "off"
- if (0 == options.has_key("-l")) and device_opt.count("login") and (device_opt.count("no_login") == 0):
+ if (0 == options.has_key("--username")) and device_opt.count("login") and (device_opt.count("no_login") == 0):
fail_usage("Failed: You have to set login name")
- if 0 == options.has_key("-a") and 0 == options.has_key("-s"):
+ if 0 == options.has_key("--ip") and 0 == options.has_key("-s"):
fail_usage("Failed: You have to enter fence address")
if (device_opt.count("no_password") == 0):
if 0 == device_opt.count("identity_file"):
- if 0 == (options.has_key("-p") or options.has_key("-S")):
+ if 0 == (options.has_key("--password") or options.has_key("--password-script")):
fail_usage("Failed: You have to enter password or password script")
else:
- if 0 == (options.has_key("-p") or options.has_key("-S") or options.has_key("-k")):
+ if 0 == (options.has_key("--password") or options.has_key("--password-script") or options.has_key("--identity-file")):
fail_usage("Failed: You have to enter password, password script or identity file")
- if 0 == options.has_key("-x") and 1 == options.has_key("-k"):
+ if 0 == options.has_key("--ssh") and 1 == options.has_key("--identity-file"):
fail_usage("Failed: You have to use identity file together with ssh connection (-x)")
- if 1 == options.has_key("-k"):
- if 0 == os.path.isfile(options["-k"]):
- fail_usage("Failed: Identity file " + options["-k"] + " does not exist")
+ if 1 == options.has_key("--identity-file"):
+ if 0 == os.path.isfile(options["--identity-file"]):
+ fail_usage("Failed: Identity file " + options["--identity-file"] + " does not exist")
- if (0 == ["list", "monitor"].count(options["-o"].lower())) and \
- (0 == options.has_key("-n") and 0 == options.has_key("-U")) and (device_opt.count("port")):
+ if (0 == ["list", "monitor"].count(options["--action"].lower())) and \
+ (0 == options.has_key("--plug") and 0 == options.has_key("--uuid")) and (device_opt.count("port")):
fail_usage("Failed: You have to enter plug number")
- if options.has_key("-S"):
- options["-p"] = os.popen(options["-S"]).read().rstrip()
+ if options.has_key("--password-script"):
+ options["--password"] = os.popen(options["--password-script"]).read().rstrip()
- if options.has_key("-D"):
+ if options.has_key("--debug-file"):
try:
- options["debug_fh"] = file (options["-D"], "w")
+ options["debug_fh"] = file (options["--debug-file"], "w")
except IOError:
- fail_usage("Failed: Unable to create file "+options["-D"])
+ fail_usage("Failed: Unable to create file " + options["--debug-file"])
- if options.has_key("-v") and options.has_key("debug_fh") == 0:
+ if options.has_key("--verbose") and options.has_key("debug_fh") == 0:
options["debug_fh"] = sys.stderr
- if options.has_key("-R"):
- options["-P"] = os.popen(options["-R"]).read().rstrip()
+ if options.has_key("--snmp-priv-passwd-script"):
+ options["--snmp-priv-passwd"] = os.popen(options["--snmp-priv-passwd-script"]).read().rstrip()
- if options.has_key("-u") == False:
- if options.has_key("-x"):
- options["-u"] = 22
- elif options.has_key("-z"):
- options["-u"] = 443
+ if options.has_key("--ipport") == False:
+ if options.has_key("--ssh"):
+ options["--ipport"] = 22
+ elif options.has_key("--ssl"):
+ options["--ipport"] = 443
elif device_opt.count("web"):
- options["-u"] = 80
+ options["--ipport"] = 80
else:
- options["-u"] = 23
+ options["--ipport"] = 23
return options
def wait_power_status(tn, options, get_power_fn):
- for dummy in xrange(int(options["-g"])):
- if get_power_fn(tn, options) != options["-o"]:
+ for dummy in xrange(int(options["--power-timeout"])):
+ if get_power_fn(tn, options) != options["--action"]:
time.sleep(1)
else:
return 1
@@ -759,15 +768,15 @@ def show_docs(options, docs = None):
## Process special options (and exit)
#####
- if options.has_key("-h"):
+ if options.has_key("--help"):
usage(device_opt)
sys.exit(0)
- if options.has_key("-o") and options["-o"].lower() == "metadata":
+ if options.has_key("--action") and options["--action"].lower() == "metadata":
metadata(device_opt, options, docs)
sys.exit(0)
- if options.has_key("-V"):
+ if options.has_key("--version"):
print __main__.RELEASE_VERSION, __main__.BUILD_DATE
print __main__.REDHAT_COPYRIGHT
sys.exit(0)
@@ -778,24 +787,24 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
try:
## Process options that manipulate fencing device
#####
- if (options["-o"] == "list") and \
+ if (options["--action"] == "list") and \
0 == options["device_opt"].count("port") and 0 == options["device_opt"].count("partition") and \
0 == options["device_opt"].count("uuid") and 0 == options["device_opt"].count("module_name"):
print "N/A"
return
- elif (options["-o"] == "list" and get_outlet_list == None):
+ elif (options["--action"] == "list" and get_outlet_list == None):
## @todo: exception?
## This is just temporal solution, we will remove default value
## None as soon as all existing agent will support this operation
print "NOTICE: List option is not working on this device yet"
return
- elif (options["-o"] == "list") or ((options["-o"] == "monitor") and 1 == options["device_opt"].count("port")):
+ elif (options["--action"] == "list") or ((options["--action"] == "monitor") and 1 == options["device_opt"].count("port")):
outlets = get_outlet_list(tn, options)
## keys can be numbers (port numbers) or strings (names of VM)
for o in outlets.keys():
(alias, status) = outlets[o]
- if options["-o"] != "monitor":
- print o + options["-C"] + alias
+ if options["--action"] != "monitor":
+ print o + options["--separator"] + alias
return
status = get_power_fn(tn, options)
@@ -803,15 +812,14 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
if status != "on" and status != "off":
fail(EC_STATUS)
-
- if options["-o"] == "on":
+ if options["--action"] == "on":
if status == "on":
print "Success: Already ON"
else:
power_on = False
- for _ in range(1, 1 + int(options["-F"])):
+ for _ in range(1, 1 + int(options["--retry-on"])):
set_power_fn(tn, options)
- time.sleep(int(options["-G"]))
+ time.sleep(int(options["--power-wait"]))
if wait_power_status(tn, options, get_power_fn):
power_on = True
break
@@ -820,30 +828,30 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
print "Success: Powered ON"
else:
fail(EC_WAITING_ON)
- elif options["-o"] == "off":
+ elif options["--action"] == "off":
if status == "off":
print "Success: Already OFF"
else:
set_power_fn(tn, options)
- time.sleep(int(options["-G"]))
+ time.sleep(int(options["--power-wait"]))
if wait_power_status(tn, options, get_power_fn):
print "Success: Powered OFF"
else:
fail(EC_WAITING_OFF)
- elif options["-o"] == "reboot":
+ elif options["--action"] == "reboot":
if status != "off":
- options["-o"] = "off"
+ options["--action"] = "off"
set_power_fn(tn, options)
- time.sleep(int(options["-G"]))
+ time.sleep(int(options["--power-wait"]))
if wait_power_status(tn, options, get_power_fn) == 0:
fail(EC_WAITING_OFF)
- options["-o"] = "on"
+ options["--action"] = "on"
power_on = False
try:
- for _ in range(1, 1 + int(options["-F"])):
+ for _ in range(1, 1 + int(options["--retry-on"])):
set_power_fn(tn, options)
- time.sleep(int(options["-G"]))
+ time.sleep(int(options["--power-wait"]))
if wait_power_status(tn, options, get_power_fn) == 1:
power_on = True
break
@@ -858,11 +866,11 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
sys.stderr.write('Timed out waiting to power ON\n')
print "Success: Rebooted"
- elif options["-o"] == "status":
+ elif options["--action"] == "status":
print "Status: " + status.upper()
if status.upper() == "OFF":
result = 2
- elif options["-o"] == "monitor":
+ elif options["--action"] == "monitor":
pass
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
@@ -877,10 +885,10 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
def fence_login(options):
force_ipvx = ""
- if (options.has_key("-6")):
+ if (options.has_key("--inet6-only")):
force_ipvx = "-6 "
- if (options.has_key("-4")):
+ if (options.has_key("--inet4-only")):
force_ipvx = "-4 "
if (options.has_key("eol") == False):
@@ -888,23 +896,23 @@ def fence_login(options):
## Do the delay of the fence device before logging in
## Delay is important for two-node clusters fencing but we do not need to delay 'status' operations
- if options["-o"] in ["off", "reboot"]:
- time.sleep(int(options["-f"]))
+ if options["--action"] in ["off", "reboot"]:
+ time.sleep(int(options["--delay"]))
try:
re_login = re.compile("(login\s*: )|(Login Name: )|(username: )|(User Name :)", re.IGNORECASE)
re_pass = re.compile("(password)|(pass phrase)", re.IGNORECASE)
- if options.has_key("-z"):
- command = '%s %s %s %s' % (SSL_PATH, force_ipvx, options["-a"], options["-u"])
+ if options.has_key("--ssl"):
+ command = '%s %s %s %s' % (SSL_PATH, force_ipvx, options["--ip"], options["--ipport"])
try:
conn = fspawn(options, command)
except pexpect.ExceptionPexpect, ex:
## SSL telnet is part of the fencing package
sys.stderr.write(str(ex) + "\n")
sys.exit(EC_GENERIC_ERROR)
- elif options.has_key("-x") and 0 == options.has_key("-k"):
- command = '%s %s %s@%s -p %s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"], options["-u"])
+ elif options.has_key("--ssh") and 0 == options.has_key("--identity-file"):
+ command = '%s %s %s@%s -p %s' % (SSH_PATH, force_ipvx, options["--username"], options["--ip"], options["--ipport"])
if options.has_key("ssh_options"):
command += ' ' + options["ssh_options"]
try:
@@ -917,23 +925,23 @@ def fence_login(options):
if options.has_key("telnet_over_ssh"):
#This is for stupid ssh servers (like ALOM) which behave more like telnet (ignore name and display login prompt)
- result = conn.log_expect(options, [ re_login, "Are you sure you want to continue connecting (yes/no)?" ], int(options["-y"]))
+ result = conn.log_expect(options, [ re_login, "Are you sure you want to continue connecting (yes/no)?" ], int(options["--login-timeout"]))
if result == 1:
conn.sendline("yes") # Host identity confirm
- conn.log_expect(options, re_login, int(options["-y"]))
+ conn.log_expect(options, re_login, int(options["--login-timeout"]))
- conn.sendline(options["-l"])
- conn.log_expect(options, re_pass, int(options["-y"]))
+ conn.sendline(options["--username"])
+ conn.log_expect(options, re_pass, int(options["--login-timeout"]))
else:
- result = conn.log_expect(options, [ "ssword:", "Are you sure you want to continue connecting (yes/no)?" ], int(options["-y"]))
+ result = conn.log_expect(options, [ "ssword:", "Are you sure you want to continue connecting (yes/no)?" ], int(options["--login-timeout"]))
if result == 1:
conn.sendline("yes")
- conn.log_expect(options, "ssword:", int(options["-y"]))
+ conn.log_expect(options, "ssword:", int(options["--login-timeout"]))
- conn.sendline(options["-p"])
- conn.log_expect(options, options["-c"], int(options["-y"]))
- elif options.has_key("-x") and 1 == options.has_key("-k"):
- command = '%s %s %s@%s -i %s -p %s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"], options["-k"], options["-u"])
+ conn.sendline(options["--password"])
+ conn.log_expect(options, options["--command-prompt"], int(options["--login-timeout"]))
+ elif options.has_key("--ssh") and options.has_key("--identity-file"):
+ command = '%s %s %s@%s -i %s -p %s' % (SSH_PATH, force_ipvx, options["--username"], options["--ip"], options["--identity-file"], options["--ipport"])
if options.has_key("ssh_options"):
command += ' ' + options["ssh_options"]
try:
@@ -944,44 +952,44 @@ def fence_login(options):
"are not in the spec file and must be installed separately." + "\n")
sys.exit(EC_GENERIC_ERROR)
- result = conn.log_expect(options, [ options["-c"], \
+ result = conn.log_expect(options, [ options["--command-prompt"], \
"Are you sure you want to continue connecting (yes/no)?", \
- "Enter passphrase for key '" + options["-k"] + "':" ], int(options["-y"]))
+ "Enter passphrase for key '" + options["--identity-file"] + "':" ], int(options["--login-timeout"]))
if result == 1:
conn.sendline("yes")
- conn.log_expect(options, [ options["-c"], "Enter passphrase for key '"+options["-k"]+"':"] , int(options["-y"]))
+ conn.log_expect(options, [ options["--command-prompt"], "Enter passphrase for key '"+options["--identity-file"]+"':"] , int(options["--login-timeout"]))
if result != 0:
- if options.has_key("-p"):
- conn.sendline(options["-p"])
- conn.log_expect(options, options["-c"], int(options["-y"]))
+ if options.has_key("--password"):
+ conn.sendline(options["--password"])
+ conn.log_expect(options, options["--command-prompt"], int(options["--login-timeout"]))
else:
fail_usage("Failed: You have to enter passphrase (-p) for identity file")
else:
try:
conn = fspawn(options, TELNET_PATH)
conn.send("set binary\n")
- conn.send("open %s -%s\n"%(options["-a"], options["-u"]))
+ conn.send("open %s -%s\n"%(options["--ip"], options["--ipport"]))
except pexpect.ExceptionPexpect, ex:
sys.stderr.write(str(ex) + "\n")
sys.stderr.write("Due to limitations, binary dependencies on fence agents "
"are not in the spec file and must be installed separately." + "\n")
sys.exit(EC_GENERIC_ERROR)
- result = conn.log_expect(options, re_login, int(options["-y"]))
- conn.send_eol(options["-l"])
+ result = conn.log_expect(options, re_login, int(options["--login-timeout"]))
+ conn.send_eol(options["--username"])
## automatically change end of line separator
- screen = conn.read_nonblocking(size=100, timeout=int(options["-Y"]))
+ screen = conn.read_nonblocking(size=100, timeout=int(options["--shell-timeout"]))
if (re_login.search(screen) != None):
options["eol"] = "\n"
- conn.send_eol(options["-l"])
- result = conn.log_expect(options, re_pass, int(options["-y"]))
+ conn.send_eol(options["--username"])
+ result = conn.log_expect(options, re_pass, int(options["--login-timeout"]))
elif (re_pass.search(screen) == None):
- conn.log_expect(options, re_pass, int(options["-Y"]))
+ conn.log_expect(options, re_pass, int(options["--shell-timeout"]))
try:
- conn.send_eol(options["-p"])
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ conn.send_eol(options["--password"])
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
except KeyError:
fail(EC_PASSWORD_MISSING)
except pexpect.EOF:
11 years, 5 months
fence-agents: master - fence_scsi: support unfence action in Pacemaker
by rohara
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=a2b07e...
Commit: a2b07ebb3b2050bf04b4d31a7a613efccf1096ff
Parent: 752879cf1f77c85149925f0a48f03215d544ee4f
Author: David Vossel <dvossel(a)redhat.com>
AuthorDate: Wed Nov 7 14:15:03 2012 -0600
Committer: Ryan O'Hara <rohara(a)redhat.com>
CommitterDate: Wed Nov 7 14:19:47 2012 -0600
fence_scsi: support unfence action in Pacemaker
Add attribute to fence_scsi's metadata that indicates that on action
must be performed on local node. Also allow metadata action via stdin.
Signed-off-by: Ryan O'Hara <rohara(a)redhat.com>
---
fence/agents/scsi/fence_scsi.pl | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/fence/agents/scsi/fence_scsi.pl b/fence/agents/scsi/fence_scsi.pl
index ef7d14d..e3c78b4 100644
--- a/fence/agents/scsi/fence_scsi.pl
+++ b/fence/agents/scsi/fence_scsi.pl
@@ -746,7 +746,7 @@ sub print_metadata ()
print "\t</parameter>\n";
print "</parameters>\n";
print "<actions>\n";
- print "\t<action name=\"on\"/>\n";
+ print "\t<action name=\"on\" on_target=\"true\"/>\n";
print "\t<action name=\"off\"/>\n";
print "\t<action name=\"status\"/>\n";
print "\t<action name=\"metadata\"/>\n";
@@ -760,19 +760,18 @@ sub print_metadata ()
if (@ARGV > 0) {
getopts ("ad:f:hk:n:o:qV") or print_usage;
-
print_usage if (defined $opt_h);
print_version if (defined $opt_V);
-
- ## handle the metadata action here to avoid other parameter checks
- ##
- if ($opt_o =~ /^metadata$/i) {
- print_metadata;
- }
} else {
get_options_stdin ();
}
+## handle the metadata action here to avoid other parameter checks
+##
+if ($opt_o =~ /^metadata$/i) {
+ print_metadata;
+}
+
## if the logfile (-f) parameter was specified, open the logfile
## and redirect STDOUT and STDERR to the logfile.
##
11 years, 6 months
dlm: master - dlm_controld: fix modes for run dir and file
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=f15a2daed713748...
Commit: f15a2daed7137481c7161e1447b1796c308c7e08
Parent: 499cb28a0c53c96b9d58d0b63de0d599ad549baf
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Nov 6 15:40:00 2012 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Nov 6 15:40:00 2012 -0600
dlm_controld: fix modes for run dir and file
dir should be 775 and file 644
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/main.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index 91fbc4f..a68e1b8 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -1107,7 +1107,7 @@ static int lockfile(const char *dir, const char *name)
int fd, rv;
old_umask = umask(0022);
- rv = mkdir(dir, 0777);
+ rv = mkdir(dir, 0775);
if (rv < 0 && errno != EEXIST) {
umask(old_umask);
return rv;
@@ -1116,7 +1116,7 @@ static int lockfile(const char *dir, const char *name)
snprintf(path, PATH_MAX, "%s/%s", dir, name);
- fd = open(path, O_CREAT|O_WRONLY|O_CLOEXEC, 0666);
+ fd = open(path, O_CREAT|O_WRONLY|O_CLOEXEC, 0644);
if (fd < 0) {
log_error("lockfile open error %s: %s",
path, strerror(errno));
11 years, 6 months
dlm: master - release 4.0.0
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=499cb28a0c53c96...
Commit: 499cb28a0c53c96b9d58d0b63de0d599ad549baf
Parent: c2e1d61f57b14073300d94337b900e3c8cabfb8e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Nov 6 12:25:15 2012 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Nov 6 12:25:15 2012 -0600
release 4.0.0
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
include/version.cf | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/version.cf b/include/version.cf
index e423c07..5d75ee5 100644
--- a/include/version.cf
+++ b/include/version.cf
@@ -1,6 +1,6 @@
#ifndef _RELEASE_VERSION_CF_
#define _RELEASE_VERSION_CF_
-#define RELEASE_VERSION "3.99.5"
+#define RELEASE_VERSION "4.0.0"
#endif
11 years, 6 months
dlm: master - dlm_stonith: change syslog name
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=c2e1d61f57b1407...
Commit: c2e1d61f57b14073300d94337b900e3c8cabfb8e
Parent: de04b4e0fa5c6908e3a3d78028e6066a176f80f0
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Nov 6 12:20:27 2012 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Nov 6 12:20:27 2012 -0600
dlm_stonith: change syslog name
from stonith-helper to match dlm_stonith
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
fence/stonith_helper.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/stonith_helper.c b/fence/stonith_helper.c
index 32d2c0d..c2821ec 100644
--- a/fence/stonith_helper.c
+++ b/fence/stonith_helper.c
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
rv = stonith_api_kick_helper(nodeid, 300, 0);
if (rv) {
fprintf(stderr, "kick_helper error %d nodeid %d\n", rv, nodeid);
- openlog("stonith_helper", LOG_CONS | LOG_PID, LOG_DAEMON);
+ openlog("dlm_stonith", LOG_CONS | LOG_PID, LOG_DAEMON);
syslog(LOG_ERR, "kick_helper error %d nodeid %d\n", rv, nodeid);
return rv;
}
11 years, 6 months
dlm: master - stonith-helper: use reboot instead of off
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=de04b4e0fa5c690...
Commit: de04b4e0fa5c6908e3a3d78028e6066a176f80f0
Parent: 30e3ef3ebf98e9ea753e8e8a0597030abc89bdeb
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Nov 5 14:53:23 2012 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Nov 5 14:53:23 2012 -0600
stonith-helper: use reboot instead of off
That 0 means reboot was verified by
Jacek Konieczny <jajcus(a)jajcus.net>
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
fence/stonith_helper.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/stonith_helper.c b/fence/stonith_helper.c
index 5b384c1..32d2c0d 100644
--- a/fence/stonith_helper.c
+++ b/fence/stonith_helper.c
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
if (t >= fail_time)
return 0;
- rv = stonith_api_kick_helper(nodeid, 300, 1);
+ rv = stonith_api_kick_helper(nodeid, 300, 0);
if (rv) {
fprintf(stderr, "kick_helper error %d nodeid %d\n", rv, nodeid);
openlog("stonith_helper", LOG_CONS | LOG_PID, LOG_DAEMON);
11 years, 6 months
dlm: master - dlm_controld: don't use high priority scheduling
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=30e3ef3ebf98e9e...
Commit: 30e3ef3ebf98e9ea753e8e8a0597030abc89bdeb
Parent: f545f48edeaab6a76e5c8e55a5f072d41b553597
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Nov 5 14:20:07 2012 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Nov 5 14:20:07 2012 -0600
dlm_controld: don't use high priority scheduling
I don't think it's necessary.
Also set OOM value in service file.
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/dlm_daemon.h | 2 +-
dlm_controld/main.c | 5 ++++-
init/dlm.service | 1 +
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 377f28d..ad99e17 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -89,6 +89,7 @@ enum {
enum {
daemon_debug_ind = 0,
+ foreground_ind,
log_debug_ind,
timewarn_ind,
protocol_ind,
@@ -109,7 +110,6 @@ enum {
enable_quorum_lockspace_ind,
help_ind,
version_ind,
- foreground_ind,
dlm_options_max,
};
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index d1fdb2a..91fbc4f 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -1533,6 +1533,8 @@ static void set_opt_cli(int argc, char **argv)
}
}
+#if 0
+/* When this is used, the systemd service file needs ControlGroup=cpu:/ */
static void set_scheduler(void)
{
struct sched_param sched_param;
@@ -1550,6 +1552,7 @@ static void set_scheduler(void)
errno);
}
}
+#endif
int main(int argc, char **argv)
{
@@ -1612,7 +1615,7 @@ int main(int argc, char **argv)
if (rv < 0)
return -rv;
- set_scheduler();
+ /* set_scheduler(); */
loop();
diff --git a/init/dlm.service b/init/dlm.service
index f068c63..198c8ce 100644
--- a/init/dlm.service
+++ b/init/dlm.service
@@ -3,6 +3,7 @@ Description=dlm control daemon
After=syslog.target network.target corosync.service sys-kernel-config.mount
[Service]
+OOMScoreAdjust=-1000
Type=notify
NotifyAccess=main
EnvironmentFile=/etc/sysconfig/dlm
11 years, 6 months
dlm: master - Startup notification by sd_notify()
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=f545f48edeaab6a...
Commit: f545f48edeaab6a76e5c8e55a5f072d41b553597
Parent: ea0b5a37ab1bbc0f34a8ba49629d7350cfd55cd4
Author: Jacek Konieczny <jajcus(a)jajcus.net>
AuthorDate: Sat Nov 3 16:27:56 2012 +0100
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Nov 5 13:34:31 2012 -0600
Startup notification by sd_notify()
Implements simple start-up status notification via the sd_notify(3)
function from the libsystemd-daemon library. This allows proper
service startup serialization by the init daemon – services depending
on DLM will be started after dlm_controld completes the initialization.
As this pulls additional dependency, the feature my by disabled on
compile time by calling 'make' with 'USE_SD_NOTIFY=no'.
Signed-off-by: Jacek Konieczny <jajcus(a)jajcus.net>
---
dlm_controld/Makefile | 8 ++++++++
dlm_controld/main.c | 8 ++++++++
init/dlm.service | 5 +++--
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index f42a913..13d6339 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -6,6 +6,8 @@ LIBDIR=$(PREFIX)/$(LIBNUM)
HDRDIR=$(PREFIX)/include
MANDIR=$(PREFIX)/share/man
+USE_SD_NOTIFY=yes
+
BIN_TARGET = dlm_controld
LIB_NAME = libdlmcontrol
@@ -59,6 +61,12 @@ BIN_LDFLAGS += -lpthread -lrt -lcpg -lcmap -lcfg -lquorum
LIB_CFLAGS += $(BIN_CFLAGS)
LIB_LDFLAGS += -Wl,-z,relro -pie
+ifeq ($(USE_SD_NOTIFY),yes)
+ BIN_CFLAGS += $(shell pkg-config --cflags libsystemd-daemon) \
+ -DUSE_SD_NOTIFY
+ BIN_LDFLAGS += $(shell pkg-config --libs libsystemd-daemon)
+endif
+
all: $(LIB_TARGET) $(BIN_TARGET)
$(BIN_TARGET): $(BIN_SOURCE)
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index deda60c..d1fdb2a 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -14,6 +14,10 @@
#include <linux/genetlink.h>
#include <linux/dlm_netlink.h>
+#ifdef USE_SD_NOTIFY
+#include <systemd/sd-daemon.h>
+#endif
+
#include "copyright.cf"
#include "version.cf"
@@ -1012,6 +1016,10 @@ static void loop(void)
plock_fd = rv;
plock_ci = client_add(rv, process_plocks, NULL);
+#ifdef USE_SD_NOTIFY
+ sd_notify(0, "READY=1");
+#endif
+
for (;;) {
rv = poll(pollfd, client_maxi + 1, poll_timeout);
if (rv == -1 && errno == EINTR) {
diff --git a/init/dlm.service b/init/dlm.service
index 3c4e53e..f068c63 100644
--- a/init/dlm.service
+++ b/init/dlm.service
@@ -3,10 +3,11 @@ Description=dlm control daemon
After=syslog.target network.target corosync.service sys-kernel-config.mount
[Service]
-Type=forking
+Type=notify
+NotifyAccess=main
EnvironmentFile=/etc/sysconfig/dlm
ExecStartPre=/sbin/modprobe dlm
-ExecStart=/usr/sbin/dlm_controld $DLM_CONTROLD_OPTS
+ExecStart=/usr/sbin/dlm_controld --foreground $DLM_CONTROLD_OPTS
#ExecStopPost=/sbin/modprobe -r dlm
[Install]
11 years, 6 months