Implemented build_metadata plugin

This commit is contained in:
Anders Ingemann 2013-08-10 18:32:23 +02:00
parent 0be80c0c43
commit b9081891dd
4 changed files with 42 additions and 14 deletions

View file

@ -1,5 +1,5 @@
def tasks(tasklist, manifest):
from buildmetadata import PrintInfo
tasklist.add(PrintInfo())
from tasks import WriteMetadata
tasklist.add(WriteMetadata())

View file

@ -1,12 +0,0 @@
from base import Task
from common import phases
from providers.ec2.tasks.host import GetInfo
class PrintInfo(Task):
description = 'Printing `info\' to the console'
phase = phases.install_os
after = [GetInfo]
def run(self, info):
print('info')

View file

@ -0,0 +1,23 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Build metadata plugin manifest",
"type": "object",
"properties": {
"plugins": {
"type": "object",
"properties": {
"build_metadata": {
"type": "object",
"properties": {
"path": {
"type": "string"
}
},
"required": ["path"]
}
},
"required": ["build_metadata"]
}
},
"required": ["plugins"]
}

View file

@ -0,0 +1,17 @@
from base import Task
from common import phases
class WriteMetadata(Task):
description = 'Writing bootstrap metadata to file'
phase = phases.cleaning
def run(self, info):
metadata_path = info.manifest.plugins['build_metadata']['path']
with open(metadata_path, 'w') as metadata:
metadata.write(('AMI_ID={ami_id}\n'
'AMI_NAME={ami_name}'
'SNAPSHOT_ID={snapshot_id}'
.format(ami_id=info.image,
ami_name=info.ami_name,
snapshot_id=info.snapshot.id)))