Blame SOURCES/bz1464933-1-fence_redfish.patch

bbedc2
From 64e3f3ef4d0abefd2836fe015c87173310b1e130 Mon Sep 17 00:00:00 2001
bbedc2
From: Jose Delarosa <jose.delarosa@dell.com>
bbedc2
Date: Mon, 3 Dec 2018 10:11:15 -0600
bbedc2
Subject: [PATCH 1/8] Add new fence agent for Redfish
bbedc2
bbedc2
- Agent works on all fence devices that implement the Redfish API specification
bbedc2
- Agent programatically finds the Systems Resouce URI if it's not provided
bbedc2
---
bbedc2
 agents/redfish/fence_redfish.py       | 151 +++++++++++++++++++++
bbedc2
 tests/data/metadata/fence_redfish.xml | 181 ++++++++++++++++++++++++++
bbedc2
 2 files changed, 332 insertions(+)
bbedc2
 create mode 100644 agents/redfish/fence_redfish.py
bbedc2
 create mode 100644 tests/data/metadata/fence_redfish.xml
bbedc2
bbedc2
diff --git a/agents/redfish/fence_redfish.py b/agents/redfish/fence_redfish.py
bbedc2
new file mode 100644
bbedc2
index 00000000..df7cf8c2
bbedc2
--- /dev/null
bbedc2
+++ b/agents/redfish/fence_redfish.py
bbedc2
@@ -0,0 +1,151 @@
bbedc2
+#!@PYTHON@ -tt
bbedc2
+
bbedc2
+# Copyright (c) 2018 Dell Inc. or its subsidiaries. All Rights Reserved.
bbedc2
+
bbedc2
+# Fence agent for devices that support the Redfish API Specification.
bbedc2
+
bbedc2
+import sys
bbedc2
+import re
bbedc2
+import json
bbedc2
+import requests
bbedc2
+import atexit
bbedc2
+sys.path.append("@FENCEAGENTSLIBDIR@")
bbedc2
+
bbedc2
+from requests.packages.urllib3.exceptions import InsecureRequestWarning
bbedc2
+from fencing import *
bbedc2
+from fencing import fail_usage
bbedc2
+
bbedc2
+def get_power_status(conn, options):
bbedc2
+    uri = options["--systems-uri"]
bbedc2
+    response = send_get_request(options, uri)
bbedc2
+    if response['ret'] is False:
bbedc2
+        fail_usage("Couldn't get power information")
bbedc2
+    data = response['data']
bbedc2
+    if data[u'PowerState'].strip() == "On":
bbedc2
+        return "on"
bbedc2
+    else:
bbedc2
+        return "off"
bbedc2
+
bbedc2
+def set_power_status(conn, options):
bbedc2
+    action = {
bbedc2
+        'on' : "On",
bbedc2
+        'off': "ForceOff",
bbedc2
+        'reboot': "GracefulRestart"
bbedc2
+    }[options["--action"]]
bbedc2
+
bbedc2
+    payload = {'ResetType': action}
bbedc2
+    headers = {'content-type': 'application/json'}
bbedc2
+
bbedc2
+    # Search for 'Actions' key and extract URI from it
bbedc2
+    uri = options["--systems-uri"]
bbedc2
+    response = send_get_request(options, uri)
bbedc2
+    if response['ret'] is False:
bbedc2
+        return {'ret': False}
bbedc2
+    data = response['data']
bbedc2
+    uri = data["Actions"]["#ComputerSystem.Reset"]["target"]
bbedc2
+
bbedc2
+    response = send_post_request(options, uri, payload, headers)
bbedc2
+    if response['ret'] is False:
bbedc2
+        fail_usage("Error sending power command")
bbedc2
+    return
bbedc2
+
bbedc2
+def send_get_request(options, uri):
bbedc2
+    full_uri = "https://" + options["--ip"] + uri
bbedc2
+    try:
bbedc2
+        resp = requests.get(full_uri, verify=False,
bbedc2
+                            auth=(options["--username"], options["--password"]))
bbedc2
+        data = resp.json()
bbedc2
+    except:
bbedc2
+        return {'ret': False}
bbedc2
+    return {'ret': True, 'data': data}
bbedc2
+
bbedc2
+def send_post_request(options, uri, payload, headers):
bbedc2
+    full_uri = "https://" + options["--ip"] + uri
bbedc2
+    try:
bbedc2
+        requests.post(full_uri, data=json.dumps(payload),
bbedc2
+                      headers=headers, verify=False,
bbedc2
+                      auth=(options["--username"], options["--password"]))
bbedc2
+    except:
bbedc2
+        return {'ret': False}
bbedc2
+    return {'ret': True}
bbedc2
+
bbedc2
+def find_systems_resource(options):
bbedc2
+    uri = options["--redfish-uri"]
bbedc2
+    response = send_get_request(options, uri)
bbedc2
+    if response['ret'] is False:
bbedc2
+        return {'ret': False}
bbedc2
+    data = response['data']
bbedc2
+
bbedc2
+    if 'Systems' not in data:
bbedc2
+        # Systems resource not found"
bbedc2
+        return {'ret': False}
bbedc2
+    else:
bbedc2
+        uri = data["Systems"]["@odata.id"]
bbedc2
+        response = send_get_request(options, uri)
bbedc2
+        if response['ret'] is False:
bbedc2
+            return {'ret': False}
bbedc2
+        data = response['data']
bbedc2
+
bbedc2
+        # need to be able to handle more than one entry
bbedc2
+        for member in data[u'Members']:
bbedc2
+            system_uri = member[u'@odata.id']
bbedc2
+        return {'ret': True, 'uri': system_uri}
bbedc2
+
bbedc2
+def define_new_opts():
bbedc2
+    all_opt["redfish-uri"] = {
bbedc2
+        "getopt" : ":",
bbedc2
+        "longopt" : "redfish-uri",
bbedc2
+        "help" : "--redfish-uri=[uri]            Base or starting Redifsh URI",
bbedc2
+        "required" : "0",
bbedc2
+        "default" : "/redfish/v1",
bbedc2
+        "shortdesc" : "Base or starting Redfish URI",
bbedc2
+        "order": 1
bbedc2
+    }
bbedc2
+    all_opt["systems-uri"] = {
bbedc2
+        "getopt" : ":",
bbedc2
+        "longopt" : "systems-uri",
bbedc2
+        "help" : "--systems-uri=[uri]            Redfish Systems resource URI",
bbedc2
+        "required" : "0",
bbedc2
+        "shortdesc" : "Redfish Systems resource URI, i.e. /redfish/v1/Systems/System.Embedded.1",
bbedc2
+        "order": 1
bbedc2
+    }
bbedc2
+
bbedc2
+def main():
bbedc2
+    atexit.register(atexit_handler)
bbedc2
+    device_opt = ["ipaddr", "login", "passwd", "redfish-uri", "systems-uri", "ssl"]
bbedc2
+    define_new_opts()
bbedc2
+
bbedc2
+    opt = process_input(device_opt)
bbedc2
+
bbedc2
+    all_opt["ipport"]["default"] = "443"
bbedc2
+    options = check_input(device_opt, opt)
bbedc2
+
bbedc2
+    docs = {}
bbedc2
+    docs["shortdesc"] = "I/O Fencing agent for Redfish"
bbedc2
+    docs["longdesc"] = "fence_redfish is an I/O Fencing agent which can be used with \
bbedc2
+Out-of-Band controllers that support Redfish APIs. These controllers provide remote \
bbedc2
+access to control power on a server."
bbedc2
+    docs["vendorurl"] = "http://www.dmtf.org"
bbedc2
+    show_docs(options, docs)
bbedc2
+
bbedc2
+    ##
bbedc2
+    ## Operate the fencing device
bbedc2
+    ####
bbedc2
+
bbedc2
+    # Disable insecure-certificate-warning message
bbedc2
+    if "--ssl-insecure" in opt:
bbedc2
+        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
bbedc2
+
bbedc2
+    if "--systems-uri" not in opt:
bbedc2
+        # Systems URI not provided, find it
bbedc2
+        sysresult = find_systems_resource(options)
bbedc2
+        if sysresult['ret'] is False:
bbedc2
+            sys.exit(1)
bbedc2
+        else:
bbedc2
+            options["--systems-uri"] = sysresult["uri"]
bbedc2
+
bbedc2
+    result = fence_action(None, options, set_power_status, get_power_status, None)
bbedc2
+    sys.exit(result)
bbedc2
+
bbedc2
+if __name__ == "__main__":
bbedc2
+    main()
bbedc2
diff --git a/tests/data/metadata/fence_redfish.xml b/tests/data/metadata/fence_redfish.xml
bbedc2
new file mode 100644
bbedc2
index 00000000..43d447d0
bbedc2
--- /dev/null
bbedc2
+++ b/tests/data/metadata/fence_redfish.xml
bbedc2
@@ -0,0 +1,181 @@
bbedc2
+
bbedc2
+<resource-agent name="fence_redfish" shortdesc="I/O Fencing agent for Redfish" >
bbedc2
+<longdesc>fence_redfish is an I/O Fencing agent which can be used with Out-of-Band controllers that support Redfish APIs. These controllers provide remote access to control power on a server.</longdesc>
bbedc2
+<vendor-url>http://www.dmtf.org</vendor-url>
bbedc2
+<parameters>
bbedc2
+	<parameter name="ipport" unique="0" required="0">
bbedc2
+		<getopt mixed="-u, --ipport=[port]" />
bbedc2
+		<content type="integer" default="443"  />
bbedc2
+		<shortdesc lang="en">TCP/UDP port to use for connection with device</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="ssl_secure" unique="0" required="0">
bbedc2
+		<getopt mixed="--ssl-secure" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">SSL connection with verifying fence device's certificate</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="systems-uri" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="--systems-uri=[uri]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Redfish Systems resource URI, i.e. /redfish/v1/Systems/System.Embedded.1</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="action" unique="0" required="1">
bbedc2
+		<getopt mixed="-o, --action=[action]" />
bbedc2
+		<content type="string" default="reboot"  />
bbedc2
+		<shortdesc lang="en">Fencing Action</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="inet6_only" unique="0" required="0">
bbedc2
+		<getopt mixed="-6, --inet6-only" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Forces agent to use IPv6 addresses only</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="ipaddr" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="-a, --ip=[ip]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">IP Address or Hostname</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="port" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="-n, --plug=[ip]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">IP address or hostname of fencing device (together with --port-as-ip)</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="passwd_script" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="-S, --password-script=[script]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Script to retrieve password</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="inet4_only" unique="0" required="0">
bbedc2
+		<getopt mixed="-4, --inet4-only" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Forces agent to use IPv4 addresses only</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="passwd" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="-p, --password=[password]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Login password or passphrase</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="ssl" unique="0" required="0">
bbedc2
+		<getopt mixed="-z, --ssl" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">SSL connection</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="redfish-uri" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="--redfish-uri=[uri]" />
bbedc2
+		<content type="string" default="/redfish/v1"  />
bbedc2
+		<shortdesc lang="en">Base or starting Redfish URI</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="ssl_insecure" unique="0" required="0">
bbedc2
+		<getopt mixed="--ssl-insecure" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">SSL connection without verifying fence device's certificate</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="login" unique="0" required="1" deprecated="1">
bbedc2
+		<getopt mixed="-l, --username=[name]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Login Name</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="plug" unique="0" required="0" obsoletes="port">
bbedc2
+		<getopt mixed="-n, --plug=[ip]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">IP address or hostname of fencing device (together with --port-as-ip)</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="username" unique="0" required="1" obsoletes="login">
bbedc2
+		<getopt mixed="-l, --username=[name]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Login Name</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="redfish_uri" unique="0" required="0" obsoletes="redfish-uri">
bbedc2
+		<getopt mixed="--redfish-uri=[uri]" />
bbedc2
+		<content type="string" default="/redfish/v1"  />
bbedc2
+		<shortdesc lang="en">Base or starting Redfish URI</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="ip" unique="0" required="0" obsoletes="ipaddr">
bbedc2
+		<getopt mixed="-a, --ip=[ip]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">IP Address or Hostname</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="systems_uri" unique="0" required="0" obsoletes="systems-uri">
bbedc2
+		<getopt mixed="--systems-uri=[uri]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Redfish Systems resource URI, i.e. /redfish/v1/Systems/System.Embedded.1</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="password" unique="0" required="0" obsoletes="passwd">
bbedc2
+		<getopt mixed="-p, --password=[password]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Login password or passphrase</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="password_script" unique="0" required="0" obsoletes="passwd_script">
bbedc2
+		<getopt mixed="-S, --password-script=[script]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Script to retrieve password</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="verbose" unique="0" required="0">
bbedc2
+		<getopt mixed="-v, --verbose" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Verbose mode</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="debug" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="-D, --debug-file=[debugfile]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Write debug information to given file</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="debug_file" unique="0" required="0" obsoletes="debug">
bbedc2
+		<getopt mixed="-D, --debug-file=[debugfile]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Write debug information to given file</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="version" unique="0" required="0">
bbedc2
+		<getopt mixed="-V, --version" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Display version information and exit</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="help" unique="0" required="0">
bbedc2
+		<getopt mixed="-h, --help" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Display help and exit</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="power_wait" unique="0" required="0">
bbedc2
+		<getopt mixed="--power-wait=[seconds]" />
bbedc2
+		<content type="second" default="0"  />
bbedc2
+		<shortdesc lang="en">Wait X seconds after issuing ON/OFF</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="login_timeout" unique="0" required="0">
bbedc2
+		<getopt mixed="--login-timeout=[seconds]" />
bbedc2
+		<content type="second" default="5"  />
bbedc2
+		<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="power_timeout" unique="0" required="0">
bbedc2
+		<getopt mixed="--power-timeout=[seconds]" />
bbedc2
+		<content type="second" default="20"  />
bbedc2
+		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="delay" unique="0" required="0">
bbedc2
+		<getopt mixed="--delay=[seconds]" />
bbedc2
+		<content type="second" default="0"  />
bbedc2
+		<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="shell_timeout" unique="0" required="0">
bbedc2
+		<getopt mixed="--shell-timeout=[seconds]" />
bbedc2
+		<content type="second" default="3"  />
bbedc2
+		<shortdesc lang="en">Wait X seconds for cmd prompt after issuing command</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="port_as_ip" unique="0" required="0">
bbedc2
+		<getopt mixed="--port-as-ip" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Make "port/plug" to be an alias to IP address</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="retry_on" unique="0" required="0">
bbedc2
+		<getopt mixed="--retry-on=[attempts]" />
bbedc2
+		<content type="integer" default="1"  />
bbedc2
+		<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
bbedc2
+	</parameter>
bbedc2
+</parameters>
bbedc2
+<actions>
bbedc2
+	<action name="on" automatic="0"/>
bbedc2
+	<action name="off" />
bbedc2
+	<action name="reboot" />
bbedc2
+	<action name="status" />
bbedc2
+	<action name="monitor" />
bbedc2
+	<action name="metadata" />
bbedc2
+	<action name="validate-all" />
bbedc2
+</actions>
bbedc2
+</resource-agent>
bbedc2
bbedc2
From 6921a34d64d098a7b1f32205e0be434438c36898 Mon Sep 17 00:00:00 2001
bbedc2
From: Jose Delarosa <jose.delarosa@dell.com>
bbedc2
Date: Mon, 3 Dec 2018 10:46:52 -0600
bbedc2
Subject: [PATCH 2/8] Updated fence_redfish.xml with make xml-upload
bbedc2
bbedc2
---
bbedc2
 tests/data/metadata/fence_redfish.xml | 148 ++++++++++++++------------
