Merge pull request #2 from JamesBromberger/master

Remove deprecated hd00 pvgrub AKIs (hd0 pvgrubs AKIs check hd0 and hd0,0...
This commit is contained in:
Anders Ingemann 2014-02-16 16:04:26 +01:00
commit 9d3ab025ea
9 changed files with 180 additions and 45 deletions

View file

@ -25,7 +25,7 @@
"system": { "system": {
"type": "object", "type": "object",
"properties": { "properties": {
"release": { "enum": ["wheezy", "testing", "unstable"] }, "release": { "enum": ["wheezy", "jessie", "testing", "unstable"] },
"sections": { "sections": {
"type": "array", "type": "array",
"minItems": 1 "minItems": 1

View file

@ -35,7 +35,9 @@ class CheckHostDependencies(Task):
missing_packages = [] missing_packages = []
for package in info.host_dependencies: for package in info.host_dependencies:
try: 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: except CalledProcessError:
missing_packages.append(package) missing_packages.append(package)
if len(missing_packages) > 0: if len(missing_packages) > 0:

View file

@ -7,6 +7,9 @@
"wheezy": [ "wheezy": [
"auto eth0", "auto eth0",
"iface eth0 inet dhcp" ], "iface eth0 inet dhcp" ],
"jessie": [
"auto eth0",
"iface eth0 inet dhcp" ],
"testing": [ "testing": [
"auto eth0", "auto eth0",
"iface eth0 inet dhcp" ], "iface eth0 inet dhcp" ],

View file

@ -10,7 +10,9 @@ class RemoveDNSInfo(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from os import remove 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): class RemoveHostname(Task):
@ -20,7 +22,9 @@ class RemoveHostname(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from os import remove 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): class ConfigureNetworkIF(Task):

View file

@ -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" ]
}
}
}

View file

@ -0,0 +1,44 @@
{
"provider": "ec2",
"virtualization": "pvm",
"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": "pvgrub",
"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" ]
}
}
}

View file

@ -0,0 +1,47 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null,
// "certificate": null,
// "private-key": null,
// "user-id": null
},
"bootstrapper": {
"workspace": "/target"
},
"image": {
"name": "debian-{system.release}-{system.architecture}-{virtualization}-{%Y}-{%m}-{%d}",
"description": "Debian {system.release} {system.architecture} AMI",
"bucket": "debian-amis-cn-north-1"
},
"system": {
"release": "wheezy",
"architecture": "amd64",
"bootloader": "pvgrub",
"timezone": "UTC",
"locale": "en_US",
"charmap": "UTF-8"
},
"packages": {
"mirror": "http://ftp.cn.debian.org/debian"
},
"volume": {
"backing": "s3",
"partitions": {
"type": "none",
"root": {
"size": "1GiB",
"filesystem": "ext4"
}
}
},
"plugins": {
"cloud_init": {
"username": "admin",
"disable_modules": [ "landscape", "byobu", "ssh-import-id" ]
}
}
}

View file

@ -58,8 +58,11 @@ class UploadImage(Task):
manifest_file = os.path.join(info.bundle_path, info.ami_name + '.manifest.xml') manifest_file = os.path.join(info.bundle_path, info.ami_name + '.manifest.xml')
if info.host['region'] == 'us-east-1': if info.host['region'] == 'us-east-1':
s3_url = 'https://s3.amazonaws.com/' s3_url = 'https://s3.amazonaws.com/'
elif info.host['region'] == 'cn-north-1':
s3_url = 'https://s3.cn-north-1.amazonaws.com.cn'
else: else:
s3_url = 'https://s3-{region}.amazonaws.com/'.format(region=info.host['region']) s3_url = 'https://s3-{region}.amazonaws.com/'.format(region=info.host['region'])
info.manifest.manifest_location = info.manifest.image['bucket'] + '/' + info.ami_name + '.manifest.xml'
log_check_call(['/usr/bin/euca-upload-bundle', log_check_call(['/usr/bin/euca-upload-bundle',
'--bucket', info.manifest.image['bucket'], '--bucket', info.manifest.image['bucket'],
'--manifest', manifest_file, '--manifest', manifest_file,
@ -89,61 +92,46 @@ class RegisterAMI(Task):
# Source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UserProvidedKernels.html#AmazonKernelImageIDs # Source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UserProvidedKernels.html#AmazonKernelImageIDs
kernel_mapping = {'ap-northeast-1': # Asia Pacific (Tokyo) Region kernel_mapping = {'ap-northeast-1': # Asia Pacific (Tokyo) Region
{'hd0': {'i386': 'aki-136bf512', # pv-grub-hd0_1.04-i386.gz {'i386': 'aki-136bf512', # pv-grub-hd0_1.04-i386.gz
'amd64': 'aki-176bf516'}, # pv-grub-hd0_1.04-x86_64.gz 'amd64': 'aki-176bf516' # pv-grub-hd0_1.04-x86_64.gz
'hd00': {'i386': 'aki-196bf518', # pv-grub-hd00_1.04-i386.gz },
'amd64': 'aki-1f6bf51e'} # pv-grub-hd00_1.04-x86_64.gz
},
'ap-southeast-1': # Asia Pacific (Singapore) Region 'ap-southeast-1': # Asia Pacific (Singapore) Region
{'hd0': {'i386': 'aki-ae3973fc', # pv-grub-hd0_1.04-i386.gz {'i386': 'aki-ae3973fc', # pv-grub-hd0_1.04-i386.gz
'amd64': 'aki-503e7402'}, # pv-grub-hd0_1.04-x86_64.gz 'amd64': 'aki-503e7402' # pv-grub-hd0_1.04-x86_64.gz
'hd00': {'i386': 'aki-563e7404', # pv-grub-hd00_1.04-i386.gz },
'amd64': 'aki-5e3e740c'} # pv-grub-hd00_1.04-x86_64.gz
},
'ap-southeast-2': # Asia Pacific (Sydney) Region 'ap-southeast-2': # Asia Pacific (Sydney) Region
{'hd0': {'i386': 'aki-cd62fff7', # pv-grub-hd0_1.04-i386.gz {'i386': 'aki-cd62fff7', # pv-grub-hd0_1.04-i386.gz
'amd64': 'aki-c362fff9'}, # pv-grub-hd0_1.04-x86_64.gz 'amd64': 'aki-c362fff9' # pv-grub-hd0_1.04-x86_64.gz
'hd00': {'i386': 'aki-c162fffb', # pv-grub-hd00_1.04-i386.gz
'amd64': 'aki-3b1d8001'} # pv-grub-hd00_1.04-x86_64.gz
}, },
'eu-west-1': # EU (Ireland) Region 'eu-west-1': # EU (Ireland) Region
{'hd0': {'i386': 'aki-68a3451f', # pv-grub-hd0_1.04-i386.gz {'i386': 'aki-68a3451f', # pv-grub-hd0_1.04-i386.gz
'amd64': 'aki-52a34525'}, # pv-grub-hd0_1.04-x86_64.gz 'amd64': 'aki-52a34525' # pv-grub-hd0_1.04-x86_64.gz
'hd00': {'i386': 'aki-5ea34529', # pv-grub-hd00_1.04-i386.gz
'amd64': 'aki-58a3452f'} # pv-grub-hd00_1.04-x86_64.gz
}, },
'sa-east-1': # South America (Sao Paulo) Region 'sa-east-1': # South America (Sao Paulo) Region
{'hd0': {'i386': 'aki-5b53f446', # pv-grub-hd0_1.04-i386.gz {'i386': 'aki-5b53f446', # pv-grub-hd0_1.04-i386.gz
'amd64': 'aki-5553f448'}, # pv-grub-hd0_1.04-x86_64.gz 'amd64': 'aki-5553f448' # pv-grub-hd0_1.04-x86_64.gz
'hd00': {'i386': 'aki-5753f44a', # pv-grub-hd00_1.04-i386.gz
'amd64': 'aki-5153f44c'} # pv-grub-hd00_1.04-x86_64.gz
}, },
'us-east-1': # US East (Northern Virginia) Region 'us-east-1': # US East (Northern Virginia) Region
{'hd0': {'i386': 'aki-8f9dcae6', # pv-grub-hd0_1.04-i386.gz {'i386': 'aki-8f9dcae6', # pv-grub-hd0_1.04-i386.gz
'amd64': 'aki-919dcaf8'}, # pv-grub-hd0_1.04-x86_64.gz 'amd64': 'aki-919dcaf8' # pv-grub-hd0_1.04-x86_64.gz
'hd00': {'i386': 'aki-659ccb0c', # pv-grub-hd00_1.04-i386.gz
'amd64': 'aki-499ccb20'} # pv-grub-hd00_1.04-x86_64.gz
}, },
'us-gov-west-1': # AWS GovCloud (US) 'us-gov-west-1': # AWS GovCloud (US)
{'hd0': {'i386': 'aki-1fe98d3c', # pv-grub-hd0_1.04-i386.gz {'i386': 'aki-1fe98d3c', # pv-grub-hd0_1.04-i386.gz
'amd64': 'aki-1de98d3e'}, # pv-grub-hd0_1.04-x86_64.gz 'amd64': 'aki-1de98d3e' # pv-grub-hd0_1.04-x86_64.gz
'hd00': {'i386': 'aki-63e98d40', # pv-grub-hd00_1.04-i386.gz
'amd64': 'aki-61e98d42'} # pv-grub-hd00_1.04-x86_64.gz
}, },
'us-west-1': # US West (Northern California) Region 'us-west-1': # US West (Northern California) Region
{'hd0': {'i386': 'aki-8e0531cb', # pv-grub-hd0_1.04-i386.gz {'i386': 'aki-8e0531cb', # pv-grub-hd0_1.04-i386.gz
'amd64': 'aki-880531cd'}, # pv-grub-hd0_1.04-x86_64.gz 'amd64': 'aki-880531cd' # pv-grub-hd0_1.04-x86_64.gz
'hd00': {'i386': 'aki-960531d3', # pv-grub-hd00_1.04-i386.gz
'amd64': 'aki-920531d7'} # pv-grub-hd00_1.04-x86_64.gz
}, },
'us-west-2': # US West (Oregon) Region 'us-west-2': # US West (Oregon) Region
{'hd0': {'i386': 'aki-f08f11c0', # pv-grub-hd0_1.04-i386.gz {'i386': 'aki-f08f11c0', # pv-grub-hd0_1.04-i386.gz
'amd64': 'aki-fc8f11cc'}, # pv-grub-hd0_1.04-x86_64.gz 'amd64': 'aki-fc8f11cc' # pv-grub-hd0_1.04-x86_64.gz
'hd00': {'i386': 'aki-e28f11d2', # pv-grub-hd00_1.04-i386.gz },
'amd64': 'aki-e68f11d6'} # pv-grub-hd00_1.04-x86_64.gz 'cn-north-1': # China North (Beijing) Region
} {'i386': 'aki-908f1da9', # pv-grub-hd0_1.04-i386.gz
'amd64': 'aki-9e8f1da7' # pv-grub-hd0_1.04-x86_64.gz
} }
}
@classmethod @classmethod
def run(cls, info): def run(cls, info):
registration_params = {'name': info.ami_name, registration_params = {'name': info.ami_name,
@ -153,6 +141,7 @@ class RegisterAMI(Task):
if info.manifest.volume['backing'] == 's3': if info.manifest.volume['backing'] == 's3':
grub_boot_device = 'hd0' grub_boot_device = 'hd0'
registration_params['image_location'] = info.manifest.manifest_location
else: else:
root_dev_name = {'pvm': '/dev/sda', root_dev_name = {'pvm': '/dev/sda',
'hvm': '/dev/xvda'}.get(info.manifest.data['virtualization']) 'hvm': '/dev/xvda'}.get(info.manifest.data['virtualization'])
@ -176,7 +165,6 @@ class RegisterAMI(Task):
registration_params['virtualization_type'] = 'paravirtual' registration_params['virtualization_type'] = 'paravirtual'
registration_params['kernel_id'] = (cls.kernel_mapping registration_params['kernel_id'] = (cls.kernel_mapping
.get(info.host['region']) .get(info.host['region'])
.get(grub_boot_device)
.get(info.manifest.system['architecture'])) .get(info.manifest.system['architecture']))
info.image = info.connection.register_image(**registration_params) info.image = info.connection.register_image(**registration_params)

View file

@ -5,6 +5,9 @@
"wheezy": { "wheezy": {
"amd64": "linux-image-amd64", "amd64": "linux-image-amd64",
"i386" : "linux-image-686" }, "i386" : "linux-image-686" },
"jessie": {
"amd64": "linux-image-amd64",
"i386" : "linux-image-686" },
"testing": { "testing": {
"amd64": "linux-image-amd64", "amd64": "linux-image-amd64",
"i386" : "linux-image-686" }, "i386" : "linux-image-686" },