forked from NTTdocomo-openstack/devstack-baremetal-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocal.sh
More file actions
executable file
·147 lines (113 loc) · 5.62 KB
/
local.sh
File metadata and controls
executable file
·147 lines (113 loc) · 5.62 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
set -x
TOP_DIR=$(cd $(dirname "$0") && pwd)
source $TOP_DIR/stackrc
source $TOP_DIR/functions
DEST=${DEST:-/opt/stack}
source $TOP_DIR/openrc
NOVA_DIR=$DEST/nova
if [ -d $NOVA_DIR/bin ] ; then
NOVA_BIN_DIR=$NOVA_DIR/bin
else
NOVA_BIN_DIR=/usr/local/bin
fi
MYSQL_USER=${MYSQL_USER:-root}
BM_PXE_INTERFACE=${BM_PXE_INTERFACE:-eth1}
BM_PXE_PER_NODE=`trueorfalse False $BM_PXE_PER_NODE`
$NOVA_BIN_DIR/nova-manage instance_type create --name=baremetal.small --cpu=1 --memory=2048 --root_gb=10 --ephemeral_gb=20 --swap=1024 --rxtx_factor=1
$NOVA_BIN_DIR/nova-manage instance_type set_key --name=baremetal.small --key cpu_arch --value x86_64
$NOVA_BIN_DIR/nova-manage instance_type create --name=baremetal.medium --cpu=1 --memory=4096 --root_gb=10 --ephemeral_gb=20 --swap=1024 --rxtx_factor=1
$NOVA_BIN_DIR/nova-manage instance_type set_key --name=baremetal.medium --key cpu_arch --value x86_64
$NOVA_BIN_DIR/nova-manage instance_type create --name=baremetal.minimum --cpu=1 --memory=1 --root_gb=1 --ephemeral_gb=0 --swap=1 --rxtx_factor=1
$NOVA_BIN_DIR/nova-manage instance_type set_key --name=baremetal.minimum --key cpu_arch --value x86_64
apt_get install dnsmasq syslinux ipmitool qemu-kvm open-iscsi
apt_get install busybox tgt
BMIB_REPO=https://github.com/NTTdocomo-openstack/baremetal-initrd-builder.git
BMIB_DIR=$DEST/barematal-initrd-builder
BMIB_BRANCH=master
git_clone $BMIB_REPO $BMIB_DIR $BMIB_BRANCH
KERNEL_VER=`uname -r`
KERNEL_=/boot/vmlinuz-$KERNEL_VER
KERNEL=/tmp/deploy-kernel
sudo cp "$KERNEL_" "$KERNEL"
sudo chmod a+r "$KERNEL"
RAMDISK=/tmp/deploy-ramdisk.img
if [ ! -f "$RAMDISK" ]; then
(
cd "$BMIB_DIR"
./baremetal-mkinitrd.sh "$RAMDISK" "$KERNEL_VER"
)
fi
GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$GLANCE_HOST:9292}
TOKEN=$(keystone token-get | grep ' id ' | get_field 2)
KERNEL_ID=$(glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "baremetal-deployment-kernel" --public --container-format aki --disk-format aki < "$KERNEL" | grep ' id ' | get_field 2)
echo "$KERNEL_ID"
RAMDISK_ID=$(glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "baremetal-deployment-ramdisk" --public --container-format ari --disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2)
echo "$RAMDISK_ID"
echo "building ubuntu image"
IMG=$DEST/ubuntu.img
./build-ubuntu-image.sh "$IMG" "$DEST"
REAL_KERNEL_ID=$(glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "baremetal-real-kernel" --public --container-format aki --disk-format aki < "$DEST/kernel" | grep ' id ' | get_field 2)
REAL_RAMDISK_ID=$(glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "baremetal-deployment-ramdisk" --public --container-format ari --disk-format ari < "$DEST/initrd" | grep ' id ' | get_field 2)
glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "Ubuntu" --public --container-format bare --disk-format raw --property kernel_id=$REAL_KERNEL_ID --property ramdisk_id=$REAL_RAMDISK_ID < "$IMG"
TFTPROOT=$DEST/tftproot
if [ -d "$TFTPROOT" ]; then
rm -r "$TFTPROOT"
fi
mkdir "$TFTPROOT"
cp /usr/lib/syslinux/pxelinux.0 "$TFTPROOT"
mkdir $TFTPROOT/pxelinux.cfg
DNSMASQ_PID=/dnsmasq.pid
if [ -f "$DNSMASQ_PID" ]; then
sudo kill `cat "$DNSMASQ_PID"`
sudo rm "$DNSMASQ_PID"
fi
sudo /etc/init.d/dnsmasq stop
sudo sudo update-rc.d dnsmasq disable
if [ "$BM_PXE_PER_NODE" = "False" ]; then
sudo dnsmasq --conf-file= --port=0 --enable-tftp --tftp-root=$TFTPROOT --dhcp-boot=pxelinux.0 --bind-interfaces --pid-file=$DNSMASQ_PID --interface=$BM_PXE_INTERFACE --dhcp-range=192.168.175.100,192.168.175.254
fi
mkdir -p $NOVA_DIR/baremetal/console
mkdir -p $NOVA_DIR/baremetal/dnsmasq
inicomment /etc/nova/nova.conf DEFAULT firewall_driver
function is() {
iniset /etc/nova/nova.conf DEFAULT "$1" "$2"
}
is baremetal_sql_connection mysql://$MYSQL_USER:$MYSQL_PASSWORD@127.0.0.1/nova_bm
is compute_driver nova.virt.baremetal.driver.BareMetalDriver
is baremetal_driver nova.virt.baremetal.pxe.PXE
is power_manager nova.virt.baremetal.ipmi.Ipmi
is instance_type_extra_specs cpu_arch:x86_64
is baremetal_tftp_root $TFTPROOT
#is baremetal_term /usr/local/bin/shellinaboxd
is baremetal_dnsmasq_pid_dir $NOVA_DIR/baremetal/dnsmasq
is baremetal_dnsmasq_lease_dir $NOVA_DIR/baremetal/dnsmasq
is baremetal_deploy_kernel $KERNEL_ID
is baremetal_deploy_ramdisk $RAMDISK_ID
is scheduler_host_manager nova.scheduler.baremetal_host_manager.BaremetalHostManager
is baremetal_pxe_vlan_per_host $BM_PXE_PER_NODE
is baremetal_pxe_parent_interface $BM_PXE_INTERFACE
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS nova_bm;'
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE nova_bm CHARACTER SET latin1;'
# workaround for invalid compute_node that non-bare-metal nova-compute has left
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD nova -e 'DELETE FROM compute_nodes;'
$NOVA_BIN_DIR/nova-bm-manage db sync
$NOVA_BIN_DIR/nova-bm-manage pxe_ip create --cidr 192.168.175.0/24
if [ -f ./bm-nodes.sh ]; then
. ./bm-nodes.sh
fi
NL=`echo -ne '\015'`
echo "restarting nova-scheduler"
screen -S stack -p n-sch -X kill
screen -S stack -X screen -t n-sch
sleep 1.5
screen -S stack -p n-sch -X stuff "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-scheduler $NL"
echo "restarting nova-compute"
screen -S stack -p n-cpu -X kill
screen -S stack -X screen -t n-cpu
sleep 1.5
screen -S stack -p n-cpu -X stuff "cd $NOVA_DIR && sg libvirtd $NOVA_BIN_DIR/nova-compute $NL"
echo "starting bm_deploy_server"
screen -S stack -p n-bmd -X kill
screen -S stack -X screen -t n-bmd
sleep 1.5
screen -S stack -p n-bmd -X stuff "cd $NOVA_DIR && $NOVA_BIN_DIR/bm_deploy_server $NL"