-
Notifications
You must be signed in to change notification settings - Fork 1
/
add-kvm-to-lava.sh
executable file
·53 lines (42 loc) · 2.62 KB
/
add-kvm-to-lava.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
#!/bin/bash
#Create a kvm devicetype and add a kvm device to the lava server
adminuser=admin
adminpass=admin
lavaurl=http://localhost
hostn=`cat /hostname`
#obtain the csrf token
data=$(curl -s -c cookies.txt $lavaurl/accounts/login/); tail cookies.txt
#login
csrf="csrfmiddlewaretoken="$(cat cookies.txt | grep csrftoken | cut -d$'\t' -f 7); echo $csrf
login=$csrf\&username=$adminuser\&password=$adminpass; echo $login
curl -b cookies.txt -c cookies.txt -d $login -X POST $lavaurl/admin/login/
devicename=kvm01
devicetype=kvm
# add device type
csrf="csrfmiddlewaretoken="$(cat cookies.txt | grep csrftoken | cut -d$'\t' -f 7); echo $csrf
createdevicetype=$csrf\&name=$devicetype\&display=on\&health_frequency=24\&_save=Save\&health_denominator=0
curl -b cookies.txt -c cookies.txt -d $createdevicetype -X POST $lavaurl/admin/lava_scheduler_app/devicetype/add/
# add device
csrf="csrfmiddlewaretoken="$(cat cookies.txt | grep csrftoken | cut -d$'\t' -f 7); echo $csrf
createdevice=$csrf\&hostname=$devicename\&device_type=$devicetype\&device_version=1\&status=1\&health_status=0\&worker_host=$hostn
curl -b cookies.txt -c cookies.txt -d $createdevice -X POST $lavaurl/admin/lava_scheduler_app/device/add/
devicename=qemu-aarch64-01
devicetype=qemu-aarch64
# add device type
csrf="csrfmiddlewaretoken="$(cat cookies.txt | grep csrftoken | cut -d$'\t' -f 7); echo $csrf
createdevicetype=$csrf\&name=$devicetype\&display=on\&health_frequency=24\&_save=Save\&health_denominator=0
curl -b cookies.txt -c cookies.txt -d $createdevicetype -X POST $lavaurl/admin/lava_scheduler_app/devicetype/add/
## Add device
csrf="csrfmiddlewaretoken="$(cat cookies.txt | grep csrftoken | cut -d$'\t' -f 7); echo $csrf
createdevice=$csrf\&hostname=$devicename\&device_type=$devicetype\&device_version=1\&status=1\&health_status=0\&worker_host=$hostn
curl -b cookies.txt -c cookies.txt -d $createdevice -X POST $lavaurl/admin/lava_scheduler_app/device/add/
devicename=qemu01
devicetype=qemu
# add device type
csrf="csrfmiddlewaretoken="$(cat cookies.txt | grep csrftoken | cut -d$'\t' -f 7); echo $csrf
createdevicetype=$csrf\&name=$devicetype\&display=on\&health_frequency=24\&_save=Save\&health_denominator=0
curl -b cookies.txt -c cookies.txt -d $createdevicetype -X POST $lavaurl/admin/lava_scheduler_app/devicetype/add/
## Add device
csrf="csrfmiddlewaretoken="$(cat cookies.txt | grep csrftoken | cut -d$'\t' -f 7); echo $csrf
createdevice=$csrf\&hostname=$devicename\&device_type=$devicetype\&device_version=1\&status=1\&health_status=0\&is_pipeline="on"\&worker_host=$hostn
curl -b cookies.txt -c cookies.txt -d $createdevice -X POST $lavaurl/admin/lava_scheduler_app/device/add/