bbedc2
 1 file changed, 79 insertions(+), 69 deletions(-)
bbedc2
bbedc2
diff --git a/tests/data/metadata/fence_redfish.xml b/tests/data/metadata/fence_redfish.xml
bbedc2
index 43d447d0..a39541e6 100644
bbedc2
--- a/tests/data/metadata/fence_redfish.xml
bbedc2
+++ b/tests/data/metadata/fence_redfish.xml
bbedc2
@@ -3,110 +3,115 @@
bbedc2
 <longdesc>fence_redfish is an I/O Fencing agent which can be used with Out-of-Band controllers that support Redfish APIs. These controllers provide remote access to control power on a server.</longdesc>
bbedc2
 <vendor-url>http://www.dmtf.org</vendor-url>
bbedc2
 <parameters>
bbedc2
-	<parameter name="ipport" unique="0" required="0">
bbedc2
-		<getopt mixed="-u, --ipport=[port]" />
bbedc2
-		<content type="integer" default="443"  />
bbedc2
-		<shortdesc lang="en">TCP/UDP port to use for connection with device</shortdesc>
bbedc2
-	</parameter>
bbedc2
-	<parameter name="ssl_secure" unique="0" required="0">
bbedc2
-		<getopt mixed="--ssl-secure" />
bbedc2
-		<content type="boolean"  />
bbedc2
-		<shortdesc lang="en">SSL connection with verifying fence device's certificate</shortdesc>
bbedc2
-	</parameter>
bbedc2
-	<parameter name="systems-uri" unique="0" required="0" deprecated="1">
bbedc2
-		<getopt mixed="--systems-uri=[uri]" />
bbedc2
-		<content type="string"  />
bbedc2
-		<shortdesc lang="en">Redfish Systems resource URI, i.e. /redfish/v1/Systems/System.Embedded.1</shortdesc>
bbedc2
-	</parameter>
bbedc2
 	<parameter name="action" unique="0" required="1">
