mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 09:50:37 +00:00
bootstrap-vz is now a proper python package
logs/ was remove. logs are now placed in /var/logs/bootstrap-vz instead
This commit is contained in:
parent
bbb06d717e
commit
33a430566b
29 changed files with 76 additions and 22 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -5,3 +5,6 @@ _site/
|
|||
# When developing for ec2 `vagrant provision' is quite handy
|
||||
/Vagrantfile
|
||||
/.vagrant
|
||||
/build
|
||||
/dist
|
||||
/bootstrap_vz.egg-info
|
||||
|
|
4
MANIFEST.in
Normal file
4
MANIFEST.in
Normal file
|
@ -0,0 +1,4 @@
|
|||
include LICENSE
|
||||
include manifests/*
|
||||
recursive-include bootstrapvz assets/*
|
||||
recursive-include bootstrapvz *.json
|
|
@ -81,7 +81,7 @@ class BasePartition(AbstractPartition):
|
|||
def _before_create(self, e):
|
||||
"""Creates the partition
|
||||
"""
|
||||
from common.tools import log_check_call
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
# The create command is failry simple, start and end are just Bytes objects coerced into strings
|
||||
create_command = ('mkpart primary {start} {end}'
|
||||
.format(start=str(self.get_start()),
|
||||
|
|
|
@ -5,7 +5,20 @@ both to a file and to the console.
|
|||
import logging
|
||||
|
||||
|
||||
def get_logfile_path(manifest_path):
|
||||
def create_log_dir():
|
||||
"""Creates the log directory
|
||||
|
||||
Returns:
|
||||
str. The path to the logdirectory
|
||||
"""
|
||||
log_dir_path = '/var/log/bootstrap-vz'
|
||||
import os
|
||||
if not os.path.exists(log_dir_path):
|
||||
os.makedirs(log_dir_path)
|
||||
return log_dir_path
|
||||
|
||||
|
||||
def get_log_filename(manifest_path):
|
||||
"""Returns the path to a logfile given a manifest
|
||||
The logfile name is constructed from the current timestamp and the basename of the manifest
|
||||
|
||||
|
@ -22,7 +35,7 @@ def get_logfile_path(manifest_path):
|
|||
manifest_name, _ = os.path.splitext(manifest_basename)
|
||||
timestamp = datetime.now().strftime('%Y%m%d%H%M%S')
|
||||
filename = "{timestamp}_{name}.log".format(timestamp=timestamp, name=manifest_name)
|
||||
return os.path.normpath(os.path.join(os.path.dirname(__file__), '../logs', filename))
|
||||
return filename
|
||||
|
||||
|
||||
def setup_logger(logfile=None, debug=False):
|
||||
|
|
|
@ -20,7 +20,9 @@ def main():
|
|||
raise Exception('This program requires root privileges.')
|
||||
# Setup logging
|
||||
import log
|
||||
logfile = log.get_logfile_path(args.manifest)
|
||||
log_dir = log.create_log_dir()
|
||||
log_filename = log.get_log_filename(args.manifest)
|
||||
logfile = os.path.join(log_dir, log_filename)
|
||||
log.setup_logger(logfile=logfile, debug=args.debug)
|
||||
# Everything has been set up, begin the bootstrapping process
|
||||
run(args)
|
||||
|
|
|
@ -121,5 +121,5 @@ class Manifest(object):
|
|||
message (str): Message to user about the error
|
||||
json_path (list): A path to the location in the manifest where the error occurred
|
||||
"""
|
||||
from common.exceptions import ManifestError
|
||||
from bootstrapvz.common.exceptions import ManifestError
|
||||
raise ManifestError(message, self.path, json_path)
|
||||
|
|
|
@ -17,7 +17,7 @@ def get_partitions():
|
|||
|
||||
|
||||
def remount(volume, fn):
|
||||
from base.fs.partitionmaps.none import NoPartitions
|
||||
from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
|
||||
|
||||
p_map = volume.partition_map
|
||||
root_dir = p_map.root.mount_dir
|
||||
|
|
|
@ -45,17 +45,17 @@ class AddGrubPackage(Task):
|
|||
|
||||
|
||||
class ConfigureGrub(Task):
|
||||
description = 'Configuring grub'
|
||||
phase = phases.system_modification
|
||||
predecessors = [filesystem.FStab]
|
||||
description = 'Configuring grub'
|
||||
phase = phases.system_modification
|
||||
predecessors = [filesystem.FStab]
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.tools import sed_i
|
||||
grub_def = os.path.join(info.root, 'etc/default/grub')
|
||||
sed_i(grub_def, '^#GRUB_TERMINAL=console', 'GRUB_TERMINAL=console')
|
||||
sed_i(grub_def, '^GRUB_CMDLINE_LINUX_DEFAULT="quiet"',
|
||||
'GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"')
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from bootstrapvz.common.tools import sed_i
|
||||
grub_def = os.path.join(info.root, 'etc/default/grub')
|
||||
sed_i(grub_def, '^#GRUB_TERMINAL=console', 'GRUB_TERMINAL=console')
|
||||
sed_i(grub_def, '^GRUB_CMDLINE_LINUX_DEFAULT="quiet"',
|
||||
'GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"')
|
||||
|
||||
|
||||
class InstallGrub(Task):
|
||||
|
|
|
@ -24,7 +24,7 @@ class Format(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from base.fs.partitions.unformatted import UnformattedPartition
|
||||
from bootstrapvz.base.fs.partitions.unformatted import UnformattedPartition
|
||||
for partition in info.volume.partition_map.partitions:
|
||||
if not isinstance(partition, UnformattedPartition):
|
||||
partition.format()
|
||||
|
@ -37,7 +37,7 @@ class TuneVolumeFS(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from base.fs.partitions.unformatted import UnformattedPartition
|
||||
from bootstrapvz.base.fs.partitions.unformatted import UnformattedPartition
|
||||
import re
|
||||
# Disable the time based filesystem check
|
||||
for partition in info.volume.partition_map.partitions:
|
||||
|
|
|
@ -83,7 +83,7 @@ class AdjustExpandRootScript(Task):
|
|||
if 'expand-root' not in info.initd['install']:
|
||||
raise TaskError('The expand-root script was not installed')
|
||||
|
||||
from base.fs.partitionmaps.none import NoPartitions
|
||||
from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
|
||||
if not isinstance(info.volume.partition_map, NoPartitions):
|
||||
import os.path
|
||||
from ..tools import sed_i
|
||||
|
|
2
bootstrapvz/logs/.gitignore
vendored
2
bootstrapvz/logs/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -53,7 +53,7 @@ class CopyPuppetAssets(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.tools import copy_tree
|
||||
from bootstrapvz.common.tools import copy_tree
|
||||
copy_tree(info.manifest.plugins['puppet']['assets'], os.path.join(info.root, 'etc/puppet'))
|
||||
|
||||
|
||||
|
|
34
setup.py
Normal file
34
setup.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
from setuptools import setup
|
||||
from setuptools import find_packages
|
||||
import os.path
|
||||
|
||||
|
||||
def find_version(path):
|
||||
import re
|
||||
version_file = open(path).read()
|
||||
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
|
||||
if version_match:
|
||||
return version_match.group(1)
|
||||
raise RuntimeError("Unable to find version string.")
|
||||
|
||||
setup(name='bootstrap-vz',
|
||||
version=find_version(os.path.join(os.path.dirname(__file__), 'bootstrapvz/__init__.py')),
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
entry_points={'console_scripts': ['bootstrap-vz = bootstrapvz.base:main']},
|
||||
install_requires=['termcolor >= 1.1.0',
|
||||
'fysom >= 1.0.15',
|
||||
'jsonschema >= 2.3.0',
|
||||
],
|
||||
license='Apache License, Version 2.0',
|
||||
description='Bootstrap Debian images for virtualized environments',
|
||||
long_description='''bootstrap-vz is a bootstrapping framework for Debian.
|
||||
It is is specifically targeted at bootstrapping systems for virtualized environments.
|
||||
bootstrap-vz runs without any user intervention and generates ready-to-boot images for
|
||||
a number of virtualization platforms.
|
||||
Its aim is to provide a reproducable bootstrapping process using manifests
|
||||
as well as supporting a high degree of customizability through plugins.''',
|
||||
author='Anders Ingemann',
|
||||
author_email='anders@ingemann.de',
|
||||
url='http://www.python.org/sigs/distutils-sig/',
|
||||
)
|
Loading…
Add table
Reference in a new issue