-
Notifications
You must be signed in to change notification settings - Fork 4
/
ofcirctl.sh
executable file
·66 lines (54 loc) · 1.56 KB
/
ofcirctl.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
#!/bin/bash
# This script is for testing / debugging purpouses only
TOKEN=${TOKEN:-testtoken}
if [ $# -lt 1 ]; then
echo "Please specify at least one command:"
echo " - acquire <type>"
echo " - status <cir-id>"
echo " - release <cir-id>"
echo " - change-state <cir-id> <state>"
echo " - resize-pool <pool-id> <size>"
exit 1
fi
ofcirUrl=$(minikube service ofcir-service --namespace=ofcir-system --url)
case $1 in
acquire)
if [ $# -eq 2 ]; then
type="?type=$2"
fi
res=$(curl -s -X POST -H "X-OFCIRTOKEN: $TOKEN" ${ofcirUrl}/v1/ofcir${type})
echo $res
;;
status)
if [ $# -ne 2 ]; then
echo "Command requires <cir-id>"
exit 1
fi
res=$(curl -s -H "X-OFCIRTOKEN: $TOKEN" ${ofcirUrl}/v1/ofcir/$2)
echo $res
;;
release)
if [ $# -ne 2 ]; then
echo "Command requires <cir-id>"
exit 1
fi
res=$(curl -s -X DELETE -H "X-OFCIRTOKEN: $TOKEN" ${ofcirUrl}/v1/ofcir/$2)
echo $res
;;
change-state)
if [ $# -ne 3 ]; then
echo "Command requires <cir-id> <state>"
exit 1
fi
res=$(kubectl patch cir $2 --type merge --patch '{"spec": {"state": "'$3'"}}')
echo $res
;;
resize-pool)
if [ $# -ne 3 ]; then
echo "Command requires <pool-id> <size>"
exit 1
fi
res=$(kubectl patch cipool $2 --type merge --patch '{"spec": {"size": '$3'}}')
echo $res
;;
esac