File: oci-scp-ring

package info (click to toggle)
openstack-cluster-installer 43.0.18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,484 kB
  • sloc: php: 19,127; sh: 18,142; ruby: 75; makefile: 31; xml: 8
file content (61 lines) | stat: -rwxr-xr-x 1,482 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh

set -eu
#set -x

unset SSH_AUTH_SOCK

ME=$(basename $0)

RED="\033[1;31m"
NO_COL="\033[0m"
GREEN="\033[1;32m"
green_echo () {
        echo ${GREEN}${1}${NO_COL}
}
red_echo () {
        echo ${RED}${1}${NO_COL}
}

usage (){
	echo "${ME} -c/--cluster <CLUSTER-NAME>"
	exit 1
}

MY_CLUSTER=""
for i in $@ ; do
case "${i}" in
"-c"|"--cluster")
	MY_CLUSTER=${2}
	shift
	shift
;;
*)
;;
esac
done

if [ "${MY_CLUSTER}" = "" ] ; then
	NUM_CLUST=$(ocicli -csv cluster-list | q -d, -H "SELECT name FROM -" | wc -l)
	if [ "${NUM_CLUST}" = 1 ] ; then
		MY_CLUSTER=$(ocicli -csv cluster-list | q -d, -H "SELECT name FROM -")
		echo "-> Only one cluster, and no -c / --cluster option: will default to use ${MY_CLUSTER}."
	else
		echo "Please define a cluster name with -c or --cluster"
		usage
	fi
fi

cd /var/lib/oci/clusters/${MY_CLUSTER}/swift-ring

for MACHINE in $(ocicli -csv machine-list --filter cluster_name=${MY_CLUSTER},status=installed -a |
		q -H -d, "SELECT hostname,Cur_ip FROM - WHERE role='swiftstore' or role='swiftproxy'") ; do
	M_HOSTNAME=$(echo $MACHINE | cut -d, -f1)
	M_IP=$(echo $MACHINE | cut -d, -f2)
	green_echo "=> Rsync ring to ${M_HOSTNAME} (${M_IP}):"
	rsync -e "ssh -i /etc/openstack-cluster-installer/id_rsa -o ConnectTimeout=5" \
		--chmod=644 --chown=swift:swift --itemize-changes --timeout=5 --times \
		account.builder container.builder object.builder \
		account.ring.gz container.ring.gz object.ring.gz \
		"${M_IP}":/etc/swift/ || continue
done