diff --git a/tools/ocft/Filesystem b/tools/ocft/Filesystem index f84bae57a..2b22d1b88 100644 --- a/tools/ocft/Filesystem +++ b/tools/ocft/Filesystem @@ -1,112 +1,105 @@ # Filesystem # by dejan@suse.de on # Tue Feb 15 18:50:04 CET 2011 # CONFIG Agent Filesystem AgentRoot /usr/lib/ocf/resource.d/heartbeat HangTimeout 20 VARIABLE - OCFT_vardir="`mount | grep '/run ' | awk '{print $3}'`" - OCFT_fs="$OCFT_vardir/resource-agents/ocft-Filesystem-fs" - OCFT_dir="$OCFT_vardir/resource-agents/ocft-Filesystem-mnt" - OCFT_loop_f="$OCFT_vardir/resource-agents/ocft-loopdev" - OCFT_loop="`cat $OCFT_loop_f 2>/dev/null`" + OCFT_rundir="`get_rundir`" + OCFT_fs="$OCFT_rundir/resource-agents/ocft-Filesystem-fs" + OCFT_dir="$OCFT_rundir/resource-agents/ocft-Filesystem-mnt" + OCFT_loop="`loopbackeddev make $OCFT_fs 16M`" SETUP-AGENT - losetup -f > $OCFT_loop_f - rmdir $OCFT_dir 2>/dev/null || true - mkdir $OCFT_dir - dd if=/dev/zero of=$OCFT_fs bs=1 count=0 seek=16M 2>/dev/null - mke2fs -j -Fq -m 0 $OCFT_fs - losetup `cat $OCFT_loop_f` $OCFT_fs + mke2fs -j -Fq -m 0 $OCFT_loop CLEANUP-AGENT + loopbackeddev unmake $OCFT_fs rmdir $OCFT_dir - rm $OCFT_fs $OCFT_loop_f - losetup -d $OCFT_loop CASE-BLOCK required_args Env OCF_RESKEY_device=$OCFT_loop Env OCF_RESKEY_fstype=ext3 Env OCF_RESKEY_directory=$OCFT_dir CASE-BLOCK default_status AgentRun stop CASE-BLOCK prepare Include required_args Include default_status CASE "check base env" Include prepare AgentRun start OCF_SUCCESS CASE "check base env: invalid 'OCF_RESKEY_device'" Include prepare Env OCF_RESKEY_device=/dev/no_such_device AgentRun start OCF_ERR_INSTALLED CASE "check base env: unset 'OCF_RESKEY_device'" Include prepare Unenv OCF_RESKEY_device 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 "monitor depth 10 when running" Include prepare AgentRun start Env OCF_CHECK_LEVEL=10 AgentRun monitor OCF_SUCCESS CASE "monitor depth 20 with running" Include prepare AgentRun start Env OCF_CHECK_LEVEL=20 AgentRun monitor OCF_SUCCESS CASE "start insert failure (remove device)" Include prepare Bash losetup -d $OCFT_loop BashAtExit losetup $OCFT_loop $OCFT_fs AgentRun start OCF_ERR_GENERIC CASE "monitor depth 20 insert failure (r/o fs)" Include prepare AgentRun start Bash mount -o remount,ro $OCFT_dir BashAtExit mount -o remount,rw $OCFT_dir Env OCF_CHECK_LEVEL=20 AgentRun monitor OCF_ERR_GENERIC CASE "unimplemented command" Include prepare AgentRun no_cmd OCF_ERR_UNIMPLEMENTED diff --git a/tools/ocft/LVM b/tools/ocft/LVM index 6e75ed5fa..00b69ee7d 100644 --- a/tools/ocft/LVM +++ b/tools/ocft/LVM @@ -1,89 +1,83 @@ # LVM # by dejan@suse.de on # Wed Feb 16 13:15:01 CET 2011 CONFIG Agent LVM AgentRoot /usr/lib/ocf/resource.d/heartbeat HangTimeout 20 VARIABLE - OCFT_vardir="`mount | grep '/run ' | awk '{print $3}'`" - OCFT_pv=$OCFT_vardir/resource-agents/ocft-LVM-pv + OCFT_rundir="`get_rundir`" + OCFT_pv=$OCFT_rundir/resource-agents/ocft-LVM-pv OCFT_vg=ocft-vg OCFT_lv=ocft-lv - OCFT_loop_f="$OCFT_vardir/resource-agents/ocft-loopdev" - OCFT_loop="`cat $OCFT_loop_f 2>/dev/null`" + OCFT_loop="`loopbackeddev make $OCFT_pv 16M`" SETUP-AGENT - losetup -f > $OCFT_loop_f - OCFT_loop=`cat $OCFT_loop_f` - dd if=/dev/zero of=$OCFT_pv bs=1 count=0 seek=16M 2>/dev/null - losetup $OCFT_loop $OCFT_pv pvcreate $OCFT_loop vgcreate -s 4K $OCFT_vg $OCFT_loop lvcreate -n $OCFT_lv -L 600K $OCFT_vg CLEANUP-AGENT vgchange -an $OCFT_vg lvremove -f /dev/$OCFT_vg/$OCFT_lv vgremove -f $OCFT_vg pvremove $OCFT_loop - losetup -d $OCFT_loop - rm $OCFT_pv $OCFT_loop_f + loopbackeddev unmake $OCFT_pv CASE-BLOCK required_args Env OCF_RESKEY_volgrpname=$OCFT_vg CASE-BLOCK default_status AgentRun stop CASE-BLOCK prepare Include required_args Include default_status CASE "check base env" Include prepare AgentRun start OCF_SUCCESS CASE "check base env: invalid 'OCF_RESKEY_volgrpname'" Include prepare Env OCF_RESKEY_volgrpname=/dev/no_such_device AgentRun start OCF_ERR_GENERIC CASE "check base env: unset 'OCF_RESKEY_volgrpname'" Include prepare Unenv OCF_RESKEY_volgrpname 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 "unimplemented command" Include prepare AgentRun no_cmd OCF_ERR_UNIMPLEMENTED diff --git a/tools/ocft/Raid1 b/tools/ocft/Raid1 index 1c239c8a0..462b9b981 100644 --- a/tools/ocft/Raid1 +++ b/tools/ocft/Raid1 @@ -1,146 +1,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_disk0=/var/run/resource-agents/ocft-Raid1-disk0 - OCFT_disk1=/var/run/resource-agents/ocft-Raid1-disk1 - OCFT_disk2=/var/run/resource-agents/ocft-Raid1-disk2 - OCFT_disk3=/var/run/resource-agents/ocft-Raid1-disk3 - OCFT_raidconf=/var/run/resource-agents/ocft-mdadm.conf + 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=/dev/loop6 - OCFT_loop1=/dev/loop7 - OCFT_loop2=/dev/loop4 - OCFT_loop3=/dev/loop5 + 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 - losetup $OCFT_loop0 2>/dev/null && exit 1 - losetup $OCFT_loop1 2>/dev/null && exit 1 - losetup $OCFT_loop2 2>/dev/null && exit 1 - losetup $OCFT_loop3 2>/dev/null && exit 1 - dd if=/dev/zero of=$OCFT_disk0 bs=1 count=0 seek=16M 2>/dev/null - dd if=/dev/zero of=$OCFT_disk1 bs=1 count=0 seek=16M 2>/dev/null - dd if=/dev/zero of=$OCFT_disk2 bs=1 count=0 seek=16M 2>/dev/null - dd if=/dev/zero of=$OCFT_disk3 bs=1 count=0 seek=16M 2>/dev/null - losetup $OCFT_loop0 $OCFT_disk0 - losetup $OCFT_loop1 $OCFT_disk1 - losetup $OCFT_loop2 $OCFT_disk2 - losetup $OCFT_loop3 $OCFT_disk3 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 - losetup -d $OCFT_loop0 - losetup -d $OCFT_loop1 - losetup -d $OCFT_loop2 - losetup -d $OCFT_loop3 - rm $OCFT_disk0 $OCFT_disk1 $OCFT_raidconf - rm $OCFT_disk2 $OCFT_disk3 + 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 diff --git a/tools/ocft/iscsi b/tools/ocft/iscsi index c16218447..e47dacfe1 100644 --- a/tools/ocft/iscsi +++ b/tools/ocft/iscsi @@ -1,117 +1,109 @@ # iscsi CONFIG Agent iscsi AgentRoot /usr/lib/ocf/resource.d/heartbeat InstallPackage open-iscsi targetcli HangTimeout 20 VARIABLE - OCFT_disk="/var/run/resource-agents/ocft-iscsi" + OCFT_rundir="`get_rundir`" + OCFT_disk="$OCFT_rundir/resource-agents/ocft-iscsi" OCFT_target="iqn.2003-01.org.linux-iscsi:ocft" OCFT_portal="127.0.0.1:3260" - OCFT_loop_f="/var/run/resource-agents/ocft-iscsi-loopdev" - OCFT_loop="`cat $OCFT_loop_f 2>/dev/null`" - OCF_ROOT=/usr/lib/ocf + OCFT_loop="`loopbackeddev make $OCFT_disk 16M`" OCF_RESKEY_iqn=$OCFT_target OCF_RESKEY_portals=$OCFT_portal OCF_RESKEY_target_iqn=$OCFT_target OCF_RESKEY_path=$OCFT_loop OCF_RESKEY_lun=1 SETUP-AGENT - losetup -f > $OCFT_loop_f - OCFT_loop="`cat $OCFT_loop_f`" - dd if=/dev/zero of=$OCFT_disk bs=1 count=0 seek=16M 2>/dev/null - losetup $OCFT_loop $OCFT_disk if [ -n "`which rcopen-iscsi >/dev/null 2>&1`" ]; then rcopen-iscsi start else rciscsi start rciscsid start fi if systemctl list-unit-files 2>/dev/null | fgrep -q target.service; then systemctl start target.service else rctarget start fi - export OCF_ROOT=/usr/lib/ocf export OCF_RESKEY_iqn=$OCFT_target export OCF_RESKEY_portals=$OCFT_portal export OCF_RESKEY_target_iqn=$OCFT_target export OCF_RESKEY_path=$OCFT_loop export OCF_RESKEY_lun=1 /usr/lib/ocf/resource.d/heartbeat/iSCSITarget start /usr/lib/ocf/resource.d/heartbeat/iSCSILogicalUnit start CLEANUP-AGENT - export OCF_ROOT=/usr/lib/ocf export OCF_RESKEY_iqn=$OCFT_target export OCF_RESKEY_portals=$OCFT_portal export OCF_RESKEY_target_iqn=$OCFT_target export OCF_RESKEY_path=$OCFT_loop export OCF_RESKEY_lun=1 /usr/lib/ocf/resource.d/heartbeat/iSCSILogicalUnit stop /usr/lib/ocf/resource.d/heartbeat/iSCSITarget stop if systemctl list-unit-files 2>/dev/null | fgrep -q target.service; then systemctl stop target.service fi - losetup -d $OCFT_loop - rm -f $OCFT_disk $OCFT_loop_f + loopbackeddev unmake $OCFT_disk CASE-BLOCK required_args Env OCF_RESKEY_portal=$OCFT_portal Env OCF_RESKEY_target=$OCFT_target CASE-BLOCK default_status AgentRun stop CASE-BLOCK prepare Include required_args Include default_status CASE "check base env" Include prepare AgentRun start OCF_SUCCESS CASE "check base env: invalid 'OCF_RESKEY_portal'" Include prepare Unenv OCF_RESKEY_portal AgentRun start OCF_ERR_CONFIGURED CASE "check base env: unset 'OCF_RESKEY_target'" Include prepare Unenv OCF_RESKEY_target 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 "unimplemented command" Include prepare AgentRun no_cmd OCF_ERR_UNIMPLEMENTED