summaryrefslogtreecommitdiff
path: root/bz2042496-fence_ibm_vpc-fence_ibm_powervs.patch
blob: d68612c011a60cfc92903cdc0b298d5b8c340a86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
From 3078e4d55d3bad2bbf9309785fdb2b53afac8d65 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Tue, 13 Jul 2021 13:39:33 +0200
Subject: [PATCH] fence_ibm_vpc/fence_ibm_powervs: new fence agents

---
 agents/ibm_powervs/fence_ibm_powervs.py   | 202 +++++++++++++++++++
 agents/ibm_vpc/fence_ibm_vpc.py           | 230 ++++++++++++++++++++++
 tests/data/metadata/fence_ibm_powervs.xml | 134 +++++++++++++
 tests/data/metadata/fence_ibm_vpc.xml     | 134 +++++++++++++
 5 files changed, 724 insertions(+)
 create mode 100755 agents/ibm_powervs/fence_ibm_powervs.py
 create mode 100755 agents/ibm_vpc/fence_ibm_vpc.py
 create mode 100644 tests/data/metadata/fence_ibm_powervs.xml
 create mode 100644 tests/data/metadata/fence_ibm_vpc.xml

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