#!/bin/sh
set -x
##############################################:
#pre for openstack local network env,pre for mutil node,and for migration.
#date:2012.10.23
#author:kikupotter
##############################################
if [ $# -ne 1 ]
then
echo "please specify one arg.node1,node2,ro master"
exit 1
fi
#############################################
#main func.
# sub func node1,node2,master.
pre_master(){
cat > /etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.21
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
dns-nameservers 218.85.157.99
EOF
cat >/etc/hostname <<EOF
master
EOF
}
pre_node1(){
cat > /etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.20
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
dns-nameservers 218.85.157.99
EOF
cat >/etc/hostname <<EOF
node1
EOF
}
pre_node2(){
cat > /etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.23
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
dns-nameservers 218.85.157.99
EOF
cat >/etc/hostname <<EOF
node2
EOF
}
#END func.
############################################
case "${1}" in
master)
pre_master
;;
node1)
pre_node1
;;
node2)
pre_node2
;;
*)
echo "Please specify master ,ro nodeX"
exit
;;
esac
##############################################
######all node must do for migration########
#update system
apt-get update;apt-get upgrade
apt-get -y install vim
sleep 2
#hosts for dns.
cat > /etc/hosts <<EOF
127.0.0.1 localhost
192.168.0.21 master.cloud.com master
192.168.0.20 node1.cloud.com node1
192.168.0.23 node2.cloud.com node2
EOF
#NOTE: If you are going to use live migration functionality, pre-create system user/group id so they can map directly in cluster setup.
addgroup --system --gid 119 kvm
addgroup --system --gid 118 libvirtd
addgroup --system --gid 117 nova
adduser --system --home /var/lib/libvirt --shell /bin/false --uid 119 --gid 119 --disabled-password libvirt-qemu
adduser --system --home /var/lib/libvirt/dnsmasq --shell /bin/false --uid 118 --gid 118 --disabled-password libvirt-dnsmasq
adduser --system --home /var/lib/nova --shell /bin/false --uid 117 --gid 117 --disabled-password nova
adduser nova libvirtd