Blame SOURCES/bz1666914-1-fence_redfish.patch

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