mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 18:00:35 +00:00
add plugin to convert raw images to vdi,qcow etc...
This commit is contained in:
parent
5e1a531890
commit
3dd3e00e5c
4 changed files with 52 additions and 0 deletions
|
@ -9,6 +9,7 @@ system_modification = Phase('System modification', 'Installing software, modifyi
|
|||
system_cleaning = Phase('System cleaning', 'Removing sensitive data, temporary files and other leftovers')
|
||||
volume_unmounting = Phase('Volume unmounting', 'Unmounting the bootstrap volume')
|
||||
image_registration = Phase('Image registration', 'Uploading/Registering with the provider')
|
||||
image_conversion = Phase('Image conversion', 'Conversion/Compression of the image result file')
|
||||
cleaning = Phase('Cleaning', 'Removing temporary files')
|
||||
|
||||
order = [preparation,
|
||||
|
@ -20,5 +21,6 @@ order = [preparation,
|
|||
system_cleaning,
|
||||
volume_unmounting,
|
||||
image_registration,
|
||||
image_conversion,
|
||||
cleaning,
|
||||
]
|
||||
|
|
11
plugins/convert_image/__init__.py
Normal file
11
plugins/convert_image/__init__.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
|
||||
def tasks(tasklist, manifest):
|
||||
from tasks import ConvertImage
|
||||
tasklist.add(ConvertImage())
|
||||
|
||||
|
||||
def validate_manifest(data, schema_validate):
|
||||
from os import path
|
||||
schema_path = path.normpath(path.join(path.dirname(__file__), 'manifest-schema.json'))
|
||||
schema_validate(data, schema_path)
|
23
plugins/convert_image/manifest-schema.json
Normal file
23
plugins/convert_image/manifest-schema.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "Convert image",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"plugins": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"convert_image": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"format": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["format"]
|
||||
}
|
||||
},
|
||||
"required": ["convert_image"]
|
||||
}
|
||||
},
|
||||
"required": ["plugins"]
|
||||
}
|
16
plugins/convert_image/tasks.py
Normal file
16
plugins/convert_image/tasks.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks.filesystem import DeleteMountDir
|
||||
|
||||
|
||||
class ConvertImage(Task):
|
||||
description = 'Convert raw image'
|
||||
phase = phases.image_conversion
|
||||
|
||||
def run(self, info):
|
||||
from common.tools import log_check_call
|
||||
converted_file = info.loopback_file.replace('img',info.manifest.plugins['convert_image']['format'])
|
||||
log_check_call(['/usr/bin/qemu-img', 'convert', '-O', info.manifest.plugins['convert_image']['format'], info.loopback_file, converted_file])
|
||||
import os
|
||||
os.remove(info.loopback_file)
|
||||
|
Loading…
Add table
Reference in a new issue