summaryrefslogtreecommitdiffstats
path: root/tools/ocft/Raid1
blob: 462b9b981398f7641e683e363989402f7e8d2ac1 (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
# Raid1
# by dejan@suse.de on 
# Fri Aug 24 17:01:40 CEST 2012

CONFIG
	Agent Raid1
	AgentRoot /usr/lib/ocf/resource.d/heartbeat
	InstallPackage mdadm
	HangTimeout 20

VARIABLE
	OCFT_rundir="`get_rundir`"
	OCFT_disk0=$OCFT_rundir/resource-agents/ocft-Raid1-disk0
	OCFT_disk1=$OCFT_rundir/resource-agents/ocft-Raid1-disk1
	OCFT_disk2=$OCFT_rundir/resource-agents/ocft-Raid1-disk2
	OCFT_disk3=$OCFT_rundir/resource-agents/ocft-Raid1-disk3
	OCFT_raidconf=$OCFT_rundir/resource-agents/ocft-mdadm.conf
	OCFT_raiddev=/dev/md8
	OCFT_raiddev2=/dev/md9
	OCFT_loop0="`loopbackeddev make $OCFT_disk0 16M`"
	OCFT_loop1="`loopbackeddev make $OCFT_disk1 16M`"
	OCFT_loop2="`loopbackeddev make $OCFT_disk2 16M`"
	OCFT_loop3="`loopbackeddev make $OCFT_disk3 16M`"

SETUP-AGENT
	mdadm --create $OCFT_raiddev -l 0 --raid-devices=2 $OCFT_loop0 $OCFT_loop1
	mdadm --create $OCFT_raiddev2 -l 0 --raid-devices=2 $OCFT_loop2 $OCFT_loop3
	echo DEVICE $OCFT_loop0 $OCFT_loop1 > $OCFT_raidconf
	echo DEVICE $OCFT_loop2 $OCFT_loop3 >> $OCFT_raidconf
	echo ARRAY $OCFT_raiddev devices=$OCFT_loop0,$OCFT_loop1 >> $OCFT_raidconf
	echo ARRAY $OCFT_raiddev2 devices=$OCFT_loop2,$OCFT_loop3 >> $OCFT_raidconf

CLEANUP-AGENT
	mdadm --zero-superblock $OCFT_loop0
	mdadm --zero-superblock $OCFT_loop1
	mdadm --zero-superblock $OCFT_loop2
	mdadm --zero-superblock $OCFT_loop3
	mdadm --remove $OCFT_raiddev 2>/dev/null
	mdadm --remove $OCFT_raiddev2 2>/dev/null
	loopbackeddev unmake $OCFT_disk0
	loopbackeddev unmake $OCFT_disk1
	loopbackeddev unmake $OCFT_disk2
	loopbackeddev unmake $OCFT_disk3
	rm -f $OCFT_raidconf

CASE-BLOCK required_args
	Env OCF_RESKEY_raidconf=$OCFT_raidconf
	Env OCF_RESKEY_raiddev=$OCFT_raiddev

CASE-BLOCK default_status
	AgentRun stop

CASE-BLOCK prepare
	Include required_args
	Include default_status

CASE-BLOCK prepare_auto
	Include required_args
	Env OCF_RESKEY_raiddev="auto"
	Include default_status

CASE-BLOCK prepare_multiple
	Include required_args
	Env OCF_RESKEY_raiddev="$OCFT_raiddev $OCFT_raiddev2"
	Include default_status

CASE "check base env"
	Include prepare
	AgentRun start OCF_SUCCESS

CASE "check base env: invalid 'OCF_RESKEY_raiddev'"
	Include prepare
	Env OCF_RESKEY_raiddev=/dev/no_such_device
	AgentRun start OCF_ERR_GENERIC

CASE "check base env: unset 'OCF_RESKEY_raiddev'"
	Include prepare
	Unenv OCF_RESKEY_raiddev
	AgentRun start OCF_ERR_CONFIGURED

CASE "normal start"
	Include prepare
	AgentRun start OCF_SUCCESS

CASE "normal stop"
	Include prepare
	AgentRun start
	AgentRun stop OCF_SUCCESS

CASE "double start"
	Include prepare
	AgentRun start
	AgentRun start OCF_SUCCESS

CASE "double stop"
	Include prepare
	AgentRun stop OCF_SUCCESS

CASE "monitor when running"
	Include prepare
	AgentRun start
	AgentRun monitor OCF_SUCCESS

CASE "monitor when not running"
	Include prepare
	AgentRun monitor OCF_NOT_RUNNING

CASE "normal start (auto)"
	Include prepare_auto
	AgentRun start OCF_SUCCESS
	AgentRun monitor OCF_SUCCESS

CASE "normal stop (auto)"
	Include prepare_auto
	AgentRun start
	AgentRun stop OCF_SUCCESS
	AgentRun monitor OCF_NOT_RUNNING

CASE "normal start (multiple)"
	Include prepare
	AgentRun start OCF_SUCCESS
	AgentRun monitor OCF_SUCCESS

CASE "normal stop (multiple)"
	Include prepare
	Env OCF_RESKEY_raiddev="$OCFT_raiddev $OCFT_raiddev2"
	AgentRun start
	AgentRun stop OCF_SUCCESS
	AgentRun monitor OCF_NOT_RUNNING

CASE "unimplemented command"
	Include prepare
	AgentRun no_cmd OCF_ERR_UNIMPLEMENTED