Merge remote-tracking branch 'origin/master' into jenkins
This commit is contained in:
commit
c986b3f8c7
3 changed files with 131 additions and 4 deletions
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Make sure that we have the proper version of ubuntu (only works on natty/oneiric)
|
||||
if ! egrep -q "oneiric|natty" /etc/lsb-release; then
|
||||
echo "This script only works with ubuntu oneiric and natty"
|
||||
# Make sure that we have the proper version of ubuntu (only works on oneiric)
|
||||
if ! egrep -q "oneiric" /etc/lsb-release; then
|
||||
echo "This script only works with ubuntu oneiric."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -33,7 +33,7 @@ if [ ! -e $TOP_DIR/localrc ]; then
|
|||
fi
|
||||
|
||||
# Install deps if needed
|
||||
DEPS="kvm libvirt-bin kpartx"
|
||||
DEPS="kvm libvirt-bin kpartx cloud-utils"
|
||||
dpkg -l $DEPS || apt-get install -y --force-yes $DEPS
|
||||
|
||||
# Where to store files and instances
|
||||
|
|
74
tools/setup_stack_user.sh
Executable file
74
tools/setup_stack_user.sh
Executable file
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Echo commands
|
||||
set -o xtrace
|
||||
|
||||
# Exit on error to stop unexpected errors
|
||||
set -o errexit
|
||||
|
||||
# Keep track of the current directory
|
||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
||||
|
||||
# Change dir to top of devstack
|
||||
cd $TOP_DIR
|
||||
|
||||
# Echo usage
|
||||
usage() {
|
||||
echo "Add stack user and keys"
|
||||
echo ""
|
||||
echo "Usage: $0 [full path to raw uec base image]"
|
||||
}
|
||||
|
||||
# Make sure this is a raw image
|
||||
if ! qemu-img info $1 | grep -q "file format: raw"; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Mount the image
|
||||
DEST=/opt/stack
|
||||
STAGING_DIR=/tmp/`echo $1 | sed "s/\//_/g"`.stage.user
|
||||
mkdir -p $STAGING_DIR
|
||||
umount $STAGING_DIR || true
|
||||
sleep 1
|
||||
mount -t ext4 -o loop $1 $STAGING_DIR
|
||||
mkdir -p $STAGING_DIR/$DEST
|
||||
|
||||
# Create a stack user that is a member of the libvirtd group so that stack
|
||||
# is able to interact with libvirt.
|
||||
chroot $STAGING_DIR groupadd libvirtd || true
|
||||
chroot $STAGING_DIR useradd stack -s /bin/bash -d $DEST -G libvirtd || true
|
||||
|
||||
# Add a simple password - pass
|
||||
echo stack:pass | chroot $STAGING_DIR chpasswd
|
||||
|
||||
# Configure sudo
|
||||
grep -q "^#includedir.*/etc/sudoers.d" $STAGING_DIR/etc/sudoers ||
|
||||
echo "#includedir /etc/sudoers.d" | sudo tee -a $STAGING_DIR/etc/sudoers
|
||||
cp $TOP_DIR/files/sudo/* $STAGING_DIR/etc/sudoers.d/
|
||||
sed -e "s,%USER%,$USER,g" -i $STAGING_DIR/etc/sudoers.d/*
|
||||
|
||||
# and has sudo ability (in the future this should be limited to only what
|
||||
# stack requires)
|
||||
echo "stack ALL=(ALL) NOPASSWD: ALL" >> $STAGING_DIR/etc/sudoers
|
||||
|
||||
# Gracefully cp only if source file/dir exists
|
||||
function cp_it {
|
||||
if [ -e $1 ] || [ -d $1 ]; then
|
||||
cp -pRL $1 $2
|
||||
fi
|
||||
}
|
||||
|
||||
# Copy over your ssh keys and env if desired
|
||||
cp_it ~/.ssh $STAGING_DIR/$DEST/.ssh
|
||||
cp_it ~/.ssh/id_rsa.pub $STAGING_DIR/$DEST/.ssh/authorized_keys
|
||||
cp_it ~/.gitconfig $STAGING_DIR/$DEST/.gitconfig
|
||||
cp_it ~/.vimrc $STAGING_DIR/$DEST/.vimrc
|
||||
cp_it ~/.bashrc $STAGING_DIR/$DEST/.bashrc
|
||||
|
||||
# Give stack ownership over $DEST so it may do the work needed
|
||||
chroot $STAGING_DIR chown -R stack $DEST
|
||||
|
||||
# Unmount
|
||||
umount $STAGING_DIR
|
53
tools/warm_apts_and_pips.sh
Executable file
53
tools/warm_apts_and_pips.sh
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Echo commands
|
||||
set -o xtrace
|
||||
|
||||
# Exit on error to stop unexpected errors
|
||||
set -o errexit
|
||||
|
||||
# Keep track of the current directory
|
||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
||||
|
||||
# Change dir to top of devstack
|
||||
cd $TOP_DIR
|
||||
|
||||
# Echo usage
|
||||
usage() {
|
||||
echo "Cache OpenStack dependencies on a uec image to speed up performance."
|
||||
echo ""
|
||||
echo "Usage: $0 [full path to raw uec base image]"
|
||||
}
|
||||
|
||||
# Make sure this is a raw image
|
||||
if ! qemu-img info $1 | grep -q "file format: raw"; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure we are in the correct dir
|
||||
if [ ! -d files/apts ]; then
|
||||
echo "Please run this script from devstack/tools/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Mount the image
|
||||
STAGING_DIR=/tmp/`echo $1 | sed "s/\//_/g"`.stage
|
||||
mkdir -p $STAGING_DIR
|
||||
umount $STAGING_DIR || true
|
||||
sleep 1
|
||||
mount -t ext4 -o loop $1 $STAGING_DIR
|
||||
|
||||
# Make sure that base requirements are installed
|
||||
cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
|
||||
|
||||
# Perform caching on the base image to speed up subsequent runs
|
||||
chroot $STAGING_DIR apt-get update
|
||||
chroot $STAGING_DIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1`
|
||||
chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` || true
|
||||
mkdir -p $STAGING_DIR/var/cache/pip
|
||||
PIP_DOWNLOAD_CACHE=/var/cache/pip chroot $STAGING_DIR pip install `cat files/pips/*` || true
|
||||
|
||||
# Unmount
|
||||
umount $STAGING_DIR
|
Loading…
Reference in a new issue