bbedc2
 		<getopt mixed="-o, --action=[action]" />
bbedc2
 		<content type="string" default="reboot"  />
bbedc2
-		<shortdesc lang="en">Fencing Action</shortdesc>
bbedc2
+		<shortdesc lang="en">Fencing action</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="inet4_only" unique="0" required="0">
bbedc2
+		<getopt mixed="-4, --inet4-only" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Forces agent to use IPv4 addresses only</shortdesc>
bbedc2
 	</parameter>
bbedc2
 	<parameter name="inet6_only" unique="0" required="0">
bbedc2
 		<getopt mixed="-6, --inet6-only" />
bbedc2
 		<content type="boolean"  />
bbedc2
 		<shortdesc lang="en">Forces agent to use IPv6 addresses only</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="ipaddr" unique="0" required="0" deprecated="1">
bbedc2
+	<parameter name="ip" unique="0" required="0" obsoletes="ipaddr">
bbedc2
 		<getopt mixed="-a, --ip=[ip]" />
bbedc2
 		<content type="string"  />
bbedc2
-		<shortdesc lang="en">IP Address or Hostname</shortdesc>
bbedc2
+		<shortdesc lang="en">IP address or hostname of fencing device</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="port" unique="0" required="0" deprecated="1">
bbedc2
-		<getopt mixed="-n, --plug=[ip]" />
bbedc2
+	<parameter name="ipaddr" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="-a, --ip=[ip]" />
bbedc2
 		<content type="string"  />
