summaryrefslogtreecommitdiff
path: root/templates/add
diff options
context:
space:
mode:
Diffstat (limited to 'templates/add')
-rw-r--r--templates/add/node.def1
-rw-r--r--templates/add/raid/node.def1
-rw-r--r--templates/add/raid/node.tag/member/node.def1
-rw-r--r--templates/add/raid/node.tag/member/node.tag/node.def38
-rw-r--r--templates/add/raid/node.tag/node.def6
5 files changed, 47 insertions, 0 deletions
diff --git a/templates/add/node.def b/templates/add/node.def
new file mode 100644
index 0000000..39ff67a
--- /dev/null
+++ b/templates/add/node.def
@@ -0,0 +1 @@
+help: Add an object to a service
diff --git a/templates/add/raid/node.def b/templates/add/raid/node.def
new file mode 100644
index 0000000..26cc4a3
--- /dev/null
+++ b/templates/add/raid/node.def
@@ -0,0 +1 @@
+help: Add a RAID set element
diff --git a/templates/add/raid/node.tag/member/node.def b/templates/add/raid/node.tag/member/node.def
new file mode 100644
index 0000000..efa1d45
--- /dev/null
+++ b/templates/add/raid/node.tag/member/node.def
@@ -0,0 +1 @@
+help: Add a member to a RAID set \ No newline at end of file
diff --git a/templates/add/raid/node.tag/member/node.tag/node.def b/templates/add/raid/node.tag/member/node.tag/node.def
new file mode 100644
index 0000000..60eff63
--- /dev/null
+++ b/templates/add/raid/node.tag/member/node.tag/node.def
@@ -0,0 +1,38 @@
+help: Name of RAID set member to add
+
+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'`
+ partitions=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep "[0-9]"`
+ for member in $membership; do
+ partitions=`echo $partitions | sed -e s/$member//g`
+ done
+ partitions=`echo $partitions | sed -e 's/md[0-9]*//g'`
+ echo "$partitions"
+
+run:
+ raid_set=$3
+ member_to_add=$5
+ membership=`cat /proc/mdstat | grep $raid_set | sed -e 's/\[.\]//g' | awk '{ print $5 " " $6 }'`
+ is_in=`echo $membership | grep $member_to_add`
+
+ partitions=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep "[0-9]"`
+ partitions=`echo $partitions | sed -e 's/md[0-9]*//g'`
+ valid_partition=`echo $partitions | grep $member_to_add`
+
+ if [ -z "$membership" ]; then
+ echo "$raid_set is not a RAID set"
+ elif [ -n "$is_in" ]; then
+ echo "$member_to_add is already a member of RAID set $raid_set"
+ echo "actual members are: $membership"
+ elif [ -z "$valid_partition" ]; then
+ echo "$member_to_add is not a valid disk partition"
+ else
+ echo "adding member $member_to_add to RAID set $raid_set"
+ mdadm /dev/$raid_set --add /dev/$member_to_add
+ if [ $? -ne 0 ]; then
+ echo "Unable to add member to RAID set"
+ fi
+ fi
+
diff --git a/templates/add/raid/node.tag/node.def b/templates/add/raid/node.tag/node.def
new file mode 100644
index 0000000..e0ae4d9
--- /dev/null
+++ b/templates/add/raid/node.tag/node.def
@@ -0,0 +1,6 @@
+help: Name of RAID set to add object to
+
+allowed:
+ local -a array ;
+ array=`cat /proc/partitions | grep md | awk '{ print $4 }'`
+ echo -n $array