summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2018-03-18 22:59:31 +0100
committerSuren A. Chilingaryan <csa@suren.me>2018-03-18 22:59:31 +0100
commit47f350bc3aa85a8bd406d95faf084df2abf74ae9 (patch)
tree72ad1e91bac46d3457f89781dc90f0d6c1c074d5 /scripts
parent006f333828db373435daa15483d2ab753048f62a (diff)
downloadands-47f350bc3aa85a8bd406d95faf084df2abf74ae9.tar.gz
ands-47f350bc3aa85a8bd406d95faf084df2abf74ae9.tar.bz2
ands-47f350bc3aa85a8bd406d95faf084df2abf74ae9.tar.xz
ands-47f350bc3aa85a8bd406d95faf084df2abf74ae9.zip
Second revision: includes hostpath mounts, gluster block storage, kaas apps, etc.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gluster.sh96
-rwxr-xr-xscripts/hawakular.sh18
-rwxr-xr-xscripts/kube-ops-view.sh12
-rw-r--r--scripts/opts.sh12
4 files changed, 134 insertions, 4 deletions
diff --git a/scripts/gluster.sh b/scripts/gluster.sh
index 9efea45..07ca7f9 100755
--- a/scripts/gluster.sh
+++ b/scripts/gluster.sh
@@ -63,16 +63,104 @@ function migrate {
heal $vol
}
+
+function transport {
+ vol=$1
+ transport=${2:-tcp,rdma}
+ echo "Changing $vol to transport $transport"
+ gluster volume stop "$vol"
+ gluster volume set "$vol" config.transport "$transport"
+ gluster volume start "$vol"
+}
+
+
+
+function restart {
+ vol=$1
+
+ echo $vol
+ bricks=$(gluster volume info "$vol" | grep -P 'Number of Bricks' | awk '{ print $NF }' | tr -d '\r\n')
+ online=$(gluster volume status "$vol" detail | grep Online | grep Y | wc -l)
+
+ if [ "$bricks" -ne "$online" ]; then
+ echo "Restarting $vol ($online bricks of $bricks are/is online)"
+ gluster --mode=script volume stop "$vol"
+ gluster --mode=script volume start "$vol"
+ fi
+}
+
+function delete_failed {
+ vol=$1
+
+ bricks=$(gluster volume info "$vol" | grep -P 'Number of Bricks' | awk '{ print $NF }' | tr -d '\r\n')
+ online=$(gluster volume status "$vol" detail | grep Online | grep Y | wc -l)
+
+ if [ "$online" == "0" ]; then
+ echo "Deleting $vol ($online bricks of $bricks are/is online)"
+# gluster --mode=script volume stop "$vol"
+ gluster --mode=script volume delete "$vol"
+ fi
+}
+
+
+function lvm_clean {
+ used_bricks=`gluster volume info | grep "/brick_" | sed -r -e 's/.*brick_(.*)\/brick/\1/'`
+
+ for ip in $(seq 1 3); do
+ echo "Node $ip"
+ echo "========"
+ lvm_bricks=`node $ip lvscan | grep brick | sed -r -e 's/.*brick_([0-9a-z]*)[^0-9a-z].*/\1/'`
+ diff=$(echo $used_bricks $lvm_bricks | tr -d '\r' | tr ' ' '\n' | sort | uniq -u)
+ remove=$(echo "$diff $lvm_bricks" | tr -d '\r' | tr ' ' '\n' | sort | uniq -d)
+
+ for id in $remove; do
+ echo "Removing ---------------------------------------------"
+ node $ip lvs -o name,time,size -S "'name =~ $id'"
+ echo "Removing ---------------------------------------------"
+ node $ip lvremove -y -S "'name =~ $id'"
+ done
+ done
+
+
+}
+
+function lvm_remove_today {
+ for ip in $(seq 1 3); do
+ node $ip hostname
+#lvdisplay -o name,time -S 'time since "2018-03-16"'
+ done
+}
-#
-# heal $1
+function heketi_cmd {
+ heketi "$@"
+}
-if [ -z "$1" -a "$1" =~ ^all ]; then
+function heketi_clean {
+ heketi_vols=`heketi topology info | grep "Name: vol_" | sed -r -e 's/.*(vol_[0-9a-z]+)\s*$/\1/'`
+ gluster_vols=`gluster volume info | grep "Name: vol_" | sed -r -e 's/.*(vol_[0-9a-z]+)\s*$/\1/'`
+ echo $heketi_vols
+
+ diff=$(echo $gluster_vols $heketi_vols | tr -d '\r' | tr ' ' '\n' | sort | uniq -u)
+ remove=$(echo "$diff $gluster_vols" | tr -d '\r' | tr ' ' '\n' | sort | uniq -d)
+
+ for vol in $remove; do
+ echo "Stopping and deleting volume $vol"
+ echo "---------------------------------"
+ gluster --mode=script volume stop "$vol"
+ gluster --mode=script volume delete "$vol"
+ done
+}
+
+if [[ "$action" =~ ^heketi ]]; then
+ eval "$action" "$@"
+elif [[ "$action" =~ ^lvm ]]; then
+ eval "$action" "$@"
+elif [[ -z "$1" || "$1" =~ ^all ]]; then
all=0
[ "$1" == "all_heketi" ] && all=1
- [ "$1" =~ ^all ] && shift
+ [[ "$1" =~ ^all ]] && shift
vols=$(gluster volume info | grep -P '^Volume Name' | awk '{ print $NF }' | tr '\r\n' ' ')
for vol in $vols; do
diff --git a/scripts/hawakular.sh b/scripts/hawakular.sh
new file mode 100755
index 0000000..73e3a87
--- /dev/null
+++ b/scripts/hawakular.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+case $1 in
+ "stop")
+ oc -n openshift-infra scale --replicas 0 rc/hawkular-metrics
+ oc -n openshift-infra scale --replicas 0 rc/heapster
+ oc -n openshift-infra scale --replicas 0 dc/hawkular-cassandra
+ ;;
+ "start")
+ oc -n openshift-infra scale --replicas 0 dc/hawkular-cassandra
+ sleep 1
+ oc -n openshift-infra scale --replicas 0 rc/heapster
+ sleep 1
+ oc -n openshift-infra scale --replicas 0 rc/hawkular-metrics
+ ;;
+ *)
+ echo "Usage: $0 stop/start"
+esac
diff --git a/scripts/kube-ops-view.sh b/scripts/kube-ops-view.sh
new file mode 100755
index 0000000..ca1389e
--- /dev/null
+++ b/scripts/kube-ops-view.sh
@@ -0,0 +1,12 @@
+#! /bin/bash
+
+NS=mon
+
+
+oc -n $NS new-project ocp-ops-view
+oc -n $NS create sa kube-ops-view
+oc -n $NS adm policy add-scc-to-user anyuid -z kube-ops-view
+oc -n $NS adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:mon:kube-ops-view
+oc -n $NS apply -f https://raw.githubusercontent.com/raffaelespazzoli/kube-ops-view/ocp/deploy-openshift/kube-ops-view.yaml
+oc -n $NS expose svc kube-ops-view
+oc -n $NS get route | grep kube-ops-view | awk '{print $2}'
diff --git a/scripts/opts.sh b/scripts/opts.sh
index d484efc..2f76d8e 100644
--- a/scripts/opts.sh
+++ b/scripts/opts.sh
@@ -7,3 +7,15 @@ gpod=$(get_gluster_pod)
function gluster {
oc -n glusterfs rsh po/$gpod gluster "$@"
}
+
+
+function node {
+ ip=$1
+ shift
+
+ ssh -xq root@192.168.26.$ip "$@"
+}
+
+function heketi {
+ node 1 heketi-cli -s http://heketi-storage.glusterfs.svc.cluster.local:8080 --user admin --secret "$(oc get secret heketi-storage-admin-secret -n glusterfs -o jsonpath='{.data.key}' | base64 -d)" "$@"
+}