bbedc2
-		<shortdesc lang="en">IP address or hostname of fencing device (together with --port-as-ip)</shortdesc>
bbedc2
+		<shortdesc lang="en">IP address or hostname of fencing device</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="passwd_script" unique="0" required="0" deprecated="1">
bbedc2
-		<getopt mixed="-S, --password-script=[script]" />
bbedc2
-		<content type="string"  />
bbedc2
-		<shortdesc lang="en">Script to retrieve password</shortdesc>
bbedc2
+	<parameter name="ipport" unique="0" required="0">
bbedc2
+		<getopt mixed="-u, --ipport=[port]" />
bbedc2
+		<content type="integer" default="443"  />
bbedc2
+		<shortdesc lang="en">TCP/UDP port to use for connection with device</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="inet4_only" unique="0" required="0">
bbedc2
-		<getopt mixed="-4, --inet4-only" />
bbedc2
-		<content type="boolean"  />
bbedc2
-		<shortdesc lang="en">Forces agent to use IPv4 addresses only</shortdesc>
bbedc2
+	<parameter name="login" unique="0" required="1" deprecated="1">
bbedc2
+		<getopt mixed="-l, --username=[name]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Login name</shortdesc>
bbedc2
 	</parameter>
bbedc2
 	<parameter name="passwd" unique="0" required="0" deprecated="1">
bbedc2
 		<getopt mixed="-p, --password=[password]" />
bbedc2
 		<content type="string"  />
bbedc2
 		<shortdesc lang="en">Login password or passphrase</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="ssl" unique="0" required="0">
