diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_resizefs.py | 27 | ||||
-rw-r--r-- | cloudinit/distros/debian.py | 7 | ||||
-rw-r--r-- | doc/examples/cloud-config.txt | 18 | ||||
-rw-r--r-- | doc/merging.rst | 2 | ||||
-rwxr-xr-x | packages/bddeb | 1 | ||||
-rwxr-xr-x | packages/brpm | 1 | ||||
-rwxr-xr-x | tools/ccfg-merge-debug | 81 | ||||
-rwxr-xr-x | tools/make-dist-tarball | 14 | ||||
-rwxr-xr-x | tools/make-tarball | 12 | ||||
-rwxr-xr-x | tools/read-dependencies | 8 | ||||
-rwxr-xr-x | tools/read-version | 4 | ||||
-rw-r--r-- | upstart/cloud-init-nonet.conf | 7 |
13 files changed, 156 insertions, 30 deletions
@@ -52,6 +52,10 @@ (LP: #1023179) - use python-requests rather than urllib2. By using recent versions of python-requests, we get https support (LP: #1067888). + - make apt-get invoke 'dist-upgrade' rather than 'upgrade' for + package_upgrade. (LP: #1164147) + - improvements for systemd with Fedora 18 + - workaround 2.6 kernel issue that stopped blkid from showing /dev/sr0 0.7.1: - sysvinit: fix missing dependency in cloud-init job for RHEL 5.6 diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py index 51dead2f..b4ee16b2 100644 --- a/cloudinit/config/cc_resizefs.py +++ b/cloudinit/config/cc_resizefs.py @@ -18,6 +18,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import errno import os import stat import time @@ -75,9 +76,29 @@ def handle(name, cfg, _cloud, log, args): (devpth, fs_type, mount_point) = result # Ensure the path is a block device. - if not stat.S_ISBLK(os.stat(devpth).st_mode): - log.debug("The %s device which was found for mount point %s for %s " - "is not a block device" % (devpth, mount_point, resize_what)) + info = "dev=%s mnt_point=%s path=%s" % (devpth, mount_point, resize_what) + log.debug("resize_info: %s" % info) + + try: + statret = os.stat(devpth) + except OSError as exc: + if util.is_container() and exc.errno == errno.ENOENT: + log.debug("Device '%s' did not exist in container. " + "cannot resize: %s" % (devpth, info)) + elif exc.errno == errno.ENOENT: + log.warn("Device '%s' did not exist. cannot resize: %s" % + (devpth, info)) + else: + raise exc + return + + if not stat.S_ISBLK(statret.st_mode): + if util.is_container(): + log.debug("device '%s' not a block device in container." + " cannot resize: %s" % (devpth, info)) + else: + log.warn("device '%s' not a block device. cannot resize: %s" % + (devpth, info)) return resizer = None diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py index 4b779d57..0811eefd 100644 --- a/cloudinit/distros/debian.py +++ b/cloudinit/distros/debian.py @@ -161,7 +161,12 @@ class Distro(distros.Distro): elif args and isinstance(args, list): cmd.extend(args) - cmd.append(command) + subcmd = command + if command == "upgrade": + subcmd = self.get_option("apt_get_upgrade_subcommand", + "dist-upgrade") + + cmd.append(subcmd) pkglist = util.expand_package_list('%s=%s', pkgs) cmd.extend(pkglist) diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index 09298655..24b4b36c 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -125,6 +125,24 @@ apt_sources: =Y2oI -----END PGP PUBLIC KEY BLOCK----- +## apt config via system_info: +# under the 'system_info', you can further customize cloud-init's interaction +# with apt. +# system_info: +# apt_get_command: [command, argument, argument] +# apt_get_upgrade_subcommand: dist-upgrade +# +# apt_get_command: +# To specify a different 'apt-get' command, set 'apt_get_command'. +# This must be a list, and the subcommand (update, upgrade) is appended to it. +# default is: +# ['apt-get', '--option=Dpkg::Options::=--force-confold', +# '--option=Dpkg::options::=--force-unsafe-io', '--assume-yes', '--quiet'] +# +# apt_get_upgrade_subcommand: +# Specify a different subcommand for 'upgrade. The default is 'dist-upgrade'. +# This is the subcommand that is invoked if package_upgrade is set to true above. + # Install additional packages on first boot # # Default: none diff --git a/doc/merging.rst b/doc/merging.rst index 6344facd..d4d5cd05 100644 --- a/doc/merging.rst +++ b/doc/merging.rst @@ -145,7 +145,7 @@ For example, the default string that is used when none is provided is the follow :: - list(extend)+dict()+str(append) + list()+dict()+str() Dictionary format ******** diff --git a/packages/bddeb b/packages/bddeb index 61399739..00bc717e 100755 --- a/packages/bddeb +++ b/packages/bddeb @@ -35,6 +35,7 @@ PKG_MP = { 'oauth': 'python-oauth', 'prettytable': 'python-prettytable', 'pyyaml': 'python-yaml', + 'requests': 'python-requests', } DEBUILD_ARGS = ["-us", "-S", "-uc", "-d"] diff --git a/packages/brpm b/packages/brpm index eea2a046..53de802c 100755 --- a/packages/brpm +++ b/packages/brpm @@ -41,6 +41,7 @@ PKG_MP = { 'oauth': 'python-oauth', 'prettytable': 'python-prettytable', 'pyyaml': 'PyYAML', + 'requests': 'python-requests', } # Subdirectories of the ~/rpmbuild dir diff --git a/tools/ccfg-merge-debug b/tools/ccfg-merge-debug new file mode 100755 index 00000000..aac60528 --- /dev/null +++ b/tools/ccfg-merge-debug @@ -0,0 +1,81 @@ +#!/usr/bin/python + +from cloudinit import handlers +from cloudinit.handlers import cloud_config as cc_part +from cloudinit import helpers +from cloudinit.settings import PER_INSTANCE +from cloudinit import user_data as ud + +import argparse +import os +import shutil +import tempfile + + +def main(): + parser = argparse.ArgumentParser( + description='test cloud-config merging') + parser.add_argument("--output", "-o", metavar="file", + help="specify output file", default="-") + parser.add_argument('files', nargs='+') + + args = parser.parse_args() + outfile = args.output + if args.output == "-": + outfile = "/dev/stdout" + + tempd = tempfile.mkdtemp() + handler_dir = os.path.join(tempd, "hdir") + data = None # the 'init' object + frequency = PER_INSTANCE + + paths = helpers.Paths({}) + + # make a '#include <f1>' style + udproc = ud.UserDataProcessor(paths=paths) + user_data_msg = udproc.process("#include\n" + + '\n'.join([os.path.abspath(f) for f in args.files])) + + ccph = cc_part.CloudConfigPartHandler(paths=paths) + ccph.cloud_fn = outfile + + c_handlers = helpers.ContentHandlers() + c_handlers.register_defaults([ccph]) + + called = [] + for (_ctype, mod) in c_handlers.iteritems(): + if mod in called: + continue + handlers.call_begin(mod, data, frequency) + called.append(mod) + + # Walk the user data + part_data = { + 'handlers': c_handlers, + # Any new handlers that are encountered get writen here + 'handlerdir': handler_dir, + 'data': data, + # The default frequency if handlers don't have one + 'frequency': frequency, + # This will be used when new handlers are found + # to help write there contents to files with numbered + # names... + 'handlercount': 0, + } + + handlers.walk(user_data_msg, handlers.walker_callback, data=part_data) + + # Give callbacks opportunity to finalize + called = [] + for (_ctype, mod) in c_handlers.iteritems(): + if mod in called: + continue + handlers.call_end(mod, data, frequency) + called.append(mod) + + shutil.rmtree(tempd) + +if __name__ == "__main__": + main() + +# vi: ts=4 expandtab diff --git a/tools/make-dist-tarball b/tools/make-dist-tarball index 7742caea..5b078515 100755 --- a/tools/make-dist-tarball +++ b/tools/make-dist-tarball @@ -10,16 +10,12 @@ EOF } topdir="$PWD" -tag=${1} +tag="$1" [ -n "$tag" ] || { Usage 1>&2 ; exit 1; } -tmpd=$(mktemp -d ); -trap "rm -Rf '${tmpd}'" 0 +out="${topdir}/cloud-init-${tag}.tar.gz" -out=${topdir}/cloud-init-${tag}.tar.gz - -cd ${tmpd} && - bzr branch -r "tag:${tag}" "${topdir}" ./cloud-init-${tag} && - tar czf "${out}" cloud-init-${tag}/ --exclude cloud-init-${tag}/.bzr && - echo "Wrote ${out}" +bzr export --format=tgz --root="cloud-init-$tag" \ + "--revision=tag:${tag}" "$out" "$topdir" && + echo "Wrote ${out}" diff --git a/tools/make-tarball b/tools/make-tarball index 47979f5b..27f5f374 100755 --- a/tools/make-tarball +++ b/tools/make-tarball @@ -18,18 +18,16 @@ if ! find_root; then exit 1; fi +REVNO=$(bzr revno "$ROOT_DIR") + if [ ! -z "$1" ]; then ARCHIVE_FN="$1" else - REVNO=$(bzr revno $ROOT_DIR) - VERSION=$($ROOT_DIR/tools/read-version) + VERSION=$("$ROOT_DIR/tools/read-version") ARCHIVE_FN="$PWD/cloud-init-$VERSION~bzr$REVNO.tar.gz" fi -FILES=$(cd $ROOT_DIR && bzr ls --versioned --recursive) -echo "$FILES" | tar czf $ARCHIVE_FN \ - -C "$ROOT_DIR" \ - --transform "s,^,cloud-init-$VERSION~bzr$REVNO/," \ - --no-recursion --files-from - +bzr export --format=tgz --root="cloud-init-$VERSION~bzr$REVNO" \ + "--revision=${REVNO}" "${ARCHIVE_FN}" "$ROOT_DIR" echo "$ARCHIVE_FN" diff --git a/tools/read-dependencies b/tools/read-dependencies index 4c88aa87..cadb09a8 100755 --- a/tools/read-dependencies +++ b/tools/read-dependencies @@ -21,15 +21,11 @@ fi REQUIRES="$ROOT_DIR/Requires" -if [ ! -e "$REQUIRES" ] -then +if [ ! -e "$REQUIRES" ]; then echo "Unable to find 'Requires' file located at $REQUIRES" exit 1 fi # Filter out comments and empty liens -DEPS=$(cat $REQUIRES | grep -Pv "^\s*#" | grep -Pv '^\s*$') +DEPS=$(grep -Pv "^\s*#" "$REQUIRES" | grep -Pv '^\s*$') echo "$DEPS" | sort -d -f - - - diff --git a/tools/read-version b/tools/read-version index 323357fe..c76b24a9 100755 --- a/tools/read-version +++ b/tools/read-version @@ -27,5 +27,5 @@ then exit 1 fi -VERSION=$(grep -P "\d+.\d+.\d+:" $CHNG_LOG | cut -f1 -d ":" | head -n 1) -echo $VERSION +VERSION=$(grep -P "\d+.\d+.\d+:" "$CHNG_LOG" | cut -f1 -d ":" | head -n 1) +echo "$VERSION" diff --git a/upstart/cloud-init-nonet.conf b/upstart/cloud-init-nonet.conf index 36b99fb5..a94b1474 100644 --- a/upstart/cloud-init-nonet.conf +++ b/upstart/cloud-init-nonet.conf @@ -31,7 +31,12 @@ script handle_sigterm() { # if we received sigterm and static networking is up then it probably # came from upstart as a result of 'stop on static-network-up' - [ -z "$SLEEP_CHILD" ] || kill $SLEEP_CHILD + if [ -n "$SLEEP_CHILD" ]; then + if ! kill $SLEEP_CHILD 2>/dev/null; then + [ ! -d "/proc/$SLEEP_CHILD" ] || + msg "hm.. failed to kill sleep pid $SLEEP_CHILD" + fi + fi if static_network_up; then msg "static networking is now up" exit 0 |