From b64ad495ab199548253b02a29fe06e2579c745aa Mon Sep 17 00:00:00 2001 From: James Brombegrer Date: Fri, 7 Feb 2014 17:42:45 +0000 Subject: [PATCH] Only delete files form the image if they exist. Add in an HVM manifest file. --- common/tasks/host.py | 4 +- common/tasks/network.py | 8 +++- ...fficial-amd64-hvm-cn-north-1.manifest.json | 44 +++++++++++++++++++ providers/ec2/tasks/ami.py | 1 - 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 manifests/ec2-ebs-debian-official-amd64-hvm-cn-north-1.manifest.json diff --git a/common/tasks/host.py b/common/tasks/host.py index f156bf4..7bf79dd 100644 --- a/common/tasks/host.py +++ b/common/tasks/host.py @@ -35,7 +35,9 @@ class CheckHostDependencies(Task): missing_packages = [] for package in info.host_dependencies: try: - log_check_call(['/usr/bin/dpkg-query', '-s', package]) + import os.path + if os.path.isfile('/usr/bin/dpkg-query'): + log_check_call(['/usr/bin/dpkg-query', '-s', package]) except CalledProcessError: missing_packages.append(package) if len(missing_packages) > 0: diff --git a/common/tasks/network.py b/common/tasks/network.py index 32bfd01..8418a84 100644 --- a/common/tasks/network.py +++ b/common/tasks/network.py @@ -10,7 +10,9 @@ class RemoveDNSInfo(Task): @classmethod def run(cls, info): from os import remove - remove(os.path.join(info.root, 'etc/resolv.conf')) + import os.path + if os.path.isfile(os.path.join(info.root, 'etc/resolv.conf')): + remove(os.path.join(info.root, 'etc/resolv.conf')) class RemoveHostname(Task): @@ -20,7 +22,9 @@ class RemoveHostname(Task): @classmethod def run(cls, info): from os import remove - remove(os.path.join(info.root, 'etc/hostname')) + import os.path + if os.path.isfile(os.path.join(info.root, 'etc/hostname')): + remove(os.path.join(info.root, 'etc/hostname')) class ConfigureNetworkIF(Task): diff --git a/manifests/ec2-ebs-debian-official-amd64-hvm-cn-north-1.manifest.json b/manifests/ec2-ebs-debian-official-amd64-hvm-cn-north-1.manifest.json new file mode 100644 index 0000000..afd55ba --- /dev/null +++ b/manifests/ec2-ebs-debian-official-amd64-hvm-cn-north-1.manifest.json @@ -0,0 +1,44 @@ +{ + "provider": "ec2", + "virtualization": "hvm", + "credentials": { + // "access-key": null, + // "secret-key": null + }, + + "bootstrapper": { + "workspace": "/target" + }, + "image": { + "name": "debian-{system.release}-{system.architecture}-{virtualization}-{%Y}-{%m}-{%d}-ebs", + "description": "Debian {system.release} {system.architecture}" + }, + "system": { + "release": "wheezy", + "architecture": "amd64", + "bootloader": "extlinux", + "timezone": "UTC", + "locale": "en_US", + "charmap": "UTF-8" + }, + "packages": { + "mirror": "http://ftp.cn.debian.org/debian" + }, + "volume": { + "backing": "ebs", + "partitions": { + "type": "none", + "root": { + "size": "8GiB", + "filesystem": "ext4" + } + } + }, + "plugins": { + "cloud_init": { + "username": "admin", + //"metadata_sources": "Ec2", + "disable_modules": [ "landscape", "byobu", "ssh-import-id" ] + } + } +} diff --git a/providers/ec2/tasks/ami.py b/providers/ec2/tasks/ami.py index fc463de..582c59e 100644 --- a/providers/ec2/tasks/ami.py +++ b/providers/ec2/tasks/ami.py @@ -163,7 +163,6 @@ class RegisterAMI(Task): registration_params['virtualization_type'] = 'paravirtual' registration_params['kernel_id'] = (cls.kernel_mapping .get(info.host['region']) - .get(grub_boot_device) .get(info.manifest.system['architecture'])) info.image = info.connection.register_image(**registration_params)