-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate-topology-update-script.sh
executable file
·108 lines (90 loc) · 1.85 KB
/
create-topology-update-script.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
#!/bin/bash
#
# This script creates the topology update script and registers it with 'strigger'
#
set -eo pipefail
if [ "$UID" -ne 0 ]; then
echo "Must run as root."
exit 1
fi
SCRIPT_PATH="update-topology-config.sh"
PROVIDER=""
TOPOLOGY_CONFIG_PATH=""
if [[ ! -z "$SLURM_CONF" ]]; then
TOPOLOGY_CONFIG_PATH="$(dirname $SLURM_CONF)/topology.conf"
fi
#
# print script description and usage
#
function usage() {
cat << EOF
Usage: $(basename $0) [options]
Options:
-s <path to the generated topology update script>
Default: $SCRIPT_PATH
-c <path to the topology config>
Default: $TOPOLOGY_CONFIG_PATH
-p <CSP provider>
Options: aws, oci, gcp, azure
-h
Print this message
EOF
}
### MAIN
while getopts 's:c:p:h' opt; do
case "$opt" in
s)
SCRIPT_PATH=$OPTARG
;;
c)
TOPOLOGY_CONFIG_PATH=$OPTARG
;;
p)
PROVIDER=$OPTARG
;;
h)
usage
exit 0
;;
?)
usage
exit 1
;;
esac
done
if [[ -z "$TOPOLOGY_CONFIG_PATH" ]]; then
echo "topology config file is not set"
usage
exit 1
fi
if [[ -z "$PROVIDER" ]]; then
echo "provider is not set"
usage
exit 1
fi
case $PROVIDER in
"aws")
;;
"oci")
;;
"gcp")
;;
"azure")
;;
*)
echo "unsupported provider $PROVIDER"
usage
exit 1
;;
esac
echo "Creating $SCRIPT_PATH to update topology config $TOPOLOGY_CONFIG_PATH"
echo ""
cat <<EOF > $SCRIPT_PATH
#!/bin/bash
curl -X POST -H "Content-Type: application/json" -d '{"provider":{"name":"$PROVIDER"},"engine":{"name":"slurm","params":{"topology_config_path":"$TOPOLOGY_CONFIG_PATH","reconfigure":true}}}' http://localhost:49021/v1/generate
EOF
chmod 755 $SCRIPT_PATH
echo "Registering $SCRIPT_PATH with stigger"
echo ""
su - slurm -c "strigger --set --node --down --up --flags=perm --program=$(realpath $SCRIPT_PATH)"
echo "Done"