mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
Merge pull request #69 from Rory-Finnegan/development
YAML config support
This commit is contained in:
commit
36ff04398a
4 changed files with 51 additions and 3 deletions
|
@ -4,6 +4,7 @@ invocations should have etc..
|
||||||
.. module:: manifest
|
.. module:: manifest
|
||||||
"""
|
"""
|
||||||
from bootstrapvz.common.tools import load_json
|
from bootstrapvz.common.tools import load_json
|
||||||
|
from bootstrapvz.common.tools import load_yaml
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -34,7 +35,11 @@ class Manifest(object):
|
||||||
"""
|
"""
|
||||||
# Load the manifest JSON using the loader in common.tools
|
# Load the manifest JSON using the loader in common.tools
|
||||||
# It strips comments (which are invalid in strict json) before loading the data.
|
# It strips comments (which are invalid in strict json) before loading the data.
|
||||||
self.data = load_json(self.path)
|
if self.path.endswith('.json'):
|
||||||
|
self.data = load_json(self.path)
|
||||||
|
elif self.path.endswith('.yml') or self.path.endswith('.yaml'):
|
||||||
|
self.data = load_yaml(self.path)
|
||||||
|
|
||||||
# Get the provider name from the manifest and load the corresponding module
|
# Get the provider name from the manifest and load the corresponding module
|
||||||
provider_modname = 'bootstrapvz.providers.{provider}'.format(provider=self.data['provider'])
|
provider_modname = 'bootstrapvz.providers.{provider}'.format(provider=self.data['provider'])
|
||||||
log.debug('Loading provider `{modname}\''.format(modname=provider_modname))
|
log.debug('Loading provider `{modname}\''.format(modname=provider_modname))
|
||||||
|
|
|
@ -64,13 +64,20 @@ def load_json(path):
|
||||||
return json.loads(json_minify(stream.read(), False))
|
return json.loads(json_minify(stream.read(), False))
|
||||||
|
|
||||||
|
|
||||||
|
def load_yaml(path):
|
||||||
|
import yaml
|
||||||
|
with open(path, 'r') as fobj:
|
||||||
|
return yaml.load(fobj)
|
||||||
|
|
||||||
|
|
||||||
def config_get(path, config_path):
|
def config_get(path, config_path):
|
||||||
config = load_json(path)
|
config = load_json(path)
|
||||||
for key in config_path:
|
for key in config_path:
|
||||||
config = config.get(key)
|
config = config.get(key)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def copy_tree(from_path,to_path):
|
|
||||||
|
def copy_tree(from_path, to_path):
|
||||||
from shutil import copy
|
from shutil import copy
|
||||||
import os
|
import os
|
||||||
for abs_prefix, dirs, files in os.walk(from_path):
|
for abs_prefix, dirs, files in os.walk(from_path):
|
||||||
|
@ -86,4 +93,3 @@ def copy_tree(from_path,to_path):
|
||||||
for path in files:
|
for path in files:
|
||||||
copy(os.path.join(abs_prefix, path),
|
copy(os.path.join(abs_prefix, path),
|
||||||
os.path.join(to_path, prefix, path))
|
os.path.join(to_path, prefix, path))
|
||||||
|
|
||||||
|
|
36
manifests/ec2-ebs-debian-testing-amd64-pvm.manifest.yml
Normal file
36
manifests/ec2-ebs-debian-testing-amd64-pvm.manifest.yml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
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: "testing"
|
||||||
|
architecture: "amd64"
|
||||||
|
bootloader: "pvgrub"
|
||||||
|
timezone: "UTC"
|
||||||
|
locale: "en_US"
|
||||||
|
charmap: "UTF-8"
|
||||||
|
packages:
|
||||||
|
#mirror: "http://cloudfront.debian.net/debian"
|
||||||
|
install_standard: true
|
||||||
|
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"
|
1
setup.py
1
setup.py
|
@ -19,6 +19,7 @@ setup(name='bootstrap-vz',
|
||||||
install_requires=['termcolor >= 1.1.0',
|
install_requires=['termcolor >= 1.1.0',
|
||||||
'fysom >= 1.0.15',
|
'fysom >= 1.0.15',
|
||||||
'jsonschema >= 2.3.0',
|
'jsonschema >= 2.3.0',
|
||||||
|
'pyyaml >= 3.10',
|
||||||
],
|
],
|
||||||
license='Apache License, Version 2.0',
|
license='Apache License, Version 2.0',
|
||||||
description='Bootstrap Debian images for virtualized environments',
|
description='Bootstrap Debian images for virtualized environments',
|
||||||
|
|
Loading…
Add table
Reference in a new issue