-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from vondrt4/openstack-work
Upgrade OpenStack support from AMI compatibility to qcow2 native
- Loading branch information
Showing
11 changed files
with
459 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/bash -e | ||
# Copyright (c) 2011-2015 TurnKey GNU/Linux - http://www.turnkeylinux.org | ||
# | ||
# This file is part of buildtasks. | ||
# | ||
# Buildtasks is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU Affero General Public License as published by the | ||
# Free Software Foundation; either version 3 of the License, or (at your | ||
# option) any later version. | ||
|
||
|
||
fatal() { echo "FATAL [$(basename $0)]: $@" 1>&2; exit 1; } | ||
info() { echo "INFO [$(basename $0)]: $@"; } | ||
|
||
usage() { | ||
cat<<EOF | ||
Syntax: $0 rootfs | ||
Bundles rootfs into an openstack tarball | ||
Arguments:: | ||
rootfs - root filesystem path | ||
EOF | ||
exit 1 | ||
} | ||
|
||
if [[ "$#" != "1" ]]; then | ||
usage | ||
fi | ||
|
||
rootfs=$1 | ||
name=$(echo $rootfs | sed 's/.rootfs//') | ||
appname=$(echo $name |sed 's/turnkey-\(.*\)-[0-9].*/\1/') | ||
|
||
case "$appname" in | ||
canvas) loopsize_padding=524288 ;; | ||
ejabberd) loopsize_padding=524288 ;; | ||
appengine-python) loopsize_padding=524288 ;; | ||
*) loopsize_padding=262144 ;; | ||
esac | ||
|
||
info "getting size for loopback" | ||
rootsize=$(du -s $rootfs | awk '{print $1}') | ||
loopsize=$[$rootsize + $loopsize_padding] | ||
|
||
info "creating sparse loopback" | ||
dd if=/dev/null of=$rootfs.img bs=1 seek=${loopsize}K | ||
mkfs.ext4 -F -j $rootfs.img | ||
|
||
mkdir $rootfs.img.mount | ||
mount -o loop $rootfs.img $rootfs.img.mount | ||
|
||
info "syncing rootfs to loopback" | ||
rsync -a -t -r -S -I -H $rootfs/ $rootfs.img.mount | ||
|
||
info "umount loopback" | ||
umount -d $rootfs.img.mount | ||
rmdir $rootfs.img.mount | ||
|
||
info "setting up image directory" | ||
mkdir $name | ||
mv $rootfs.img $name/$name.img | ||
cp $rootfs/boot/vmlinuz-* $name/$name-kernel | ||
cp $rootfs/boot/initrd.img-* $name/$name-initrd | ||
|
||
info "creating $name-openstack.tar.gz" | ||
tar --sparse -zcvf $name-openstack.tar.gz $name | ||
|
||
if [ -z "$BT_DEBUG" ]; then | ||
info "removing directory" | ||
rm -rf $name | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/bin/bash -e | ||
# Copyright (c) 2011-2015 TurnKey GNU/Linux - http://www.turnkeylinux.org | ||
# | ||
# This file is part of buildtasks. | ||
# | ||
# Buildtasks is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU Affero General Public License as published by the | ||
# Free Software Foundation; either version 3 of the License, or (at your | ||
# option) any later version. | ||
|
||
|
||
fatal() { echo "FATAL [$(basename $0)]: $@" 1>&2; exit 1; } | ||
warning() { echo "WARNING [$(basename $0)]: $@"; } | ||
info() { echo "INFO [$(basename $0)]: $@"; } | ||
|
||
usage() { | ||
cat<<EOF | ||
Syntax: $(basename $0) [--publish] appname | ||
Converts appliance appname (e.g., core) to openstack image | ||
Options:: | ||
--publish - if set, image will be devpay'ed and made public | ||
Environment:: | ||
BT_DEBUG - turn on debugging | ||
EOF | ||
exit 1 | ||
} | ||
|
||
while [ "$1" != "" ]; do | ||
case $1 in | ||
--help|-h ) usage;; | ||
--publish) publish="yes";; | ||
*) if [ -n "$appname" ]; then usage; else appname=$1; fi ;; | ||
esac | ||
shift | ||
done | ||
|
||
[ -n "$appname" ] || usage | ||
[ -n "$publish" ] || warning "--publish was not specified" | ||
|
||
[ -n "$BT_DEBUG" ] && set -x | ||
|
||
export BT=$(dirname $(readlink -f $0)) | ||
export BT_CONFIG=$BT/config | ||
. $BT_CONFIG/common.cfg | ||
. $BT_CONFIG/build.cfg | ||
|
||
O=$BT_BUILDS/openstack | ||
mkdir -p $O | ||
|
||
[ -n "$BT_VERSION" ] || fatal "BT_VERSION not set" | ||
|
||
isofile=turnkey-$appname-$BT_VERSION.iso | ||
name=turnkey-$appname-$BT_VERSION | ||
rootfs=$name.rootfs | ||
cdroot=$name.cdroot | ||
|
||
$BT/bin/iso-download $BT_ISOS $BT_VERSION $appname | ||
$BT/bin/iso-verify $BT_ISOS $BT_VERSION $appname | ||
|
||
cd $O | ||
tklpatch-extract-iso $BT_ISOS/$isofile | ||
|
||
tklpatch-apply $rootfs $BT/patches/headless | ||
tklpatch-apply $rootfs $BT/patches/cloud | ||
tklpatch-apply $rootfs $BT/patches/openstack-ami | ||
$BT/bin/rootfs-cleanup $rootfs | ||
|
||
$BT/bin/aptconf-tag $rootfs openstack | ||
|
||
$BT/bin/openstack-bundle-ami $rootfs | ||
|
||
$BT/bin/generate-signature $O/$name-openstack.tar.gz | ||
|
||
$BT/bin/generate-buildenv openstack $BT_ISOS/$isofile.sig > $O/$name-openstack.tar.gz.buildenv | ||
|
||
# publish if specified | ||
if [ "$publish" == "yes" ]; then | ||
export PUBLISH_DEST=${BT_PUBLISH_IMGS}/openstack/ | ||
$BT/bin/publish-files $O/$name-openstack.tar.gz | ||
|
||
export PUBLISH_DEST=${BT_PUBLISH_META}/ | ||
$BT/bin/publish-files $O/$name-openstack.{tar.gz.sig,tar.gz.buildenv} | ||
fi | ||
|
||
if [ -z "$BT_DEBUG" ] && ! (mount | grep -q $(basename $rootfs)); then | ||
rm -rf $rootfs | ||
rm -rf $cdroot | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash -ex | ||
|
||
install() { | ||
apt-get update | ||
DEBIAN_FRONTEND=noninteractive apt-get -y \ | ||
-o DPkg::Options::=--force-confdef \ | ||
-o DPkg::Options::=--force-confold \ | ||
install $@ | ||
} | ||
|
||
# install useful packages | ||
install ebsmount sysvinit-core systemd-shim | ||
|
||
# remove systemd (sysvinit used in container) | ||
dpkg --purge systemd-sysv systemd || true | ||
|
||
# support hot-plugging of attached volumes | ||
echo "acpiphp" >> /etc/modules | ||
|
||
# hold kernel (not used in image, pro-longs sec-updates) | ||
ARCH=$(dpkg --print-architecture) | ||
case "$ARCH" in | ||
"i386") | ||
META_KERNEL="linux-image-686"; | ||
;; | ||
"amd64") | ||
META_KERNEL="linux-image-amd64"; | ||
;; | ||
*) | ||
fatal "non-supported architecture: $ARCH"; | ||
;; | ||
esac | ||
KERNEL=$(echo /boot/vmlinuz-* | sed 's|/boot/vmlinuz-|linux-image-|') | ||
echo "$KERNEL hold" | dpkg --set-selections | ||
echo "$META_KERNEL hold" | dpkg --set-selections | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# /etc/fstab: static file system information. | ||
# <file system> <mount point> <type> <options> <dump> <pass> | ||
proc /proc proc nodev,noexec,nosuid 0 0 | ||
/dev/vda / ext4 defaults 0 0 | ||
/dev/vdb /mnt auto defaults 0 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# /etc/fstab: static file system information. | ||
# <file system> <mount point> <type> <options> <dump> <pass> | ||
proc /proc proc nodev,noexec,nosuid 0 0 | ||
/dev/vda / ext4 defaults 0 0 | ||
/dev/vdb /mnt auto defaults 0 0 | ||
/dev/vda1 / ext4 defaults 0 0 | ||
|
Oops, something went wrong.