summaryrefslogtreecommitdiff
path: root/templates/remove
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2008-09-10 15:54:16 -0700
committerBob Gilligan <gilligan@vyatta.com>2008-09-10 15:54:16 -0700
commit15c75d023be453a717aefc82f02b6ef6fd8b7ace (patch)
tree3aafdd6511dd56d79de6599d5eed17a625f5a56a /templates/remove
parent39ef568ad5da594f92ea445bfd1190aa54ff0fb8 (diff)
downloadvyatta-op-15c75d023be453a717aefc82f02b6ef6fd8b7ace.tar.gz
vyatta-op-15c75d023be453a717aefc82f02b6ef6fd8b7ace.zip
Add operational mode commands for RAID.
Diffstat (limited to 'templates/remove')
-rw-r--r--templates/remove/node.def1
-rw-r--r--templates/remove/raid/node.def1
-rw-r--r--templates/remove/raid/node.tag/member/node.def1
-rw-r--r--templates/remove/raid/node.tag/member/node.tag/node.def35
-rw-r--r--templates/remove/raid/node.tag/node.def6
5 files changed, 44 insertions, 0 deletions
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