-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade OpenStack support from AMI compatibility to qcow2 native #22
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that inithooks needs ec2metadata?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Several inithooks need the package ec2metadata from your custom repository and include the Python library from it.
The generic package cloud-utils (which gets pulled in as a dependency of cloud-initramfs-growroot, which resizes the root partition, but not yet the file system) also includes ec2metadata, but only the CLI version.
This hack installs both and overwrites the CLI ec2metadata with the TKL package. It is just one file that conflicts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification.
BTW, hopefully Anton will post regarding his inithooks/cloud-init stuff so you can have a look