summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-09-22 08:34:00 -0500
committerGitHub <noreply@github.com>2023-09-22 08:34:00 -0500
commit44f769ccb633b4ee6c4b7c1289e08596d4b4f233 (patch)
treea5fc3a93db5552fbfb1d347be29b4afbd4cfd613
parent4b81c794554c4f159bfc4337c0d62741d8be57c7 (diff)
parent38c5919054c62054eed3c6f825e3aea4f931d131 (diff)
downloadvyatta-op-44f769ccb633b4ee6c4b7c1289e08596d4b4f233.tar.gz
vyatta-op-44f769ccb633b4ee6c4b7c1289e08596d4b4f233.zip
Merge pull request #71 from jestabro/disk-by-id
op-mode: raid: T5608: add/delete raid template now in vyos-1x
-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.def41
-rw-r--r--templates/add/raid/node.tag/node.def6
-rw-r--r--templates/delete/raid/node.def1
-rw-r--r--templates/delete/raid/node.tag/member/node.def1
-rw-r--r--templates/delete/raid/node.tag/member/node.tag/node.def37
-rw-r--r--templates/delete/raid/node.tag/node.def6
8 files changed, 0 insertions, 94 deletions
diff --git a/templates/add/raid/node.def b/templates/add/raid/node.def
deleted file mode 100644
index 26cc4a3..0000000
--- a/templates/add/raid/node.def
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 100644
index fd2bc72..0000000
--- a/templates/add/raid/node.tag/member/node.def
+++ /dev/null
@@ -1 +0,0 @@
-help: Add a member to a RAID set
diff --git a/templates/add/raid/node.tag/member/node.tag/node.def b/templates/add/raid/node.tag/member/node.tag/node.def
deleted file mode 100644
index 198bc99..0000000
--- a/templates/add/raid/node.tag/member/node.tag/node.def
+++ /dev/null
@@ -1,41 +0,0 @@
-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"
- elif [ ! -r /dev/$raid_set ]; then
- echo "Must be admin or root to add RAID set member"
- else
- echo "adding member $member_to_add to RAID set $raid_set"
- sudo /sbin/mdadm /dev/$raid_set --add /dev/$member_to_add
- if [ $? -ne 0 ]; then
- echo "Unable to add member to RAID set"
- fi
- disk=$(lsblk -ndo pkname /dev/$member_to_add)
- sudo grub-install /dev/$disk
- fi \ No newline at end of file
diff --git a/templates/add/raid/node.tag/node.def b/templates/add/raid/node.tag/node.def
deleted file mode 100644
index e0ae4d9..0000000
--- a/templates/add/raid/node.tag/node.def
+++ /dev/null
@@ -1,6 +0,0 @@
-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
diff --git a/templates/delete/raid/node.def b/templates/delete/raid/node.def
deleted file mode 100644
index 2700b93..0000000
--- a/templates/delete/raid/node.def
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 100644
index 52c411b..0000000
--- a/templates/delete/raid/node.tag/member/node.def
+++ /dev/null
@@ -1 +0,0 @@
-help: Remove a member of a RAID set
diff --git a/templates/delete/raid/node.tag/member/node.tag/node.def b/templates/delete/raid/node.tag/member/node.tag/node.def
deleted file mode 100644
index a48fd4a..0000000
--- a/templates/delete/raid/node.tag/member/node.tag/node.def
+++ /dev/null
@@ -1,37 +0,0 @@
-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
deleted file mode 100644
index a8d8485..0000000
--- a/templates/delete/raid/node.tag/node.def
+++ /dev/null
@@ -1,6 +0,0 @@
-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