-
Notifications
You must be signed in to change notification settings - Fork 94
/
storageserver-partition-config.sh
executable file
·119 lines (105 loc) · 3.64 KB
/
storageserver-partition-config.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# Copyright (c) 2013 EMC Corporation
# All Rights Reserved
#
# This software contains the intellectual property of EMC Corporation
# or is licensed to EMC Corporation from third parties. Use of this
# software and the intellectual property contained therein is expressly
# limited to the terms and conditions of the License Agreement under which
# it is provided by or on behalf of EMC.
#
date
# This script will generate the partition file (ss-partition-conf.json) to be used on this server if one is not found.
# Also a general configuration file will be generated with main parameters and a ss uuid.
# Assumes this is running on gen 3 hardware or a vipr data test node using disks mounted with a
# /dae/uuid-58f917ab-23ba-457f-a9df-d0f4b0597e2d type pattern or will look for /data (vipr)
export configdir="/opt/storageos/conf"
export p_configfile="$configdir/storageserver-partition-conf.json"
export configfile="$configdir/storageserver.conf"
blockbinsizegb=10
vm_bb_cout=5
vm_part_count=5
function setopt() {
opt=$1
val=$2
if grep -q "$opt" "$configfile" ; then
sed -i "s#$opt=.*#$opt=$val#g" "$configfile"
else
echo "$opt=$val" >> $configfile
fi
}
echo "creating main config file: $configfile"
if [ ! -e "$configfile" ]; then
echo "creating $configfile"
mkdir -p "$configdir"
cat << EOF > "$configfile"
listenaddress=0.0.0.0
port=9099
iothreads=100
blockbinsizegb=$blockbinsizegb
debugenabled=false
logtoconsole=false
logtosyslog=true
maxoutstandingrequests=0
initblockbins=0
netserverListenPort=9069
netserverLogLevel=INFO
ioThreadNumber=200
perfCountEnabled=true
maxMemThresholdKb=3145728
sendQHighWaterMark=1000
recvThreadNicePriority=-15
sendThreadNicePriority=-15
enableAffinity=true
partitionroot=/dae
agentUrlEndPoint=/host/data/agent.json
agentDisksRestFragment=/v1/agent/node/storage/disk/disks
trustStore=/host/data/security/truststore.pem
verifyCerts=true
dbusEnabled=false
EOF
else
echo "$configfile already exists, no action taken"
fi
if grep -q -E 'VMware.*Virtual.*disk' /proc/scsi/sg/device_strs && [ ! -e /data/is_community_edition ]
then
# this a virtual datanode, creating a json file with predefined values
echo "virtual node detected - using json config file"
setopt partitionconfig $p_configfile
setopt partitionroot=/dae
root="/data/storageserver"
for part in $(seq 1 $vm_part_count); do
for bb in $(seq 1 $vm_bb_cout); do
bb=$(printf "%0*d\n" 4 $bb)
mkdir -m 777 -p $root/uuid-$part
fallocate -l${blockbinsizegb}G $root/uuid-$part/$bb
chmod 777 $root/uuid-$part/$bb
done
done
if [ ! -e "$p_configfile" ]; then
echo "creating $p_configfile"
mkdir -p "$configdir"
printf '{\n%2s"disks": [\n' > $p_configfile
for part in $(seq 1 "$vm_part_count"); do
printf '%4s{\n%6s"uuid": "'$part'",\n%6s"health": "Good"\n%4s}' >> $p_configfile
[ "$part" -lt "$vm_part_count" ] && echo "," >> $p_configfile || echo "" >> $p_configfile
done
printf '%2s]\n}' >> $p_configfile
else
echo "$p_configfile already exists, no action taken"
fi
else
# this is a commodity hardware node. do not generate a json file - ss will use dbus to obtain partitions
echo "commodity node detected - using dbus api"
fi
if ! grep --quiet "uuid" "$configfile"; then
echo "generating server uuid"
uuidgen="$(which uuidgen)"
if [ ! -z "$uuidgen" ]; then
uuid="$(uuidgen)"
else
echo "warning: uuidgen utility was not found on your system. using timestamp as a uuid"
uuid="$(date +%s)"
fi
setopt uuid "$uuid"
fi