|
|
3bc0dd |
From b885e0f65af626154096a49554e9765e18bfbbd9 Mon Sep 17 00:00:00 2001
|
|
|
3bc0dd |
From: Frank Toth <ftoth1@bloomberg.net>
|
|
|
3bc0dd |
Date: Wed, 16 Oct 2019 13:58:50 +0800
|
|
|
3bc0dd |
Subject: [PATCH 1/3] Added cookie file management to properly reuse session
|
|
|
3bc0dd |
and do not create new one every time.
|
|
|
3bc0dd |
|
|
|
3bc0dd |
---
|
|
|
3bc0dd |
agents/rhevm/fence_rhevm.py | 15 ++++++++++++++-
|
|
|
3bc0dd |
1 file changed, 14 insertions(+), 1 deletion(-)
|
|
|
3bc0dd |
|
|
|
3bc0dd |
diff --git a/agents/rhevm/fence_rhevm.py b/agents/rhevm/fence_rhevm.py
|
|
|
3bc0dd |
index 9e4650cd..defa35e6 100644
|
|
|
3bc0dd |
--- a/agents/rhevm/fence_rhevm.py
|
|
|
3bc0dd |
+++ b/agents/rhevm/fence_rhevm.py
|
|
|
3bc0dd |
@@ -117,7 +117,12 @@ def send_command(opt, command, method="GET"):
|
|
|
3bc0dd |
conn.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC)
|
|
|
3bc0dd |
conn.setopt(pycurl.USERPWD, opt["--username"] + ":" + opt["--password"])
|
|
|
3bc0dd |
if "--use-cookies" in opt:
|
|
|
3bc0dd |
- conn.setopt(pycurl.COOKIEFILE, "")
|
|
|
3bc0dd |
+ if "--cookie-file" in opt:
|
|
|
3bc0dd |
+ cookie_file = opt["--cookie-file"]
|
|
|
3bc0dd |
+ else:
|
|
|
3bc0dd |
+ cookie_file = "/tmp/fence_rhevm_" + opt["--ip"] + "_" + opt["--username"] + "_cookie.dat"
|
|
|
3bc0dd |
+ conn.setopt(pycurl.COOKIEFILE, cookie_file)
|
|
|
3bc0dd |
+ conn.setopt(pycurl.COOKIEJAR, cookie_file)
|
|
|
3bc0dd |
|
|
|
3bc0dd |
conn.setopt(pycurl.TIMEOUT, int(opt["--shell-timeout"]))
|
|
|
3bc0dd |
if "--ssl" in opt or "--ssl-secure" in opt:
|
|
|
3bc0dd |
@@ -166,6 +171,14 @@ def define_new_opts():
|
|
|
3bc0dd |
"required" : "0",
|
|
|
3bc0dd |
"shortdesc" : "Reuse cookies for authentication",
|
|
|
3bc0dd |
"order" : 1}
|
|
|
3bc0dd |
+ all_opt["cookie_file"] = {
|
|
|
3bc0dd |
+ "getopt" : ":",
|
|
|
3bc0dd |
+ "longopt" : "cookie-file",
|
|
|
3bc0dd |
+ "help" : "--cookie-file Path to cookie file for authentication\n"
|
|
|
3bc0dd |
+ "\t\t\t\t (Default: /tmp/fence_rhevm_ip_username_cookie.dat)",
|
|
|
3bc0dd |
+ "required" : "0",
|
|
|
3bc0dd |
+ "shortdesc" : "Path to cookie file for authentication",
|
|
|
3bc0dd |
+ "order" : 2}
|
|
|
3bc0dd |
all_opt["api_version"] = {
|
|
|
3bc0dd |
"getopt" : ":",
|
|
|
3bc0dd |
"longopt" : "api-version",
|
|
|
3bc0dd |
|
|
|
3bc0dd |
From 874344acbfee5f774b320e384a46e1ce953a34ce Mon Sep 17 00:00:00 2001
|
|
|
3bc0dd |
From: Frank Toth <ftoth1@bloomberg.net>
|
|
|
3bc0dd |
Date: Wed, 16 Oct 2019 23:41:50 +0800
|
|
|
3bc0dd |
Subject: [PATCH 2/3] Added cookie_file to device_opt array. Use
|
|
|
3bc0dd |
tempfile.gettempdir() to get the TMP dir instead of hardcoded /tmp
|
|
|
3bc0dd |
|
|
|
3bc0dd |
---
|
|
|
3bc0dd |
agents/rhevm/fence_rhevm.py | 4 +++-
|
|
|
3bc0dd |
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
3bc0dd |
|
|
|
3bc0dd |
diff --git a/agents/rhevm/fence_rhevm.py b/agents/rhevm/fence_rhevm.py
|
|
|
3bc0dd |
index defa35e6..25aecbe5 100644
|
|
|
3bc0dd |
--- a/agents/rhevm/fence_rhevm.py
|
|
|
3bc0dd |
+++ b/agents/rhevm/fence_rhevm.py
|
|
|
3bc0dd |
@@ -4,6 +4,7 @@
|
|
|
3bc0dd |
import pycurl, io
|
|
|
3bc0dd |
import logging
|
|
|
3bc0dd |
import atexit
|
|
|
3bc0dd |
+import tempfile
|
|
|
3bc0dd |
sys.path.append("@FENCEAGENTSLIBDIR@")
|
|
|
3bc0dd |
from fencing import *
|
|
|
3bc0dd |
from fencing import fail, EC_FETCH_VM_UUID, run_delay
|
|
|
3bc0dd |
@@ -120,7 +121,7 @@ def send_command(opt, command, method="GET"):
|
|
|
3bc0dd |
if "--cookie-file" in opt:
|
|
|
3bc0dd |
cookie_file = opt["--cookie-file"]
|
|
|
3bc0dd |
else:
|
|
|
3bc0dd |
- cookie_file = "/tmp/fence_rhevm_" + opt["--ip"] + "_" + opt["--username"] + "_cookie.dat"
|
|
|
3bc0dd |
+ cookie_file = tempfile.gettempdir() + "/fence_rhevm_" + opt["--ip"] + "_" + opt["--username"] + "_cookie.dat"
|
|
|
3bc0dd |
conn.setopt(pycurl.COOKIEFILE, cookie_file)
|
|
|
3bc0dd |
conn.setopt(pycurl.COOKIEJAR, cookie_file)
|
|
|
3bc0dd |
|
|
|
3bc0dd |
@@ -215,6 +216,7 @@ def main():
|
|
|
3bc0dd |
"web",
|
|
|
3bc0dd |
"port",
|
|
|
3bc0dd |
"use_cookies",
|
|
|
3bc0dd |
+ "cookie_file",
|
|
|
3bc0dd |
"api_version",
|
|
|
3bc0dd |
"api_path",
|
|
|
3bc0dd |
"disable_http_filter",
|
|
|
3bc0dd |
|
|
|
3bc0dd |
From 196513cfc0edfd28f483a00b4adfa230b666a47d Mon Sep 17 00:00:00 2001
|
|
|
3bc0dd |
From: Frank Toth <ftoth1@bloomberg.net>
|
|
|
3bc0dd |
Date: Fri, 18 Oct 2019 05:16:18 +0200
|
|
|
3bc0dd |
Subject: [PATCH 3/3] After 'make xml-upload'
|
|
|
3bc0dd |
|
|
|
3bc0dd |
---
|
|
|
3bc0dd |
tests/data/metadata/fence_rhevm.xml | 5 +++++
|
|
|
3bc0dd |
1 file changed, 5 insertions(+)
|
|
|
3bc0dd |
|
|
|
3bc0dd |
diff --git a/tests/data/metadata/fence_rhevm.xml b/tests/data/metadata/fence_rhevm.xml
|
|
|
3bc0dd |
index c56cf64b..2b6b02b2 100644
|
|
|
3bc0dd |
--- a/tests/data/metadata/fence_rhevm.xml
|
|
|
3bc0dd |
+++ b/tests/data/metadata/fence_rhevm.xml
|
|
|
3bc0dd |
@@ -103,6 +103,11 @@
|
|
|
3bc0dd |
<content type="string" default="auto" />
|
|
|
3bc0dd |
<shortdesc lang="en">Version of RHEV API (default: auto)</shortdesc>
|
|
|
3bc0dd |
</parameter>
|
|
|
3bc0dd |
+ <parameter name="cookie_file" unique="0" required="0">
|
|
|
3bc0dd |
+ <getopt mixed="--cookie-file" />
|
|
|
3bc0dd |
+ <content type="string" />
|
|
|
3bc0dd |
+ <shortdesc lang="en">Path to cookie file for authentication</shortdesc>
|
|
|
3bc0dd |
+ </parameter>
|
|
|
3bc0dd |
<parameter name="api_path" unique="0" required="0">
|
|
|
3bc0dd |
<getopt mixed="--api-path=[path]" />
|
|
|
3bc0dd |
<shortdesc lang="en">The path part of the API URL</shortdesc>
|