|
|
d67cb5 |
commit be464e49a941f727812615107cbeeda119cf5669
|
|
|
d67cb5 |
Author: Marek 'marx' Grac <mgrac@redhat.com>
|
|
|
d67cb5 |
Date: Mon Oct 14 13:54:47 2013 +0200
|
|
|
d67cb5 |
|
|
|
d67cb5 |
fence_vmware_soap: Correct error message when user does not have privileges
|
|
|
d67cb5 |
|
|
|
d67cb5 |
Previously, when an user does not have privileges to reboot a virtual machine, the
|
|
|
d67cb5 |
fence agent fails with python traceback. After applying this patch (by Shane Bradley),
|
|
|
d67cb5 |
the fence_vmware_soap fails with human readable error message.
|
|
|
d67cb5 |
|
|
|
d67cb5 |
Resolves: rhbz#1918263
|
|
|
d67cb5 |
|
|
|
d67cb5 |
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
|
|
|
d67cb5 |
index d6b02d3..b2ab4be 100644
|
|
|
d67cb5 |
--- a/fence/agents/lib/fencing.py.py
|
|
|
d67cb5 |
+++ b/fence/agents/lib/fencing.py.py
|
|
|
d67cb5 |
@@ -24,6 +24,7 @@ EC_WAITING_OFF = 7
|
|
|
d67cb5 |
EC_STATUS = 8
|
|
|
d67cb5 |
EC_STATUS_HMC = 9
|
|
|
d67cb5 |
EC_PASSWORD_MISSING = 10
|
|
|
d67cb5 |
+EC_INVALID_PRIVILEGES = 11
|
|
|
d67cb5 |
|
|
|
d67cb5 |
TELNET_PATH = "/usr/bin/telnet"
|
|
|
d67cb5 |
SSH_PATH = "/usr/bin/ssh"
|
|
|
d67cb5 |
@@ -413,7 +414,8 @@ def fail(error_code):
|
|
|
d67cb5 |
EC_STATUS : "Failed: Unable to obtain correct plug status or plug is not available",
|
|
|
d67cb5 |
EC_STATUS_HMC :
|
|
|
d67cb5 |
"Failed: Either unable to obtain correct plug status, partition is not available or incorrect HMC version used",
|
|
|
d67cb5 |
- EC_PASSWORD_MISSING : "Failed: You have to set login password"
|
|
|
d67cb5 |
+ EC_PASSWORD_MISSING : "Failed: You have to set login password",
|
|
|
d67cb5 |
+ EC_INVALID_PRIVILEGES : "Failed: The user does not have the correct privileges to do the requested action."
|
|
|
d67cb5 |
}[error_code] + "\n"
|
|
|
d67cb5 |
sys.stderr.write(message)
|
|
|
d67cb5 |
syslog.syslog(syslog.LOG_ERR, message)
|
|
|
d67cb5 |
diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
|
|
|
d67cb5 |
index ac7f0d9..98ac011 100644
|
|
|
d67cb5 |
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
|
|
|
d67cb5 |
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
|
|
|
d67cb5 |
@@ -156,10 +156,19 @@ def set_power_status(conn, options):
|
|
|
d67cb5 |
mo_machine = Property(vm.value)
|
|
|
d67cb5 |
mo_machine._type = "VirtualMachine"
|
|
|
d67cb5 |
|
|
|
d67cb5 |
- if options["--action"] == "on":
|
|
|
d67cb5 |
- conn.service.PowerOnVM_Task(mo_machine)
|
|
|
d67cb5 |
- else:
|
|
|
d67cb5 |
- conn.service.PowerOffVM_Task(mo_machine)
|
|
|
d67cb5 |
+ try:
|
|
|
d67cb5 |
+ if options["--action"] == "on":
|
|
|
d67cb5 |
+ conn.service.PowerOnVM_Task(mo_machine)
|
|
|
d67cb5 |
+ else:
|
|
|
d67cb5 |
+ conn.service.PowerOffVM_Task(mo_machine)
|
|
|
d67cb5 |
+ except WebFault, ex:
|
|
|
d67cb5 |
+ if ((str(ex).find("Permission to perform this operation was denied")) >= 0):
|
|
|
d67cb5 |
+ fail(EC_INVALID_PRIVILEGES)
|
|
|
d67cb5 |
+ else:
|
|
|
d67cb5 |
+ if options["--action"] == "on":
|
|
|
d67cb5 |
+ fail(EC_WAITING_ON)
|
|
|
d67cb5 |
+ else:
|
|
|
d67cb5 |
+ fail(EC_WAITING_OFF)
|
|
|
d67cb5 |
|
|
|
d67cb5 |
def remove_tmp_dir(tmp_dir):
|
|
|
d67cb5 |
shutil.rmtree(tmp_dir)
|