| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,42 +0,0 @@ |
| 1 |
-Tool to quickly deploy openstack dev environments. |
|
| 2 |
- |
|
| 3 |
-# Goals |
|
| 4 |
- |
|
| 5 |
-* To quickly build dev openstack environments in clean natty environments |
|
| 6 |
-* To describe working configurations of openstack (which code branches work together? what do config files look like for those branches?) |
|
| 7 |
-* To make it easier for developers to dive into openstack so that they can productively contribute without having to understand every part of the system at once |
|
| 8 |
-* To make it easy to prototype cross-project features |
|
| 9 |
- |
|
| 10 |
-Be sure to carefully read these scripts before you run them as they install software and may alter your networking configuration. |
|
| 11 |
- |
|
| 12 |
-# To start a dev cloud on your local machine (installing on a dedicated vm is safer!): |
|
| 13 |
- |
|
| 14 |
- ./stack.sh |
|
| 15 |
- |
|
| 16 |
-If working correctly, you should be able to access openstack endpoints, like: |
|
| 17 |
- |
|
| 18 |
-* Dashboard: http://myhost/ |
|
| 19 |
-* Keystone: http://myhost:5000/v2.0/ |
|
| 20 |
- |
|
| 21 |
-# To start a dev cloud in an lxc container: |
|
| 22 |
- |
|
| 23 |
- ./build_lxc.sh |
|
| 24 |
- |
|
| 25 |
-You will need to configure a bridge and network on your host machine (by default br0) before starting build_lxc.sh. A sample host-only network configuration can be found in lxc_network_hostonlyplusnat.sh. |
|
| 26 |
- |
|
| 27 |
-# Customizing |
|
| 28 |
- |
|
| 29 |
-You can tweak environment variables by creating file name 'localrc' should you need to override defaults. It is likely that you will need to do this to tweak your networking configuration should you need to access your cloud from a different host. |
|
| 30 |
- |
|
| 31 |
-# Todo |
|
| 32 |
- |
|
| 33 |
-* Add python-novaclient cli support |
|
| 34 |
-* syslog |
|
| 35 |
-* allow rabbit connection to be specified via environment variables with sensible defaults |
|
| 36 |
-* Add volume support |
|
| 37 |
-* Add quantum support |
|
| 38 |
- |
|
| 39 |
-# Future |
|
| 40 |
- |
|
| 41 |
-* idea: move from screen to tmux? |
|
| 42 |
-* idea: create a live-cd / vmware preview image using this? |
| 43 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,43 @@ |
| 0 |
+Tool to quickly deploy openstack dev environments. |
|
| 1 |
+ |
|
| 2 |
+# Goals |
|
| 3 |
+ |
|
| 4 |
+* To quickly build dev openstack environments in clean natty environments |
|
| 5 |
+* To describe working configurations of openstack (which code branches work together? what do config files look like for those branches?) |
|
| 6 |
+* To make it easier for developers to dive into openstack so that they can productively contribute without having to understand every part of the system at once |
|
| 7 |
+* To make it easy to prototype cross-project features |
|
| 8 |
+ |
|
| 9 |
+Read more at http://devstack.org (built from the gh-pages branch) |
|
| 10 |
+ |
|
| 11 |
+Be sure to carefully read these scripts before you run them as they install software and may alter your networking configuration. |
|
| 12 |
+ |
|
| 13 |
+# To start a dev cloud on your local machine (installing on a dedicated vm is safer!): |
|
| 14 |
+ |
|
| 15 |
+ ./stack.sh |
|
| 16 |
+ |
|
| 17 |
+If working correctly, you should be able to access openstack endpoints, like: |
|
| 18 |
+ |
|
| 19 |
+* Dashboard: http://myhost/ |
|
| 20 |
+* Keystone: http://myhost:5000/v2.0/ |
|
| 21 |
+ |
|
| 22 |
+# To start a dev cloud in an lxc container: |
|
| 23 |
+ |
|
| 24 |
+ ./build_lxc.sh |
|
| 25 |
+ |
|
| 26 |
+You will need to configure a bridge and network on your host machine (by default br0) before starting build_lxc.sh. A sample host-only network configuration can be found in lxc_network_hostonlyplusnat.sh. |
|
| 27 |
+ |
|
| 28 |
+# Customizing |
|
| 29 |
+ |
|
| 30 |
+You can tweak environment variables by creating file name 'localrc' should you need to override defaults. It is likely that you will need to do this to tweak your networking configuration should you need to access your cloud from a different host. |
|
| 31 |
+ |
|
| 32 |
+# Todo |
|
| 33 |
+ |
|
| 34 |
+* Add python-novaclient cli support |
|
| 35 |
+* syslog |
|
| 36 |
+* Add volume support |
|
| 37 |
+* Add quantum support |
|
| 38 |
+ |
|
| 39 |
+# Future |
|
| 40 |
+ |
|
| 41 |
+* idea: move from screen to tmux? |
|
| 42 |
+* idea: create a live-cd / vmware preview image using this? |
| 0 | 43 |
deleted file mode 100755 |
| ... | ... |
@@ -1,117 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-PROGDIR=`dirname $0` |
|
| 4 |
-CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack}
|
|
| 5 |
- |
|
| 6 |
-# Source params |
|
| 7 |
-source ./stackrc |
|
| 8 |
- |
|
| 9 |
-# Store cwd |
|
| 10 |
-CWD=`pwd` |
|
| 11 |
- |
|
| 12 |
-NAME=$1 |
|
| 13 |
-NFSDIR="/nfs/$NAME" |
|
| 14 |
-DEST=${DEST:-/opt/stack}
|
|
| 15 |
- |
|
| 16 |
-# Option to use the version of devstack on which we are currently working |
|
| 17 |
-USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
|
|
| 18 |
- |
|
| 19 |
-# remove old nfs filesystem if one exists |
|
| 20 |
-rm -rf $DEST |
|
| 21 |
- |
|
| 22 |
-# clean install of natty |
|
| 23 |
-if [ ! -d $CHROOTCACHE/natty-base ]; then |
|
| 24 |
- $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base |
|
| 25 |
- # copy kernel modules... |
|
| 26 |
- # NOTE(ja): is there a better way to do this? |
|
| 27 |
- cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules |
|
| 28 |
- # a simple password - pass |
|
| 29 |
- echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd |
|
| 30 |
-fi |
|
| 31 |
- |
|
| 32 |
-# prime natty with as many apt/pips as we can |
|
| 33 |
-if [ ! -d $CHROOTCACHE/natty-dev ]; then |
|
| 34 |
- rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/ |
|
| 35 |
- chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` |
|
| 36 |
- chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*` |
|
| 37 |
- |
|
| 38 |
- # Create a stack user that is a member of the libvirtd group so that stack |
|
| 39 |
- # is able to interact with libvirt. |
|
| 40 |
- chroot $CHROOTCACHE/natty-dev groupadd libvirtd |
|
| 41 |
- chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd |
|
| 42 |
- mkdir -p $CHROOTCACHE/natty-dev/$DEST |
|
| 43 |
- chown stack $CHROOTCACHE/natty-dev/$DEST |
|
| 44 |
- |
|
| 45 |
- # a simple password - pass |
|
| 46 |
- echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd |
|
| 47 |
- |
|
| 48 |
- # and has sudo ability (in the future this should be limited to only what |
|
| 49 |
- # stack requires) |
|
| 50 |
- echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers |
|
| 51 |
-fi |
|
| 52 |
- |
|
| 53 |
-# clone git repositories onto the system |
|
| 54 |
-# ====================================== |
|
| 55 |
- |
|
| 56 |
-if [ ! -d $CHROOTCACHE/natty-stack ]; then |
|
| 57 |
- rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/ |
|
| 58 |
-fi |
|
| 59 |
- |
|
| 60 |
-# git clone only if directory doesn't exist already. Since ``DEST`` might not |
|
| 61 |
-# be owned by the installation user, we create the directory and change the |
|
| 62 |
-# ownership to the proper user. |
|
| 63 |
-function git_clone {
|
|
| 64 |
- |
|
| 65 |
- # clone new copy or fetch latest changes |
|
| 66 |
- CHECKOUT=$CHROOTCACHE/natty-stack$2 |
|
| 67 |
- if [ ! -d $CHECKOUT ]; then |
|
| 68 |
- mkdir -p $CHECKOUT |
|
| 69 |
- git clone $1 $CHECKOUT |
|
| 70 |
- else |
|
| 71 |
- pushd $CHECKOUT |
|
| 72 |
- git fetch |
|
| 73 |
- popd |
|
| 74 |
- fi |
|
| 75 |
- |
|
| 76 |
- # FIXME(ja): checkout specified version (should works for branches and tags) |
|
| 77 |
- |
|
| 78 |
- pushd $CHECKOUT |
|
| 79 |
- # checkout the proper branch/tag |
|
| 80 |
- git checkout $3 |
|
| 81 |
- # force our local version to be the same as the remote version |
|
| 82 |
- git reset --hard origin/$3 |
|
| 83 |
- popd |
|
| 84 |
- |
|
| 85 |
- # give ownership to the stack user |
|
| 86 |
- chroot $CHROOTCACHE/natty-stack/ chown -R stack $2 |
|
| 87 |
-} |
|
| 88 |
- |
|
| 89 |
-git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH |
|
| 90 |
-git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH |
|
| 91 |
-git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH |
|
| 92 |
-git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH |
|
| 93 |
-git_clone $DASH_REPO $DEST/dash $DASH_BRANCH $DASH_TAG |
|
| 94 |
-git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH |
|
| 95 |
-git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH |
|
| 96 |
- |
|
| 97 |
-chroot $CHROOTCACHE/natty-stack mkdir -p $DEST/files |
|
| 98 |
-wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack$DEST/files/tty.tgz |
|
| 99 |
- |
|
| 100 |
-# Use this version of devstack? |
|
| 101 |
-if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then |
|
| 102 |
- rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack |
|
| 103 |
- cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack |
|
| 104 |
-fi |
|
| 105 |
- |
|
| 106 |
-cp -pr $CHROOTCACHE/natty-stack $NFSDIR |
|
| 107 |
- |
|
| 108 |
-# set hostname |
|
| 109 |
-echo $NAME > $NFSDIR/etc/hostname |
|
| 110 |
-echo "127.0.0.1 localhost $NAME" > $NFSDIR/etc/hosts |
|
| 111 |
- |
|
| 112 |
-# injecting root's public ssh key if it exists |
|
| 113 |
-if [ -f /root/.ssh/id_rsa.pub ]; then |
|
| 114 |
- mkdir $NFSDIR/root/.ssh |
|
| 115 |
- chmod 700 $NFSDIR/root/.ssh |
|
| 116 |
- cp /root/.ssh/id_rsa.pub $NFSDIR/root/.ssh/authorized_keys |
|
| 117 |
-fi |
| 118 | 1 |
deleted file mode 100755 |
| ... | ... |
@@ -1,116 +0,0 @@ |
| 1 |
-#!/bin/bash -e |
|
| 2 |
-# build_pxe_boot.sh - Create a PXE boot environment |
|
| 3 |
-# |
|
| 4 |
-# build_pxe_boot.sh [-k kernel-version] destdir |
|
| 5 |
-# |
|
| 6 |
-# Assumes syslinux is installed |
|
| 7 |
-# Assumes devstack files are in `pwd`/pxe |
|
| 8 |
-# Only needs to run as root if the destdir permissions require it |
|
| 9 |
- |
|
| 10 |
-UBUNTU_MIRROR=http://archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64 |
|
| 11 |
- |
|
| 12 |
-MEMTEST_VER=4.10 |
|
| 13 |
-MEMTEST_BIN=memtest86+-${MEMTEST_VER}.bin
|
|
| 14 |
-MEMTEST_URL=http://www.memtest.org/download/${MEMTEST_VER}/
|
|
| 15 |
- |
|
| 16 |
-KVER=`uname -r` |
|
| 17 |
-if [ "$1" = "-k" ]; then |
|
| 18 |
- KVER=$2 |
|
| 19 |
- shift;shift |
|
| 20 |
-fi |
|
| 21 |
- |
|
| 22 |
-DEST_DIR=${1:-/tmp}/tftpboot
|
|
| 23 |
-PXEDIR=${PXEDIR:-/var/cache/devstack/pxe}
|
|
| 24 |
-OPWD=`pwd` |
|
| 25 |
-PROGDIR=`dirname $0` |
|
| 26 |
- |
|
| 27 |
-mkdir -p $DEST_DIR/pxelinux.cfg |
|
| 28 |
-cd $DEST_DIR |
|
| 29 |
-for i in memdisk menu.c32 pxelinux.0; do |
|
| 30 |
- cp -p /usr/lib/syslinux/$i $DEST_DIR |
|
| 31 |
-done |
|
| 32 |
- |
|
| 33 |
-DEFAULT=$DEST_DIR/pxelinux.cfg/default |
|
| 34 |
-cat >$DEFAULT <<EOF |
|
| 35 |
-default menu.c32 |
|
| 36 |
-prompt 0 |
|
| 37 |
-timeout 0 |
|
| 38 |
- |
|
| 39 |
-MENU TITLE PXE Boot Menu |
|
| 40 |
- |
|
| 41 |
-EOF |
|
| 42 |
- |
|
| 43 |
-# Setup devstack boot |
|
| 44 |
-mkdir -p $DEST_DIR/ubuntu |
|
| 45 |
-if [ ! -d $PXEDIR ]; then |
|
| 46 |
- mkdir -p $PXEDIR |
|
| 47 |
-fi |
|
| 48 |
-if [ ! -r $PXEDIR/vmlinuz-${KVER} ]; then
|
|
| 49 |
- sudo chmod 644 /boot/vmlinuz-${KVER}
|
|
| 50 |
- if [ ! -r /boot/vmlinuz-${KVER} ]; then
|
|
| 51 |
- echo "No kernel found" |
|
| 52 |
- else |
|
| 53 |
- cp -p /boot/vmlinuz-${KVER} $PXEDIR
|
|
| 54 |
- fi |
|
| 55 |
-fi |
|
| 56 |
-cp -p $PXEDIR/vmlinuz-${KVER} $DEST_DIR/ubuntu
|
|
| 57 |
-if [ ! -r $PXEDIR/stack-initrd.gz ]; then |
|
| 58 |
- cd $OPWD |
|
| 59 |
- sudo $PROGDIR/build_pxe_ramdisk.sh $PXEDIR/stack-initrd.gz |
|
| 60 |
-fi |
|
| 61 |
-cp -p $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu |
|
| 62 |
-cat >>$DEFAULT <<EOF |
|
| 63 |
- |
|
| 64 |
-LABEL devstack |
|
| 65 |
- MENU LABEL ^devstack |
|
| 66 |
- MENU DEFAULT |
|
| 67 |
- KERNEL ubuntu/vmlinuz-$KVER |
|
| 68 |
- APPEND initrd=ubuntu/stack-initrd.gz ramdisk_size=2109600 root=/dev/ram0 |
|
| 69 |
-EOF |
|
| 70 |
- |
|
| 71 |
-# Get Ubuntu |
|
| 72 |
-if [ -d $PXEDIR ]; then |
|
| 73 |
- cp -p $PXEDIR/natty-base-initrd.gz $DEST_DIR/ubuntu |
|
| 74 |
-fi |
|
| 75 |
-cat >>$DEFAULT <<EOF |
|
| 76 |
- |
|
| 77 |
-LABEL ubuntu |
|
| 78 |
- MENU LABEL ^Ubuntu Natty |
|
| 79 |
- KERNEL ubuntu/vmlinuz-$KVER |
|
| 80 |
- APPEND initrd=ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0 |
|
| 81 |
-EOF |
|
| 82 |
- |
|
| 83 |
-# Get Memtest |
|
| 84 |
-cd $DEST_DIR |
|
| 85 |
-if [ ! -r $MEMTEST_BIN ]; then |
|
| 86 |
- wget -N --quiet ${MEMTEST_URL}/${MEMTEST_BIN}.gz
|
|
| 87 |
- gunzip $MEMTEST_BIN |
|
| 88 |
-fi |
|
| 89 |
-cat >>$DEFAULT <<EOF |
|
| 90 |
- |
|
| 91 |
-LABEL memtest |
|
| 92 |
- MENU LABEL ^Memtest86+ |
|
| 93 |
- KERNEL $MEMTEST_BIN |
|
| 94 |
-EOF |
|
| 95 |
- |
|
| 96 |
-# Get FreeDOS |
|
| 97 |
-mkdir -p $DEST_DIR/freedos |
|
| 98 |
-cd $DEST_DIR/freedos |
|
| 99 |
-wget -N --quiet http://www.fdos.org/bootdisks/autogen/FDSTD.288.gz |
|
| 100 |
-gunzip -f FDSTD.288.gz |
|
| 101 |
-cat >>$DEFAULT <<EOF |
|
| 102 |
- |
|
| 103 |
-LABEL freedos |
|
| 104 |
- MENU LABEL ^FreeDOS bootdisk |
|
| 105 |
- KERNEL memdisk |
|
| 106 |
- APPEND initrd=freedos/FDSTD.288 |
|
| 107 |
-EOF |
|
| 108 |
- |
|
| 109 |
-# Local disk boot |
|
| 110 |
-cat >>$DEFAULT <<EOF |
|
| 111 |
- |
|
| 112 |
-LABEL local |
|
| 113 |
- MENU LABEL ^Local disk |
|
| 114 |
- MENU DEFAULT |
|
| 115 |
- LOCALBOOT 0 |
|
| 116 |
-EOF |
| 117 | 1 |
deleted file mode 100755 |
| ... | ... |
@@ -1,135 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-if [ ! "$#" -eq "1" ]; then |
|
| 4 |
- echo "$0 builds a gziped natty openstack install" |
|
| 5 |
- echo "usage: $0 dest" |
|
| 6 |
- exit 1 |
|
| 7 |
-fi |
|
| 8 |
- |
|
| 9 |
-PROGDIR=`dirname $0` |
|
| 10 |
-CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack}
|
|
| 11 |
- |
|
| 12 |
-# Source params |
|
| 13 |
-source ./stackrc |
|
| 14 |
- |
|
| 15 |
-# Store cwd |
|
| 16 |
-CWD=`pwd` |
|
| 17 |
- |
|
| 18 |
-DEST=${DEST:-/opt/stack}
|
|
| 19 |
- |
|
| 20 |
-# Option to use the version of devstack on which we are currently working |
|
| 21 |
-USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
|
|
| 22 |
- |
|
| 23 |
-# clean install of natty |
|
| 24 |
-if [ ! -d $CHROOTCACHE/natty-base ]; then |
|
| 25 |
- $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base |
|
| 26 |
- # copy kernel modules... |
|
| 27 |
- # NOTE(ja): is there a better way to do this? |
|
| 28 |
- cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules |
|
| 29 |
- # a simple password - pass |
|
| 30 |
- echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd |
|
| 31 |
-fi |
|
| 32 |
- |
|
| 33 |
-# prime natty with as many apt/pips as we can |
|
| 34 |
-if [ ! -d $CHROOTCACHE/natty-dev ]; then |
|
| 35 |
- rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/ |
|
| 36 |
- chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` |
|
| 37 |
- chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*` |
|
| 38 |
- |
|
| 39 |
- # Create a stack user that is a member of the libvirtd group so that stack |
|
| 40 |
- # is able to interact with libvirt. |
|
| 41 |
- chroot $CHROOTCACHE/natty-dev groupadd libvirtd |
|
| 42 |
- chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd |
|
| 43 |
- mkdir -p $CHROOTCACHE/natty-dev/$DEST |
|
| 44 |
- chown stack $CHROOTCACHE/natty-dev/$DEST |
|
| 45 |
- |
|
| 46 |
- # a simple password - pass |
|
| 47 |
- echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd |
|
| 48 |
- |
|
| 49 |
- # and has sudo ability (in the future this should be limited to only what |
|
| 50 |
- # stack requires) |
|
| 51 |
- echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers |
|
| 52 |
-fi |
|
| 53 |
- |
|
| 54 |
-# clone git repositories onto the system |
|
| 55 |
-# ====================================== |
|
| 56 |
- |
|
| 57 |
-if [ ! -d $CHROOTCACHE/natty-stack ]; then |
|
| 58 |
- rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/ |
|
| 59 |
-fi |
|
| 60 |
- |
|
| 61 |
-# git clone only if directory doesn't exist already. Since ``DEST`` might not |
|
| 62 |
-# be owned by the installation user, we create the directory and change the |
|
| 63 |
-# ownership to the proper user. |
|
| 64 |
-function git_clone {
|
|
| 65 |
- |
|
| 66 |
- # clone new copy or fetch latest changes |
|
| 67 |
- CHECKOUT=$CHROOTCACHE/natty-stack$2 |
|
| 68 |
- if [ ! -d $CHECKOUT ]; then |
|
| 69 |
- mkdir -p $CHECKOUT |
|
| 70 |
- git clone $1 $CHECKOUT |
|
| 71 |
- else |
|
| 72 |
- pushd $CHECKOUT |
|
| 73 |
- git fetch |
|
| 74 |
- popd |
|
| 75 |
- fi |
|
| 76 |
- |
|
| 77 |
- # FIXME(ja): checkout specified version (should works for branches and tags) |
|
| 78 |
- |
|
| 79 |
- pushd $CHECKOUT |
|
| 80 |
- # checkout the proper branch/tag |
|
| 81 |
- git checkout $3 |
|
| 82 |
- # force our local version to be the same as the remote version |
|
| 83 |
- git reset --hard origin/$3 |
|
| 84 |
- popd |
|
| 85 |
- |
|
| 86 |
- # give ownership to the stack user |
|
| 87 |
- chroot $CHROOTCACHE/natty-stack/ chown -R stack $2 |
|
| 88 |
-} |
|
| 89 |
- |
|
| 90 |
-git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH |
|
| 91 |
-git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH |
|
| 92 |
-git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH |
|
| 93 |
-git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH |
|
| 94 |
-git_clone $DASH_REPO $DEST/dash $DASH_BRANCH |
|
| 95 |
-git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH |
|
| 96 |
-git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH |
|
| 97 |
- |
|
| 98 |
-# Use this version of devstack? |
|
| 99 |
-if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then |
|
| 100 |
- rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack |
|
| 101 |
- cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack |
|
| 102 |
-fi |
|
| 103 |
- |
|
| 104 |
-# Configure host network for DHCP |
|
| 105 |
-mkdir -p $CHROOTCACHE/natty-stack/etc/network |
|
| 106 |
-cat > $CHROOTCACHE/natty-stack/etc/network/interfaces <<EOF |
|
| 107 |
-auto lo |
|
| 108 |
-iface lo inet loopback |
|
| 109 |
- |
|
| 110 |
-auto eth0 |
|
| 111 |
-iface eth0 inet dhcp |
|
| 112 |
-EOF |
|
| 113 |
- |
|
| 114 |
-# build a new image |
|
| 115 |
-BASE=$CHROOTCACHE/build.$$ |
|
| 116 |
-IMG=$BASE.img |
|
| 117 |
-MNT=$BASE/ |
|
| 118 |
- |
|
| 119 |
-# (quickly) create a 2GB blank filesystem |
|
| 120 |
-dd bs=1 count=1 seek=$((2*1024*1024*1024)) if=/dev/zero of=$IMG |
|
| 121 |
-# force it to be initialized as ext2 |
|
| 122 |
-mkfs.ext2 -F $IMG |
|
| 123 |
- |
|
| 124 |
-# mount blank image loopback and load it |
|
| 125 |
-mkdir -p $MNT |
|
| 126 |
-mount -o loop $IMG $MNT |
|
| 127 |
-rsync -azH $CHROOTCACHE/natty-stack/ $MNT |
|
| 128 |
- |
|
| 129 |
-# umount and cleanup |
|
| 130 |
-umount $MNT |
|
| 131 |
-rmdir $MNT |
|
| 132 |
- |
|
| 133 |
-# gzip into final location |
|
| 134 |
-gzip -1 $IMG -c > $1 |
|
| 135 |
- |
| 136 | 1 |
deleted file mode 100755 |
| ... | ... |
@@ -1,178 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
-# make_image.sh - Create Ubuntu images in various formats |
|
| 3 |
-# |
|
| 4 |
-# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc), raw |
|
| 5 |
-# |
|
| 6 |
-# Requires sudo to root |
|
| 7 |
- |
|
| 8 |
-ROOTSIZE=${ROOTSIZE:-8192}
|
|
| 9 |
-SWAPSIZE=${SWAPSIZE:-1024}
|
|
| 10 |
-MIN_PKGS=${MIN_PKGS:-"apt-utils gpgv openssh-server"}
|
|
| 11 |
- |
|
| 12 |
-usage() {
|
|
| 13 |
- echo "Usage: $0 - Create Ubuntu images" |
|
| 14 |
- echo "" |
|
| 15 |
- echo "$0 [-m] [-r rootsize] [-s swapsize] release format" |
|
| 16 |
- echo "$0 -C [-m] release chrootdir" |
|
| 17 |
- echo "$0 -I [-r rootsize] [-s swapsize] chrootdir format" |
|
| 18 |
- echo "" |
|
| 19 |
- echo "-C - Create the initial chroot dir" |
|
| 20 |
- echo "-I - Create the final image from a chroot" |
|
| 21 |
- echo "-m - minimal installation" |
|
| 22 |
- echo "-r size - root fs size in MB" |
|
| 23 |
- echo "-s size - swap fs size in MB" |
|
| 24 |
- echo "release - Ubuntu release: jaunty - oneric" |
|
| 25 |
- echo "format - image format: qcow2, vmdk, vdi, vhd, xen, raw, fs" |
|
| 26 |
- exit 1 |
|
| 27 |
-} |
|
| 28 |
- |
|
| 29 |
-while getopts CIhmr:s: c; do |
|
| 30 |
- case $c in |
|
| 31 |
- C) CHROOTONLY=1 |
|
| 32 |
- ;; |
|
| 33 |
- I) IMAGEONLY=1 |
|
| 34 |
- ;; |
|
| 35 |
- h) usage |
|
| 36 |
- ;; |
|
| 37 |
- m) MINIMAL=1 |
|
| 38 |
- ;; |
|
| 39 |
- r) ROOTSIZE=$OPTARG |
|
| 40 |
- ;; |
|
| 41 |
- s) SWAPSIZE=$OPTARG |
|
| 42 |
- ;; |
|
| 43 |
- esac |
|
| 44 |
-done |
|
| 45 |
-shift `expr $OPTIND - 1` |
|
| 46 |
- |
|
| 47 |
-if [ ! "$#" -eq "2" -o -n "$CHROOTONLY" -a -n "$IMAGEONLY" ]; then |
|
| 48 |
- usage |
|
| 49 |
-fi |
|
| 50 |
- |
|
| 51 |
-# Default args |
|
| 52 |
-RELEASE=$1 |
|
| 53 |
-FORMAT=$2 |
|
| 54 |
-CHROOTDIR="" |
|
| 55 |
- |
|
| 56 |
-if [ -n "$CHROOTONLY" ]; then |
|
| 57 |
- RELEASE=$1 |
|
| 58 |
- CHROOTDIR=$2 |
|
| 59 |
- FORMAT="pass" |
|
| 60 |
-fi |
|
| 61 |
- |
|
| 62 |
-if [ -n "$IMAGEONLY" ]; then |
|
| 63 |
- CHROOTDIR=$1 |
|
| 64 |
- FORMAT=$2 |
|
| 65 |
- RELEASE="pass" |
|
| 66 |
-fi |
|
| 67 |
- |
|
| 68 |
-case $FORMAT in |
|
| 69 |
- kvm|qcow2) FORMAT=qcow2 |
|
| 70 |
- QFORMAT=qcow2 |
|
| 71 |
- HYPER=kvm |
|
| 72 |
- ;; |
|
| 73 |
- vmserver|vmdk) |
|
| 74 |
- FORMAT=vmdk |
|
| 75 |
- QFORMAT=vmdk |
|
| 76 |
- HYPER=vmserver |
|
| 77 |
- ;; |
|
| 78 |
- vbox|vdi) FORMAT=vdi |
|
| 79 |
- QFORMAT=vdi |
|
| 80 |
- HYPER=kvm |
|
| 81 |
- ;; |
|
| 82 |
- vhd|vpc) FORMAT=vhd |
|
| 83 |
- QFORMAT=vpc |
|
| 84 |
- HYPER=kvm |
|
| 85 |
- ;; |
|
| 86 |
- xen) FORMAT=raw |
|
| 87 |
- QFORMAT=raw |
|
| 88 |
- HYPER=xen |
|
| 89 |
- ;; |
|
| 90 |
- raw) FORMAT=raw |
|
| 91 |
- QFORMAT=raw |
|
| 92 |
- HYPER=kvm |
|
| 93 |
- ;; |
|
| 94 |
- pass) ;; |
|
| 95 |
- *) echo "Unknown format: $FORMAT" |
|
| 96 |
- usage |
|
| 97 |
-esac |
|
| 98 |
- |
|
| 99 |
-case $RELEASE in |
|
| 100 |
- natty) ;; |
|
| 101 |
- maverick) ;; |
|
| 102 |
- lucid) ;; |
|
| 103 |
- karmic) ;; |
|
| 104 |
- jaunty) ;; |
|
| 105 |
- pass) ;; |
|
| 106 |
- *) echo "Unknown release: $RELEASE" |
|
| 107 |
- usage |
|
| 108 |
- ;; |
|
| 109 |
-esac |
|
| 110 |
- |
|
| 111 |
-# Install stuff if necessary |
|
| 112 |
-if [ -z `which vmbuilder` ]; then |
|
| 113 |
- sudo apt-get install ubuntu-vm-builder |
|
| 114 |
-fi |
|
| 115 |
- |
|
| 116 |
-if [ -n "$CHROOTONLY" ]; then |
|
| 117 |
- # Build a chroot directory |
|
| 118 |
- HYPER=kvm |
|
| 119 |
- if [ "$MINIMAL" = 1 ]; then |
|
| 120 |
- ARGS="--variant=minbase" |
|
| 121 |
- for i in $MIN_PKGS; do |
|
| 122 |
- ARGS="$ARGS --addpkg=$i" |
|
| 123 |
- done |
|
| 124 |
- fi |
|
| 125 |
- sudo vmbuilder $HYPER ubuntu $ARGS \ |
|
| 126 |
- --suite $RELEASE \ |
|
| 127 |
- --only-chroot \ |
|
| 128 |
- --chroot-dir=$CHROOTDIR \ |
|
| 129 |
- --overwrite \ |
|
| 130 |
- --addpkg=$MIN_PKGS \ |
|
| 131 |
- |
|
| 132 |
- sudo cp -p files/sources.list $CHROOTDIR/etc/apt/sources.list |
|
| 133 |
- sudo chroot $CHROOTDIR apt-get update |
|
| 134 |
- |
|
| 135 |
- exit 0 |
|
| 136 |
-fi |
|
| 137 |
- |
|
| 138 |
-# Build the image |
|
| 139 |
-TMPDIR=tmp |
|
| 140 |
-TMPDISK=`mktemp imgXXXXXXXX` |
|
| 141 |
-SIZE=$[$ROOTSIZE+$SWAPSIZE+1] |
|
| 142 |
-dd if=/dev/null of=$TMPDISK bs=1M seek=$SIZE count=1 |
|
| 143 |
- |
|
| 144 |
-if [ -n "$IMAGEONLY" ]; then |
|
| 145 |
- # Build image from chroot |
|
| 146 |
- sudo vmbuilder $HYPER ubuntu $ARGS \ |
|
| 147 |
- --existing-chroot=$CHROOTDIR \ |
|
| 148 |
- --overwrite \ |
|
| 149 |
- --rootsize=$ROOTSIZE \ |
|
| 150 |
- --swapsize=$SWAPSIZE \ |
|
| 151 |
- --tmpfs - \ |
|
| 152 |
- --raw=$TMPDISK \ |
|
| 153 |
- |
|
| 154 |
-else |
|
| 155 |
- # Do the whole shebang in one pass |
|
| 156 |
- ARGS="--variant=minbase" |
|
| 157 |
- for i in $MIN_PKGS; do |
|
| 158 |
- ARGS="$ARGS --addpkg=$i" |
|
| 159 |
- done |
|
| 160 |
- sudo vmbuilder $HYPER ubuntu $ARGS \ |
|
| 161 |
- --suite $RELEASE \ |
|
| 162 |
- --overwrite \ |
|
| 163 |
- --rootsize=$ROOTSIZE \ |
|
| 164 |
- --swapsize=$SWAPSIZE \ |
|
| 165 |
- --tmpfs - \ |
|
| 166 |
- --raw=$TMPDISK \ |
|
| 167 |
- |
|
| 168 |
-fi |
|
| 169 |
- |
|
| 170 |
-if [ "$FORMAT" = "raw" ]; then |
|
| 171 |
- # Get image |
|
| 172 |
- mv $TMPDISK $RELEASE.$FORMAT |
|
| 173 |
-else |
|
| 174 |
- # Convert image |
|
| 175 |
- qemu-img convert -O $QFORMAT $TMPDISK $RELEASE.$FORMAT |
|
| 176 |
- rm $TMPDISK |
|
| 177 |
-fi |
|
| 178 |
-rm -rf ubuntu-$HYPER |
| ... | ... |
@@ -20,9 +20,6 @@ |
| 20 | 20 |
# Sanity Check |
| 21 | 21 |
# ============ |
| 22 | 22 |
|
| 23 |
-# Record the start time. This allows us to print how long this script takes to run. |
|
| 24 |
-START_TIME=`python -c "import time; print time.time()"` |
|
| 25 |
- |
|
| 26 | 23 |
# Warn users who aren't on natty, but allow them to override check and attempt |
| 27 | 24 |
# installation with ``FORCE=yes ./stack`` |
| 28 | 25 |
if ! grep -q natty /etc/lsb-release; then |
| ... | ... |
@@ -53,40 +50,38 @@ TOP_DIR=$(cd $(dirname "$0") && pwd) |
| 53 | 53 |
|
| 54 | 54 |
if [[ $EUID -eq 0 ]]; then |
| 55 | 55 |
echo "You are running this script as root." |
| 56 |
+ echo "In 10 seconds, we will create a user 'stack' and run as that user" |
|
| 57 |
+ sleep 10 |
|
| 56 | 58 |
|
| 57 | 59 |
# since this script runs as a normal user, we need to give that user |
| 58 | 60 |
# ability to run sudo |
| 59 | 61 |
apt-get update |
| 60 |
- apt-get install -qqy sudo |
|
| 62 |
+ apt-get install -y sudo |
|
| 61 | 63 |
|
| 62 |
- if ! getent passwd | grep -q stack; then |
|
| 64 |
+ if ! getent passwd stack >/dev/null; then |
|
| 63 | 65 |
echo "Creating a user called stack" |
| 64 | 66 |
useradd -U -G sudo -s /bin/bash -m stack |
| 65 | 67 |
fi |
| 68 |
+ |
|
| 66 | 69 |
echo "Giving stack user passwordless sudo priviledges" |
| 67 |
- echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers |
|
| 70 |
+ # natty uec images sudoers does not have a '#includedir'. add one. |
|
| 71 |
+ grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers || |
|
| 72 |
+ echo "#includedir /etc/sudoers.d" >> /etc/sudoers |
|
| 73 |
+ ( umask 226 && echo "stack ALL=(ALL) NOPASSWD:ALL" \ |
|
| 74 |
+ > /etc/sudoers.d/50_stack_sh ) |
|
| 68 | 75 |
|
| 69 | 76 |
echo "Copying files to stack user" |
| 70 |
- cp -r -f `pwd` /home/stack/ |
|
| 71 |
- THIS_DIR=$(basename $(dirname $(readlink -f $0))) |
|
| 72 |
- chown -R stack /home/stack/$THIS_DIR |
|
| 73 |
- echo "Running the script as stack in 3 seconds..." |
|
| 74 |
- sleep 3 |
|
| 77 |
+ STACK_DIR="/home/stack/${PWD##*/}"
|
|
| 78 |
+ cp -r -f "$PWD" "$STACK_DIR" |
|
| 79 |
+ chown -R stack "$STACK_DIR" |
|
| 75 | 80 |
if [[ "$SHELL_AFTER_RUN" != "no" ]]; then |
| 76 |
- exec su -c "cd /home/stack/$THIS_DIR/; bash stack.sh; bash" stack |
|
| 81 |
+ exec su -c "set -e; cd $STACK_DIR; bash stack.sh; bash" stack |
|
| 77 | 82 |
else |
| 78 |
- exec su -c "cd /home/stack/$THIS_DIR/; bash stack.sh" stack |
|
| 83 |
+ exec su -c "set -e; cd $STACK_DIR; bash stack.sh" stack |
|
| 79 | 84 |
fi |
| 80 |
- exit 0 |
|
| 85 |
+ exit 1 |
|
| 81 | 86 |
fi |
| 82 | 87 |
|
| 83 |
-# So that errors don't compound we exit on any errors so you see only the |
|
| 84 |
-# first error that occured. |
|
| 85 |
-set -o errexit |
|
| 86 |
- |
|
| 87 |
-# Print the commands being run so that we can see the command that triggers |
|
| 88 |
-# an error. It is also useful for following allowing as the install occurs. |
|
| 89 |
-set -o xtrace |
|
| 90 | 88 |
|
| 91 | 89 |
# Settings |
| 92 | 90 |
# ======== |
| ... | ... |
@@ -120,8 +115,6 @@ source ./stackrc |
| 120 | 120 |
|
| 121 | 121 |
# Destination path for installation ``DEST`` |
| 122 | 122 |
DEST=${DEST:-/opt/stack}
|
| 123 |
-sudo mkdir -p $DEST |
|
| 124 |
-sudo chown `whoami` $DEST |
|
| 125 | 123 |
|
| 126 | 124 |
# Set the destination directories for openstack projects |
| 127 | 125 |
NOVA_DIR=$DEST/nova |
| ... | ... |
@@ -261,6 +254,24 @@ read_password SERVICE_TOKEN "ENTER A SERVICE_TOKEN TO USE FOR THE SERVICE ADMIN |
| 261 | 261 |
# Dash currently truncates usernames and passwords at 20 characters |
| 262 | 262 |
read_password ADMIN_PASSWORD "ENTER A PASSWORD TO USE FOR DASH AND KEYSTONE (20 CHARS OR LESS)." |
| 263 | 263 |
|
| 264 |
+LOGFILE=${LOGFILE:-"$PWD/stack.sh.$$.log"}
|
|
| 265 |
+( |
|
| 266 |
+# So that errors don't compound we exit on any errors so you see only the |
|
| 267 |
+# first error that occured. |
|
| 268 |
+trap failed ERR |
|
| 269 |
+failed() {
|
|
| 270 |
+ local r=$? |
|
| 271 |
+ set +o xtrace |
|
| 272 |
+ [ -n "$LOGFILE" ] && echo "${0##*/} failed: full log in $LOGFILE"
|
|
| 273 |
+ exit $r |
|
| 274 |
+} |
|
| 275 |
+ |
|
| 276 |
+# Print the commands being run so that we can see the command that triggers |
|
| 277 |
+# an error. It is also useful for following along as the install occurs. |
|
| 278 |
+set -o xtrace |
|
| 279 |
+ |
|
| 280 |
+sudo mkdir -p $DEST |
|
| 281 |
+sudo chown `whoami` $DEST |
|
| 264 | 282 |
|
| 265 | 283 |
# Install Packages |
| 266 | 284 |
# ================ |
| ... | ... |
@@ -269,6 +280,7 @@ read_password ADMIN_PASSWORD "ENTER A PASSWORD TO USE FOR DASH AND KEYSTONE (20 |
| 269 | 269 |
|
| 270 | 270 |
|
| 271 | 271 |
# install apt requirements |
| 272 |
+sudo apt-get update |
|
| 272 | 273 |
sudo apt-get install -qqy `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server"` |
| 273 | 274 |
|
| 274 | 275 |
# install python requirements |
| ... | ... |
@@ -347,6 +359,19 @@ mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASSWORD |
| 347 | 347 |
mysql-server-5.1 mysql-server/start_on_boot boolean true |
| 348 | 348 |
MYSQL_PRESEED |
| 349 | 349 |
|
| 350 |
+ # while ``.my.cnf`` is not needed for openstack to function, it is useful |
|
| 351 |
+ # as it allows you to access the mysql databases via ``mysql nova`` instead |
|
| 352 |
+ # of having to specify the username/password each time. |
|
| 353 |
+ if [[ ! -e $HOME/.my.cnf ]]; then |
|
| 354 |
+ cat <<EOF >$HOME/.my.cnf |
|
| 355 |
+[client] |
|
| 356 |
+user=$MYSQL_USER |
|
| 357 |
+password=$MYSQL_PASS |
|
| 358 |
+host=$MYSQL_HOST |
|
| 359 |
+EOF |
|
| 360 |
+ chmod 0600 $HOME/.my.cnf |
|
| 361 |
+ fi |
|
| 362 |
+ |
|
| 350 | 363 |
# Install and start mysql-server |
| 351 | 364 |
sudo apt-get -y -q install mysql-server |
| 352 | 365 |
# Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases: |
| ... | ... |
@@ -625,9 +650,8 @@ fi |
| 625 | 625 |
# have to do a little more than that in our script. Since we add the group |
| 626 | 626 |
# ``libvirtd`` to our user in this script, when nova-compute is run it is |
| 627 | 627 |
# within the context of our original shell (so our groups won't be updated). |
| 628 |
-# We can send the command nova-compute to the ``newgrp`` command to execute |
|
| 629 |
-# in a specific context. |
|
| 630 |
-screen_it n-cpu "cd $NOVA_DIR && echo $NOVA_DIR/bin/nova-compute | newgrp libvirtd" |
|
| 628 |
+# Use 'sg' to execute nova-compute as a member of the libvirtd group. |
|
| 629 |
+screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_DIR/bin/nova-compute" |
|
| 631 | 630 |
screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network" |
| 632 | 631 |
screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler" |
| 633 | 632 |
screen_it n-vnc "cd $NOVNC_DIR && ./utils/nova-wsproxy.py 6080 --web . --flagfile=../nova/bin/nova.conf" |
| ... | ... |
@@ -687,6 +711,16 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then |
| 687 | 687 |
|
| 688 | 688 |
fi |
| 689 | 689 |
|
| 690 |
+# Fin |
|
| 691 |
+# === |
|
| 692 |
+ |
|
| 693 |
+ |
|
| 694 |
+) 2>&1 | tee "${LOGFILE}"
|
|
| 695 |
+ |
|
| 696 |
+# Check that the left side of the above pipe succeeded |
|
| 697 |
+for ret in "${PIPESTATUS[@]}"; do [ $ret -eq 0 ] || exit $ret; done
|
|
| 698 |
+ |
|
| 699 |
+( |
|
| 690 | 700 |
# Using the cloud |
| 691 | 701 |
# =============== |
| 692 | 702 |
|
| ... | ... |
@@ -704,10 +738,7 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then |
| 704 | 704 |
echo "the password: $ADMIN_PASSWORD" |
| 705 | 705 |
fi |
| 706 | 706 |
|
| 707 |
-# Fin |
|
| 708 |
-# === |
|
| 707 |
+# indicate how long this took to run (bash maintained variable 'SECONDS') |
|
| 708 |
+echo "stack.sh completed in $SECONDS seconds." |
|
| 709 | 709 |
|
| 710 |
-# End our timer and give a timing summary |
|
| 711 |
-END_TIME=`python -c "import time; print time.time()"` |
|
| 712 |
-ELAPSED=`python -c "print $END_TIME - $START_TIME"` |
|
| 713 |
-echo "stack.sh completed in $ELAPSED seconds." |
|
| 710 |
+) | tee -a "$LOGFILE" |
| 714 | 711 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,117 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+PROGDIR=`dirname $0` |
|
| 3 |
+CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack}
|
|
| 4 |
+ |
|
| 5 |
+# Source params |
|
| 6 |
+source ./stackrc |
|
| 7 |
+ |
|
| 8 |
+# Store cwd |
|
| 9 |
+CWD=`pwd` |
|
| 10 |
+ |
|
| 11 |
+NAME=$1 |
|
| 12 |
+NFSDIR="/nfs/$NAME" |
|
| 13 |
+DEST=${DEST:-/opt/stack}
|
|
| 14 |
+ |
|
| 15 |
+# Option to use the version of devstack on which we are currently working |
|
| 16 |
+USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
|
|
| 17 |
+ |
|
| 18 |
+# remove old nfs filesystem if one exists |
|
| 19 |
+rm -rf $DEST |
|
| 20 |
+ |
|
| 21 |
+# clean install of natty |
|
| 22 |
+if [ ! -d $CHROOTCACHE/natty-base ]; then |
|
| 23 |
+ $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base |
|
| 24 |
+ # copy kernel modules... |
|
| 25 |
+ # NOTE(ja): is there a better way to do this? |
|
| 26 |
+ cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules |
|
| 27 |
+ # a simple password - pass |
|
| 28 |
+ echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd |
|
| 29 |
+fi |
|
| 30 |
+ |
|
| 31 |
+# prime natty with as many apt/pips as we can |
|
| 32 |
+if [ ! -d $CHROOTCACHE/natty-dev ]; then |
|
| 33 |
+ rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/ |
|
| 34 |
+ chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` |
|
| 35 |
+ chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*` |
|
| 36 |
+ |
|
| 37 |
+ # Create a stack user that is a member of the libvirtd group so that stack |
|
| 38 |
+ # is able to interact with libvirt. |
|
| 39 |
+ chroot $CHROOTCACHE/natty-dev groupadd libvirtd |
|
| 40 |
+ chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd |
|
| 41 |
+ mkdir -p $CHROOTCACHE/natty-dev/$DEST |
|
| 42 |
+ chown stack $CHROOTCACHE/natty-dev/$DEST |
|
| 43 |
+ |
|
| 44 |
+ # a simple password - pass |
|
| 45 |
+ echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd |
|
| 46 |
+ |
|
| 47 |
+ # and has sudo ability (in the future this should be limited to only what |
|
| 48 |
+ # stack requires) |
|
| 49 |
+ echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers |
|
| 50 |
+fi |
|
| 51 |
+ |
|
| 52 |
+# clone git repositories onto the system |
|
| 53 |
+# ====================================== |
|
| 54 |
+ |
|
| 55 |
+if [ ! -d $CHROOTCACHE/natty-stack ]; then |
|
| 56 |
+ rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/ |
|
| 57 |
+fi |
|
| 58 |
+ |
|
| 59 |
+# git clone only if directory doesn't exist already. Since ``DEST`` might not |
|
| 60 |
+# be owned by the installation user, we create the directory and change the |
|
| 61 |
+# ownership to the proper user. |
|
| 62 |
+function git_clone {
|
|
| 63 |
+ |
|
| 64 |
+ # clone new copy or fetch latest changes |
|
| 65 |
+ CHECKOUT=$CHROOTCACHE/natty-stack$2 |
|
| 66 |
+ if [ ! -d $CHECKOUT ]; then |
|
| 67 |
+ mkdir -p $CHECKOUT |
|
| 68 |
+ git clone $1 $CHECKOUT |
|
| 69 |
+ else |
|
| 70 |
+ pushd $CHECKOUT |
|
| 71 |
+ git fetch |
|
| 72 |
+ popd |
|
| 73 |
+ fi |
|
| 74 |
+ |
|
| 75 |
+ # FIXME(ja): checkout specified version (should works for branches and tags) |
|
| 76 |
+ |
|
| 77 |
+ pushd $CHECKOUT |
|
| 78 |
+ # checkout the proper branch/tag |
|
| 79 |
+ git checkout $3 |
|
| 80 |
+ # force our local version to be the same as the remote version |
|
| 81 |
+ git reset --hard origin/$3 |
|
| 82 |
+ popd |
|
| 83 |
+ |
|
| 84 |
+ # give ownership to the stack user |
|
| 85 |
+ chroot $CHROOTCACHE/natty-stack/ chown -R stack $2 |
|
| 86 |
+} |
|
| 87 |
+ |
|
| 88 |
+git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH |
|
| 89 |
+git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH |
|
| 90 |
+git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH |
|
| 91 |
+git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH |
|
| 92 |
+git_clone $DASH_REPO $DEST/dash $DASH_BRANCH $DASH_TAG |
|
| 93 |
+git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH |
|
| 94 |
+git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH |
|
| 95 |
+ |
|
| 96 |
+chroot $CHROOTCACHE/natty-stack mkdir -p $DEST/files |
|
| 97 |
+wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack$DEST/files/tty.tgz |
|
| 98 |
+ |
|
| 99 |
+# Use this version of devstack? |
|
| 100 |
+if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then |
|
| 101 |
+ rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack |
|
| 102 |
+ cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack |
|
| 103 |
+fi |
|
| 104 |
+ |
|
| 105 |
+cp -pr $CHROOTCACHE/natty-stack $NFSDIR |
|
| 106 |
+ |
|
| 107 |
+# set hostname |
|
| 108 |
+echo $NAME > $NFSDIR/etc/hostname |
|
| 109 |
+echo "127.0.0.1 localhost $NAME" > $NFSDIR/etc/hosts |
|
| 110 |
+ |
|
| 111 |
+# injecting root's public ssh key if it exists |
|
| 112 |
+if [ -f /root/.ssh/id_rsa.pub ]; then |
|
| 113 |
+ mkdir $NFSDIR/root/.ssh |
|
| 114 |
+ chmod 700 $NFSDIR/root/.ssh |
|
| 115 |
+ cp /root/.ssh/id_rsa.pub $NFSDIR/root/.ssh/authorized_keys |
|
| 116 |
+fi |
| 0 | 117 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,82 @@ |
| 0 |
+#!/bin/bash -e |
|
| 1 |
+# build_pxe_boot.sh - Create a PXE boot environment |
|
| 2 |
+# |
|
| 3 |
+# build_pxe_boot.sh [-k kernel-version] destdir |
|
| 4 |
+# |
|
| 5 |
+# Assumes syslinux is installed |
|
| 6 |
+# Only needs to run as root if the destdir permissions require it |
|
| 7 |
+ |
|
| 8 |
+KVER=`uname -r` |
|
| 9 |
+if [ "$1" = "-k" ]; then |
|
| 10 |
+ KVER=$2 |
|
| 11 |
+ shift;shift |
|
| 12 |
+fi |
|
| 13 |
+ |
|
| 14 |
+DEST_DIR=${1:-/tmp}/tftpboot
|
|
| 15 |
+PXEDIR=${PXEDIR:-/var/cache/devstack/pxe}
|
|
| 16 |
+OPWD=`pwd` |
|
| 17 |
+PROGDIR=`dirname $0` |
|
| 18 |
+ |
|
| 19 |
+mkdir -p $DEST_DIR/pxelinux.cfg |
|
| 20 |
+cd $DEST_DIR |
|
| 21 |
+for i in memdisk menu.c32 pxelinux.0; do |
|
| 22 |
+ cp -p /usr/lib/syslinux/$i $DEST_DIR |
|
| 23 |
+done |
|
| 24 |
+ |
|
| 25 |
+CFG=$DEST_DIR/pxelinux.cfg/default |
|
| 26 |
+cat >$CFG <<EOF |
|
| 27 |
+default menu.c32 |
|
| 28 |
+prompt 0 |
|
| 29 |
+timeout 0 |
|
| 30 |
+ |
|
| 31 |
+MENU TITLE PXE Boot Menu |
|
| 32 |
+ |
|
| 33 |
+EOF |
|
| 34 |
+ |
|
| 35 |
+# Setup devstack boot |
|
| 36 |
+mkdir -p $DEST_DIR/ubuntu |
|
| 37 |
+if [ ! -d $PXEDIR ]; then |
|
| 38 |
+ mkdir -p $PXEDIR |
|
| 39 |
+fi |
|
| 40 |
+if [ ! -r $PXEDIR/vmlinuz-${KVER} ]; then
|
|
| 41 |
+ sudo chmod 644 /boot/vmlinuz-${KVER}
|
|
| 42 |
+ if [ ! -r /boot/vmlinuz-${KVER} ]; then
|
|
| 43 |
+ echo "No kernel found" |
|
| 44 |
+ else |
|
| 45 |
+ cp -p /boot/vmlinuz-${KVER} $PXEDIR
|
|
| 46 |
+ fi |
|
| 47 |
+fi |
|
| 48 |
+cp -p $PXEDIR/vmlinuz-${KVER} $DEST_DIR/ubuntu
|
|
| 49 |
+if [ ! -r $PXEDIR/stack-initrd.gz ]; then |
|
| 50 |
+ cd $OPWD |
|
| 51 |
+ sudo $PROGDIR/build_ramdisk.sh $PXEDIR/stack-initrd.gz |
|
| 52 |
+fi |
|
| 53 |
+cp -p $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu |
|
| 54 |
+cat >>$CFG <<EOF |
|
| 55 |
+ |
|
| 56 |
+LABEL devstack |
|
| 57 |
+ MENU LABEL ^devstack |
|
| 58 |
+ MENU DEFAULT |
|
| 59 |
+ KERNEL ubuntu/vmlinuz-$KVER |
|
| 60 |
+ APPEND initrd=ubuntu/stack-initrd.gz ramdisk_size=2109600 root=/dev/ram0 |
|
| 61 |
+EOF |
|
| 62 |
+ |
|
| 63 |
+# Get Ubuntu |
|
| 64 |
+if [ -d $PXEDIR -a -r $PXEDIR/natty-base-initrd.gz ]; then |
|
| 65 |
+ cp -p $PXEDIR/natty-base-initrd.gz $DEST_DIR/ubuntu |
|
| 66 |
+ cat >>$CFG <<EOF |
|
| 67 |
+ |
|
| 68 |
+LABEL ubuntu |
|
| 69 |
+ MENU LABEL ^Ubuntu Natty |
|
| 70 |
+ KERNEL ubuntu/vmlinuz-$KVER |
|
| 71 |
+ APPEND initrd=ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0 |
|
| 72 |
+EOF |
|
| 73 |
+fi |
|
| 74 |
+ |
|
| 75 |
+# Local disk boot |
|
| 76 |
+cat >>$CFG <<EOF |
|
| 77 |
+ |
|
| 78 |
+LABEL local |
|
| 79 |
+ MENU LABEL ^Local disk |
|
| 80 |
+ LOCALBOOT 0 |
|
| 81 |
+EOF |
| 0 | 82 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,136 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+# build_ramdisk.sh - Build RAM disk images |
|
| 2 |
+ |
|
| 3 |
+if [ ! "$#" -eq "1" ]; then |
|
| 4 |
+ echo "$0 builds a gziped natty openstack install" |
|
| 5 |
+ echo "usage: $0 dest" |
|
| 6 |
+ exit 1 |
|
| 7 |
+fi |
|
| 8 |
+ |
|
| 9 |
+PROGDIR=`dirname $0` |
|
| 10 |
+CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack}
|
|
| 11 |
+ |
|
| 12 |
+# Source params |
|
| 13 |
+source ./stackrc |
|
| 14 |
+ |
|
| 15 |
+# Store cwd |
|
| 16 |
+CWD=`pwd` |
|
| 17 |
+ |
|
| 18 |
+DEST=${DEST:-/opt/stack}
|
|
| 19 |
+ |
|
| 20 |
+# Option to use the version of devstack on which we are currently working |
|
| 21 |
+USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
|
|
| 22 |
+ |
|
| 23 |
+# clean install of natty |
|
| 24 |
+if [ ! -d $CHROOTCACHE/natty-base ]; then |
|
| 25 |
+ $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base |
|
| 26 |
+ # copy kernel modules... |
|
| 27 |
+ # NOTE(ja): is there a better way to do this? |
|
| 28 |
+ cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules |
|
| 29 |
+ # a simple password - pass |
|
| 30 |
+ echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd |
|
| 31 |
+fi |
|
| 32 |
+ |
|
| 33 |
+# prime natty with as many apt/pips as we can |
|
| 34 |
+if [ ! -d $CHROOTCACHE/natty-dev ]; then |
|
| 35 |
+ rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/ |
|
| 36 |
+ chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` |
|
| 37 |
+ chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*` |
|
| 38 |
+ |
|
| 39 |
+ # Create a stack user that is a member of the libvirtd group so that stack |
|
| 40 |
+ # is able to interact with libvirt. |
|
| 41 |
+ chroot $CHROOTCACHE/natty-dev groupadd libvirtd |
|
| 42 |
+ chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd |
|
| 43 |
+ mkdir -p $CHROOTCACHE/natty-dev/$DEST |
|
| 44 |
+ chown stack $CHROOTCACHE/natty-dev/$DEST |
|
| 45 |
+ |
|
| 46 |
+ # a simple password - pass |
|
| 47 |
+ echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd |
|
| 48 |
+ |
|
| 49 |
+ # and has sudo ability (in the future this should be limited to only what |
|
| 50 |
+ # stack requires) |
|
| 51 |
+ echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers |
|
| 52 |
+fi |
|
| 53 |
+ |
|
| 54 |
+# clone git repositories onto the system |
|
| 55 |
+# ====================================== |
|
| 56 |
+ |
|
| 57 |
+if [ ! -d $CHROOTCACHE/natty-stack ]; then |
|
| 58 |
+ rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/ |
|
| 59 |
+fi |
|
| 60 |
+ |
|
| 61 |
+# git clone only if directory doesn't exist already. Since ``DEST`` might not |
|
| 62 |
+# be owned by the installation user, we create the directory and change the |
|
| 63 |
+# ownership to the proper user. |
|
| 64 |
+function git_clone {
|
|
| 65 |
+ |
|
| 66 |
+ # clone new copy or fetch latest changes |
|
| 67 |
+ CHECKOUT=$CHROOTCACHE/natty-stack$2 |
|
| 68 |
+ if [ ! -d $CHECKOUT ]; then |
|
| 69 |
+ mkdir -p $CHECKOUT |
|
| 70 |
+ git clone $1 $CHECKOUT |
|
| 71 |
+ else |
|
| 72 |
+ pushd $CHECKOUT |
|
| 73 |
+ git fetch |
|
| 74 |
+ popd |
|
| 75 |
+ fi |
|
| 76 |
+ |
|
| 77 |
+ # FIXME(ja): checkout specified version (should works for branches and tags) |
|
| 78 |
+ |
|
| 79 |
+ pushd $CHECKOUT |
|
| 80 |
+ # checkout the proper branch/tag |
|
| 81 |
+ git checkout $3 |
|
| 82 |
+ # force our local version to be the same as the remote version |
|
| 83 |
+ git reset --hard origin/$3 |
|
| 84 |
+ popd |
|
| 85 |
+ |
|
| 86 |
+ # give ownership to the stack user |
|
| 87 |
+ chroot $CHROOTCACHE/natty-stack/ chown -R stack $2 |
|
| 88 |
+} |
|
| 89 |
+ |
|
| 90 |
+git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH |
|
| 91 |
+git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH |
|
| 92 |
+git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH |
|
| 93 |
+git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH |
|
| 94 |
+git_clone $DASH_REPO $DEST/dash $DASH_BRANCH |
|
| 95 |
+git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH |
|
| 96 |
+git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH |
|
| 97 |
+ |
|
| 98 |
+# Use this version of devstack? |
|
| 99 |
+if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then |
|
| 100 |
+ rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack |
|
| 101 |
+ cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack |
|
| 102 |
+fi |
|
| 103 |
+ |
|
| 104 |
+# Configure host network for DHCP |
|
| 105 |
+mkdir -p $CHROOTCACHE/natty-stack/etc/network |
|
| 106 |
+cat > $CHROOTCACHE/natty-stack/etc/network/interfaces <<EOF |
|
| 107 |
+auto lo |
|
| 108 |
+iface lo inet loopback |
|
| 109 |
+ |
|
| 110 |
+auto eth0 |
|
| 111 |
+iface eth0 inet dhcp |
|
| 112 |
+EOF |
|
| 113 |
+ |
|
| 114 |
+# build a new image |
|
| 115 |
+BASE=$CHROOTCACHE/build.$$ |
|
| 116 |
+IMG=$BASE.img |
|
| 117 |
+MNT=$BASE/ |
|
| 118 |
+ |
|
| 119 |
+# (quickly) create a 2GB blank filesystem |
|
| 120 |
+dd bs=1 count=1 seek=$((2*1024*1024*1024)) if=/dev/zero of=$IMG |
|
| 121 |
+# force it to be initialized as ext2 |
|
| 122 |
+mkfs.ext2 -F $IMG |
|
| 123 |
+ |
|
| 124 |
+# mount blank image loopback and load it |
|
| 125 |
+mkdir -p $MNT |
|
| 126 |
+mount -o loop $IMG $MNT |
|
| 127 |
+rsync -azH $CHROOTCACHE/natty-stack/ $MNT |
|
| 128 |
+ |
|
| 129 |
+# umount and cleanup |
|
| 130 |
+umount $MNT |
|
| 131 |
+rmdir $MNT |
|
| 132 |
+ |
|
| 133 |
+# gzip into final location |
|
| 134 |
+gzip -1 $IMG -c > $1 |
|
| 135 |
+ |
| 0 | 136 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,103 @@ |
| 0 |
+#!/bin/bash -e |
|
| 1 |
+# build_usb_boot.sh - Create a syslinux boot environment |
|
| 2 |
+# |
|
| 3 |
+# build_usb_boot.sh [-k kernel-version] destdev |
|
| 4 |
+# |
|
| 5 |
+# Assumes syslinux is installed |
|
| 6 |
+# Needs to run as root |
|
| 7 |
+ |
|
| 8 |
+KVER=`uname -r` |
|
| 9 |
+if [ "$1" = "-k" ]; then |
|
| 10 |
+ KVER=$2 |
|
| 11 |
+ shift;shift |
|
| 12 |
+fi |
|
| 13 |
+ |
|
| 14 |
+DEST_DIR=${1:-/tmp/syslinux-boot}
|
|
| 15 |
+PXEDIR=${PXEDIR:-/var/cache/devstack/pxe}
|
|
| 16 |
+OPWD=`pwd` |
|
| 17 |
+PROGDIR=`dirname $0` |
|
| 18 |
+ |
|
| 19 |
+if [ -b $DEST_DIR ]; then |
|
| 20 |
+ # We have a block device, install syslinux and mount it |
|
| 21 |
+ DEST_DEV=$DEST_DIR |
|
| 22 |
+ DEST_DIR=`mktemp -d mntXXXXXX` |
|
| 23 |
+ |
|
| 24 |
+ # Install syslinux on the device |
|
| 25 |
+ syslinux --install --directory syslinux $DEST_DEV |
|
| 26 |
+ |
|
| 27 |
+ mount $DEST_DEV $DEST_DIR |
|
| 28 |
+else |
|
| 29 |
+ # We have a directory (for sanity checking output) |
|
| 30 |
+ DEST_DEV="" |
|
| 31 |
+ if [ ! -d $DEST_DIR/syslinux ]; then |
|
| 32 |
+ mkdir -p $DEST_DIR/syslinux |
|
| 33 |
+ fi |
|
| 34 |
+fi |
|
| 35 |
+ |
|
| 36 |
+# Get some more stuff from syslinux |
|
| 37 |
+for i in memdisk menu.c32; do |
|
| 38 |
+ cp -p /usr/lib/syslinux/$i $DEST_DIR/syslinux |
|
| 39 |
+done |
|
| 40 |
+ |
|
| 41 |
+CFG=$DEST_DIR/syslinux/syslinux.cfg |
|
| 42 |
+cat >$CFG <<EOF |
|
| 43 |
+default /syslinux/menu.c32 |
|
| 44 |
+prompt 0 |
|
| 45 |
+timeout 0 |
|
| 46 |
+ |
|
| 47 |
+MENU TITLE Boot Menu |
|
| 48 |
+ |
|
| 49 |
+EOF |
|
| 50 |
+ |
|
| 51 |
+# Setup devstack boot |
|
| 52 |
+mkdir -p $DEST_DIR/ubuntu |
|
| 53 |
+if [ ! -d $PXEDIR ]; then |
|
| 54 |
+ mkdir -p $PXEDIR |
|
| 55 |
+fi |
|
| 56 |
+if [ ! -r $PXEDIR/vmlinuz-${KVER} ]; then
|
|
| 57 |
+ sudo chmod 644 /boot/vmlinuz-${KVER}
|
|
| 58 |
+ if [ ! -r /boot/vmlinuz-${KVER} ]; then
|
|
| 59 |
+ echo "No kernel found" |
|
| 60 |
+ else |
|
| 61 |
+ cp -p /boot/vmlinuz-${KVER} $PXEDIR
|
|
| 62 |
+ fi |
|
| 63 |
+fi |
|
| 64 |
+cp -p $PXEDIR/vmlinuz-${KVER} $DEST_DIR/ubuntu
|
|
| 65 |
+if [ ! -r $PXEDIR/stack-initrd.gz ]; then |
|
| 66 |
+ cd $OPWD |
|
| 67 |
+ sudo $PROGDIR/build_ramdisk.sh $PXEDIR/stack-initrd.gz |
|
| 68 |
+fi |
|
| 69 |
+cp -p $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu |
|
| 70 |
+cat >>$CFG <<EOF |
|
| 71 |
+ |
|
| 72 |
+LABEL devstack |
|
| 73 |
+ MENU LABEL ^devstack |
|
| 74 |
+ MENU DEFAULT |
|
| 75 |
+ KERNEL /ubuntu/vmlinuz-$KVER |
|
| 76 |
+ APPEND initrd=/ubuntu/stack-initrd.gz ramdisk_size=2109600 root=/dev/ram0 |
|
| 77 |
+EOF |
|
| 78 |
+ |
|
| 79 |
+# Get Ubuntu |
|
| 80 |
+if [ -d $PXEDIR -a -r $PXEDIR/natty-base-initrd.gz ]; then |
|
| 81 |
+ cp -p $PXEDIR/natty-base-initrd.gz $DEST_DIR/ubuntu |
|
| 82 |
+ cat >>$CFG <<EOF |
|
| 83 |
+ |
|
| 84 |
+LABEL ubuntu |
|
| 85 |
+ MENU LABEL ^Ubuntu Natty |
|
| 86 |
+ KERNEL /ubuntu/vmlinuz-$KVER |
|
| 87 |
+ APPEND initrd=/ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0 |
|
| 88 |
+EOF |
|
| 89 |
+fi |
|
| 90 |
+ |
|
| 91 |
+# Local disk boot |
|
| 92 |
+cat >>$CFG <<EOF |
|
| 93 |
+ |
|
| 94 |
+LABEL local |
|
| 95 |
+ MENU LABEL ^Local disk |
|
| 96 |
+ LOCALBOOT 0 |
|
| 97 |
+EOF |
|
| 98 |
+ |
|
| 99 |
+if [ -n "$DEST_DEV" ]; then |
|
| 100 |
+ umount $DEST_DIR |
|
| 101 |
+ rmdir $DEST_DIR |
|
| 102 |
+fi |
| 0 | 103 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,178 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+# make_image.sh - Create Ubuntu images in various formats |
|
| 2 |
+# |
|
| 3 |
+# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc), raw |
|
| 4 |
+# |
|
| 5 |
+# Requires sudo to root |
|
| 6 |
+ |
|
| 7 |
+ROOTSIZE=${ROOTSIZE:-8192}
|
|
| 8 |
+SWAPSIZE=${SWAPSIZE:-1024}
|
|
| 9 |
+MIN_PKGS=${MIN_PKGS:-"apt-utils gpgv openssh-server"}
|
|
| 10 |
+ |
|
| 11 |
+usage() {
|
|
| 12 |
+ echo "Usage: $0 - Create Ubuntu images" |
|
| 13 |
+ echo "" |
|
| 14 |
+ echo "$0 [-m] [-r rootsize] [-s swapsize] release format" |
|
| 15 |
+ echo "$0 -C [-m] release chrootdir" |
|
| 16 |
+ echo "$0 -I [-r rootsize] [-s swapsize] chrootdir format" |
|
| 17 |
+ echo "" |
|
| 18 |
+ echo "-C - Create the initial chroot dir" |
|
| 19 |
+ echo "-I - Create the final image from a chroot" |
|
| 20 |
+ echo "-m - minimal installation" |
|
| 21 |
+ echo "-r size - root fs size in MB" |
|
| 22 |
+ echo "-s size - swap fs size in MB" |
|
| 23 |
+ echo "release - Ubuntu release: jaunty - oneric" |
|
| 24 |
+ echo "format - image format: qcow2, vmdk, vdi, vhd, xen, raw, fs" |
|
| 25 |
+ exit 1 |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+while getopts CIhmr:s: c; do |
|
| 29 |
+ case $c in |
|
| 30 |
+ C) CHROOTONLY=1 |
|
| 31 |
+ ;; |
|
| 32 |
+ I) IMAGEONLY=1 |
|
| 33 |
+ ;; |
|
| 34 |
+ h) usage |
|
| 35 |
+ ;; |
|
| 36 |
+ m) MINIMAL=1 |
|
| 37 |
+ ;; |
|
| 38 |
+ r) ROOTSIZE=$OPTARG |
|
| 39 |
+ ;; |
|
| 40 |
+ s) SWAPSIZE=$OPTARG |
|
| 41 |
+ ;; |
|
| 42 |
+ esac |
|
| 43 |
+done |
|
| 44 |
+shift `expr $OPTIND - 1` |
|
| 45 |
+ |
|
| 46 |
+if [ ! "$#" -eq "2" -o -n "$CHROOTONLY" -a -n "$IMAGEONLY" ]; then |
|
| 47 |
+ usage |
|
| 48 |
+fi |
|
| 49 |
+ |
|
| 50 |
+# Default args |
|
| 51 |
+RELEASE=$1 |
|
| 52 |
+FORMAT=$2 |
|
| 53 |
+CHROOTDIR="" |
|
| 54 |
+ |
|
| 55 |
+if [ -n "$CHROOTONLY" ]; then |
|
| 56 |
+ RELEASE=$1 |
|
| 57 |
+ CHROOTDIR=$2 |
|
| 58 |
+ FORMAT="pass" |
|
| 59 |
+fi |
|
| 60 |
+ |
|
| 61 |
+if [ -n "$IMAGEONLY" ]; then |
|
| 62 |
+ CHROOTDIR=$1 |
|
| 63 |
+ FORMAT=$2 |
|
| 64 |
+ RELEASE="pass" |
|
| 65 |
+fi |
|
| 66 |
+ |
|
| 67 |
+case $FORMAT in |
|
| 68 |
+ kvm|qcow2) FORMAT=qcow2 |
|
| 69 |
+ QFORMAT=qcow2 |
|
| 70 |
+ HYPER=kvm |
|
| 71 |
+ ;; |
|
| 72 |
+ vmserver|vmdk) |
|
| 73 |
+ FORMAT=vmdk |
|
| 74 |
+ QFORMAT=vmdk |
|
| 75 |
+ HYPER=vmserver |
|
| 76 |
+ ;; |
|
| 77 |
+ vbox|vdi) FORMAT=vdi |
|
| 78 |
+ QFORMAT=vdi |
|
| 79 |
+ HYPER=kvm |
|
| 80 |
+ ;; |
|
| 81 |
+ vhd|vpc) FORMAT=vhd |
|
| 82 |
+ QFORMAT=vpc |
|
| 83 |
+ HYPER=kvm |
|
| 84 |
+ ;; |
|
| 85 |
+ xen) FORMAT=raw |
|
| 86 |
+ QFORMAT=raw |
|
| 87 |
+ HYPER=xen |
|
| 88 |
+ ;; |
|
| 89 |
+ raw) FORMAT=raw |
|
| 90 |
+ QFORMAT=raw |
|
| 91 |
+ HYPER=kvm |
|
| 92 |
+ ;; |
|
| 93 |
+ pass) ;; |
|
| 94 |
+ *) echo "Unknown format: $FORMAT" |
|
| 95 |
+ usage |
|
| 96 |
+esac |
|
| 97 |
+ |
|
| 98 |
+case $RELEASE in |
|
| 99 |
+ natty) ;; |
|
| 100 |
+ maverick) ;; |
|
| 101 |
+ lucid) ;; |
|
| 102 |
+ karmic) ;; |
|
| 103 |
+ jaunty) ;; |
|
| 104 |
+ pass) ;; |
|
| 105 |
+ *) echo "Unknown release: $RELEASE" |
|
| 106 |
+ usage |
|
| 107 |
+ ;; |
|
| 108 |
+esac |
|
| 109 |
+ |
|
| 110 |
+# Install stuff if necessary |
|
| 111 |
+if [ -z `which vmbuilder` ]; then |
|
| 112 |
+ sudo apt-get install ubuntu-vm-builder |
|
| 113 |
+fi |
|
| 114 |
+ |
|
| 115 |
+if [ -n "$CHROOTONLY" ]; then |
|
| 116 |
+ # Build a chroot directory |
|
| 117 |
+ HYPER=kvm |
|
| 118 |
+ if [ "$MINIMAL" = 1 ]; then |
|
| 119 |
+ ARGS="--variant=minbase" |
|
| 120 |
+ for i in $MIN_PKGS; do |
|
| 121 |
+ ARGS="$ARGS --addpkg=$i" |
|
| 122 |
+ done |
|
| 123 |
+ fi |
|
| 124 |
+ sudo vmbuilder $HYPER ubuntu $ARGS \ |
|
| 125 |
+ --suite $RELEASE \ |
|
| 126 |
+ --only-chroot \ |
|
| 127 |
+ --chroot-dir=$CHROOTDIR \ |
|
| 128 |
+ --overwrite \ |
|
| 129 |
+ --addpkg=$MIN_PKGS \ |
|
| 130 |
+ |
|
| 131 |
+ sudo cp -p files/sources.list $CHROOTDIR/etc/apt/sources.list |
|
| 132 |
+ sudo chroot $CHROOTDIR apt-get update |
|
| 133 |
+ |
|
| 134 |
+ exit 0 |
|
| 135 |
+fi |
|
| 136 |
+ |
|
| 137 |
+# Build the image |
|
| 138 |
+TMPDIR=tmp |
|
| 139 |
+TMPDISK=`mktemp imgXXXXXXXX` |
|
| 140 |
+SIZE=$[$ROOTSIZE+$SWAPSIZE+1] |
|
| 141 |
+dd if=/dev/null of=$TMPDISK bs=1M seek=$SIZE count=1 |
|
| 142 |
+ |
|
| 143 |
+if [ -n "$IMAGEONLY" ]; then |
|
| 144 |
+ # Build image from chroot |
|
| 145 |
+ sudo vmbuilder $HYPER ubuntu $ARGS \ |
|
| 146 |
+ --existing-chroot=$CHROOTDIR \ |
|
| 147 |
+ --overwrite \ |
|
| 148 |
+ --rootsize=$ROOTSIZE \ |
|
| 149 |
+ --swapsize=$SWAPSIZE \ |
|
| 150 |
+ --tmpfs - \ |
|
| 151 |
+ --raw=$TMPDISK \ |
|
| 152 |
+ |
|
| 153 |
+else |
|
| 154 |
+ # Do the whole shebang in one pass |
|
| 155 |
+ ARGS="--variant=minbase" |
|
| 156 |
+ for i in $MIN_PKGS; do |
|
| 157 |
+ ARGS="$ARGS --addpkg=$i" |
|
| 158 |
+ done |
|
| 159 |
+ sudo vmbuilder $HYPER ubuntu $ARGS \ |
|
| 160 |
+ --suite $RELEASE \ |
|
| 161 |
+ --overwrite \ |
|
| 162 |
+ --rootsize=$ROOTSIZE \ |
|
| 163 |
+ --swapsize=$SWAPSIZE \ |
|
| 164 |
+ --tmpfs - \ |
|
| 165 |
+ --raw=$TMPDISK \ |
|
| 166 |
+ |
|
| 167 |
+fi |
|
| 168 |
+ |
|
| 169 |
+if [ "$FORMAT" = "raw" ]; then |
|
| 170 |
+ # Get image |
|
| 171 |
+ mv $TMPDISK $RELEASE.$FORMAT |
|
| 172 |
+else |
|
| 173 |
+ # Convert image |
|
| 174 |
+ qemu-img convert -O $QFORMAT $TMPDISK $RELEASE.$FORMAT |
|
| 175 |
+ rm $TMPDISK |
|
| 176 |
+fi |
|
| 177 |
+rm -rf ubuntu-$HYPER |
| 0 | 178 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,90 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+# upload_image.sh - Upload Ubuntu images (create if necessary) in various formats |
|
| 2 |
+# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc) |
|
| 3 |
+# Requires sudo to root |
|
| 4 |
+ |
|
| 5 |
+usage() {
|
|
| 6 |
+ echo "$0 - Upload images to OpenStack" |
|
| 7 |
+ echo "" |
|
| 8 |
+ echo "$0 [-h host] [-p port] release format" |
|
| 9 |
+ exit 1 |
|
| 10 |
+} |
|
| 11 |
+ |
|
| 12 |
+HOST=${HOST:-localhost}
|
|
| 13 |
+PORT=${PORT:-9292}
|
|
| 14 |
+DEST=${DEST:-/opt/stack}
|
|
| 15 |
+ |
|
| 16 |
+while getopts h:p: c; do |
|
| 17 |
+ case $c in |
|
| 18 |
+ h) HOST=$OPTARG |
|
| 19 |
+ ;; |
|
| 20 |
+ p) PORT=$OPTARG |
|
| 21 |
+ ;; |
|
| 22 |
+ esac |
|
| 23 |
+done |
|
| 24 |
+shift `expr $OPTIND - 1` |
|
| 25 |
+ |
|
| 26 |
+RELEASE=$1 |
|
| 27 |
+FORMAT=$2 |
|
| 28 |
+ |
|
| 29 |
+case $FORMAT in |
|
| 30 |
+ kvm|qcow2) FORMAT=qcow2 |
|
| 31 |
+ TARGET=kvm |
|
| 32 |
+ ;; |
|
| 33 |
+ vmserver|vmdk) |
|
| 34 |
+ FORMAT=vmdk |
|
| 35 |
+ TARGET=vmserver |
|
| 36 |
+ ;; |
|
| 37 |
+ vbox|vdi) TARGET=kvm |
|
| 38 |
+ FORMAT=vdi |
|
| 39 |
+ ;; |
|
| 40 |
+ vhd|vpc) TARGET=kvm |
|
| 41 |
+ FORMAT=vhd |
|
| 42 |
+ ;; |
|
| 43 |
+ *) echo "Unknown format: $FORMAT" |
|
| 44 |
+ usage |
|
| 45 |
+esac |
|
| 46 |
+ |
|
| 47 |
+case $RELEASE in |
|
| 48 |
+ natty) ;; |
|
| 49 |
+ maverick) ;; |
|
| 50 |
+ lucid) ;; |
|
| 51 |
+ karmic) ;; |
|
| 52 |
+ jaunty) ;; |
|
| 53 |
+ *) if [ ! -r $RELEASE.$FORMAT ]; then |
|
| 54 |
+ echo "Unknown release: $RELEASE" |
|
| 55 |
+ usage |
|
| 56 |
+ fi |
|
| 57 |
+ ;; |
|
| 58 |
+esac |
|
| 59 |
+ |
|
| 60 |
+GLANCE=`which glance` |
|
| 61 |
+if [ -z "$GLANCE" ]; then |
|
| 62 |
+ if [ -x "$DEST/glance/bin/glance" ]; then |
|
| 63 |
+ # Look for stack.sh's install |
|
| 64 |
+ GLANCE="$DEST/glance/bin/glance" |
|
| 65 |
+ else |
|
| 66 |
+ # Install Glance client in $DEST |
|
| 67 |
+ echo "Glance not found, must install client" |
|
| 68 |
+ OWD=`pwd` |
|
| 69 |
+ cd $DEST |
|
| 70 |
+ sudo apt-get install python-pip python-eventlet python-routes python-greenlet python-argparse python-sqlalchemy python-wsgiref python-pastedeploy python-xattr |
|
| 71 |
+ sudo pip install kombu |
|
| 72 |
+ sudo git clone https://github.com/cloudbuilders/glance.git |
|
| 73 |
+ cd glance |
|
| 74 |
+ sudo python setup.py develop |
|
| 75 |
+ cd $OWD |
|
| 76 |
+ GLANCE=`which glance` |
|
| 77 |
+ fi |
|
| 78 |
+fi |
|
| 79 |
+ |
|
| 80 |
+# Create image if it doesn't exist |
|
| 81 |
+if [ ! -r $RELEASE.$FORMAT ]; then |
|
| 82 |
+ DIR=`dirname $0` |
|
| 83 |
+ echo "$RELEASE.$FORMAT not found, creating..." |
|
| 84 |
+ $DIR/make_image.sh $RELEASE $FORMAT |
|
| 85 |
+fi |
|
| 86 |
+ |
|
| 87 |
+# Upload the image |
|
| 88 |
+echo "Uploading image $RELEASE.$FORMAT to $HOST" |
|
| 89 |
+$GLANCE add name=$RELEASE.$FORMAT is_public=true disk_format=$FORMAT --host $HOST --port $PORT <$RELEASE.$FORMAT |
| 0 | 90 |
deleted file mode 100755 |
| ... | ... |
@@ -1,90 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
-# upload_image.sh - Upload Ubuntu images (create if necessary) in various formats |
|
| 3 |
-# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc) |
|
| 4 |
-# Requires sudo to root |
|
| 5 |
- |
|
| 6 |
-usage() {
|
|
| 7 |
- echo "$0 - Upload images to OpenStack" |
|
| 8 |
- echo "" |
|
| 9 |
- echo "$0 [-h host] [-p port] release format" |
|
| 10 |
- exit 1 |
|
| 11 |
-} |
|
| 12 |
- |
|
| 13 |
-HOST=${HOST:-localhost}
|
|
| 14 |
-PORT=${PORT:-9292}
|
|
| 15 |
-DEST=${DEST:-/opt/stack}
|
|
| 16 |
- |
|
| 17 |
-while getopts h:p: c; do |
|
| 18 |
- case $c in |
|
| 19 |
- h) HOST=$OPTARG |
|
| 20 |
- ;; |
|
| 21 |
- p) PORT=$OPTARG |
|
| 22 |
- ;; |
|
| 23 |
- esac |
|
| 24 |
-done |
|
| 25 |
-shift `expr $OPTIND - 1` |
|
| 26 |
- |
|
| 27 |
-RELEASE=$1 |
|
| 28 |
-FORMAT=$2 |
|
| 29 |
- |
|
| 30 |
-case $FORMAT in |
|
| 31 |
- kvm|qcow2) FORMAT=qcow2 |
|
| 32 |
- TARGET=kvm |
|
| 33 |
- ;; |
|
| 34 |
- vmserver|vmdk) |
|
| 35 |
- FORMAT=vmdk |
|
| 36 |
- TARGET=vmserver |
|
| 37 |
- ;; |
|
| 38 |
- vbox|vdi) TARGET=kvm |
|
| 39 |
- FORMAT=vdi |
|
| 40 |
- ;; |
|
| 41 |
- vhd|vpc) TARGET=kvm |
|
| 42 |
- FORMAT=vhd |
|
| 43 |
- ;; |
|
| 44 |
- *) echo "Unknown format: $FORMAT" |
|
| 45 |
- usage |
|
| 46 |
-esac |
|
| 47 |
- |
|
| 48 |
-case $RELEASE in |
|
| 49 |
- natty) ;; |
|
| 50 |
- maverick) ;; |
|
| 51 |
- lucid) ;; |
|
| 52 |
- karmic) ;; |
|
| 53 |
- jaunty) ;; |
|
| 54 |
- *) if [ ! -r $RELEASE.$FORMAT ]; then |
|
| 55 |
- echo "Unknown release: $RELEASE" |
|
| 56 |
- usage |
|
| 57 |
- fi |
|
| 58 |
- ;; |
|
| 59 |
-esac |
|
| 60 |
- |
|
| 61 |
-GLANCE=`which glance` |
|
| 62 |
-if [ -z "$GLANCE" ]; then |
|
| 63 |
- if [ -x "$DEST/glance/bin/glance" ]; then |
|
| 64 |
- # Look for stack.sh's install |
|
| 65 |
- GLANCE="$DEST/glance/bin/glance" |
|
| 66 |
- else |
|
| 67 |
- # Install Glance client in $DEST |
|
| 68 |
- echo "Glance not found, must install client" |
|
| 69 |
- OWD=`pwd` |
|
| 70 |
- cd $DEST |
|
| 71 |
- sudo apt-get install python-pip python-eventlet python-routes python-greenlet python-argparse python-sqlalchemy python-wsgiref python-pastedeploy python-xattr |
|
| 72 |
- sudo pip install kombu |
|
| 73 |
- sudo git clone https://github.com/cloudbuilders/glance.git |
|
| 74 |
- cd glance |
|
| 75 |
- sudo python setup.py develop |
|
| 76 |
- cd $OWD |
|
| 77 |
- GLANCE=`which glance` |
|
| 78 |
- fi |
|
| 79 |
-fi |
|
| 80 |
- |
|
| 81 |
-# Create image if it doesn't exist |
|
| 82 |
-if [ ! -r $RELEASE.$FORMAT ]; then |
|
| 83 |
- DIR=`dirname $0` |
|
| 84 |
- echo "$RELEASE.$FORMAT not found, creating..." |
|
| 85 |
- $DIR/make_image.sh $RELEASE $FORMAT |
|
| 86 |
-fi |
|
| 87 |
- |
|
| 88 |
-# Upload the image |
|
| 89 |
-echo "Uploading image $RELEASE.$FORMAT to $HOST" |
|
| 90 |
-$GLANCE add name=$RELEASE.$FORMAT is_public=true disk_format=$FORMAT --host $HOST --port $PORT <$RELEASE.$FORMAT |