bbedc2
-		<getopt mixed="-z, --ssl" />
bbedc2
-		<content type="boolean"  />
bbedc2
-		<shortdesc lang="en">SSL connection</shortdesc>
bbedc2
-	</parameter>
bbedc2
-	<parameter name="redfish-uri" unique="0" required="0" deprecated="1">
bbedc2
-		<getopt mixed="--redfish-uri=[uri]" />
bbedc2
-		<content type="string" default="/redfish/v1"  />
bbedc2
-		<shortdesc lang="en">Base or starting Redfish URI</shortdesc>
bbedc2
+	<parameter name="passwd_script" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="-S, --password-script=[script]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Script to run to retrieve password</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="ssl_insecure" unique="0" required="0">
bbedc2
-		<getopt mixed="--ssl-insecure" />
bbedc2
-		<content type="boolean"  />
bbedc2
-		<shortdesc lang="en">SSL connection without verifying fence device's certificate</shortdesc>
bbedc2
+	<parameter name="password" unique="0" required="0" obsoletes="passwd">
bbedc2
+		<getopt mixed="-p, --password=[password]" />
bbedc2
+		<content type="string"  />
bbedc2
+		<shortdesc lang="en">Login password or passphrase</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="login" unique="0" required="1" deprecated="1">
bbedc2
-		<getopt mixed="-l, --username=[name]" />
bbedc2
+	<parameter name="password_script" unique="0" required="0" obsoletes="passwd_script">
bbedc2
+		<getopt mixed="-S, --password-script=[script]" />
bbedc2
 		<content type="string"  />
bbedc2
-		<shortdesc lang="en">Login Name</shortdesc>
bbedc2
+		<shortdesc lang="en">Script to run to retrieve password</shortdesc>
bbedc2
 	</parameter>
bbedc2
 	<parameter name="plug" unique="0" required="0" obsoletes="port">
bbedc2
 		<getopt mixed="-n, --plug=[ip]" />
bbedc2
 		<content type="string"  />
bbedc2
 		<shortdesc lang="en">IP address or hostname of fencing device (together with --port-as-ip)</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="username" unique="0" required="1" obsoletes="login">
bbedc2
-		<getopt mixed="-l, --username=[name]" />
bbedc2
+	<parameter name="port" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="-n, --plug=[ip]" />
bbedc2
 		<content type="string"  />
bbedc2
-		<shortdesc lang="en">Login Name</shortdesc>
bbedc2
+		<shortdesc lang="en">IP address or hostname of fencing device (together with --port-as-ip)</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="redfish-uri" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="--redfish-uri=[uri]" />
bbedc2
+		<content type="string" default="/redfish/v1"  />
bbedc2
+		<shortdesc lang="en">Base or starting Redfish URI</shortdesc>
bbedc2
 	</parameter>
bbedc2
 	<parameter name="redfish_uri" unique="0" required="0" obsoletes="redfish-uri">
bbedc2
 		<getopt mixed="--redfish-uri=[uri]" />
bbedc2
 		<content type="string" default="/redfish/v1"  />
bbedc2
 		<shortdesc lang="en">Base or starting Redfish URI</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="ip" unique="0" required="0" obsoletes="ipaddr">
bbedc2
-		<getopt mixed="-a, --ip=[ip]" />
bbedc2
+	<parameter name="ssl" unique="0" required="0">
bbedc2
+		<getopt mixed="-z, --ssl" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Use SSL connection with verifying certificate</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="ssl_insecure" unique="0" required="0">
bbedc2
+		<getopt mixed="--ssl-insecure" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Use SSL connection without verifying certificate</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="ssl_secure" unique="0" required="0">
bbedc2
+		<getopt mixed="--ssl-secure" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Use SSL connection with verifying certificate</shortdesc>
bbedc2
+	</parameter>
bbedc2
+	<parameter name="systems-uri" unique="0" required="0" deprecated="1">
bbedc2
+		<getopt mixed="--systems-uri=[uri]" />
bbedc2
 		<content type="string"  />
bbedc2
-		<shortdesc lang="en">IP Address or Hostname</shortdesc>
bbedc2
+		<shortdesc lang="en">Redfish Systems resource URI, i.e. /redfish/v1/Systems/System.Embedded.1</shortdesc>
bbedc2
 	</parameter>
bbedc2
 	<parameter name="systems_uri" unique="0" required="0" obsoletes="systems-uri">
bbedc2
 		<getopt mixed="--systems-uri=[uri]" />
bbedc2
 		<content type="string"  />
bbedc2
 		<shortdesc lang="en">Redfish Systems resource URI, i.e. /redfish/v1/Systems/System.Embedded.1</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="password" unique="0" required="0" obsoletes="passwd">
bbedc2
-		<getopt mixed="-p, --password=[password]" />
bbedc2
+	<parameter name="username" unique="0" required="1" obsoletes="login">
bbedc2
+		<getopt mixed="-l, --username=[name]" />
bbedc2
 		<content type="string"  />
bbedc2
-		<shortdesc lang="en">Login password or passphrase</shortdesc>
bbedc2
+		<shortdesc lang="en">Login name</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="password_script" unique="0" required="0" obsoletes="passwd_script">
bbedc2
-		<getopt mixed="-S, --password-script=[script]" />
bbedc2
-		<content type="string"  />
bbedc2
-		<shortdesc lang="en">Script to retrieve password</shortdesc>
bbedc2
+	<parameter name="quiet" unique="0" required="0">
bbedc2
+		<getopt mixed="-q, --quiet" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Disable logging to stderr. Does not affect --verbose or --debug-file or logging to syslog.</shortdesc>
bbedc2
 	</parameter>
bbedc2
 	<parameter name="verbose" unique="0" required="0">
bbedc2
 		<getopt mixed="-v, --verbose" />
bbedc2
@@ -133,41 +138,45 @@
bbedc2
 		<content type="boolean"  />
bbedc2
 		<shortdesc lang="en">Display help and exit</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="power_wait" unique="0" required="0">
bbedc2
-		<getopt mixed="--power-wait=[seconds]" />
bbedc2
+	<parameter name="delay" unique="0" required="0">
bbedc2
+		<getopt mixed="--delay=[seconds]" />
bbedc2
 		<content type="second" default="0"  />
bbedc2
-		<shortdesc lang="en">Wait X seconds after issuing ON/OFF</shortdesc>
bbedc2
+		<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
bbedc2
 	</parameter>
bbedc2
 	<parameter name="login_timeout" unique="0" required="0">
bbedc2
 		<getopt mixed="--login-timeout=[seconds]" />
bbedc2
 		<content type="second" default="5"  />
bbedc2
 		<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
bbedc2
 	</parameter>
bbedc2
+	<parameter name="port_as_ip" unique="0" required="0">
bbedc2
+		<getopt mixed="--port-as-ip" />
bbedc2
+		<content type="boolean"  />
bbedc2
+		<shortdesc lang="en">Make "port/plug" to be an alias to IP address</shortdesc>
bbedc2
+	</parameter>
bbedc2
 	<parameter name="power_timeout" unique="0" required="0">
bbedc2
 		<getopt mixed="--power-timeout=[seconds]" />
bbedc2
 		<content type="second" default="20"  />
bbedc2
 		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="delay" unique="0" required="0">
bbedc2
-		<getopt mixed="--delay=[seconds]" />
bbedc2
+	<parameter name="power_wait" unique="0" required="0">
bbedc2
+		<getopt mixed="--power-wait=[seconds]" />
bbedc2
 		<content type="second" default="0"  />
bbedc2
-		<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
bbedc2
+		<shortdesc lang="en">Wait X seconds after issuing ON/OFF</shortdesc>
bbedc2
 	</parameter>
bbedc2
 	<parameter name="shell_timeout" unique="0" required="0">
bbedc2
 		<getopt mixed="--shell-timeout=[seconds]" />
bbedc2
 		<content type="second" default="3"  />
bbedc2
 		<shortdesc lang="en">Wait X seconds for cmd prompt after issuing command</shortdesc>
bbedc2
 	</parameter>
bbedc2
-	<parameter name="port_as_ip" unique="0" required="0">
bbedc2
-		<getopt mixed="--port-as-ip" />
bbedc2
-		<content type="boolean"  />
bbedc2
-		<shortdesc lang="en">Make "port/plug" to be an alias to IP address</shortdesc>
bbedc2
-	</parameter>
bbedc2
 	<parameter name="retry_on" unique="0" required="0">
bbedc2
 		<getopt mixed="--retry-on=[attempts]" />
bbedc2
 		<content type="integer" default="1"  />
bbedc2
 		<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
bbedc2
 	</parameter>
bbedc2
+	<parameter name="gnutlscli_path" unique="0" required="0">
bbedc2
+		<getopt mixed="--gnutlscli-path=[path]" />
bbedc2
+		<shortdesc lang="en">Path to gnutls-cli binary</shortdesc>
bbedc2
+	</parameter>
bbedc2
 </parameters>
bbedc2
 <actions>
bbedc2
 	<action name="on" automatic="0"/>
bbedc2
@@ -176,6 +185,7 @@
bbedc2
 	<action name="status" />
bbedc2
 	<action name="monitor" />
bbedc2
 	<action name="metadata" />
bbedc2
+	<action name="manpage" />
bbedc2
 	<action name="validate-all" />
bbedc2
 </actions>
bbedc2
 </resource-agent>
bbedc2
bbedc2
From 755627fadd711848ea256d72f5e75f36f83b4d31 Mon Sep 17 00:00:00 2001
bbedc2
From: Jose Delarosa <jose.delarosa@dell.com>
bbedc2
Date: Mon, 3 Dec 2018 11:55:23 -0600
bbedc2
Subject: [PATCH 3/8] Added run_delay()
bbedc2
bbedc2
---
bbedc2
 agents/redfish/fence_redfish.py | 3 ++-
bbedc2
 1 file changed, 2 insertions(+), 1 deletion(-)
bbedc2
bbedc2
diff --git a/agents/redfish/fence_redfish.py b/agents/redfish/fence_redfish.py
bbedc2
index df7cf8c2..0e4a4f68 100644
bbedc2
--- a/agents/redfish/fence_redfish.py
bbedc2
+++ b/agents/redfish/fence_redfish.py
bbedc2
@@ -13,7 +13,7 @@
bbedc2
 
bbedc2
 from requests.packages.urllib3.exceptions import InsecureRequestWarning
