Skip to content

Commit 7b1aa5b

Browse files
committed
Merge branch 'master' of github.com:cloudbuilders/devstack
2 parents 7d45a0f + 86c996b commit 7b1aa5b

5 files changed

Lines changed: 208 additions & 18 deletions

File tree

exercise.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ IP=`nova show $NAME | grep "private network" | cut -d"|" -f3`
9393

9494
# for single node deployments, we can ping private ips
9595
MULTI_HOST=${MULTI_HOST:-0}
96-
if [ "$MULTI_HOST" = "0"]; then
96+
if [ "$MULTI_HOST" = "0" ]; then
9797
# ping it once (timeout of a second)
9898
ping -c1 -w1 $IP || true
9999

stack.sh

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -302,20 +302,31 @@ sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*`
302302
# be owned by the installation user, we create the directory and change the
303303
# ownership to the proper user.
304304
function git_clone {
305-
# if there is an existing checkout, move it out of the way
306-
if [[ "$RECLONE" == "yes" ]]; then
307-
# FIXME(ja): if we were smarter we could speed up RECLONE by
308-
# using the old git repo as the basis of our new clone...
309-
if [ -d $2 ]; then
310-
mv $2 /tmp/stack.`date +%s`
311-
fi
312-
fi
313305

314-
if [ ! -d $2 ]; then
315-
git clone $1 $2
306+
GIT_REMOTE=$1
307+
GIT_DEST=$2
308+
GIT_BRANCH=$3
309+
310+
# do a full clone only if the directory doesn't exist
311+
if [ ! -d $GIT_DEST ]; then
312+
git clone $GIT_REMOTE $GIT_DEST
316313
cd $2
317314
# This checkout syntax works for both branches and tags
318-
git checkout $3
315+
git checkout $GIT_BRANCH
316+
elif [[ "$RECLONE" == "yes" ]]; then
317+
# if it does exist then simulate what clone does if asked to RECLONE
318+
cd $GIT_DEST
319+
# set the url to pull from and fetch
320+
git remote set-url origin $GIT_REMOTE
321+
git fetch origin
322+
# remove the existing ignored files (like pyc) as they cause breakage
323+
# (due to the py files having older timestamps than our pyc, so python
324+
# thinks the pyc files are correct using them)
325+
sudo git clean -f -d
326+
git checkout -f origin/$GIT_BRANCH
327+
# a local branch might not exist
328+
git branch -D $GIT_BRANCH || true
329+
git checkout -b $GIT_BRANCH
319330
fi
320331
}
321332

@@ -470,11 +481,15 @@ fi
470481
# Nova
471482
# ----
472483

473-
# We are going to use the sample http middleware configuration from the keystone
474-
# project to launch nova. This paste config adds the configuration required
475-
# for nova to validate keystone tokens - except we need to switch the config
476-
# to use our service token instead (instead of the invalid token 999888777666).
477-
sudo sed -e "s,999888777666,$SERVICE_TOKEN,g" -i $KEYSTONE_DIR/examples/paste/nova-api-paste.ini
484+
if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
485+
# We are going to use the sample http middleware configuration from the
486+
# keystone project to launch nova. This paste config adds the configuration
487+
# required for nova to validate keystone tokens - except we need to switch
488+
# the config to use our service token instead (instead of the invalid token
489+
# 999888777666).
490+
cp $KEYSTONE_DIR/examples/paste/nova-api-paste.ini $NOVA_DIR/bin
491+
sed -e "s,999888777666,$SERVICE_TOKEN,g" -i $NOVA_DIR/bin/nova-api-paste.ini
492+
fi
478493

479494
if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
480495

@@ -591,7 +606,7 @@ add_nova_flag "--libvirt_type=$LIBVIRT_TYPE"
591606
add_nova_flag "--osapi_extensions_path=$OPENSTACKX_DIR/extensions"
592607
add_nova_flag "--vncproxy_url=http://$HOST_IP:6080"
593608
add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/"
594-
add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini"
609+
add_nova_flag "--api_paste_config=$NOVA_DIR/bin/nova-api-paste.ini"
595610
add_nova_flag "--image_service=nova.image.glance.GlanceImageService"
596611
add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST"
597612
add_nova_flag "--rabbit_host=$RABBIT_HOST"

tools/build_kvm.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,15 @@ if [ "$COPYENV" = "1" ]; then
285285
cp_it ~/.bashrc $ROOTFS/$DEST/.bashrc
286286
fi
287287

288+
# pre-cache uec images
289+
for image_url in ${IMAGE_URLS//,/ }; do
290+
IMAGE_FNAME=`basename "$image_url"`
291+
if [ ! -f $IMAGES_DIR/$IMAGE_FNAME ]; then
292+
wget -c $image_url -O $IMAGES_DIR/$IMAGE_FNAME
293+
fi
294+
cp $IMAGES_DIR/$IMAGE_FNAME $ROOTFS/$DEST/devstack/files
295+
done
296+
288297
# Configure the runner
289298
RUN_SH=$ROOTFS/$DEST/run.sh
290299
cat > $RUN_SH <<EOF

tools/get_uec_image.sh

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#!/bin/bash
2+
# get_uec_image.sh - Prepare Ubuntu images in various formats
3+
#
4+
# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc), raw
5+
#
6+
# Required to run as root
7+
8+
CACHEDIR=${CACHEDIR:-/var/cache/devstack}
9+
FORMAT=${FORMAT:-qcow2}
10+
ROOTSIZE=${ROOTSIZE:-2000}
11+
MIN_PKGS=${MIN_PKGS:-"apt-utils gpgv openssh-server"}
12+
13+
usage() {
14+
echo "Usage: $0 - Prepare Ubuntu images"
15+
echo ""
16+
echo "$0 [-f format] [-r rootsize] release imagefile"
17+
echo ""
18+
echo "-f format - image format: qcow2 (default), vmdk, vdi, vhd, xen, raw, fs"
19+
echo "-r size - root fs size in MB (min 2000MB)"
20+
echo "release - Ubuntu release: jaunty - oneric"
21+
echo "imagefile - output image file"
22+
exit 1
23+
}
24+
25+
while getopts f:hmr: c; do
26+
case $c in
27+
f) FORMAT=$OPTARG
28+
;;
29+
h) usage
30+
;;
31+
m) MINIMAL=1
32+
;;
33+
r) ROOTSIZE=$OPTARG
34+
if $(( ROOTSIZE < 2000 )); then
35+
echo "root size must be greater than 2000MB"
36+
exit 1
37+
fi
38+
;;
39+
esac
40+
done
41+
shift `expr $OPTIND - 1`
42+
43+
if [ ! "$#" -eq "2" ]; then
44+
usage
45+
fi
46+
47+
# Default args
48+
DIST_NAME=$1
49+
IMG_FILE=$2
50+
51+
case $FORMAT in
52+
kvm|qcow2) FORMAT=qcow2
53+
QFORMAT=qcow2
54+
;;
55+
vmserver|vmdk)
56+
FORMAT=vmdk
57+
QFORMAT=vmdk
58+
;;
59+
vbox|vdi) FORMAT=vdi
60+
QFORMAT=vdi
61+
;;
62+
vhd|vpc) FORMAT=vhd
63+
QFORMAT=vpc
64+
;;
65+
xen) FORMAT=raw
66+
QFORMAT=raw
67+
;;
68+
raw) FORMAT=raw
69+
QFORMAT=raw
70+
;;
71+
*) echo "Unknown format: $FORMAT"
72+
usage
73+
esac
74+
75+
case $DIST_NAME in
76+
oneiric) ;;
77+
natty) ;;
78+
maverick) ;;
79+
lucid) ;;
80+
karmic) ;;
81+
jaunty) ;;
82+
*) echo "Unknown release: $DIST_NAME"
83+
usage
84+
;;
85+
esac
86+
87+
# Set up nbd
88+
modprobe nbd max_part=63
89+
NBD=${NBD:-/dev/nbd9}
90+
NBD_DEV=`basename $NBD`
91+
92+
# Prepare the base image
93+
94+
# Get the UEC image
95+
UEC_NAME=$DIST_NAME-server-cloudimg-amd64
96+
if [ ! -e $CACHEDIR/$UEC_NAME-disk1.img ]; then
97+
(cd $CACHEDIR; wget -N http://uec-images.ubuntu.com/$DIST_NAME/current/$UEC_NAME-disk1.img)
98+
99+
100+
# Connect to nbd and wait till it is ready
101+
qemu-nbd -d $NBD
102+
qemu-nbd -c $NBD $CACHEDIR/$UEC_NAME-disk1.img
103+
if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then
104+
echo "Couldn't connect $NBD"
105+
exit 1
106+
fi
107+
MNTDIR=`mktemp -d mntXXXXXXXX`
108+
mount -t ext4 ${NBD}p1 $MNTDIR
109+
110+
# Install our required packages
111+
cp -p files/sources.list $MNTDIR/etc/apt/sources.list
112+
cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf
113+
chroot $MNTDIR apt-get update
114+
chroot $MNTDIR apt-get install -y $MIN_PKGS
115+
rm -f $MNTDIR/etc/resolv.conf
116+
117+
umount $MNTDIR
118+
rmdir $MNTDIR
119+
qemu-nbd -d $NBD
120+
fi
121+
122+
if [ "$FORMAT" = "qcow2" ]; then
123+
# Just copy image
124+
cp -p $CACHEDIR/$UEC_NAME-disk1.img $IMG_FILE
125+
else
126+
# Convert image
127+
qemu-img convert -O $QFORMAT $CACHEDIR/$UEC_NAME-disk1.img $IMG_FILE
128+
fi
129+
130+
# Resize the image if necessary
131+
if [ $ROOTSIZE -gt 2000 ]; then
132+
# Resize the container
133+
qemu-img resize $IMG_FILE +$((ROOTSIZE - 2000))M
134+
135+
# Connect to nbd and wait till it is ready
136+
qemu-nbd -c $NBD $IMG_FILE
137+
if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then
138+
echo "Couldn't connect $NBD"
139+
exit 1
140+
fi
141+
142+
# Resize partition 1 to full size of the disk image
143+
echo "d
144+
n
145+
p
146+
1
147+
2
148+
149+
t
150+
83
151+
a
152+
1
153+
w
154+
" | fdisk $NBD
155+
fsck -t ext4 -f ${NBD}p1
156+
resize2fs ${NBD}p1
157+
158+
qemu-nbd -d $NBD
159+
fi

tools/make_image.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ if [ -n "$IMAGEONLY" ]; then
6565
RELEASE="pass"
6666
fi
6767

68+
# Make sure that we have the proper version of ubuntu
69+
UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'`
70+
if [ "$UBUNTU_VERSION" = "natty" -a "$RELEASE" = "oneiric" ]; then
71+
echo "natty installs can't build oneiric images"
72+
exit 1
73+
fi
74+
6875
case $FORMAT in
6976
kvm|qcow2) FORMAT=qcow2
7077
QFORMAT=qcow2

0 commit comments

Comments
 (0)