Convert "provider" into provider specific section

This is where all provider specific settings belong
like waagent on azure, guest additions iso path on vbox and virtualization type on ec2
This commit is contained in:
Anders Ingemann 2014-07-05 18:14:29 +02:00
parent 5bb0e5428e
commit ebba39f59b
37 changed files with 234 additions and 183 deletions

View file

@ -4,7 +4,11 @@
"type": "object",
"properties": {
"provider": {
"type": "string"
"type": "object",
"properties": {
"name": { "type": "string" }
},
"required": ["name"]
},
"bootstrapper": {
"type": "object",

View file

@ -39,7 +39,7 @@ class Manifest(object):
self.data = load_yaml(self.path)
# Get the provider name from the manifest and load the corresponding module
provider_modname = 'bootstrapvz.providers.' + self.data['provider']
provider_modname = 'bootstrapvz.providers.' + self.data['provider']['name']
log.debug('Loading provider ' + provider_modname)
# Create a modules dict that contains the loaded provider and plugins
import importlib

View file

@ -63,10 +63,10 @@ class SetMetadataSource(Task):
sources = info.manifest.plugins['cloud_init']['metadata_sources']
else:
source_mapping = {'ec2': 'Ec2'}
sources = source_mapping.get(info.manifest.provider, None)
sources = source_mapping.get(info.manifest.provider['name'], None)
if sources is None:
msg = ('No cloud-init metadata source mapping found for provider `{provider}\', '
'skipping selections setting.').format(provider=info.manifest.provider)
'skipping selections setting.').format(provider=info.manifest.provider['name'])
logging.getLogger(__name__).warn(msg)
return
sources = "cloud-init cloud-init/datasources multiselect " + sources

View file

@ -3,13 +3,9 @@
"title": "Azure manifest",
"type": "object",
"properties": {
"system": {
"provider": {
"type": "object",
"properties": {
"bootloader": {
"type": "string",
"enum": ["grub", "extlinux"]
},
"waagent": {
"type": "object",
"properties": {
@ -22,9 +18,18 @@
},
"required": ["version"]
}
},
}
"required": ["waagent"]
},
"system": {
"type": "object",
"properties": {
"bootloader": {
"type": "string",
"enum": ["grub", "extlinux"]
}
},
},
"volume": {
"type": "object",
"properties": {

View file

@ -29,7 +29,7 @@ class Waagent(Task):
def run(cls, info):
from bootstrapvz.common.tools import log_check_call
import os
waagent_version = info.manifest.system['waagent']['version']
waagent_version = info.manifest.provider['waagent']['version']
waagent_file = 'WALinuxAgent-' + waagent_version + '.tar.gz'
waagent_url = 'https://github.com/Azure/WALinuxAgent/archive/' + waagent_file
log_check_call(['wget', '-P', info.root, waagent_url])

View file

@ -38,7 +38,7 @@ def validate_manifest(data, validator, error):
validator(data, os.path.join(os.path.dirname(__file__), 'manifest-schema-s3.json'))
bootloader = data['system']['bootloader']
virtualization = data['virtualization']
virtualization = data['provider']['virtualization']
backing = data['volume']['backing']
partition_type = data['volume']['partitions']['type']

View file

@ -3,18 +3,23 @@
"title": "EC2 manifest for instance store AMIs",
"type": "object",
"properties": {
"credentials": {
"provider": {
"type": "object",
"properties": {
"certificate": {
"type": "string"
},
"private-key": {
"type": "string"
},
"user-id": {
"type": "string",
"pattern": "(^arn:aws:iam::\\d*:user/\\w.*$)|(^\\d{4}-\\d{4}-\\d{4}$)"
"credentials": {
"type": "object",
"properties": {
"certificate": {
"type": "string"
},
"private-key": {
"type": "string"
},
"user-id": {
"type": "string",
"pattern": "(^arn:aws:iam::\\d*:user/\\w.*$)|(^\\d{4}-\\d{4}-\\d{4}$)"
}
}
}
}
},

View file

@ -3,7 +3,24 @@
"title": "EC2 manifest",
"type": "object",
"properties": {
"virtualization": { "enum": ["pvm", "hvm"] },
"provider": {
"type": "object",
"properties": {
"virtualization": { "enum": ["pvm", "hvm"] },
"credentials": {
"type": "object",
"properties": {
"access-key": {
"type": "string"
},
"secret-key": {
"type": "string"
}
}
}
},
"required": ["virtualization"]
},
"image": {
"type": "object",
"properties": {
@ -12,17 +29,6 @@
}
}
},
"credentials": {
"type": "object",
"properties": {
"access-key": {
"type": "string"
},
"secret-key": {
"type": "string"
}
}
},
"system": {
"type": "object",
"properties": {

View file

@ -103,7 +103,7 @@ class RegisterAMI(Task):
registration_params['image_location'] = info._ec2['manifest_location']
else:
root_dev_name = {'pvm': '/dev/sda',
'hvm': '/dev/xvda'}.get(info.manifest.data['virtualization'])
'hvm': '/dev/xvda'}.get(info.manifest.provider['virtualization'])
registration_params['root_device_name'] = root_dev_name
from boto.ec2.blockdevicemapping import BlockDeviceType
@ -113,7 +113,7 @@ class RegisterAMI(Task):
registration_params['block_device_map'] = BlockDeviceMapping()
registration_params['block_device_map'][root_dev_name] = block_device
if info.manifest.data['virtualization'] == 'hvm':
if info.manifest.provider['virtualization'] == 'hvm':
registration_params['virtualization_type'] = 'hvm'
else:
registration_params['virtualization_type'] = 'paravirtual'

View file

@ -18,9 +18,9 @@ class GetCredentials(Task):
def get_credentials(cls, manifest, keys):
from os import getenv
creds = {}
if all(key in manifest.data['credentials'] for key in keys):
if all(key in manifest.provider['credentials'] for key in keys):
for key in keys:
creds[key] = manifest.data['credentials'][key]
creds[key] = manifest.provider['credentials'][key]
return creds
def env_key(key):

View file

@ -28,7 +28,7 @@ def resolve_tasks(taskset, manifest):
loopback.MoveImage,
])
if manifest.bootstrapper.get('virtio', []):
if manifest.provider.get('virtio', []):
from tasks import virtio
taskset.update([virtio.VirtIO])

View file

@ -3,7 +3,7 @@
"title": "KVM manifest",
"type": "object",
"properties": {
"system": {
"provider": {
"type": "object",
"properties": {
"virtio": {
@ -18,7 +18,12 @@
"virtio_ring"]
},
"minItems": 1
},
}
}
},
"system": {
"type": "object",
"properties": {
"bootloader": {
"type": "string",
"enum": ["grub", "extlinux"]

View file

@ -12,5 +12,5 @@ class VirtIO(Task):
modules = os.path.join(info.root, '/etc/initramfs-tools/modules')
with open(modules, "a") as modules_file:
modules_file.write("\n")
for module in info.manifest.system.get('virtio', []):
for module in info.manifest.provider.get('virtio', []):
modules_file.write(module + "\n")

View file

@ -22,7 +22,7 @@ def resolve_tasks(taskset, manifest):
loopback.MoveImage,
])
if manifest.bootstrapper.get('guest_additions', False):
if manifest.provider.get('guest_additions', False):
from tasks import guest_additions
taskset.update([guest_additions.CheckGuestAdditionsPath,
guest_additions.AddGuestAdditionsPackages,

View file

@ -11,7 +11,7 @@ class CheckGuestAdditionsPath(Task):
@classmethod
def run(cls, info):
import os.path
guest_additions_path = info.manifest.bootstrapper['guest_additions']
guest_additions_path = info.manifest.provider['guest_additions']
if not os.path.exists(guest_additions_path):
msg = 'The file {file} does not exist.'.format(file=guest_additions_path)
raise TaskError(msg)
@ -43,7 +43,7 @@ class InstallGuestAdditions(Task):
@classmethod
def run(cls, info):
import os
guest_additions_path = info.manifest.bootstrapper['guest_additions']
guest_additions_path = info.manifest.provider['guest_additions']
mount_dir = 'mnt/guest_additions'
mount_path = os.path.join(info.root, mount_dir)
os.mkdir(mount_path)

View file

@ -1,5 +1,10 @@
{
"provider": "azure",
"provider": {
"name": "azure",
"waagent": {
"version": "2.0.4"
}
},
"bootstrapper": {
"workspace": "/target",
"mirror": "http://ftp.fr.debian.org/debian/"
@ -14,10 +19,7 @@
"bootloader": "grub",
"timezone": "UTC",
"locale": "en_US",
"charmap": "UTF-8",
"waagent": {
"version": "2.0.4"
}
"charmap": "UTF-8"
},
"packages": {
},

View file

@ -1,11 +1,12 @@
{
"provider": "ec2",
"virtualization": "hvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "hvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,11 +1,12 @@
{
"provider": "ec2",
"virtualization": "hvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "hvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,11 +1,12 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,11 +1,12 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,11 +1,12 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,11 +1,12 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,36 +1,37 @@
---
provider: "ec2"
virtualization: "pvm"
credentials:
provider:
name: "ec2"
virtualization: "pvm"
credentials:
access-key: ""
secret-key: ""
bootstrapper:
workspace: "/target"
workspace: "/target"
image:
name: "debian-{system.release}-{system.architecture}-{virtualization}-{%Y}-{%m}-{%d}-ebs"
description: "Debian {system.release} {system.architecture}"
name: "debian-{system.release}-{system.architecture}-{virtualization}-{%Y}-{%m}-{%d}-ebs"
description: "Debian {system.release} {system.architecture}"
system:
release: "testing"
architecture: "amd64"
bootloader: "pvgrub"
timezone: "UTC"
locale: "en_US"
charmap: "UTF-8"
release: "testing"
architecture: "amd64"
bootloader: "pvgrub"
timezone: "UTC"
locale: "en_US"
charmap: "UTF-8"
packages:
#mirror: "http://cloudfront.debian.net/debian"
install_standard: true
#mirror: "http://cloudfront.debian.net/debian"
install_standard: true
volume:
backing: "ebs"
partitions:
type: "none"
root:
size: "8GiB"
filesystem: "ext4"
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"
cloud_init:
username: "admin"
#metadata_sources: "Ec2"
disable_modules:
- "landscape"
- "byobu"
- "ssh-import-id"

View file

@ -1,11 +1,12 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,11 +1,12 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,11 +1,12 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,11 +1,12 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,14 +1,12 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null,
// "certificate": null,
// "private-key": null,
// "user-id": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,14 +1,15 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null,
// "certificate": null,
// "private-key": null,
// "user-id": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null,
// "certificate": null,
// "private-key": null,
// "user-id": null
}
},
"bootstrapper": {
"workspace": "/target"
},

View file

@ -1,7 +1,9 @@
{
"provider": "gce",
"provider": {
"name": "gce"
},
"bootstrapper": {
"workspace": "/target"
"workspace": "/target"
},
"image": {
"name": "disk",

View file

@ -1,7 +1,9 @@
{
"provider": "gce",
"provider": {
"name": "gce"
},
"bootstrapper": {
"workspace": "/target"
"workspace": "/target"
},
"image": {
"name": "disk",

View file

@ -1,8 +1,10 @@
{
"provider": "kvm",
"provider": {
"name": "kvm",
"virtio_modules": [ "virtio_pci", "virtio_blk" ]
},
"bootstrapper": {
"workspace": "/target",
"mirror": "http://ftp.fr.debian.org/debian/"
"workspace": "/target"
},
"image": {
"name": "debian-{system.release}-{system.architecture}-{%y}{%m}{%d}",
@ -14,8 +16,7 @@
"bootloader": "grub",
"timezone": "UTC",
"locale": "en_US",
"charmap": "UTF-8",
"virtio_modules": [ "virtio_pci", "virtio_blk" ]
"charmap": "UTF-8"
},
"packages": {},
"volume": {

View file

@ -1,8 +1,9 @@
{
"provider": "kvm",
"provider": {
"name": "kvm"
},
"bootstrapper": {
"workspace": "/target",
"mirror": "http://ftp.fr.debian.org/debian/"
"workspace": "/target"
},
"image": {
"name": "debian-{system.release}-{system.architecture}-{%y}{%m}{%d}",

View file

@ -1,9 +1,11 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {

View file

@ -1,9 +1,11 @@
{
"provider": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
"provider": {
"name": "ec2",
"virtualization": "pvm",
"credentials": {
// "access-key": null,
// "secret-key": null
}
},
"bootstrapper": {

View file

@ -1,9 +1,11 @@
{
"provider": "virtualbox",
"bootstrapper": {
"workspace": "/target",
"provider": {
"name": "virtualbox",
"guest_additions": "/root/images/VBoxGuestAdditions.iso"
},
"bootstrapper": {
"workspace": "/target"
},
"image": {
"name": "debian-{system.release}-{system.architecture}-{%y}{%m}{%d}",
"description": "Debian {system.release} {system.architecture}"

View file

@ -1,8 +1,10 @@
{
"provider": "virtualbox",
"provider": {
"name": "virtualbox",
"guest_additions": "/root/images/VBoxGuestAdditions.iso"
},
"bootstrapper": {
"workspace": "/target"
// "guest_additions": "/root/images/VBoxGuestAdditions.iso"
"workspace": "/target"
},
"image": {
"name": "debian-{system.release}-{system.architecture}-{%y}{%m}{%d}",