bbedc2
 from fencing import *
bbedc2
-from fencing import fail_usage
bbedc2
+from fencing import fail_usage, run_delay
bbedc2
 
bbedc2
 def get_power_status(conn, options):
bbedc2
     uri = options["--systems-uri"]
bbedc2
@@ -127,6 +127,7 @@ def main():
bbedc2
 access to control power on a server."
bbedc2
     docs["vendorurl"] = "http://www.dmtf.org"
bbedc2
     show_docs(options, docs)
bbedc2
+    run_delay(options)
bbedc2
 
bbedc2
     ##
bbedc2
     ## Operate the fencing device
bbedc2
bbedc2
From 15fef4c47f391a3f03c714d86c9670ea209dec99 Mon Sep 17 00:00:00 2001
bbedc2
From: Jose Delarosa <jose.delarosa@dell.com>
bbedc2
Date: Tue, 4 Dec 2018 10:56:58 -0600
bbedc2
Subject: [PATCH 4/8] Modify power status check
bbedc2
bbedc2
- Only returns off if PowerState = Off
bbedc2
- Otherwise returns on
bbedc2
---
bbedc2
 agents/redfish/fence_redfish.py | 6 +++---
bbedc2
 1 file changed, 3 insertions(+), 3 deletions(-)
bbedc2
bbedc2
diff --git a/agents/redfish/fence_redfish.py b/agents/redfish/fence_redfish.py
bbedc2
index 0e4a4f68..7998fb1c 100644
bbedc2
--- a/agents/redfish/fence_redfish.py
bbedc2
+++ b/agents/redfish/fence_redfish.py
bbedc2
@@ -21,10 +21,10 @@ def get_power_status(conn, options):
bbedc2
     if response['ret'] is False:
bbedc2
         fail_usage("Couldn't get power information")
bbedc2
     data = response['data']
bbedc2
-    if data[u'PowerState'].strip() == "On":
bbedc2
-        return "on"
bbedc2
-    else:
bbedc2
+    if data[u'PowerState'].strip() == "Off":
bbedc2
         return "off"
bbedc2
+    else:
bbedc2
+        return "on"
bbedc2
 
bbedc2
 def set_power_status(conn, options):
