Commit 45aea4eb authored by David Johnson's avatar David Johnson

Autocreate a Hadoop image with certain things preinstalled.

parent fc2350ec
Pipeline #1268 skipped
......@@ -188,6 +188,95 @@ while [ $i -lt 4 ]; do
i=`expr $i + 1`
done
##
## Make an image with hadoop stuff preinstalled. Assume that the
## trusty-server image made by the previous setup scripts is the
## multi-nic one, so undo all that stuff, then install our hadoop stuff.
##
glance image-list | grep ' hadoop '
if [ ! $? -eq 0 ]; then
IMGFILE=$OURDIR/trusty-server-cloudimg-amd64-disk1.img
lsmod nbd
if [ ! $? -eq 0 ]; then
modprobe nbd max_part=8
fi
qemu-nbd --connect=/dev/nbd0 $IMGFILE
# Hadoop needs the full 2G -- expand the FS.
resize2fs /dev/nbd0p1
e2fsck -f /dev/nbd0p1
MNT=$OURDIR/mnt
mkdir -p $MNT
mount /dev/nbd0p1 $MNT
echo "*** Removing multi-nic stuff..."
cat <<EOF > $MNT/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
EOF
sed -i -e 's/^start on (mounted MOUNTPOINT=\/$/start on (local-filesystems/' $MNT/etc/init/networking.conf
rm -f $MNT/etc/network/if-pre-up.d/if-pre-up-upstart-faker
rm -f $MNT/etc/resolv.conf
cat <<EOF >$MNT/etc/resolv.conf
nameserver 8.8.8.8
EOF
mount -o bind /proc $MNT/proc
# Install hadoop and our config files
chroot $MNT /usr/bin/apt-get update
chroot $MNT /usr/bin/apt-get install -y vim-nox openjdk-7-jdk expect
chroot $MNT /usr/bin/apt-get clean all
wget http://www.emulab.net/downloads/hadoop-2.7.1.tar.gz
wget http://www.emulab.net/downloads/openstack-capnet-hadoop-files-v1.tar.gz
cp hadoop-2.7.1.tar.gz $MNT/home/ubuntu
tar -xzvf openstack-capnet-hadoop-files-v1.tar.gz -C $MNT/home/ubuntu
mkdir -p $MNT/root/.ssh
chmod 700 $MNT/root/.ssh
touch $MNT/root/.ssh/authorized_keys
chmod 600 $MNT/root/.ssh/authorized_keys
cat /root/.ssh/id_rsa.pub >> $MNT/root/.ssh/authorized_keys
mkdir -p $MNT/home/ubuntu/.ssh
chmod 700 $MNT/home/ubuntu/.ssh
touch $MNT/home/ubuntu/.ssh/authorized_keys
chmod 600 $MNT/home/ubuntu/.ssh/authorized_keys
cat /root/.ssh/id_rsa.pub >> $MNT/home/ubuntu/.ssh/authorized_keys
rm -f $MNT/etc/resolv.conf
ln -s ../run/resolvconf/resolv.conf $MNT/etc/resolv.conf
umount $MNT/proc
umount $MNT
sync
sync
echo "*** Importing new hadoop image ..."
glance image-create --name hadoop --disk-format qcow2 --container-format bare --progress --file $IMGFILE
qemu-nbd -d /dev/nbd0
fi
##
## Set all the images public so other tenants can boot them.
##
......@@ -195,3 +284,5 @@ IMAGELIST=`glance image-list | awk ' / [0-9a-zA-Z]*-[0-9a-zA-Z-]* / { print $2 }
for image in $IMAGELIST ; do
glance image-update --visibility public $image
done
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment