Blob Blame History Raw
From 76ddf8b54482ef4702abc35611cf1c0250c62dcd Mon Sep 17 00:00:00 2001
From: Marek 'marx' Grac <mgrac@redhat.com>
Date: Mon, 10 Aug 2015 13:17:07 +0200
Subject: [PATCH] fencing: Fence library should work correctly also when power
 state is None

Previously, valid states ON/OFF were accepted and all other values were mapped to UNKNOWN. But if value is None then
it is not possible to do state.upper() and fencing fails.

Resolves: rhbz#1251491
---
 fence/agents/lib/fencing.py.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index fb7b77d..3a6e2ab 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -951,9 +951,9 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list=None,
 				## keys can be numbers (port numbers) or strings (names of VM)
 				for outlet_id in outlets.keys():
 					(alias, status) = outlets[outlet_id]
-					status = status.upper()
-					if not status in ["ON", "OFF"]:
+					if status is None or (not status.upper() in ["ON", "OFF"]):
 						status = "UNKNOWN"
+						status = status.upper()
 
 					if options["--action"] == "list":
 						print outlet_id + options["--separator"] + alias
-- 
1.9.3