bbedc2
     action = {
bbedc2
bbedc2
From acf70f4672be65562841227ab0b4cacb87965f44 Mon Sep 17 00:00:00 2001
bbedc2
From: Jose Delarosa <jose.delarosa@dell.com>
bbedc2
Date: Wed, 5 Dec 2018 10:39:32 -0600
bbedc2
Subject: [PATCH 5/8] Changed reboot type to ForceRestart
bbedc2
bbedc2
---
bbedc2
 agents/redfish/fence_redfish.py | 2 +-
bbedc2
 1 file changed, 1 insertion(+), 1 deletion(-)
bbedc2
bbedc2
diff --git a/agents/redfish/fence_redfish.py b/agents/redfish/fence_redfish.py
bbedc2
index 7998fb1c..3fe2bfc0 100644
bbedc2
--- a/agents/redfish/fence_redfish.py
bbedc2
+++ b/agents/redfish/fence_redfish.py
bbedc2
@@ -30,7 +30,7 @@ def set_power_status(conn, options):
bbedc2
     action = {
bbedc2
         'on' : "On",
bbedc2
         'off': "ForceOff",
bbedc2
-        'reboot': "GracefulRestart"
bbedc2
+        'reboot': "ForceRestart"
bbedc2
     }[options["--action"]]
bbedc2
 
bbedc2
     payload = {'ResetType': action}
bbedc2
bbedc2
From 56e3358d45050ac669c099c56873feefa1ecda38 Mon Sep 17 00:00:00 2001
bbedc2
From: Jose Delarosa <jose.delarosa@dell.com>
bbedc2
Date: Wed, 5 Dec 2018 10:54:44 -0600
bbedc2
Subject: [PATCH 6/8] Replaced default port 443 with default ssl enabled option
bbedc2
bbedc2
---
bbedc2
 agents/redfish/fence_redfish.py       | 2 +-
bbedc2
 tests/data/metadata/fence_redfish.xml | 2 +-
bbedc2
 2 files changed, 2 insertions(+), 2 deletions(-)
bbedc2
bbedc2
diff --git a/agents/redfish/fence_redfish.py b/agents/redfish/fence_redfish.py
bbedc2
index 3fe2bfc0..6a2dbb76 100644
bbedc2
--- a/agents/redfish/fence_redfish.py
bbedc2
+++ b/agents/redfish/fence_redfish.py
bbedc2
@@ -117,7 +117,7 @@ def main():
bbedc2
 
bbedc2
     opt = process_input(device_opt)
bbedc2
 
bbedc2
-    all_opt["ipport"]["default"] = "443"
bbedc2
+    all_opt["ssl"]["default"] = "1"
bbedc2
     options = check_input(device_opt, opt)
bbedc2
 
bbedc2
     docs = {}
bbedc2
diff --git a/tests/data/metadata/fence_redfish.xml b/tests/data/metadata/fence_redfish.xml
bbedc2
index a39541e6..e1c18584 100644
bbedc2
--- a/tests/data/metadata/fence_redfish.xml
bbedc2
+++ b/tests/data/metadata/fence_redfish.xml
bbedc2
@@ -80,7 +80,7 @@
bbedc2
 	</parameter>
bbedc2
 	<parameter name="ssl" unique="0" required="0">
bbedc2
 		<getopt mixed="-z, --ssl" />
bbedc2
-		<content type="boolean"  />
bbedc2
+		<content type="boolean" default="1"  />
bbedc2
 		<shortdesc lang="en">Use SSL connection with verifying certificate</shortdesc>
bbedc2
 	</parameter>
bbedc2
 	<parameter name="ssl_insecure" unique="0" required="0">
bbedc2
bbedc2
From 5c25a85b22a17d6bbc3dcb47c99b76e3a99a5857 Mon Sep 17 00:00:00 2001
bbedc2
From: Jose Delarosa <jose.delarosa@dell.com>
bbedc2
Date: Wed, 5 Dec 2018 13:29:42 -0600
bbedc2
Subject: [PATCH 7/8] Renamed variable to avoid reusing variable name
bbedc2
bbedc2
---
bbedc2
 agents/redfish/fence_redfish.py | 4 ++--
bbedc2
 1 file changed, 2 insertions(+), 2 deletions(-)
bbedc2
bbedc2
diff --git a/agents/redfish/fence_redfish.py b/agents/redfish/fence_redfish.py
bbedc2
index 6a2dbb76..1ea25cd8 100644
bbedc2
--- a/agents/redfish/fence_redfish.py
bbedc2
+++ b/agents/redfish/fence_redfish.py
bbedc2
@@ -42,9 +42,9 @@ def set_power_status(conn, options):
bbedc2
     if response['ret'] is False:
bbedc2
         return {'ret': False}
bbedc2
     data = response['data']
bbedc2
-    uri = data["Actions"]["#ComputerSystem.Reset"]["target"]
bbedc2
+    action_uri = data["Actions"]["#ComputerSystem.Reset"]["target"]
bbedc2
 
bbedc2
-    response = send_post_request(options, uri, payload, headers)
bbedc2
+    response = send_post_request(options, action_uri, payload, headers)
bbedc2
     if response['ret'] is False:
bbedc2
         fail_usage("Error sending power command")
bbedc2
     return
bbedc2
bbedc2
From 7dce8b1e22d57fec0d34e91a99fab9d8a06f1303 Mon Sep 17 00:00:00 2001
bbedc2
From: Jose Delarosa <jose.delarosa@dell.com>
bbedc2
Date: Thu, 6 Dec 2018 10:33:06 -0600
bbedc2
Subject: [PATCH 8/8] Removed unnecessary variable assignments to simplify code
bbedc2
bbedc2
---
bbedc2
 agents/redfish/fence_redfish.py | 12 ++++--------
bbedc2
 1 file changed, 4 insertions(+), 8 deletions(-)
bbedc2
bbedc2
diff --git a/agents/redfish/fence_redfish.py b/agents/redfish/fence_redfish.py
bbedc2
index 1ea25cd8..67ef67ab 100644
bbedc2
--- a/agents/redfish/fence_redfish.py
bbedc2
+++ b/agents/redfish/fence_redfish.py
bbedc2
@@ -16,8 +16,7 @@
bbedc2
 from fencing import fail_usage, run_delay
bbedc2
 
bbedc2
 def get_power_status(conn, options):
bbedc2
-    uri = options["--systems-uri"]
bbedc2
-    response = send_get_request(options, uri)
bbedc2
+    response = send_get_request(options, options["--systems-uri"])
bbedc2
     if response['ret'] is False:
bbedc2
         fail_usage("Couldn't get power information")
bbedc2
     data = response['data']
bbedc2
@@ -37,8 +36,7 @@ def set_power_status(conn, options):
bbedc2
     headers = {'content-type': 'application/json'}
bbedc2
 
bbedc2
     # Search for 'Actions' key and extract URI from it
bbedc2
-    uri = options["--systems-uri"]
bbedc2
-    response = send_get_request(options, uri)
bbedc2
+    response = send_get_request(options, options["--systems-uri"])
bbedc2
     if response['ret'] is False:
bbedc2
         return {'ret': False}
bbedc2
     data = response['data']
bbedc2
@@ -70,8 +68,7 @@ def send_post_request(options, uri, payload, headers):
bbedc2
     return {'ret': True}
bbedc2
 
bbedc2
 def find_systems_resource(options):
bbedc2
-    uri = options["--redfish-uri"]
bbedc2
-    response = send_get_request(options, uri)
bbedc2
+    response = send_get_request(options, options["--redfish-uri"])
bbedc2
     if response['ret'] is False:
bbedc2
         return {'ret': False}
bbedc2
     data = response['data']
bbedc2
@@ -80,8 +77,7 @@ def find_systems_resource(options):
bbedc2
         # Systems resource not found"
bbedc2
         return {'ret': False}
bbedc2
     else:
bbedc2
-        uri = data["Systems"]["@odata.id"]
bbedc2
-        response = send_get_request(options, uri)
bbedc2
+        response = send_get_request(options, data["Systems"]["@odata.id"])
bbedc2
         if response['ret'] is False:
bbedc2
             return {'ret': False}
bbedc2
         data = response['data']