forked from tinova/one-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onebootstrap
executable file
·42 lines (31 loc) · 1.06 KB
/
onebootstrap
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
#!/bin/bash
REALPATH=$(readlink -f $0)
cd `dirname $REALPATH`
for host in $(ls bootstrap/host/*.host 2>/dev/null); do
unset IM VMM NET
source $host
HOSTNAME=$(basename $host)
HOSTNAME=${HOSTNAME%%.host}
onehost create $HOSTNAME -i $IM -v $VMM -n $NET
done
for vnet in $(ls bootstrap/vnet/*.vnet 2>/dev/null); do
onevnet create $vnet
done
unset DEFAULT_DS
for datastore in $(ls bootstrap/datastore/*.datastore 2>/dev/null); do
DS_ID=$(onedatastore create $datastore|awk '{print $2}')
# If it's the first registered datastore, mark it as default
[ -z "$DEFAULT_DS" ] && DEFAULT_DS=$DS_ID
# If it has DEFAULT inside the template mark it as default
if cat $datastore | grep -q DEFAULT; then
DEFAULT_DS=$DS_ID
fi
done
# If no datastore was created, used DS 1 as the default
[ -z "DEFAULT_DS" ] && DEFAULT_DS=1
for image in $(ls bootstrap/image/*.image 2>/dev/null); do
oneimage create $image -d $DEFAULT_DS
done
for template in $(ls bootstrap/template/*.template 2>/dev/null); do
onetemplate create $template
done