Blame SOURCES/bz1728203-bz1874862-fence_ibm_vpc-fence_ibm_powervs.patch

16bf74
From 3078e4d55d3bad2bbf9309785fdb2b53afac8d65 Mon Sep 17 00:00:00 2001
16bf74
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
16bf74
Date: Tue, 13 Jul 2021 13:39:33 +0200
16bf74
Subject: [PATCH] fence_ibm_vpc/fence_ibm_powervs: new fence agents
16bf74
16bf74
---
16bf74
 agents/ibm_powervs/fence_ibm_powervs.py   | 202 +++++++++++++++++++
16bf74
 agents/ibm_vpc/fence_ibm_vpc.py           | 230 ++++++++++++++++++++++
16bf74
 tests/data/metadata/fence_ibm_powervs.xml | 134 +++++++++++++
16bf74
 tests/data/metadata/fence_ibm_vpc.xml     | 134 +++++++++++++
16bf74
 5 files changed, 724 insertions(+)
16bf74
 create mode 100755 agents/ibm_powervs/fence_ibm_powervs.py
16bf74
 create mode 100755 agents/ibm_vpc/fence_ibm_vpc.py
16bf74
 create mode 100644 tests/data/metadata/fence_ibm_powervs.xml
16bf74
 create mode 100644 tests/data/metadata/fence_ibm_vpc.xml
