From 15c75d023be453a717aefc82f02b6ef6fd8b7ace Mon Sep 17 00:00:00 2001 From: Bob Gilligan Date: Wed, 10 Sep 2008 15:54:16 -0700 Subject: Add operational mode commands for RAID. --- templates/remove/node.def | 1 + templates/remove/raid/node.def | 1 + templates/remove/raid/node.tag/member/node.def | 1 + .../remove/raid/node.tag/member/node.tag/node.def | 35 ++++++++++++++++++++++ templates/remove/raid/node.tag/node.def | 6 ++++ 5 files changed, 44 insertions(+) create mode 100644 templates/remove/node.def create mode 100644 templates/remove/raid/node.def create mode 100644 templates/remove/raid/node.tag/member/node.def create mode 100644 templates/remove/raid/node.tag/member/node.tag/node.def create mode 100644 templates/remove/raid/node.tag/node.def (limited to 'templates/remove') diff --git a/templates/remove/node.def b/templates/remove/node.def new file mode 100644 index 0000000..387e0d2 --- /dev/null +++ b/templates/remove/node.def @@ -0,0 +1 @@ +help: Remove an object from service diff --git a/templates/remove/raid/node.def b/templates/remove/raid/node.def new file mode 100644 index 0000000..2700b93 --- /dev/null +++ b/templates/remove/raid/node.def @@ -0,0 +1 @@ +help: Remove a RAID set element diff --git a/templates/remove/raid/node.tag/member/node.def b/templates/remove/raid/node.tag/member/node.def new file mode 100644 index 0000000..6af665d --- /dev/null +++ b/templates/remove/raid/node.tag/member/node.def @@ -0,0 +1 @@ +help: Remove a member of a RAID set \ No newline at end of file diff --git a/templates/remove/raid/node.tag/member/node.tag/node.def b/templates/remove/raid/node.tag/member/node.tag/node.def new file mode 100644 index 0000000..d384fd3 --- /dev/null +++ b/templates/remove/raid/node.tag/member/node.tag/node.def @@ -0,0 +1,35 @@ +help: Name of RAID set member to remove + +allowed: + raid_set=${COMP_WORDS[2]} + membership=`cat /proc/mdstat | grep $raid_set | sed -e 's/\[.\]//g' | awk '{ print $5 " " $6 }'` + membership=`echo $membership | sed -e 's/(F)//g'` + echo "$membership" + +run: + raid_set=$3 + member_to_remove=$5 + membership=`cat /proc/mdstat | grep $raid_set | sed -e 's/\[.\]//g' | awk '{ print $5 " " $6 }'` + num_members=`echo $membership | wc -w` + is_in=`echo $membership | grep $member_to_remove` + + if [ -z "$membership" ]; then + echo "$raid_set is not a RAID set" + elif [ -z "$is_in" ]; then + echo "$member_to_remove is not a member of RAID set $raid_set" + echo "actual members are: $membership" + elif [ "$num_members" -eq "1" ]; then + echo "Can't remove last member of a RAID set" + else + echo "removing member $member from RAID set $raid_set" + mdadm /dev/$raid_set --fail /dev/$member_to_remove + if [ $? -ne 0 ]; then + echo "Unable to mark member as failed" + else + sleep 1 + mdadm /dev/$raid_set --remove /dev/$member_to_remove + if [ $? -ne 0 ]; then + echo "Unable to remove member from RAID set" + fi + fi + fi diff --git a/templates/remove/raid/node.tag/node.def b/templates/remove/raid/node.tag/node.def new file mode 100644 index 0000000..a8d8485 --- /dev/null +++ b/templates/remove/raid/node.tag/node.def @@ -0,0 +1,6 @@ +help: Name of RAID set to remove object from + +allowed: + local -a array ; + array=`cat /proc/partitions | grep md | awk '{ print $4 }'` + echo -n $array -- cgit v1.2.3