diff options
author | John Southworth <john.southworth@vyatta.com> | 2011-08-31 13:13:07 -0500 |
---|---|---|
committer | John Southworth <john.southworth@vyatta.com> | 2011-10-27 17:11:28 -0500 |
commit | 7106043d374852bd104d0a4e41a0d23562533731 (patch) | |
tree | e4660070bd0632bcf9ca73bcba74512c3a504ff5 /templates/delete | |
parent | 589f17253f54aee6b5bbec31c825377be2f36b95 (diff) | |
download | vyatta-op-7106043d374852bd104d0a4e41a0d23562533731.tar.gz vyatta-op-7106043d374852bd104d0a4e41a0d23562533731.zip |
move 'remove raid' to 'delete raid'
(cherry picked from commit 86584774d9a33cad75e6dac2b66ce48513fa84f1)
Diffstat (limited to 'templates/delete')
-rw-r--r-- | templates/delete/raid/node.def | 1 | ||||
-rw-r--r-- | templates/delete/raid/node.tag/member/node.def | 1 | ||||
-rw-r--r-- | templates/delete/raid/node.tag/member/node.tag/node.def | 37 | ||||
-rw-r--r-- | templates/delete/raid/node.tag/node.def | 6 |
4 files changed, 45 insertions, 0 deletions
diff --git a/templates/delete/raid/node.def b/templates/delete/raid/node.def new file mode 100644 index 0000000..2700b93 --- /dev/null +++ b/templates/delete/raid/node.def @@ -0,0 +1 @@ +help: Remove a RAID set element diff --git a/templates/delete/raid/node.tag/member/node.def b/templates/delete/raid/node.tag/member/node.def new file mode 100644 index 0000000..6af665d --- /dev/null +++ b/templates/delete/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/delete/raid/node.tag/member/node.tag/node.def b/templates/delete/raid/node.tag/member/node.tag/node.def new file mode 100644 index 0000000..a48fd4a --- /dev/null +++ b/templates/delete/raid/node.tag/member/node.tag/node.def @@ -0,0 +1,37 @@ +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" + elif [ ! -r /dev/$raid_set ]; then + echo "Must be admin or root to remove RAID set member" + else + echo "removing member $member from RAID set $raid_set" + sudo /sbin/mdadm /dev/$raid_set --fail /dev/$member_to_remove + if [ $? -ne 0 ]; then + echo "Unable to mark member as failed" + else + sleep 1 + sudo /sbin/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/delete/raid/node.tag/node.def b/templates/delete/raid/node.tag/node.def new file mode 100644 index 0000000..a8d8485 --- /dev/null +++ b/templates/delete/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 |