mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Implemented build_metadata plugin
This commit is contained in:
parent
0be80c0c43
commit
b9081891dd
4 changed files with 42 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
def tasks(tasklist, manifest):
|
def tasks(tasklist, manifest):
|
||||||
from buildmetadata import PrintInfo
|
from tasks import WriteMetadata
|
||||||
tasklist.add(PrintInfo())
|
tasklist.add(WriteMetadata())
|
||||||
|
|
|
@ -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')
|
|
23
plugins/build_metadata/manifest-schema.json
Normal file
23
plugins/build_metadata/manifest-schema.json
Normal 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"]
|
||||||
|
}
|
17
plugins/build_metadata/tasks.py
Normal file
17
plugins/build_metadata/tasks.py
Normal 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)))
|
Loading…
Add table
Reference in a new issue