Blob Blame History Raw
From 03eee868ec5f3a07024a6b7c65572e54238106c6 Mon Sep 17 00:00:00 2001
From: Rik Theys <Rik.Theys@esat.kuleuven.be>
Date: Tue, 19 May 2015 13:24:09 +0200
Subject: [PATCH 1/2] fence_rhevm: Add Filter header

oVirt users who only have the UserRole role don't have enough privileges
to query the vm list, unless the Filter header is set to true.

See rhbz#1102801 for details.
---
 fence/agents/rhevm/fence_rhevm.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fence/agents/rhevm/fence_rhevm.py b/fence/agents/rhevm/fence_rhevm.py
index 427bed5..cf85689 100644
--- a/fence/agents/rhevm/fence_rhevm.py
+++ b/fence/agents/rhevm/fence_rhevm.py
@@ -87,7 +87,7 @@ def send_command(opt, command, method="GET"):
 	conn = pycurl.Curl()
 	web_buffer = StringIO.StringIO()
 	conn.setopt(pycurl.URL, url)
-	conn.setopt(pycurl.HTTPHEADER, ["Content-type: application/xml", "Accept: application/xml", "Prefer: persistent-auth"])
+	conn.setopt(pycurl.HTTPHEADER, ["Content-type: application/xml", "Accept: application/xml", "Prefer: persistent-auth", "Filter: true"])
 
 	if opt.has_key("cookie"):
 		conn.setopt(pycurl.COOKIE, opt["cookie"])
-- 
2.5.0


From d19bb9b0e3ae285fbf36ef0fc0b76e7dccddb5d8 Mon Sep 17 00:00:00 2001
From: Rik Theys <Rik.Theys@esat.kuleuven.be>
Date: Tue, 19 May 2015 13:31:14 +0200
Subject: [PATCH 2/2] fence_rhevm: Fill in outlet status in get_list

The outlet status was set to None for all outlets. This results in a
traceback in fencing.py as it tries to execute the upper() function on
the status. This is fine when the account that tries to access the data
is an admin account as the list will be empty. If a UserRole user is
used, the vm list is not empty and the error occurs.

Fill in the status of each vm in the outlet status to prevent the
traceback.
---
 fence/agents/rhevm/fence_rhevm.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fence/agents/rhevm/fence_rhevm.py b/fence/agents/rhevm/fence_rhevm.py
index cf85689..3926f3b 100644
--- a/fence/agents/rhevm/fence_rhevm.py
+++ b/fence/agents/rhevm/fence_rhevm.py
@@ -66,7 +66,8 @@ def get_list(conn, options):
 		lines = res.split("<vm ")
 		for i in range(1, len(lines)):
 			name = RE_GET_NAME.search(lines[i]).group(1)
-			outlets[name] = ("", None)
+			status = RE_STATUS.search(lines[i]).group(1)
+			outlets[name] = ("", status)
 	except AttributeError:
 		return {}
 	except IndexError:
-- 
2.5.0