Commit
Previous version of fence_ipmilan (C-based) contains also action 'diag'. This commit adds this action to new fence agent. Resolves: rhbz#1286045
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,10 @@ def reboot_cycle(_, options): | |
output = run_command(options, create_command(options, "cycle")) | ||
return bool(re.search('chassis power control: cycle', str(output).lower())) | ||
|
||
def reboot_diag(_, options): | ||
output = run_command(options, create_command(options, "diag")) | ||
return bool(re.search('chassis power control: diag', str(output).lower())) | ||
|
||
def create_command(options, action): | ||
cmd = options["--ipmitool-path"] | ||
|
||
|
@@ -123,7 +127,7 @@ def define_new_opts(): | |
def main(): | ||
atexit.register(atexit_handler) | ||
|
||
device_opt = ["ipaddr", "login", "no_login", "no_password", "passwd", | ||
device_opt = ["ipaddr", "login", "no_login", "no_password", "passwd", "diag", | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
marxsk
Author
Contributor
|
||
"lanplus", "auth", "cipher", "privlvl", "sudo", "ipmitool_path", "method"] | ||
define_new_opts() | ||
|
||
|
@@ -156,7 +160,14 @@ def main(): | |
if not is_executable(options["--ipmitool-path"]): | ||
fail_usage("Ipmitool not found or not accessible") | ||
|
||
result = fence_action(None, options, set_power_status, get_power_status, None, reboot_cycle) | ||
reboot_fn = reboo_cycle | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
if options["--action"] == "diag": | ||
# Diag is a special action that can't be verified so we will reuse reboot functionality | ||
# to minimize impact on generic library | ||
options["--action"] = "reboot" | ||
reboot_fn = reboot_diag | ||
|
||
result = fence_action(None, options, set_power_status, get_power_status, None, reboot_fn) | ||
sys.exit(result) | ||
|
||
if __name__ == "__main__": | ||
|
3 comments
on commit 7e65180
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I'm actually testing this, fencing.py.py is also missing an update for in-line help in the action block e.g.:
"help" : "-o, --action=[action] Action: status, reboot (default), off or on",
should probably list diag too so people know they can use it?
Also, I finally took some time to test this, and... this does not behave as expected at all when I tried this?
I had to specify -m cycle to get the expected behavior, otherwise it does ipmitool chassis power off then waits till off then turns it back on (default -m offon)
e.g. fence_ipmilan -v -a IP -o diag -m cycle -P
worked but fence_ipmilan -v -a IP -o diag -P
did exactly the same as fence_ipmilan -v -a IP -o reboot -P
It's really easy to test so please do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right.
With testing, it is quite difficult as I don't have direct access to most of the devices that are supported. My obsolete ipmi does not have 'diag' so it was not tested. Currently, I had obtained access to ilo4 (what is ipmi) and it works as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm right I thought you could use a dummy IP and -v to see what command it tries to run but it will always try to do status before doing anything else.. Should be possible to test if the command it tries to run looks alright with verbose and an old ipmi though, even if the command diag itself will fail :)
Is it a requirement to add this new device option? Is it a boolean? Reading the whole patch, it seems that action="diag" should work without this new device option? Am I wrong?