16bf74
16bf74
diff --git a/agents/ibm_powervs/fence_ibm_powervs.py b/agents/ibm_powervs/fence_ibm_powervs.py
16bf74
new file mode 100755
16bf74
index 000000000..6649771ea
16bf74
--- /dev/null
16bf74
+++ b/agents/ibm_powervs/fence_ibm_powervs.py
16bf74
@@ -0,0 +1,202 @@
16bf74
+#!@PYTHON@ -tt
16bf74
+
16bf74
+import sys
16bf74
+import pycurl, io, json
16bf74
+import logging
16bf74
+import atexit
16bf74
+sys.path.append("@FENCEAGENTSLIBDIR@")
16bf74
+from fencing import *
16bf74
+from fencing import fail, run_delay, EC_LOGIN_DENIED, EC_STATUS
16bf74
+
16bf74
+state = {
16bf74
+	 "ACTIVE": "on",
16bf74
+	 "SHUTOFF": "off",
16bf74
+	 "ERROR": "unknown"
16bf74
+}
16bf74
+
16bf74
+def get_list(conn, options):
16bf74
+	outlets = {}
16bf74
+
16bf74
+	try:
16bf74
+		command = "cloud-instances/{}/pvm-instances".format(options["--instance"])
16bf74
+		res = send_command(conn, command)
16bf74
+	except Exception as e:
16bf74
+		logging.debug("Failed: {}".format(e))
16bf74
+		return outlets
16bf74
+
16bf74
+	for r in res["pvmInstances"]:
16bf74
+		if "--verbose" in options:
16bf74
+			logging.debug(json.dumps(r, indent=2))
16bf74
+		outlets[r["pvmInstanceID"]] = (r["serverName"], state[r["status"]])
16bf74
+
16bf74
+	return outlets
16bf74
+
16bf74
+def get_power_status(conn, options):
16bf74
+	try:
16bf74
+		command = "cloud-instances/{}/pvm-instances/{}".format(
16bf74
+				options["--instance"], options["--plug"])
16bf74
+		res = send_command(conn, command)
16bf74
+		result = get_list(conn, options)[options["--plug"]][1]
16bf74
+	except KeyError as e:
16bf74
+		logging.debug("Failed: Unable to get status for {}".format(e))
16bf74
+		fail(EC_STATUS)
16bf74
+
16bf74
+	return result
16bf74
+
16bf74
+def set_power_status(conn, options):
16bf74
+	action = {
16bf74
+		"on" :  '{"action" : "start"}',
16bf74
+		"off" : '{"action" : "immediate-shutdown"}',
16bf74
+	}[options["--action"]]
16bf74
+
16bf74
+	try:
16bf74
+		send_command(conn, "cloud-instances/{}/pvm-instances/{}/action".format(
16bf74
+				options["--instance"], options["--plug"]), "POST", action)
16bf74
+	except Exception as e:
16bf74
+		logging.debug("Failed: Unable to set power to {} for {}".format(options["--action"], e))
16bf74
+		fail(EC_STATUS)
16bf74
+
16bf74
+def connect(opt):
16bf74
+	conn = pycurl.Curl()
16bf74
+
16bf74
+	## setup correct URL
16bf74
+	conn.base_url = "https://" + opt["--region"] + ".power-iaas.cloud.ibm.com/pcloud/v1/"
16bf74
+
16bf74
+	if opt["--verbose-level"] > 1:
16bf74
+		conn.setopt(pycurl.VERBOSE, 1)
16bf74
+
16bf74
+	conn.setopt(pycurl.TIMEOUT, int(opt["--shell-timeout"]))
16bf74
+	conn.setopt(pycurl.SSL_VERIFYPEER, 1)
16bf74
+	conn.setopt(pycurl.SSL_VERIFYHOST, 2)
16bf74
+
16bf74
+	# set auth token for later requests
16bf74
+	conn.setopt(pycurl.HTTPHEADER, [
16bf74
+		"Content-Type: application/json",
16bf74
+		"Authorization: Bearer {}".format(opt["--token"]),
16bf74
+		"CRN: {}".format(opt["--crn"]),
16bf74
+		"User-Agent: curl",
16bf74
+	])
16bf74
+
16bf74
+	return conn
16bf74
+
16bf74
+def disconnect(conn):
16bf74
+	conn.close()
16bf74
+
16bf74
+def send_command(conn, command, method="GET", action=None):
16bf74
+	url = conn.base_url + command
16bf74
+
16bf74
+	conn.setopt(pycurl.URL, url.encode("ascii"))
16bf74
+
16bf74
+	web_buffer = io.BytesIO()
16bf74
+
16bf74
+	if method == "GET":
16bf74
+		conn.setopt(pycurl.POST, 0)
16bf74
+	if method == "POST":
16bf74
+		conn.setopt(pycurl.POSTFIELDS, action)
16bf74
+	if method == "DELETE":
16bf74
+		conn.setopt(pycurl.CUSTOMREQUEST, "DELETE")
16bf74
+
16bf74
+	conn.setopt(pycurl.WRITEFUNCTION, web_buffer.write)
16bf74
+
16bf74
+	try:
16bf74
+		conn.perform()
16bf74
+	except Exception as e:
16bf74
+		raise(e)
16bf74
+
16bf74
+	rc = conn.getinfo(pycurl.HTTP_CODE)
16bf74
+	result = web_buffer.getvalue().decode("UTF-8")
16bf74
+
16bf74
+	web_buffer.close()
16bf74
+
16bf74
+	if rc != 200:
16bf74
+		if len(result) > 0:
16bf74
+			raise Exception("{}: {}".format(rc,
16bf74
+					result["value"]["messages"][0]["default_message"]))
16bf74
+		else:
16bf74
+			raise Exception("Remote returned {} for request to {}".format(rc, url))
16bf74
+
16bf74
+	if len(result) > 0:
16bf74
+		result = json.loads(result)
16bf74
+
16bf74
+	logging.debug("url: {}".format(url))
16bf74
+	logging.debug("method: {}".format(method))
16bf74
+	logging.debug("response code: {}".format(rc))
16bf74
+	logging.debug("result: {}\n".format(result))
16bf74
+
16bf74
+	return result
16bf74
+
16bf74
+def define_new_opts():
16bf74
+	all_opt["token"] = {
16bf74
+		"getopt" : ":",
16bf74
+		"longopt" : "token",
16bf74
+		"help" : "--token=[token]                Bearer Token",
16bf74
+		"required" : "1",
16bf74
+		"shortdesc" : "Bearer Token",
16bf74
+		"order" : 0
16bf74
+	}
16bf74
+	all_opt["crn"] = {
16bf74
+		"getopt" : ":",
16bf74
+		"longopt" : "crn",
16bf74
+		"help" : "--crn=[crn]                    CRN",
16bf74
+		"required" : "1",
16bf74
+		"shortdesc" : "CRN",
16bf74
+		"order" : 0
16bf74
+	}
16bf74
+	all_opt["instance"] = {
16bf74
+		"getopt" : ":",
16bf74
+		"longopt" : "instance",
16bf74
+		"help" : "--instance=[instance]          PowerVS Instance",
16bf74
+		"required" : "1",
16bf74
+		"shortdesc" : "PowerVS Instance",
16bf74
+		"order" : 0
16bf74
+	}
16bf74
+	all_opt["region"] = {
16bf74
+		"getopt" : ":",
16bf74
+		"longopt" : "region",
16bf74
+		"help" : "--region=[region]              Region",
16bf74
+		"required" : "1",
16bf74
+		"shortdesc" : "Region",
16bf74
+		"order" : 0
16bf74
+	}
16bf74
+
16bf74
+
16bf74
+def main():
16bf74
+	device_opt = [
16bf74
+		"token",
16bf74
+		"crn",
16bf74
+		"instance",
16bf74
+		"region",
16bf74
+		"port",
16bf74
+		"no_password",
16bf74
+	]
16bf74
+
16bf74
+	atexit.register(atexit_handler)
16bf74
+	define_new_opts()
16bf74
+
16bf74
+	all_opt["shell_timeout"]["default"] = "15"
16bf74
+	all_opt["power_timeout"]["default"] = "30"
16bf74
+	all_opt["power_wait"]["default"] = "1"
16bf74
+
16bf74
+	options = check_input(device_opt, process_input(device_opt))
16bf74
+
16bf74
+	docs = {}
16bf74
+	docs["shortdesc"] = "Fence agent for IBM PowerVS"
16bf74
+	docs["longdesc"] = """fence_ibm_powervs is an I/O Fencing agent which can be \
16bf74
+used with IBM PowerVS to fence virtual machines."""
16bf74
+	docs["vendorurl"] = "https://www.ibm.com"
16bf74
+	show_docs(options, docs)
16bf74
+
16bf74
+	####
16bf74
+	## Fence operations
16bf74
+	####
16bf74
+	run_delay(options)
16bf74
+
16bf74
+	conn = connect(options)
16bf74
+	atexit.register(disconnect, conn)
16bf74
+
16bf74
+	result = fence_action(conn, options, set_power_status, get_power_status, get_list)
16bf74
+
16bf74
+	sys.exit(result)
16bf74
+
16bf74
+if __name__ == "__main__":
16bf74
+	main()
16bf74
diff --git a/agents/ibm_vpc/fence_ibm_vpc.py b/agents/ibm_vpc/fence_ibm_vpc.py
16bf74
new file mode 100755
16bf74
index 000000000..9f84f7b2d
16bf74
--- /dev/null
16bf74
+++ b/agents/ibm_vpc/fence_ibm_vpc.py
16bf74
@@ -0,0 +1,230 @@
16bf74
+#!@PYTHON@ -tt
16bf74
+
16bf74
+import sys
16bf74
+import pycurl, io, json
16bf74
+import logging
16bf74
+import atexit
16bf74
+sys.path.append("@FENCEAGENTSLIBDIR@")
16bf74
+from fencing import *
16bf74
+from fencing import fail, run_delay, EC_LOGIN_DENIED, EC_STATUS
16bf74
+
16bf74
+state = {
16bf74
+	 "running": "on",
16bf74
+	 "stopped": "off",
16bf74
+	 "starting": "unknown",
16bf74
+	 "stopping": "unknown",
16bf74
+	 "restarting": "unknown",
16bf74
+	 "pending": "unknown",
16bf74
+}
16bf74
+
16bf74
+def get_list(conn, options):
16bf74
+	outlets = {}
16bf74
+
16bf74
+	try:
16bf74
+		command = "instances?version=2021-05-25&generation=2&limit={}".format(options["--limit"])
16bf74
+		res = send_command(conn, command)
16bf74
+	except Exception as e:
16bf74
+		logging.debug("Failed: Unable to get list: {}".format(e))
16bf74
+		return outlets
16bf74
+
16bf74
+	for r in res["instances"]:
16bf74
+		if options["--verbose-level"] > 1:
16bf74
+			logging.debug("Node:\n{}".format(json.dumps(r, indent=2)))
16bf74
+			logging.debug("Status: " + state[r["status"]])
16bf74
+		outlets[r["id"]] = (r["name"], state[r["status"]])
16bf74
+
16bf74
+	return outlets
16bf74
+
16bf74
+def get_power_status(conn, options):
16bf74
+	try:
16bf74
+		command = "instances/{}?version=2021-05-25&generation=2".format(options["--plug"])
16bf74
+		res = send_command(conn, command)
16bf74
+		result = state[res["status"]]
16bf74
+		if options["--verbose-level"] > 1:
16bf74
+			logging.debug("Result:\n{}".format(json.dumps(res, indent=2)))
16bf74
+			logging.debug("Status: " + result)
16bf74
+	except Exception as e:
16bf74
+		logging.debug("Failed: Unable to get status for {}: {}".format(options["--plug"], e))
16bf74
+		fail(EC_STATUS)
16bf74
+
16bf74
+	return result
16bf74
+
16bf74
+def set_power_status(conn, options):
16bf74
+	action = {
16bf74
+		"on" :  '{"type" : "start"}',
16bf74
+		"off" : '{"type" : "stop"}',
16bf74
+	}[options["--action"]]
16bf74
+
16bf74
+	try:
16bf74
+		command = "instances/{}/actions?version=2021-05-25&generation=2".format(options["--plug"])
16bf74
+		send_command(conn, command, "POST", action, 201)
16bf74
+	except Exception as e:
16bf74
+		logging.debug("Failed: Unable to set power to {} for {}".format(options["--action"], e))
16bf74
+		fail(EC_STATUS)
16bf74
+
16bf74
+def get_bearer_token(conn, options):
16bf74
+	token = None
16bf74
+	try:
16bf74
+		conn.setopt(pycurl.HTTPHEADER, [
16bf74
+			"Content-Type: application/x-www-form-urlencoded",
16bf74
+			"User-Agent: curl",
16bf74
+		])
16bf74
+		token = send_command(conn, "https://iam.cloud.ibm.com/identity/token", "POST", "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey={}".format(options["--apikey"]))["access_token"]
16bf74
+	except Exception:
16bf74
+		logging.error("Failed: Unable to authenticate")
16bf74
+		fail(EC_LOGIN_DENIED)
16bf74
+
16bf74
+	return token
16bf74
+
16bf74
+def connect(opt):
16bf74
+	conn = pycurl.Curl()
16bf74
+
16bf74
+	## setup correct URL
16bf74
+	conn.base_url = "https://" + opt["--region"] + ".iaas.cloud.ibm.com/v1/"
16bf74
+
16bf74
+	if opt["--verbose-level"] > 1:
16bf74
+		conn.setopt(pycurl.VERBOSE, 1)
16bf74
+
16bf74
+	conn.setopt(pycurl.TIMEOUT, int(opt["--shell-timeout"]))
16bf74
+	conn.setopt(pycurl.SSL_VERIFYPEER, 1)
16bf74
+	conn.setopt(pycurl.SSL_VERIFYHOST, 2)
16bf74
+
16bf74
+	# get bearer token
16bf74
+	bearer_token = get_bearer_token(conn, opt)
16bf74
+
16bf74
+	# set auth token for later requests
16bf74
+	conn.setopt(pycurl.HTTPHEADER, [
16bf74
+		"Content-Type: application/json",
16bf74
+		"Authorization: Bearer {}".format(bearer_token),
16bf74
+		"User-Agent: curl",
16bf74
+	])
16bf74
+
16bf74
+	return conn
16bf74
+
16bf74
+def disconnect(conn):
16bf74
+	conn.close()
16bf74
+
16bf74
+def send_command(conn, command, method="GET", action=None, expected_rc=200):
16bf74
+	if not command.startswith("https"):
16bf74
+		url = conn.base_url + command
16bf74
+	else:
16bf74
+		url = command
16bf74
+
16bf74
+	conn.setopt(pycurl.URL, url.encode("ascii"))
16bf74
+
16bf74
+	web_buffer = io.BytesIO()
16bf74
+
16bf74
+	if method == "GET":
16bf74
+		conn.setopt(pycurl.POST, 0)
16bf74
+	if method == "POST":
16bf74
+		conn.setopt(pycurl.POSTFIELDS, action)
16bf74
+	if method == "DELETE":
16bf74
+		conn.setopt(pycurl.CUSTOMREQUEST, "DELETE")
16bf74
+
16bf74
+	conn.setopt(pycurl.WRITEFUNCTION, web_buffer.write)
16bf74
+
16bf74
+	try:
16bf74
+		conn.perform()
16bf74
+	except Exception as e:
16bf74
+		raise(e)
16bf74
+
16bf74
+	rc = conn.getinfo(pycurl.HTTP_CODE)
16bf74
+	result = web_buffer.getvalue().decode("UTF-8")
16bf74
+
16bf74
+	web_buffer.close()
16bf74
+
16bf74
+	# actions (start/stop/reboot) report 201 when they've been created
16bf74
+	if rc != expected_rc:
16bf74
+		logging.debug("rc: {}, result: {}".format(rc, result))
16bf74
+		if len(result) > 0:
16bf74
+			raise Exception("{}: {}".format(rc, 
16bf74
+					result["value"]["messages"][0]["default_message"]))
16bf74
+		else:
16bf74
+			raise Exception("Remote returned {} for request to {}".format(rc, url))
16bf74
+
16bf74
+	if len(result) > 0:
16bf74
+		result = json.loads(result)
16bf74
+
16bf74
+	logging.debug("url: {}".format(url))
16bf74
+	logging.debug("method: {}".format(method))
16bf74
+	logging.debug("response code: {}".format(rc))
16bf74
+	logging.debug("result: {}\n".format(result))
16bf74
+
16bf74
+	return result
16bf74
+
16bf74
+def define_new_opts():
16bf74
+	all_opt["apikey"] = {
16bf74
+		"getopt" : ":",
16bf74
+		"longopt" : "apikey",
16bf74
+		"help" : "--apikey=[key]                 API Key",
16bf74
+		"required" : "1",
16bf74
+		"shortdesc" : "API Key",
16bf74
+		"order" : 0
16bf74
+	}
16bf74
+	all_opt["instance"] = {
16bf74
+		"getopt" : ":",
16bf74
+		"longopt" : "instance",
16bf74
+		"help" : "--instance=[instance]          Cloud Instance",
16bf74
+		"required" : "1",
16bf74
+		"shortdesc" : "Cloud Instance",
16bf74
+		"order" : 0
16bf74
+	}
16bf74
+	all_opt["region"] = {
16bf74
+		"getopt" : ":",
16bf74
+		"longopt" : "region",
16bf74
+		"help" : "--region=[region]              Region",
16bf74
+		"required" : "1",
16bf74
+		"shortdesc" : "Region",
16bf74
+		"order" : 0
16bf74
+	}
16bf74
+	all_opt["limit"] = {
16bf74
+		"getopt" : ":",
16bf74
+		"longopt" : "limit",
16bf74
+		"help" : "--limit=[number]               Limit number of nodes returned by API",
16bf74
+		"required" : "1",
16bf74
+		"default": 50,
16bf74
+		"shortdesc" : "Number of nodes returned by API",
16bf74
+		"order" : 0
16bf74
+	}
16bf74
+
16bf74
+
16bf74
+def main():
16bf74
+	device_opt = [
16bf74
+		"apikey",
16bf74
+		"instance",
16bf74
+		"region",
16bf74
+		"limit",
16bf74
+		"port",
16bf74
+		"no_password",
16bf74
+	]
16bf74
+
16bf74
+	atexit.register(atexit_handler)
16bf74
+	define_new_opts()
16bf74
+
16bf74
+	all_opt["shell_timeout"]["default"] = "15"
16bf74
+	all_opt["power_timeout"]["default"] = "30"
16bf74
+	all_opt["power_wait"]["default"] = "1"
16bf74
+
16bf74
+	options = check_input(device_opt, process_input(device_opt))
16bf74
+
16bf74
+	docs = {}
16bf74
+	docs["shortdesc"] = "Fence agent for IBM Cloud VPC"
16bf74
+	docs["longdesc"] = """fence_ibm_vpc is an I/O Fencing agent which can be \
16bf74
+used with IBM Cloud VPC to fence virtual machines."""
16bf74
+	docs["vendorurl"] = "https://www.ibm.com"
16bf74
+	show_docs(options, docs)
16bf74
+
16bf74
+	####
16bf74
+	## Fence operations
16bf74
+	####
16bf74
+	run_delay(options)
16bf74
+
16bf74
+	conn = connect(options)
16bf74
+	atexit.register(disconnect, conn)
16bf74
+
16bf74
+	result = fence_action(conn, options, set_power_status, get_power_status, get_list)
16bf74
+
16bf74
+	sys.exit(result)
16bf74
+
16bf74
+if __name__ == "__main__":
16bf74
+	main()
16bf74
diff --git a/tests/data/metadata/fence_ibm_powervs.xml b/tests/data/metadata/fence_ibm_powervs.xml
16bf74
new file mode 100644
16bf74
index 000000000..fe86331bd
16bf74
--- /dev/null
16bf74
+++ b/tests/data/metadata/fence_ibm_powervs.xml
16bf74
@@ -0,0 +1,134 @@
16bf74
+
16bf74
+<resource-agent name="fence_ibm_powervs" shortdesc="Fence agent for IBM PowerVS" >
16bf74
+<longdesc>fence_ibm_powervs is an I/O Fencing agent which can be used with IBM PowerVS to fence virtual machines.</longdesc>
16bf74
+<vendor-url>https://www.ibm.com</vendor-url>
16bf74
+<parameters>
16bf74
+	<parameter name="crn" unique="0" required="1">
16bf74
+		<getopt mixed="--crn=[crn]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">CRN</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="instance" unique="0" required="1">
16bf74
+		<getopt mixed="--instance=[instance]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">PowerVS Instance</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="region" unique="0" required="1">
16bf74
+		<getopt mixed="--region=[region]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Region</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="token" unique="0" required="1">
16bf74
+		<getopt mixed="--token=[token]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Bearer Token</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="action" unique="0" required="1">
16bf74
+		<getopt mixed="-o, --action=[action]" />
16bf74
+		<content type="string" default="reboot"  />
16bf74
+		<shortdesc lang="en">Fencing action</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="plug" unique="0" required="1" obsoletes="port">
16bf74
+		<getopt mixed="-n, --plug=[id]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Physical plug number on device, UUID or identification of machine</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="port" unique="0" required="1" deprecated="1">
16bf74
+		<getopt mixed="-n, --plug=[id]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Physical plug number on device, UUID or identification of machine</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="quiet" unique="0" required="0">
16bf74
+		<getopt mixed="-q, --quiet" />
16bf74
+		<content type="boolean"  />
16bf74
+		<shortdesc lang="en">Disable logging to stderr. Does not affect --verbose or --debug-file or logging to syslog.</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="verbose" unique="0" required="0">
16bf74
+		<getopt mixed="-v, --verbose" />
16bf74
+		<content type="boolean"  />
16bf74
+		<shortdesc lang="en">Verbose mode. Multiple -v flags can be stacked on the command line (e.g., -vvv) to increase verbosity.</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="verbose_level" unique="0" required="0">
16bf74
+		<getopt mixed="--verbose-level" />
16bf74
+		<content type="integer"  />
16bf74
+		<shortdesc lang="en">Level of debugging detail in output. Defaults to the number of --verbose flags specified on the command line, or to 1 if verbose=1 in a stonith device configuration (i.e., on stdin).</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="debug" unique="0" required="0" deprecated="1">
16bf74
+		<getopt mixed="-D, --debug-file=[debugfile]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Write debug information to given file</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="debug_file" unique="0" required="0" obsoletes="debug">
16bf74
+		<getopt mixed="-D, --debug-file=[debugfile]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Write debug information to given file</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="version" unique="0" required="0">
16bf74
+		<getopt mixed="-V, --version" />
16bf74
+		<content type="boolean"  />
16bf74
+		<shortdesc lang="en">Display version information and exit</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="help" unique="0" required="0">
16bf74
+		<getopt mixed="-h, --help" />
16bf74
+		<content type="boolean"  />
16bf74
+		<shortdesc lang="en">Display help and exit</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="separator" unique="0" required="0">
16bf74
+		<getopt mixed="-C, --separator=[char]" />
16bf74
+		<content type="string" default=","  />
16bf74
+		<shortdesc lang="en">Separator for CSV created by 'list' operation</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="delay" unique="0" required="0">
16bf74
+		<getopt mixed="--delay=[seconds]" />
16bf74
+		<content type="second" default="0"  />
16bf74
+		<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="disable_timeout" unique="0" required="0">
16bf74
+		<getopt mixed="--disable-timeout=[true/false]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Disable timeout (true/false) (default: true when run from Pacemaker 2.0+)</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="login_timeout" unique="0" required="0">
16bf74
+		<getopt mixed="--login-timeout=[seconds]" />
16bf74
+		<content type="second" default="5"  />
16bf74
+		<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="power_timeout" unique="0" required="0">
16bf74
+		<getopt mixed="--power-timeout=[seconds]" />
16bf74
+		<content type="second" default="30"  />
16bf74
+		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="power_wait" unique="0" required="0">
16bf74
+		<getopt mixed="--power-wait=[seconds]" />
16bf74
+		<content type="second" default="1"  />
16bf74
+		<shortdesc lang="en">Wait X seconds after issuing ON/OFF</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="shell_timeout" unique="0" required="0">
16bf74
+		<getopt mixed="--shell-timeout=[seconds]" />
16bf74
+		<content type="second" default="15"  />
16bf74
+		<shortdesc lang="en">Wait X seconds for cmd prompt after issuing command</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="stonith_status_sleep" unique="0" required="0">
16bf74
+		<getopt mixed="--stonith-status-sleep=[seconds]" />
16bf74
+		<content type="second" default="1"  />
16bf74
+		<shortdesc lang="en">Sleep X seconds between status calls during a STONITH action</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="retry_on" unique="0" required="0">
16bf74
+		<getopt mixed="--retry-on=[attempts]" />
16bf74
+		<content type="integer" default="1"  />
16bf74
+		<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
16bf74
+	</parameter>
16bf74
+</parameters>
16bf74
+<actions>
16bf74
+	<action name="on" automatic="0"/>
16bf74
+	<action name="off" />
16bf74
+	<action name="reboot" />
16bf74
+	<action name="status" />
16bf74
+	<action name="list" />
16bf74
+	<action name="list-status" />
16bf74
+	<action name="monitor" />
16bf74
+	<action name="metadata" />
16bf74
+	<action name="manpage" />
16bf74
+	<action name="validate-all" />
16bf74
+</actions>
16bf74
+</resource-agent>
16bf74
diff --git a/tests/data/metadata/fence_ibm_vpc.xml b/tests/data/metadata/fence_ibm_vpc.xml
16bf74
new file mode 100644
16bf74
index 000000000..926efcaa0
16bf74
--- /dev/null
16bf74
+++ b/tests/data/metadata/fence_ibm_vpc.xml
16bf74
@@ -0,0 +1,134 @@
16bf74
+
16bf74
+<resource-agent name="fence_ibm_vpc" shortdesc="Fence agent for IBM Cloud VPC" >
16bf74
+<longdesc>fence_ibm_vpc is an I/O Fencing agent which can be used with IBM Cloud VPC to fence virtual machines.</longdesc>
16bf74
+<vendor-url>https://www.ibm.com</vendor-url>
16bf74
+<parameters>
16bf74
+	<parameter name="apikey" unique="0" required="1">
16bf74
+		<getopt mixed="--apikey=[key]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">API Key</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="instance" unique="0" required="1">
16bf74
+		<getopt mixed="--instance=[instance]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Cloud Instance</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="limit" unique="0" required="1">
16bf74
+		<getopt mixed="--limit=[number]" />
16bf74
+		<content type="string" default="50"  />
16bf74
+		<shortdesc lang="en">Number of nodes returned by API</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="region" unique="0" required="1">
16bf74
+		<getopt mixed="--region=[region]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Region</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="action" unique="0" required="1">
16bf74
+		<getopt mixed="-o, --action=[action]" />
16bf74
+		<content type="string" default="reboot"  />
16bf74
+		<shortdesc lang="en">Fencing action</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="plug" unique="0" required="1" obsoletes="port">
16bf74
+		<getopt mixed="-n, --plug=[id]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Physical plug number on device, UUID or identification of machine</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="port" unique="0" required="1" deprecated="1">
16bf74
+		<getopt mixed="-n, --plug=[id]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Physical plug number on device, UUID or identification of machine</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="quiet" unique="0" required="0">
16bf74
+		<getopt mixed="-q, --quiet" />
16bf74
+		<content type="boolean"  />
16bf74
+		<shortdesc lang="en">Disable logging to stderr. Does not affect --verbose or --debug-file or logging to syslog.</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="verbose" unique="0" required="0">
16bf74
+		<getopt mixed="-v, --verbose" />
16bf74
+		<content type="boolean"  />
16bf74
+		<shortdesc lang="en">Verbose mode. Multiple -v flags can be stacked on the command line (e.g., -vvv) to increase verbosity.</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="verbose_level" unique="0" required="0">
16bf74
+		<getopt mixed="--verbose-level" />
16bf74
+		<content type="integer"  />
16bf74
+		<shortdesc lang="en">Level of debugging detail in output. Defaults to the number of --verbose flags specified on the command line, or to 1 if verbose=1 in a stonith device configuration (i.e., on stdin).</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="debug" unique="0" required="0" deprecated="1">
16bf74
+		<getopt mixed="-D, --debug-file=[debugfile]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Write debug information to given file</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="debug_file" unique="0" required="0" obsoletes="debug">
16bf74
+		<getopt mixed="-D, --debug-file=[debugfile]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Write debug information to given file</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="version" unique="0" required="0">
16bf74
+		<getopt mixed="-V, --version" />
16bf74
+		<content type="boolean"  />
16bf74
+		<shortdesc lang="en">Display version information and exit</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="help" unique="0" required="0">
16bf74
+		<getopt mixed="-h, --help" />
16bf74
+		<content type="boolean"  />
16bf74
+		<shortdesc lang="en">Display help and exit</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="separator" unique="0" required="0">
16bf74
+		<getopt mixed="-C, --separator=[char]" />
16bf74
+		<content type="string" default=","  />
16bf74
+		<shortdesc lang="en">Separator for CSV created by 'list' operation</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="delay" unique="0" required="0">
16bf74
+		<getopt mixed="--delay=[seconds]" />
16bf74
+		<content type="second" default="0"  />
16bf74
+		<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="disable_timeout" unique="0" required="0">
16bf74
+		<getopt mixed="--disable-timeout=[true/false]" />
16bf74
+		<content type="string"  />
16bf74
+		<shortdesc lang="en">Disable timeout (true/false) (default: true when run from Pacemaker 2.0+)</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="login_timeout" unique="0" required="0">
16bf74
+		<getopt mixed="--login-timeout=[seconds]" />
16bf74
+		<content type="second" default="5"  />
16bf74
+		<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="power_timeout" unique="0" required="0">
16bf74
+		<getopt mixed="--power-timeout=[seconds]" />
16bf74
+		<content type="second" default="30"  />
16bf74
+		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="power_wait" unique="0" required="0">
16bf74
+		<getopt mixed="--power-wait=[seconds]" />
16bf74
+		<content type="second" default="1"  />
16bf74
+		<shortdesc lang="en">Wait X seconds after issuing ON/OFF</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="shell_timeout" unique="0" required="0">
16bf74
+		<getopt mixed="--shell-timeout=[seconds]" />
16bf74
+		<content type="second" default="15"  />
16bf74
+		<shortdesc lang="en">Wait X seconds for cmd prompt after issuing command</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="stonith_status_sleep" unique="0" required="0">
16bf74
+		<getopt mixed="--stonith-status-sleep=[seconds]" />
16bf74
+		<content type="second" default="1"  />
16bf74
+		<shortdesc lang="en">Sleep X seconds between status calls during a STONITH action</shortdesc>
16bf74
+	</parameter>
16bf74
+	<parameter name="retry_on" unique="0" required="0">
16bf74
+		<getopt mixed="--retry-on=[attempts]" />
16bf74
+		<content type="integer" default="1"  />
16bf74
+		<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
16bf74
+	</parameter>
16bf74
+</parameters>
16bf74
+<actions>
16bf74
+	<action name="on" automatic="0"/>
16bf74
+	<action name="off" />
16bf74
+	<action name="reboot" />
16bf74
+	<action name="status" />
16bf74
+	<action name="list" />
16bf74
+	<action name="list-status" />
16bf74
+	<action name="monitor" />
16bf74
+	<action name="metadata" />
16bf74
+	<action name="manpage" />
16bf74
+	<action name="validate-all" />
16bf74
+</actions>
16bf74
+</resource-agent>