Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F3152369
fence_alom.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
fence_alom.py
View Options
#!/usr/bin/python
# The Following Agent Has Been Tested On:
#
# Sun(tm) Advanced Lights Out Manager CMT v1.6.1
# as found on SUN T2000 Niagara
import
sys
,
re
,
pexpect
,
time
sys
.
path
.
append
(
"@FENCEAGENTSLIBDIR@"
)
from
fencing
import
*
#BEGIN_VERSION_GENERATION
RELEASE_VERSION
=
"Sun Advanced Lights Out Manager (ALOM)"
REDHAT_COPYRIGHT
=
""
BUILD_DATE
=
""
#END_VERSION_GENERATION
def
get_power_status
(
conn
,
options
):
result
=
""
try
:
conn
.
send_eol
(
"showplatform"
)
conn
.
log_expect
(
options
,
options
[
"-c"
],
int
(
options
[
"-Y"
]))
status
=
re
.
search
(
"standby"
,
conn
.
before
.
lower
())
result
=
(
status
!=
None
and
"off"
or
"on"
)
except
pexpect
.
EOF
:
fail
(
EC_CONNECTION_LOST
)
except
pexpect
.
TIMEOUT
:
fail
(
EC_TIMED_OUT
)
return
result
def
set_power_status
(
conn
,
options
):
try
:
cmd_line
=
(
options
[
"-o"
]
==
"on"
and
"poweron"
or
"poweroff -f -y"
)
conn
.
send_eol
(
cmd_line
)
conn
.
log_expect
(
options
,
options
[
"-c"
],
int
(
options
[
"-g"
]))
#Get the machine some time between poweron and poweroff
time
.
sleep
(
int
(
options
[
"-g"
]))
except
pexpect
.
EOF
:
fail
(
EC_CONNECTION_LOST
)
except
pexpect
.
TIMEOUT
:
fail
(
EC_TIMED_OUT
)
def
main
():
device_opt
=
[
"ipaddr"
,
"login"
,
"passwd"
,
"passwd_script"
,
"secure"
,
"identity_file"
,
"test"
,
"inet4_only"
,
"inet6_only"
,
"ipport"
]
atexit
.
register
(
atexit_handler
)
pinput
=
process_input
(
device_opt
)
pinput
[
"-x"
]
=
1
options
=
check_input
(
device_opt
,
pinput
)
# Default command is sc>
if
(
not
options
.
has_key
(
"-c"
)):
options
[
"-c"
]
=
"sc\>\ "
options
[
"telnet_over_ssh"
]
=
1
docs
=
{
}
docs
[
"shortdesc"
]
=
"Fence agent for Sun ALOM"
docs
[
"longdesc"
]
=
"fence_alom is an I/O Fencing
\
agent which can be used with ALOM connected machines."
docs
[
"vendorurl"
]
=
"http://www.sun.com"
show_docs
(
options
,
docs
)
# Operate the fencing device
conn
=
fence_login
(
options
)
result
=
fence_action
(
conn
,
options
,
set_power_status
,
get_power_status
,
None
)
# Logout from system
try
:
conn
.
send_eol
(
"logout"
)
conn
.
close
()
except
exceptions
.
OSError
:
pass
except
pexpect
.
ExceptionPexpect
:
pass
sys
.
exit
(
result
)
if
__name__
==
"__main__"
:
main
()
File Metadata
Details
Attached
Mime Type
text/x-script.python
Expires
Mon, Feb 24, 8:57 PM (12 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1464453
Default Alt Text
fence_alom.py (2 KB)
Attached To
Mode
rF Fence Agents
Attached
Detach File
Event Timeline
Log In to Comment