Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/fence/agents/eps/fence_eps.py b/fence/agents/eps/fence_eps.py
index c56ffb8e..921487bc 100644
--- a/fence/agents/eps/fence_eps.py
+++ b/fence/agents/eps/fence_eps.py
@@ -1,112 +1,112 @@
#!/usr/bin/python
# The Following Agent Has Been Tested On:
# ePowerSwitch 8M+ version 1.0.0.4
import sys, re, time
import httplib, base64, string,socket
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
#BEGIN_VERSION_GENERATION
RELEASE_VERSION="ePowerSwitch 8M+ (eps)"
REDHAT_COPYRIGHT=""
BUILD_DATE=""
#END_VERSION_GENERATION
# Log actions and results from EPS device
def eps_log(options,str):
if options["log"]>=LOG_MODE_VERBOSE:
options["debug_fh"].write(str)
# Run command on EPS device.
# @param options Device options
# @param params HTTP GET parameters (without ?)
def eps_run_command(options, params):
try:
# New http connection
conn = httplib.HTTPConnection(options["-a"])
request_str="/"+options["-c"]
if (params!=""):
request_str+="?"+params
eps_log(options,"GET "+request_str+"\n")
conn.putrequest('GET', request_str)
if (options.has_key("-l")):
if (not options.has_key("-p")):
options["-p"]="" # Default is empty password
# String for Authorization header
auth_str = 'Basic ' + string.strip(base64.encodestring(options["-l"]+':'+options["-p"]))
eps_log(options,"Authorization:"+auth_str+"\n")
conn.putheader('Authorization',auth_str)
conn.endheaders()
response = conn.getresponse()
eps_log(options,"%d %s\n"%(response.status,response.reason))
#Response != OK -> couldn't login
if (response.status!=200):
fail(EC_LOGIN_DENIED)
result=response.read()
eps_log(options,result+"\n")
conn.close()
except socket.timeout:
fail(EC_TIMED_OUT)
except socket.error:
fail(EC_LOGIN_DENIED)
return result
def get_power_status(conn, options):
ret_val=eps_run_command(options,"")
result={}
status=re.findall("p(\d{2})=(0|1)\s*\<br\>",ret_val.lower())
for out_num,out_stat in status:
result[out_num]=("",(out_stat=="1" and "on" or "off"))
- if (options["-o"] == "status"):
+ if (not (options["-o"] in ['monitor','list'])):
if (not (options["-n"] in result)):
fail_usage("Failed: You have to enter existing physical plug!")
else:
return result[options["-n"]][1]
else:
return result
def set_power_status(conn, options):
ret_val=eps_run_command(options,"P%s=%s"%(options["-n"],(options["-o"]=="on" and "1" or "0")))
# Define new option
def eps_define_new_opts():
all_opt["hidden_page"]={
"getopt":"c:",
"help":"-c <page> Name of hidden page (default hidden.htm)",
"order": 1}
# Starting point of fence agent
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"test", "port", "hidden_page", "no_login", "no_password",
"separator" ]
eps_define_new_opts()
options = check_input(device_opt,process_input(device_opt))
if (not options.has_key("-c")):
options["-c"]="hidden.htm"
#Run fence action. Conn is None, beacause we always need open new http connection
fence_action(None, options, set_power_status, get_power_status,get_power_status)
if __name__ == "__main__":
main()
diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py
index 78771c68..390d072d 100644
--- a/fence/agents/ldom/fence_ldom.py
+++ b/fence/agents/ldom/fence_ldom.py
@@ -1,113 +1,113 @@
#!/usr/bin/python
##
## The Following Agent Has Been Tested On - LDOM 1.0.3
## The interface is backward compatible so it will work
## with 1.0, 1.0.1 and .2 too.
##
#####
import sys, re, pexpect
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
#BEGIN_VERSION_GENERATION
RELEASE_VERSION="Logical Domains (LDoms) fence Agent"
REDHAT_COPYRIGHT=""
BUILD_DATE=""
#END_VERSION_GENERATION
COMMAND_PROMPT_REG="\[PEXPECT\]$"
COMMAND_PROMPT_NEW="[PEXPECT]"
# Start comunicating after login. Prepare good environment.
def start_communication(conn, options):
conn.sendline ("PS1='"+COMMAND_PROMPT_NEW+"'")
res=conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG],SHELL_TIMEOUT)
if res==0:
#CSH stuff
conn.sendline("set prompt='"+COMMAND_PROMPT_NEW+"'")
conn.log_expect(options, COMMAND_PROMPT_REG,SHELL_TIMEOUT)
def get_power_status(conn, options):
try:
start_communication(conn,options)
conn.sendline("ldm ls")
conn.log_expect(options,COMMAND_PROMPT_REG,SHELL_TIMEOUT)
result={}
#This is status of mini finite automata. 0 = we didn't found NAME and STATE, 1 = we did
fa_status=0
for line in conn.before.splitlines():
domain=re.search("^(\S+)\s+(\S+)\s+.*$",line)
if (domain!=None):
if ((fa_status==0) and (domain.group(1)=="NAME") and (domain.group(2)=="STATE")):
fa_status=1
elif (fa_status==1):
result[domain.group(1)]=("",(domain.group(2).lower()=="bound" and "off" or "on"))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
fail(EC_TIMED_OUT)
- if (options["-o"] == "status"):
+ if (not (options["-o"] in ['monitor','list'])):
if (not (options["-n"] in result)):
fail_usage("Failed: You have to enter existing logical domain!")
else:
return result[options["-n"]][1]
else:
return result
def set_power_status(conn, options):
try:
start_communication(conn,options)
cmd_line="ldm "+(options["-o"]=="on" and "start" or "stop -f")+" \""+options["-n"]+"\""
conn.sendline(cmd_line)
conn.log_expect(options,COMMAND_PROMPT_REG,POWER_TIMEOUT)
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
fail(EC_TIMED_OUT)
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"secure", "identity_file", "test" , "port", "cmd_prompt",
"separator" ]
options = check_input(device_opt, process_input(device_opt))
##
## Fence agent specific defaults
#####
if (not options.has_key("-c")):
options["-c"] = "\ $"
options["-x"] = 1
##
## Operate the fencing device
####
conn = fence_login(options)
fence_action(conn, options, set_power_status, get_power_status,get_power_status)
##
## Logout from system
######
conn.sendline("logout")
conn.close()
if __name__ == "__main__":
main()

File Metadata

Mime Type
text/x-diff
Expires
Fri, Sep 5, 9:32 AM (12 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2308706
Default Alt Text
(6 KB)

Event Timeline