Gitweb:
http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=6692c8...
Commit: 6692c808071fc1c61389277eefabde44cc31ae37
Parent: 848b801b36ccffa27fae19fe6fbcfb4a496d9d7a
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Apr 23 17:57:13 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon May 5 12:02:15 2014 +0200
[cleanup] '--action' should be normalized to lowercase at one place only
---
fence/agents/drac5/fence_drac5.py | 2 +-
fence/agents/lib/fencing.py.py | 10 +++++-----
fence/agents/xenapi/fence_xenapi.py | 8 +++-----
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index 845c6ac..7821f00 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -142,7 +142,7 @@ By default, the telnet interface is not enabled."
options["--drac-version"] = "DRAC 5"
if options["--drac-version"] in ["DRAC MC", "DRAC CMC"]:
- if not options.has_key("--plug") and 0 == ["monitor",
"list"].count(options["--action"].lower()):
+ if not options.has_key("--plug") and 0 == ["monitor",
"list"].count(options["--action"]):
fail_usage("Failed: You have to enter module name (-n)")
result = fence_action(conn, options, set_power_status, get_power_status,
get_list_devices)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index b3afa0f..c366423 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -688,14 +688,14 @@ def check_input(device_opt, opt):
if not options.has_key(getopt_long):
options[getopt_long] = all_opt[opt]["default"]
+ options["--action"] = options["--action"].lower()
+
## In special cases (show help, metadata or version) we don't need to check
anything
#####
if options.has_key("--help") or options.has_key("--version") or \
- options.get("--action", "").lower() == "metadata":
+ options["--action"] == "metadata":
return options
- options["--action"] = options["--action"].lower()
-
if options.has_key("--verbose"):
logging.getLogger().setLevel(logging.DEBUG)
@@ -744,7 +744,7 @@ def check_input(device_opt, opt):
if not os.path.isfile(options["--identity-file"]):
fail_usage("Failed: Identity file " + options["--identity-file"] +
" does not exist")
- if (0 == ["list",
"monitor"].count(options["--action"].lower())) and \
+ if (0 == ["list", "monitor"].count(options["--action"]))
and \
not options.has_key("--plug") and device_opt.count("port") and
device_opt.count("no_port") == 0:
fail_usage("Failed: You have to enter plug number or machine
identification")
@@ -840,7 +840,7 @@ def show_docs(options, docs = None):
usage(device_opt)
sys.exit(0)
- if options.get("--action", "").lower() == "metadata":
+ if options.get("--action", "") == "metadata":
metadata(device_opt, options, docs)
sys.exit(0)
diff --git a/fence/agents/xenapi/fence_xenapi.py b/fence/agents/xenapi/fence_xenapi.py
index 25db7c7..958b006 100644
--- a/fence/agents/xenapi/fence_xenapi.py
+++ b/fence/agents/xenapi/fence_xenapi.py
@@ -79,8 +79,6 @@ def get_power_fn(session, options):
# Set the state of the port given in the -U flag of options.
def set_power_fn(session, options):
- action = options["--action"].lower()
-
try:
# Get a reference to the vm specified in the UUID or vm_name/port parameter
vm = return_vm_reference(session, options)
@@ -89,13 +87,13 @@ def set_power_fn(session, options):
# Check that we are not trying to manipulate a template or a control
# domain as they show up as VM's with specific properties.
if not record["is_a_template"] and not
record["is_control_domain"]:
- if action == "on":
+ if options["--action"] == "on":
# Start the VM
session.xenapi.VM.start(vm, False, True)
- elif action == "off":
+ elif options["--action"] == "off":
# Force shutdown the VM
session.xenapi.VM.hard_shutdown(vm)
- elif action == "reboot":
+ elif options["--action"] == "reboot":
# Force reboot the VM
session.xenapi.VM.hard_reboot(vm)
except Exception, exn: