Properly fix imports and make bootstrapvz work like a package

This commit is contained in:
Anders Ingemann 2014-03-23 23:12:07 +01:00
parent 2279da3cef
commit bbb06d717e
74 changed files with 320 additions and 323 deletions

5
bootstrap-vz Executable file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env python
if __name__ == '__main__':
from bootstrapvz.base import main
main()

View file

@ -1,8 +1,3 @@
__version__ = '0.9' __version__ = '0.9'
if __name__ == '__main__':
from base import main
sys.exit(main())

View file

@ -35,7 +35,7 @@ class BootstrapInformation(object):
# Normalize the release codenames so that tasks may query for release codenames rather than # Normalize the release codenames so that tasks may query for release codenames rather than
# 'stable', 'unstable' etc. This is useful when handling cases that are specific to a release. # 'stable', 'unstable' etc. This is useful when handling cases that are specific to a release.
release_codenames_path = os.path.join(os.path.dirname(__file__), 'release-codenames.json') release_codenames_path = os.path.join(os.path.dirname(__file__), 'release-codenames.json')
from common.tools import config_get from bootstrapvz.common.tools import config_get
self.release_codename = config_get(release_codenames_path, [self.manifest.system['release']]) self.release_codename = config_get(release_codenames_path, [self.manifest.system['release']])
class DictClass(dict): class DictClass(dict):

View file

@ -9,10 +9,10 @@ def load_volume(data, bootloader):
Returns: Returns:
Volume. The volume that represents all information pertaining to the volume we bootstrap on Volume. The volume that represents all information pertaining to the volume we bootstrap on
""" """
from ...common.fs.loopbackvolume import LoopbackVolume from bootstrapvz.common.fs.loopbackvolume import LoopbackVolume
from ...providers.ec2.ebsvolume import EBSVolume from bootstrapvz.providers.ec2.ebsvolume import EBSVolume
from ...common.fs.virtualdiskimage import VirtualDiskImage from bootstrapvz.common.fs.virtualdiskimage import VirtualDiskImage
from ...common.fs.virtualmachinedisk import VirtualMachineDisk from bootstrapvz.common.fs.virtualmachinedisk import VirtualMachineDisk
# Create a mapping between valid partition maps in the manifest and their corresponding classes # Create a mapping between valid partition maps in the manifest and their corresponding classes
from partitionmaps.gpt import GPTPartitionMap from partitionmaps.gpt import GPTPartitionMap
from partitionmaps.msdos import MSDOSPartitionMap from partitionmaps.msdos import MSDOSPartitionMap

View file

@ -1,7 +1,7 @@
from abc import ABCMeta from abc import ABCMeta
from abc import abstractmethod from abc import abstractmethod
from ....common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from ....common.fsm_proxy import FSMProxy from bootstrapvz.common.fsm_proxy import FSMProxy
from ..exceptions import PartitionError from ..exceptions import PartitionError

View file

@ -1,7 +1,7 @@
from abstract import AbstractPartitionMap from abstract import AbstractPartitionMap
from ..partitions.gpt import GPTPartition from ..partitions.gpt import GPTPartition
from ..partitions.gpt_swap import GPTSwapPartition from ..partitions.gpt_swap import GPTSwapPartition
from ....common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
class GPTPartitionMap(AbstractPartitionMap): class GPTPartitionMap(AbstractPartitionMap):
@ -14,7 +14,7 @@ class GPTPartitionMap(AbstractPartitionMap):
data (dict): volume.partitions part of the manifest data (dict): volume.partitions part of the manifest
bootloader (str): Name of the bootloader we will use for bootstrapping bootloader (str): Name of the bootloader we will use for bootstrapping
""" """
from ....common.bytes import Bytes from bootstrapvz.common.bytes import Bytes
# List of partitions # List of partitions
self.partitions = [] self.partitions = []

View file

@ -1,7 +1,7 @@
from abstract import AbstractPartitionMap from abstract import AbstractPartitionMap
from ..partitions.msdos import MSDOSPartition from ..partitions.msdos import MSDOSPartition
from ..partitions.msdos_swap import MSDOSSwapPartition from ..partitions.msdos_swap import MSDOSSwapPartition
from ....common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
class MSDOSPartitionMap(AbstractPartitionMap): class MSDOSPartitionMap(AbstractPartitionMap):
@ -15,7 +15,7 @@ class MSDOSPartitionMap(AbstractPartitionMap):
data (dict): volume.partitions part of the manifest data (dict): volume.partitions part of the manifest
bootloader (str): Name of the bootloader we will use for bootstrapping bootloader (str): Name of the bootloader we will use for bootstrapping
""" """
from ....common.bytes import Bytes from bootstrapvz.common.bytes import Bytes
# List of partitions # List of partitions
self.partitions = [] self.partitions = []

View file

@ -13,7 +13,7 @@ class NoPartitions(object):
data (dict): volume.partitions part of the manifest data (dict): volume.partitions part of the manifest
bootloader (str): Name of the bootloader we will use for bootstrapping bootloader (str): Name of the bootloader we will use for bootstrapping
""" """
from ....common.bytes import Bytes from bootstrapvz.common.bytes import Bytes
# In the NoPartitions partitions map we only have a single 'partition' # In the NoPartitions partitions map we only have a single 'partition'
self.root = SinglePartition(Bytes(data['root']['size']), self.root = SinglePartition(Bytes(data['root']['size']),
data['root']['filesystem'], data['root'].get('format_command', None)) data['root']['filesystem'], data['root'].get('format_command', None))

View file

@ -1,8 +1,8 @@
from abc import ABCMeta from abc import ABCMeta
from abc import abstractmethod from abc import abstractmethod
import os.path import os.path
from ....common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from ....common.fsm_proxy import FSMProxy from bootstrapvz.common.fsm_proxy import FSMProxy
class AbstractPartition(FSMProxy): class AbstractPartition(FSMProxy):

View file

@ -29,7 +29,7 @@ class BasePartition(AbstractPartition):
# By saving the previous partition we have # By saving the previous partition we have
# a linked list that partitions can go backwards in to find the first partition. # a linked list that partitions can go backwards in to find the first partition.
self.previous = previous self.previous = previous
from common.bytes import Bytes from bootstrapvz.common.bytes import Bytes
# Initialize the offset to 0 bytes, may be changed later # Initialize the offset to 0 bytes, may be changed later
self.offset = Bytes(0) self.offset = Bytes(0)
# List of flags that parted should put on the partition # List of flags that parted should put on the partition

View file

@ -1,4 +1,4 @@
from ....common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from base import BasePartition from base import BasePartition

View file

@ -1,4 +1,4 @@
from ....common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from gpt import GPTPartition from gpt import GPTPartition

View file

@ -1,4 +1,4 @@
from ....common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from msdos import MSDOSPartition from msdos import MSDOSPartition

View file

@ -11,6 +11,6 @@ class SinglePartition(AbstractPartition):
Returns: Returns:
Bytes. The starting byte of this partition Bytes. The starting byte of this partition
""" """
from ....common.bytes import Bytes from bootstrapvz.common.bytes import Bytes
# On an unpartitioned volume there is no offset and no previous partition # On an unpartitioned volume there is no offset and no previous partition
return Bytes(0) return Bytes(0)

View file

@ -1,6 +1,6 @@
from abc import ABCMeta from abc import ABCMeta
from ...common.fsm_proxy import FSMProxy from bootstrapvz.common.fsm_proxy import FSMProxy
from ...common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from .exceptions import VolumeError from .exceptions import VolumeError
from partitionmaps.none import NoPartitions from partitionmaps.none import NoPartitions
@ -90,7 +90,7 @@ class Volume(FSMProxy):
VolumeError VolumeError
""" """
import os.path import os.path
from ...common.fs import get_partitions from bootstrapvz.common.fs import get_partitions
# Fetch information from /proc/partitions # Fetch information from /proc/partitions
proc_partitions = get_partitions() proc_partitions = get_partitions()
device_name = os.path.basename(self.device_path) device_name = os.path.basename(self.device_path)

View file

@ -3,7 +3,7 @@ to determine which tasks should be added to the tasklist, what arguments various
invocations should have etc.. invocations should have etc..
.. module:: manifest .. module:: manifest
""" """
from ..common.tools import load_json from bootstrapvz.common.tools import load_json
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -36,7 +36,7 @@ class Manifest(object):
# 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) self.data = load_json(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 = '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))
# Create a modules dict that contains the loaded provider and plugins # Create a modules dict that contains the loaded provider and plugins
self.modules = {'provider': __import__(provider_modname, fromlist=['providers']), self.modules = {'provider': __import__(provider_modname, fromlist=['providers']),
@ -45,7 +45,7 @@ class Manifest(object):
# Run through all the plugins mentioned in the manifest and load them # Run through all the plugins mentioned in the manifest and load them
if 'plugins' in self.data: if 'plugins' in self.data:
for plugin_name, plugin_data in self.data['plugins'].iteritems(): for plugin_name, plugin_data in self.data['plugins'].iteritems():
modname = 'plugins.{plugin}'.format(plugin=plugin_name) modname = 'bootstrapvz.plugins.{plugin}'.format(plugin=plugin_name)
log.debug('Loading plugin `{modname}\''.format(modname=modname)) log.debug('Loading plugin `{modname}\''.format(modname=modname))
plugin = __import__(modname, fromlist=['plugins']) plugin = __import__(modname, fromlist=['plugins'])
self.modules['plugins'].append(plugin) self.modules['plugins'].append(plugin)

View file

@ -18,7 +18,7 @@ class Phase(object):
Returns: Returns:
int. The positional index of the phase in relation to the other phases int. The positional index of the phase in relation to the other phases
""" """
from common.phases import order from bootstrapvz.common.phases import order
return next(i for i, phase in enumerate(order) if phase is self) return next(i for i, phase in enumerate(order) if phase is self)
def __cmp__(self, other): def __cmp__(self, other):

View file

@ -2,7 +2,7 @@
.. module:: tasklist .. module:: tasklist
""" """
from ..common.exceptions import TaskListError from bootstrapvz.common.exceptions import TaskListError
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -63,7 +63,7 @@ class TaskList(object):
def create_list(self): def create_list(self):
"""Creates a list of all the tasks that should be run. """Creates a list of all the tasks that should be run.
""" """
from common.phases import order from bootstrapvz.common.phases import order
# Get a hold of all tasks # Get a hold of all tasks
tasks = self.get_all_tasks() tasks = self.get_all_tasks()
# Make sure the taskset is a subset of all the tasks we have gathered # Make sure the taskset is a subset of all the tasks we have gathered
@ -113,7 +113,9 @@ class TaskList(object):
list. A list of all tasks in the package list. A list of all tasks in the package
""" """
# Get a generator that returns all classes in the package # Get a generator that returns all classes in the package
classes = self.get_all_classes('..') import os.path
pkg_path = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
classes = self.get_all_classes(pkg_path, 'bootstrapvz.')
# lambda function to check whether a class is a task (excluding the superclass Task) # lambda function to check whether a class is a task (excluding the superclass Task)
def is_task(obj): def is_task(obj):
@ -121,11 +123,12 @@ class TaskList(object):
return issubclass(obj, Task) and obj is not Task return issubclass(obj, Task) and obj is not Task
return filter(is_task, classes) # Only return classes that are tasks return filter(is_task, classes) # Only return classes that are tasks
def get_all_classes(self, path=None): def get_all_classes(self, path=None, prefix=''):
""" Given a path to a package, this function retrieves all the classes in it """ Given a path to a package, this function retrieves all the classes in it
Args: Args:
path (str): Path to the package path (str): Path to the package
prefix (str): Name of the package followed by a dot
Returns: Returns:
generator. A generator that yields classes generator. A generator that yields classes
@ -139,7 +142,7 @@ class TaskList(object):
def walk_error(module): def walk_error(module):
raise Exception('Unable to inspect module `{module}\''.format(module=module)) raise Exception('Unable to inspect module `{module}\''.format(module=module))
walker = pkgutil.walk_packages(path, '', walk_error) walker = pkgutil.walk_packages([path], prefix, walk_error)
for _, module_name, _ in walker: for _, module_name, _ in walker:
module = importlib.import_module(module_name) module = importlib.import_module(module_name)
classes = inspect.getmembers(module, inspect.isclass) classes = inspect.getmembers(module, inspect.isclass)

View file

@ -1,6 +0,0 @@
#!/usr/bin/env python
if __name__ == '__main__' and __package__ is None:
from base import main
main()

View file

@ -1,5 +1,5 @@
from base.fs.volume import Volume from bootstrapvz.base.fs.volume import Volume
from common.tools import log_check_call from ..tools import log_check_call
class LoopbackVolume(Volume): class LoopbackVolume(Volume):

View file

@ -1,7 +1,7 @@
from common.fs.loopbackvolume import LoopbackVolume from loopbackvolume import LoopbackVolume
from base.fs.exceptions import VolumeError from bootstrapvz.base.fs.exceptions import VolumeError
from common.tools import log_check_call from ..tools import log_check_call
from common.fs import get_partitions from . import get_partitions
class QEMUVolume(LoopbackVolume): class QEMUVolume(LoopbackVolume):
@ -12,7 +12,7 @@ class QEMUVolume(LoopbackVolume):
log_check_call(['qemu-img', 'create', '-f', self.qemu_format, self.image_path, vol_size]) log_check_call(['qemu-img', 'create', '-f', self.qemu_format, self.image_path, vol_size])
def _check_nbd_module(self): def _check_nbd_module(self):
from base.fs.partitionmaps.none import NoPartitions from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
if isinstance(self.partition_map, NoPartitions): if isinstance(self.partition_map, NoPartitions):
if not self._module_loaded('nbd'): if not self._module_loaded('nbd'):
msg = ('The kernel module `nbd\' must be loaded ' msg = ('The kernel module `nbd\' must be loaded '

View file

@ -1,4 +1,4 @@
from common.fs.qemuvolume import QEMUVolume from qemuvolume import QEMUVolume
class VirtualDiskImage(QEMUVolume): class VirtualDiskImage(QEMUVolume):

View file

@ -1,4 +1,4 @@
from common.fs.qemuvolume import QEMUVolume from qemuvolume import QEMUVolume
class VirtualMachineDisk(QEMUVolume): class VirtualMachineDisk(QEMUVolume):

View file

@ -1,4 +1,4 @@
from base import Phase from bootstrapvz.base.phase import Phase
preparation = Phase('Preparation', 'Initializing connections, fetching data etc.') preparation = Phase('Preparation', 'Initializing connections, fetching data etc.')
volume_creation = Phase('Volume creation', 'Creating the volume to bootstrap onto') volume_creation = Phase('Volume creation', 'Creating the volume to bootstrap onto')

View file

@ -1,15 +1,15 @@
from common.tasks import workspace from tasks import workspace
from common.tasks import packages from tasks import packages
from common.tasks import host from tasks import host
from common.tasks import boot from tasks import boot
from common.tasks import bootstrap from tasks import bootstrap
from common.tasks import volume from tasks import volume
from common.tasks import filesystem from tasks import filesystem
from common.tasks import partitioning from tasks import partitioning
from common.tasks import cleanup from tasks import cleanup
from common.tasks import apt from tasks import apt
from common.tasks import security from tasks import security
from common.tasks import locale from tasks import locale
base_set = [workspace.CreateWorkspace, base_set = [workspace.CreateWorkspace,
bootstrap.AddRequiredCommands, bootstrap.AddRequiredCommands,

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
from common.tools import log_check_call from ..tools import log_check_call
import locale import locale
import os import os

View file

@ -1,8 +1,8 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
from common.tasks import apt import apt
from common.tasks import filesystem import filesystem
from base.fs import partitionmaps from bootstrapvz.base.fs import partitionmaps
import os.path import os.path
@ -24,7 +24,7 @@ class DisableGetTTYs(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import sed_i from ..tools import sed_i
inittab_path = os.path.join(info.root, 'etc/inittab') inittab_path = os.path.join(info.root, 'etc/inittab')
tty1 = '1:2345:respawn:/sbin/getty 38400 tty1' tty1 = '1:2345:respawn:/sbin/getty 38400 tty1'
sed_i(inittab_path, '^' + tty1, '#' + tty1) sed_i(inittab_path, '^' + tty1, '#' + tty1)
@ -65,13 +65,13 @@ class InstallGrub(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.fs.loopbackvolume import LoopbackVolume from ..fs.loopbackvolume import LoopbackVolume
from common.tools import log_check_call from ..tools import log_check_call
boot_dir = os.path.join(info.root, 'boot') boot_dir = os.path.join(info.root, 'boot')
grub_dir = os.path.join(boot_dir, 'grub') grub_dir = os.path.join(boot_dir, 'grub')
from common.fs import remount from ..fs import remount
p_map = info.volume.partition_map p_map = info.volume.partition_map
def link_fn(): def link_fn():
@ -136,7 +136,7 @@ class InstallExtLinux(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import log_check_call from ..tools import log_check_call
if isinstance(info.volume.partition_map, partitionmaps.gpt.GPTPartitionMap): if isinstance(info.volume.partition_map, partitionmaps.gpt.GPTPartitionMap):
bootloader = '/usr/lib/syslinux/gptmbr.bin' bootloader = '/usr/lib/syslinux/gptmbr.bin'
else: else:

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
from common.exceptions import TaskError from ..exceptions import TaskError
import host import host
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -45,7 +45,7 @@ class MakeTarball(Task):
if os.path.isfile(info.tarball): if os.path.isfile(info.tarball):
log.debug('Found matching tarball, skipping download') log.debug('Found matching tarball, skipping download')
else: else:
from common.tools import log_call from ..tools import log_call
status, out, err = log_call(executable + options + ['--make-tarball=' + info.tarball] + arguments) status, out, err = log_call(executable + options + ['--make-tarball=' + info.tarball] + arguments)
if status != 1: if status != 1:
msg = 'debootstrap exited with status {status}, it should exit with status 1'.format(status=status) msg = 'debootstrap exited with status {status}, it should exit with status 1'.format(status=status)
@ -63,5 +63,5 @@ class Bootstrap(Task):
if hasattr(info, 'tarball'): if hasattr(info, 'tarball'):
options.extend(['--unpack-tarball=' + info.tarball]) options.extend(['--unpack-tarball=' + info.tarball])
from common.tools import log_check_call from ..tools import log_check_call
log_check_call(executable + options + arguments) log_check_call(executable + options + arguments)

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
import os import os
import shutil import shutil
@ -28,7 +28,7 @@ class ShredHostkeys(Task):
private = [os.path.join(info.root, 'etc/ssh', name) for name in ssh_hostkeys] private = [os.path.join(info.root, 'etc/ssh', name) for name in ssh_hostkeys]
public = [path + '.pub' for path in private] public = [path + '.pub' for path in private]
from common.tools import log_check_call from ..tools import log_check_call
log_check_call(['shred', '--remove'] + private + public) log_check_call(['shred', '--remove'] + private + public)

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
class TriggerRollback(Task): class TriggerRollback(Task):
@ -9,5 +9,5 @@ class TriggerRollback(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.exceptions import TaskError from ..exceptions import TaskError
raise TaskError('Trigger rollback') raise TaskError('Trigger rollback')

View file

@ -1,8 +1,8 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
from common.tools import log_check_call from ..tools import log_check_call
from bootstrap import Bootstrap
import apt import apt
import bootstrap
import host import host
import volume import volume
@ -102,7 +102,7 @@ class MountBoot(Task):
class MountSpecials(Task): class MountSpecials(Task):
description = 'Mounting special block devices' description = 'Mounting special block devices'
phase = phases.os_installation phase = phases.os_installation
predecessors = [Bootstrap] predecessors = [bootstrap.Bootstrap]
@classmethod @classmethod
def run(cls, info): def run(cls, info):

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
from common.exceptions import TaskError from ..exceptions import TaskError
class CheckExternalCommands(Task): class CheckExternalCommands(Task):
@ -9,7 +9,7 @@ class CheckExternalCommands(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import log_check_call from ..tools import log_check_call
from subprocess import CalledProcessError from subprocess import CalledProcessError
import re import re
missing_packages = [] missing_packages = []

View file

@ -1,7 +1,7 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
from common.exceptions import TaskError from ..exceptions import TaskError
from common.tools import log_check_call from ..tools import log_check_call
from . import assets from . import assets
import os.path import os.path
@ -86,7 +86,7 @@ class AdjustExpandRootScript(Task):
from base.fs.partitionmaps.none import NoPartitions from base.fs.partitionmaps.none import NoPartitions
if not isinstance(info.volume.partition_map, NoPartitions): if not isinstance(info.volume.partition_map, NoPartitions):
import os.path import os.path
from common.tools import sed_i from ..tools import sed_i
script = os.path.join(info.root, 'etc/init.d.expand-root') script = os.path.join(info.root, 'etc/init.d.expand-root')
root_idx = info.volume.partition_map.root.get_index() root_idx = info.volume.partition_map.root.get_index()
device_path = 'device_path="/dev/xvda{idx}"'.format(idx=root_idx) device_path = 'device_path="/dev/xvda{idx}"'.format(idx=root_idx)

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
import os.path import os.path
@ -20,8 +20,8 @@ class GenerateLocale(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import sed_i from ..tools import sed_i
from common.tools import log_check_call from ..tools import log_check_call
locale_gen = os.path.join(info.root, 'etc/locale.gen') locale_gen = os.path.join(info.root, 'etc/locale.gen')
locale_str = '{locale}.{charmap} {charmap}'.format(locale=info.manifest.system['locale'], locale_str = '{locale}.{charmap} {charmap}'.format(locale=info.manifest.system['locale'],
charmap=info.manifest.system['charmap']) charmap=info.manifest.system['charmap'])

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
import host import host
import volume import volume
@ -11,11 +11,11 @@ class AddRequiredCommands(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.fs.loopbackvolume import LoopbackVolume from ..fs.loopbackvolume import LoopbackVolume
if isinstance(info.volume, LoopbackVolume): if isinstance(info.volume, LoopbackVolume):
info.host_dependencies['qemu-img'] = 'qemu-utils' info.host_dependencies['qemu-img'] = 'qemu-utils'
info.host_dependencies['losetup'] = 'mount' info.host_dependencies['losetup'] = 'mount'
from common.fs.qemuvolume import QEMUVolume from ..fs.qemuvolume import QEMUVolume
if isinstance(info.volume, QEMUVolume): if isinstance(info.volume, QEMUVolume):
info.host_dependencies['losetup'] = 'mount' info.host_dependencies['losetup'] = 'mount'

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
import os import os
@ -30,7 +30,7 @@ class ConfigureNetworkIF(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
network_config_path = os.path.join(os.path.dirname(__file__), 'network-configuration.json') network_config_path = os.path.join(os.path.dirname(__file__), 'network-configuration.json')
from common.tools import config_get from ..tools import config_get
if_config = config_get(network_config_path, [info.release_codename]) if_config = config_get(network_config_path, [info.release_codename])
interfaces_path = os.path.join(info.root, 'etc/network/interfaces') interfaces_path = os.path.join(info.root, 'etc/network/interfaces')

View file

@ -1,7 +1,7 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
from common.tasks import apt import apt
from common.tools import log_check_call from ..tools import log_check_call
class AddManifestPackages(Task): class AddManifestPackages(Task):
@ -41,7 +41,7 @@ class InstallPackages(Task):
@classmethod @classmethod
def install_remote(cls, info, remote_packages): def install_remote(cls, info, remote_packages):
import os import os
from common.tools import log_check_call from ..tools import log_check_call
from subprocess import CalledProcessError from subprocess import CalledProcessError
try: try:
env = os.environ.copy() env = os.environ.copy()

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
import filesystem import filesystem
import host import host
import volume import volume
@ -12,7 +12,7 @@ class AddRequiredCommands(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from base.fs.partitionmaps.none import NoPartitions from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
if not isinstance(info.volume.partition_map, NoPartitions): if not isinstance(info.volume.partition_map, NoPartitions):
info.host_dependencies['parted'] = 'parted' info.host_dependencies['parted'] = 'parted'
info.host_dependencies['kpartx'] = 'kpartx' info.host_dependencies['kpartx'] = 'kpartx'

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
import os.path import os.path
@ -9,7 +9,7 @@ class EnableShadowConfig(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import log_check_call from ..tools import log_check_call
log_check_call(['chroot', info.root, 'shadowconfig', 'on']) log_check_call(['chroot', info.root, 'shadowconfig', 'on'])
@ -19,7 +19,7 @@ class DisableSSHPasswordAuthentication(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import sed_i from ..tools import sed_i
sshd_config_path = os.path.join(info.root, 'etc/ssh/sshd_config') sshd_config_path = os.path.join(info.root, 'etc/ssh/sshd_config')
sed_i(sshd_config_path, '^#PasswordAuthentication yes', 'PasswordAuthentication no') sed_i(sshd_config_path, '^#PasswordAuthentication yes', 'PasswordAuthentication no')

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
from common.tasks import workspace import workspace
class Attach(Task): class Attach(Task):

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from .. import phases
class CreateWorkspace(Task): class CreateWorkspace(Task):

View file

@ -8,7 +8,7 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import tasks import tasks
from providers.ec2.tasks import initd from bootstrapvz.providers.ec2.tasks import initd
if initd.AddEC2InitScripts in taskset: if initd.AddEC2InitScripts in taskset:
taskset.add(tasks.AdminUserCredentials) taskset.add(tasks.AdminUserCredentials)

View file

@ -1,7 +1,7 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks.initd import InstallInitScripts from bootstrapvz.common.tasks.initd import InstallInitScripts
from common.tasks import apt from bootstrapvz.common.tasks import apt
import os import os
@ -21,7 +21,7 @@ class CreateAdminUser(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
log_check_call(['chroot', info.root, log_check_call(['chroot', info.root,
'useradd', 'useradd',
'--create-home', '--shell', '/bin/bash', '--create-home', '--shell', '/bin/bash',
@ -50,7 +50,7 @@ class AdminUserCredentials(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import sed_i from bootstrapvz.common.tools import sed_i
getcreds_path = os.path.join(info.root, 'etc/init.d/ec2-get-credentials') getcreds_path = os.path.join(info.root, 'etc/init.d/ec2-get-credentials')
username = info.manifest.plugins['admin_user']['username'] username = info.manifest.plugins['admin_user']['username']
sed_i(getcreds_path, 'username=\'root\'', 'username=\'{username}\''.format(username=username)) sed_i(getcreds_path, 'username=\'root\'', 'username=\'{username}\''.format(username=username))
@ -63,11 +63,11 @@ class DisableRootLogin(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from subprocess import CalledProcessError from subprocess import CalledProcessError
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
try: try:
log_check_call(['chroot', info.root, log_check_call(['chroot', info.root,
'dpkg-query', '-W', 'openssh-server']) 'dpkg-query', '-W', 'openssh-server'])
from common.tools import sed_i from bootstrapvz.common.tools import sed_i
sshdconfig_path = os.path.join(info.root, 'etc/ssh/sshd_config') sshdconfig_path = os.path.join(info.root, 'etc/ssh/sshd_config')
sed_i(sshdconfig_path, 'PermitRootLogin yes', 'PermitRootLogin no') sed_i(sshdconfig_path, 'PermitRootLogin yes', 'PermitRootLogin no')
except CalledProcessError: except CalledProcessError:

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
class WriteMetadata(Task): class WriteMetadata(Task):

View file

@ -8,8 +8,8 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import tasks import tasks
import providers.ec2.tasks.initd as initd_ec2 import bootstrapvz.providers.ec2.tasks.initd as initd_ec2
from common.tasks import initd from bootstrapvz.common.tasks import initd
if manifest.system['release'] in ['wheezy', 'stable']: if manifest.system['release'] in ['wheezy', 'stable']:
taskset.add(tasks.AddBackports) taskset.add(tasks.AddBackports)

View file

@ -1,7 +1,7 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from common.tasks import apt from bootstrapvz.common.tasks import apt
import os.path import os.path
@ -40,7 +40,7 @@ class SetUsername(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import sed_i from bootstrapvz.common.tools import sed_i
cloud_cfg = os.path.join(info.root, 'etc/cloud/cloud.cfg') cloud_cfg = os.path.join(info.root, 'etc/cloud/cloud.cfg')
username = info.manifest.plugins['cloud_init']['username'] username = info.manifest.plugins['cloud_init']['username']
search = '^ name: debian$' search = '^ name: debian$'

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
class ImageExecuteCommand(Task): class ImageExecuteCommand(Task):
@ -8,7 +8,7 @@ class ImageExecuteCommand(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
for raw_command in info.manifest.plugins['image_commands']['commands']: for raw_command in info.manifest.plugins['image_commands']['commands']:
command = map(lambda part: part.format(root=info.root, **info.manifest_vars), raw_command) command = map(lambda part: part.format(root=info.root, **info.manifest_vars), raw_command)
log_check_call(command) log_check_call(command)

View file

@ -1,11 +1,11 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks import apt from bootstrapvz.common.tasks import apt
from common.tasks import bootstrap from bootstrapvz.common.tasks import bootstrap
from common.tasks import filesystem from bootstrapvz.common.tasks import filesystem
from common.tasks import host from bootstrapvz.common.tasks import host
from common.tasks import partitioning from bootstrapvz.common.tasks import partitioning
from common.tasks import volume from bootstrapvz.common.tasks import volume
import os import os
folders = ['tmp', 'var/lib/apt/lists'] folders = ['tmp', 'var/lib/apt/lists']
@ -69,7 +69,7 @@ class Zerofree(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
log_check_call(['zerofree', info.volume.partition_map.root.device_path]) log_check_call(['zerofree', info.volume.partition_map.root.device_path])
@ -80,5 +80,5 @@ class ShrinkVolume(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
log_check_call(['/usr/bin/vmware-vdiskmanager', '-k', info.volume.image_path]) log_check_call(['/usr/bin/vmware-vdiskmanager', '-k', info.volume.image_path])

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common.tasks import apt from bootstrapvz.common.tasks import apt
from common import phases from bootstrapvz.common import phases
import os import os

View file

@ -2,15 +2,15 @@ from tasks import Snapshot
from tasks import CopyImage from tasks import CopyImage
from tasks import CreateFromSnapshot from tasks import CreateFromSnapshot
from tasks import CreateFromImage from tasks import CreateFromImage
from providers.ec2.tasks import ebs from bootstrapvz.providers.ec2.tasks import ebs
from providers.virtualbox.tasks import guest_additions from bootstrapvz.providers.virtualbox.tasks import guest_additions
from common.tasks import loopback from bootstrapvz.common.tasks import loopback
from common.tasks import volume from bootstrapvz.common.tasks import volume
from common.tasks import locale from bootstrapvz.common.tasks import locale
from common.tasks import apt from bootstrapvz.common.tasks import apt
from common.tasks import bootstrap from bootstrapvz.common.tasks import bootstrap
from common.tasks import filesystem from bootstrapvz.common.tasks import filesystem
from common.tasks import partitioning from bootstrapvz.common.tasks import partitioning
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):

View file

@ -1,10 +1,10 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks import volume from bootstrapvz.common.tasks import volume
from common.tasks import packages from bootstrapvz.common.tasks import packages
from providers.virtualbox.tasks import guest_additions from bootstrapvz.providers.virtualbox.tasks import guest_additions
from providers.ec2.tasks import ebs from bootstrapvz.providers.ec2.tasks import ebs
from common.fs import remount from bootstrapvz.common.fs import remount
from shutil import copyfile from shutil import copyfile
import os.path import os.path
import time import time
@ -81,7 +81,7 @@ def set_fs_states(volume):
p_map = volume.partition_map p_map = volume.partition_map
partitions_state = 'attached' partitions_state = 'attached'
from base.fs.partitionmaps.none import NoPartitions from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
if isinstance(p_map, NoPartitions): if isinstance(p_map, NoPartitions):
partitions_state = 'formatted' partitions_state = 'formatted'
else: else:

View file

@ -1,7 +1,7 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks import apt from bootstrapvz.common.tasks import apt
from common.tasks import network from bootstrapvz.common.tasks import network
import os import os
@ -11,7 +11,7 @@ class CheckAssetsPath(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.exceptions import TaskError from bootstrapvz.common.exceptions import TaskError
assets = info.manifest.plugins['puppet']['assets'] assets = info.manifest.plugins['puppet']['assets']
if not os.path.exists(assets): if not os.path.exists(assets):
msg = 'The assets directory {assets} does not exist.'.format(assets=assets) msg = 'The assets directory {assets} does not exist.'.format(assets=assets)
@ -27,7 +27,7 @@ class CheckManifestPath(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.exceptions import TaskError from bootstrapvz.common.exceptions import TaskError
manifest = info.manifest.plugins['puppet']['manifest'] manifest = info.manifest.plugins['puppet']['manifest']
if not os.path.exists(manifest): if not os.path.exists(manifest):
msg = 'The manifest file {manifest} does not exist.'.format(manifest=manifest) msg = 'The manifest file {manifest} does not exist.'.format(manifest=manifest)
@ -77,12 +77,12 @@ class ApplyPuppetManifest(Task):
copy(pp_manifest, manifest_dst) copy(pp_manifest, manifest_dst)
manifest_path = os.path.join('/', manifest_rel_dst) manifest_path = os.path.join('/', manifest_rel_dst)
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
log_check_call(['chroot', info.root, log_check_call(['chroot', info.root,
'puppet', 'apply', manifest_path]) 'puppet', 'apply', manifest_path])
os.remove(manifest_dst) os.remove(manifest_dst)
from common.tools import sed_i from bootstrapvz.common.tools import sed_i
hosts_path = os.path.join(info.root, 'etc/hosts') hosts_path = os.path.join(info.root, 'etc/hosts')
sed_i(hosts_path, '127.0.0.1\s*{hostname}\n?'.format(hostname=hostname), '') sed_i(hosts_path, '127.0.0.1\s*{hostname}\n?'.format(hostname=hostname), '')

View file

@ -7,7 +7,7 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
from common.tasks.security import DisableSSHPasswordAuthentication from bootstrapvz.common.tasks.security import DisableSSHPasswordAuthentication
from tasks import SetRootPassword from tasks import SetRootPassword
taskset.discard(DisableSSHPasswordAuthentication) taskset.discard(DisableSSHPasswordAuthentication)
taskset.add(SetRootPassword) taskset.add(SetRootPassword)

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
class SetRootPassword(Task): class SetRootPassword(Task):
@ -8,6 +8,6 @@ class SetRootPassword(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
log_check_call(['chroot', info.root, 'chpasswd'], log_check_call(['chroot', info.root, 'chpasswd'],
'root:' + info.manifest.plugins['root_password']['password']) 'root:' + info.manifest.plugins['root_password']['password'])

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks import apt from bootstrapvz.common.tasks import apt
class AddUnattendedUpgradesPackage(Task): class AddUnattendedUpgradesPackage(Task):

View file

@ -8,14 +8,14 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
from common.tasks import security from bootstrapvz.common.tasks import security
from common.tasks import loopback from bootstrapvz.common.tasks import loopback
from common.tasks import network from bootstrapvz.common.tasks import network
taskset.discard(security.DisableSSHPasswordAuthentication) taskset.discard(security.DisableSSHPasswordAuthentication)
taskset.discard(loopback.MoveImage) taskset.discard(loopback.MoveImage)
taskset.discard(network.RemoveHostname) taskset.discard(network.RemoveHostname)
from common.tasks import volume from bootstrapvz.common.tasks import volume
taskset.update([tasks.CheckBoxPath, taskset.update([tasks.CheckBoxPath,
tasks.CreateVagrantBoxDir, tasks.CreateVagrantBoxDir,
tasks.AddPackages, tasks.AddPackages,

View file

@ -1,7 +1,7 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks import workspace from bootstrapvz.common.tasks import workspace
from common.tasks import apt from bootstrapvz.common.tasks import apt
import os import os
import shutil import shutil
@ -18,7 +18,7 @@ class CheckBoxPath(Task):
box_name = '{name}.box'.format(name=box_basename) box_name = '{name}.box'.format(name=box_basename)
box_path = os.path.join(info.manifest.bootstrapper['workspace'], box_name) box_path = os.path.join(info.manifest.bootstrapper['workspace'], box_name)
if os.path.exists(box_path): if os.path.exists(box_path):
from common.exceptions import TaskError from bootstrapvz.common.exceptions import TaskError
msg = 'The vagrant box `{name}\' already exists at `{path}\''.format(name=box_name, path=box_path) msg = 'The vagrant box `{name}\' already exists at `{path}\''.format(name=box_name, path=box_path)
raise TaskError(msg) raise TaskError(msg)
info.vagrant = {'box_name': box_name, info.vagrant = {'box_name': box_name,
@ -60,7 +60,7 @@ class SetHostname(Task):
hostname_file.write(hostname) hostname_file.write(hostname)
hosts_path = os.path.join(info.root, 'etc/hosts') hosts_path = os.path.join(info.root, 'etc/hosts')
from common.tools import sed_i from bootstrapvz.common.tools import sed_i
sed_i(hosts_path, '^127.0.0.1\tlocalhost$', '127.0.0.1\tlocalhost\n127.0.0.1\t' + hostname) sed_i(hosts_path, '^127.0.0.1\tlocalhost$', '127.0.0.1\tlocalhost\n127.0.0.1\t' + hostname)
@ -70,7 +70,7 @@ class CreateVagrantUser(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
log_check_call(['chroot', info.root, log_check_call(['chroot', info.root,
'useradd', 'useradd',
'--create-home', '--shell', '/bin/bash', '--create-home', '--shell', '/bin/bash',
@ -114,7 +114,7 @@ class AddInsecurePublicKey(Task):
os.chmod(authorized_keys_path, stat.S_IRUSR | stat.S_IWUSR) os.chmod(authorized_keys_path, stat.S_IRUSR | stat.S_IWUSR)
# We can't do this directly with python, since getpwnam gets its info from the host # We can't do this directly with python, since getpwnam gets its info from the host
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
log_check_call(['chroot', info.root, log_check_call(['chroot', info.root,
'chown', 'vagrant:vagrant', 'chown', 'vagrant:vagrant',
'/home/vagrant/.ssh', '/home/vagrant/.ssh/authorized_keys']) '/home/vagrant/.ssh', '/home/vagrant/.ssh/authorized_keys'])
@ -126,7 +126,7 @@ class SetRootPassword(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
log_check_call(['chroot', info.root, 'chpasswd'], 'root:vagrant') log_check_call(['chroot', info.root, 'chpasswd'], 'root:vagrant')
@ -142,14 +142,14 @@ class PackageBox(Task):
import random import random
mac_address = '080027{mac:06X}'.format(mac=random.randrange(16 ** 6)) mac_address = '080027{mac:06X}'.format(mac=random.randrange(16 ** 6))
from common.tools import sed_i from bootstrapvz.common.tools import sed_i
sed_i(vagrantfile, '\\[MAC_ADDRESS\\]', mac_address) sed_i(vagrantfile, '\\[MAC_ADDRESS\\]', mac_address)
metadata_source = os.path.join(assets, 'metadata.json') metadata_source = os.path.join(assets, 'metadata.json')
metadata = os.path.join(info.vagrant['folder'], 'metadata.json') metadata = os.path.join(info.vagrant['folder'], 'metadata.json')
shutil.copy(metadata_source, metadata) shutil.copy(metadata_source, metadata)
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
disk_name = 'box-disk1.{ext}'.format(ext=info.volume.extension) disk_name = 'box-disk1.{ext}'.format(ext=info.volume.extension)
disk_link = os.path.join(info.vagrant['folder'], disk_name) disk_link = os.path.join(info.vagrant['folder'], disk_name)
log_check_call(['ln', '-s', info.volume.image_path, disk_link]) log_check_call(['ln', '-s', info.volume.image_path, disk_link])

View file

@ -7,17 +7,17 @@ import tasks.filesystem
import tasks.boot import tasks.boot
import tasks.network import tasks.network
import tasks.initd import tasks.initd
from common.tasks import volume from bootstrapvz.common.tasks import volume
from common.tasks import filesystem from bootstrapvz.common.tasks import filesystem
from common.tasks import boot from bootstrapvz.common.tasks import boot
from common.tasks import network from bootstrapvz.common.tasks import network
from common.tasks import initd from bootstrapvz.common.tasks import initd
from common.tasks import partitioning from bootstrapvz.common.tasks import partitioning
from common.tasks import loopback from bootstrapvz.common.tasks import loopback
from common.tasks import bootstrap from bootstrapvz.common.tasks import bootstrap
from common.tasks import security from bootstrapvz.common.tasks import security
from common.tasks import cleanup from bootstrapvz.common.tasks import cleanup
from common.tasks import workspace from bootstrapvz.common.tasks import workspace
def initialize(): def initialize():
@ -30,7 +30,7 @@ def validate_manifest(data, validator, error):
import os.path import os.path
validator(data, os.path.join(os.path.dirname(__file__), 'manifest-schema.json')) validator(data, os.path.join(os.path.dirname(__file__), 'manifest-schema.json'))
from common.bytes import Bytes from bootstrapvz.common.bytes import Bytes
if data['volume']['backing'] == 'ebs': if data['volume']['backing'] == 'ebs':
volume_size = Bytes(0) volume_size = Bytes(0)
for key, partition in data['volume']['partitions'].iteritems(): for key, partition in data['volume']['partitions'].iteritems():
@ -51,15 +51,15 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import common.task_sets from bootstrapvz.common import task_sets
taskset.update(common.task_sets.base_set) taskset.update(task_sets.base_set)
taskset.update(common.task_sets.mounting_set) taskset.update(task_sets.mounting_set)
taskset.update(common.task_sets.get_apt_set(manifest)) taskset.update(task_sets.get_apt_set(manifest))
taskset.update(common.task_sets.locale_set) taskset.update(task_sets.locale_set)
taskset.update(common.task_sets.ssh_set) taskset.update(task_sets.ssh_set)
if manifest.volume['partitions']['type'] != 'none': if manifest.volume['partitions']['type'] != 'none':
taskset.update(common.task_sets.partitioning_set) taskset.update(task_sets.partitioning_set)
taskset.update([tasks.host.AddExternalCommands, taskset.update([tasks.host.AddExternalCommands,
tasks.packages.DefaultPackages, tasks.packages.DefaultPackages,
@ -91,7 +91,7 @@ def resolve_tasks(taskset, manifest):
taskset.add(boot.AddGrubPackage) taskset.add(boot.AddGrubPackage)
taskset.add(tasks.boot.ConfigurePVGrub) taskset.add(tasks.boot.ConfigurePVGrub)
else: else:
taskset.update(common.task_sets.bootloader_set.get(manifest.system['bootloader'])) taskset.update(task_sets.bootloader_set.get(manifest.system['bootloader']))
backing_specific_tasks = {'ebs': [tasks.ebs.Create, backing_specific_tasks = {'ebs': [tasks.ebs.Create,
tasks.ebs.Attach, tasks.ebs.Attach,
@ -113,10 +113,10 @@ def resolve_tasks(taskset, manifest):
if manifest.bootstrapper.get('tarball', False): if manifest.bootstrapper.get('tarball', False):
taskset.add(bootstrap.MakeTarball) taskset.add(bootstrap.MakeTarball)
taskset.update(common.task_sets.get_fs_specific_set(manifest.volume['partitions'])) taskset.update(task_sets.get_fs_specific_set(manifest.volume['partitions']))
if 'boot' in manifest.volume['partitions']: if 'boot' in manifest.volume['partitions']:
taskset.update(common.task_sets.boot_partition_set) taskset.update(task_sets.boot_partition_set)
def resolve_rollback_tasks(taskset, manifest, counter_task): def resolve_rollback_tasks(taskset, manifest, counter_task):

View file

@ -1,5 +1,5 @@
from base.fs.volume import Volume from bootstrapvz.base.fs.volume import Volume
from base.fs.exceptions import VolumeError from bootstrapvz.base.fs.exceptions import VolumeError
import time import time

View file

@ -1,9 +1,9 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.exceptions import TaskError from bootstrapvz.common.exceptions import TaskError
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from ebs import Snapshot from ebs import Snapshot
from common.tasks import workspace from bootstrapvz.common.tasks import workspace
from connection import Connect from connection import Connect
from . import assets from . import assets
import os.path import os.path
@ -118,7 +118,7 @@ class RegisterAMI(Task):
else: else:
registration_params['virtualization_type'] = 'paravirtual' registration_params['virtualization_type'] = 'paravirtual'
akis_path = os.path.join(os.path.dirname(__file__), 'ami-akis.json') akis_path = os.path.join(os.path.dirname(__file__), 'ami-akis.json')
from common.tools import config_get from bootstrapvz.common.tools import config_get
registration_params['kernel_id'] = config_get(akis_path, [info.host['region'], registration_params['kernel_id'] = config_get(akis_path, [info.host['region'],
info.manifest.system['architecture']]) info.manifest.system['architecture']])

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from . import assets from . import assets
import os import os
@ -26,9 +26,9 @@ class ConfigurePVGrub(Task):
copy(script_src, script_dst) copy(script_src, script_dst)
os.chmod(script_dst, rwxr_xr_x) os.chmod(script_dst, rwxr_xr_x)
from base.fs.partitionmaps.none import NoPartitions from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
if not isinstance(info.volume.partition_map, NoPartitions): if not isinstance(info.volume.partition_map, NoPartitions):
from common.tools import sed_i from bootstrapvz.common.tools import sed_i
root_idx = info.volume.partition_map.root.get_index() root_idx = info.volume.partition_map.root.get_index()
grub_device = 'GRUB_DEVICE=/dev/xvda{idx}'.format(idx=root_idx) grub_device = 'GRUB_DEVICE=/dev/xvda{idx}'.format(idx=root_idx)
sed_i(script_dst, '^GRUB_DEVICE=/dev/xvda$', grub_device) sed_i(script_dst, '^GRUB_DEVICE=/dev/xvda$', grub_device)
@ -36,15 +36,15 @@ class ConfigurePVGrub(Task):
sed_i(script_dst, '^\troot \(hd0\)$', grub_root) sed_i(script_dst, '^\troot \(hd0\)$', grub_root)
if info.manifest.volume['backing'] == 's3': if info.manifest.volume['backing'] == 's3':
from common.tools import sed_i from bootstrapvz.common.tools import sed_i
sed_i(script_dst, '^GRUB_DEVICE=/dev/xvda$', 'GRUB_DEVICE=/dev/xvda1') sed_i(script_dst, '^GRUB_DEVICE=/dev/xvda$', 'GRUB_DEVICE=/dev/xvda1')
from common.tools import sed_i from bootstrapvz.common.tools import sed_i
grub_def = os.path.join(info.root, 'etc/default/grub') grub_def = os.path.join(info.root, 'etc/default/grub')
sed_i(grub_def, '^GRUB_TIMEOUT=[0-9]+', 'GRUB_TIMEOUT=0\n' sed_i(grub_def, '^GRUB_TIMEOUT=[0-9]+', 'GRUB_TIMEOUT=0\n'
'GRUB_HIDDEN_TIMEOUT=true') 'GRUB_HIDDEN_TIMEOUT=true')
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
log_check_call(['chroot', info.root, 'update-grub']) log_check_call(['chroot', info.root, 'update-grub'])
log_check_call(['chroot', info.root, log_check_call(['chroot', info.root,
'ln', '--symbolic', '/boot/grub/grub.cfg', '/boot/grub/menu.lst']) 'ln', '--symbolic', '/boot/grub/grub.cfg', '/boot/grub/menu.lst'])

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
import host import host

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
class Create(Task): class Create(Task):

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
class S3FStab(Task): class S3FStab(Task):

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks import host from bootstrapvz.common.tasks import host
class AddExternalCommands(Task): class AddExternalCommands(Task):

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks import initd from bootstrapvz.common.tasks import initd
from . import assets from . import assets
import os.path import os.path

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks import apt from bootstrapvz.common.tasks import apt
import os.path import os.path
@ -12,7 +12,7 @@ class EnableDHCPCDDNS(Task):
def run(cls, info): def run(cls, info):
# The dhcp client that ships with debian sets the DNS servers per default. # The dhcp client that ships with debian sets the DNS servers per default.
# For dhcpcd we need to configure it to do that. # For dhcpcd we need to configure it to do that.
from common.tools import sed_i from bootstrapvz.common.tools import sed_i
dhcpcd = os.path.join(info.root, 'etc/default/dhcpcd') dhcpcd = os.path.join(info.root, 'etc/default/dhcpcd')
sed_i(dhcpcd, '^#*SET_DNS=.*', 'SET_DNS=\'yes\'') sed_i(dhcpcd, '^#*SET_DNS=.*', 'SET_DNS=\'yes\'')
@ -39,7 +39,7 @@ class InstallEnhancedNetworking(Task):
import urllib import urllib
urllib.urlretrieve(drivers_url, archive) urllib.urlretrieve(drivers_url, archive)
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
log_check_call('tar', '--ungzip', log_check_call('tar', '--ungzip',
'--extract', '--extract',
'--file', archive, '--file', archive,

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks import apt from bootstrapvz.common.tasks import apt
class DefaultPackages(Task): class DefaultPackages(Task):
@ -19,7 +19,7 @@ class DefaultPackages(Task):
import os.path import os.path
kernel_packages_path = os.path.join(os.path.dirname(__file__), 'packages-kernels.json') kernel_packages_path = os.path.join(os.path.dirname(__file__), 'packages-kernels.json')
from common.tools import config_get from bootstrapvz.common.tools import config_get
kernel_package = config_get(kernel_packages_path, [info.release_codename, kernel_package = config_get(kernel_packages_path, [info.release_codename,
info.manifest.system['architecture']]) info.manifest.system['architecture']])
info.packages.add(kernel_package) info.packages.add(kernel_package)

View file

@ -1,14 +1,14 @@
import tasks.packages import tasks.packages
from common.tasks import volume from bootstrapvz.common.tasks import volume
from common.tasks import loopback from bootstrapvz.common.tasks import loopback
from common.tasks import partitioning from bootstrapvz.common.tasks import partitioning
from common.tasks import filesystem from bootstrapvz.common.tasks import filesystem
from common.tasks import bootstrap from bootstrapvz.common.tasks import bootstrap
from common.tasks import security from bootstrapvz.common.tasks import security
from common.tasks import network from bootstrapvz.common.tasks import network
from common.tasks import initd from bootstrapvz.common.tasks import initd
from common.tasks import cleanup from bootstrapvz.common.tasks import cleanup
from common.tasks import workspace from bootstrapvz.common.tasks import workspace
def initialize(): def initialize():
@ -25,17 +25,17 @@ def validate_manifest(data, validator, error):
def resolve_tasks(tasklist, manifest): def resolve_tasks(tasklist, manifest):
import common.task_sets from bootstrapvz.common import task_sets
tasklist.update(common.task_sets.base_set) tasklist.update(task_sets.base_set)
tasklist.update(common.task_sets.volume_set) tasklist.update(task_sets.volume_set)
tasklist.update(common.task_sets.mounting_set) tasklist.update(task_sets.mounting_set)
tasklist.update(common.task_sets.get_apt_set(manifest)) tasklist.update(task_sets.get_apt_set(manifest))
tasklist.update(common.task_sets.locale_set) tasklist.update(task_sets.locale_set)
tasklist.update(common.task_sets.bootloader_set.get(manifest.system['bootloader'])) tasklist.update(task_sets.bootloader_set.get(manifest.system['bootloader']))
if manifest.volume['partitions']['type'] != 'none': if manifest.volume['partitions']['type'] != 'none':
tasklist.update(common.task_sets.partitioning_set) tasklist.update(task_sets.partitioning_set)
tasklist.update([tasks.packages.DefaultPackages, tasklist.update([tasks.packages.DefaultPackages,
@ -60,10 +60,10 @@ def resolve_tasks(tasklist, manifest):
from tasks import virtio from tasks import virtio
tasklist.update([virtio.VirtIO]) tasklist.update([virtio.VirtIO])
tasklist.update(common.task_sets.get_fs_specific_set(manifest.volume['partitions'])) tasklist.update(task_sets.get_fs_specific_set(manifest.volume['partitions']))
if 'boot' in manifest.volume['partitions']: if 'boot' in manifest.volume['partitions']:
tasklist.update(common.task_sets.boot_partition_set) tasklist.update(task_sets.boot_partition_set)
def resolve_rollback_tasks(tasklist, manifest, counter_task): def resolve_rollback_tasks(tasklist, manifest, counter_task):

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks import apt from bootstrapvz.common.tasks import apt
class DefaultPackages(Task): class DefaultPackages(Task):

View file

@ -1,5 +1,5 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
import os import os

View file

@ -1,14 +1,14 @@
import tasks.packages import tasks.packages
from common.tasks import volume from bootstrapvz.common.tasks import volume
from common.tasks import loopback from bootstrapvz.common.tasks import loopback
from common.tasks import partitioning from bootstrapvz.common.tasks import partitioning
from common.tasks import filesystem from bootstrapvz.common.tasks import filesystem
from common.tasks import bootstrap from bootstrapvz.common.tasks import bootstrap
from common.tasks import security from bootstrapvz.common.tasks import security
from common.tasks import network from bootstrapvz.common.tasks import network
from common.tasks import initd from bootstrapvz.common.tasks import initd
from common.tasks import cleanup from bootstrapvz.common.tasks import cleanup
from common.tasks import workspace from bootstrapvz.common.tasks import workspace
def initialize(): def initialize():
@ -25,17 +25,17 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import common.task_sets from bootstrapvz.common import task_sets
taskset.update(common.task_sets.base_set) taskset.update(task_sets.base_set)
taskset.update(common.task_sets.volume_set) taskset.update(task_sets.volume_set)
taskset.update(common.task_sets.mounting_set) taskset.update(task_sets.mounting_set)
taskset.update(common.task_sets.get_apt_set(manifest)) taskset.update(task_sets.get_apt_set(manifest))
taskset.update(common.task_sets.locale_set) taskset.update(task_sets.locale_set)
taskset.update(common.task_sets.bootloader_set.get(manifest.system['bootloader'])) taskset.update(task_sets.bootloader_set.get(manifest.system['bootloader']))
if manifest.volume['partitions']['type'] != 'none': if manifest.volume['partitions']['type'] != 'none':
taskset.update(common.task_sets.partitioning_set) taskset.update(task_sets.partitioning_set)
taskset.update([tasks.packages.DefaultPackages, taskset.update([tasks.packages.DefaultPackages,
@ -63,10 +63,10 @@ def resolve_tasks(taskset, manifest):
if manifest.bootstrapper.get('tarball', False): if manifest.bootstrapper.get('tarball', False):
taskset.add(bootstrap.MakeTarball) taskset.add(bootstrap.MakeTarball)
taskset.update(common.task_sets.get_fs_specific_set(manifest.volume['partitions'])) taskset.update(task_sets.get_fs_specific_set(manifest.volume['partitions']))
if 'boot' in manifest.volume['partitions']: if 'boot' in manifest.volume['partitions']:
taskset.update(common.task_sets.boot_partition_set) taskset.update(task_sets.boot_partition_set)
def resolve_rollback_tasks(taskset, manifest, counter_task): def resolve_rollback_tasks(taskset, manifest, counter_task):

View file

@ -1,7 +1,7 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks.packages import InstallPackages from bootstrapvz.common.tasks.packages import InstallPackages
from common.exceptions import TaskError from bootstrapvz.common.exceptions import TaskError
class CheckGuestAdditionsPath(Task): class CheckGuestAdditionsPath(Task):
@ -28,7 +28,7 @@ class AddGuestAdditionsPackages(Task):
info.packages.add('build-essential') info.packages.add('build-essential')
info.packages.add('dkms') info.packages.add('dkms')
from common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
[kernel_version] = log_check_call(['chroot', info.root, [kernel_version] = log_check_call(['chroot', info.root,
'uname', '-r']) 'uname', '-r'])
kernel_headers_pkg = 'linux-headers-{version}'.format(version=kernel_version) kernel_headers_pkg = 'linux-headers-{version}'.format(version=kernel_version)
@ -52,7 +52,7 @@ class InstallGuestAdditions(Task):
install_script = os.path.join('/', mount_dir, 'VBoxLinuxAdditions.run') install_script = os.path.join('/', mount_dir, 'VBoxLinuxAdditions.run')
# Don't check the return code of the scripts here, because 1 not necessarily means they have failed # Don't check the return code of the scripts here, because 1 not necessarily means they have failed
from common.tools import log_call from bootstrapvz.common.tools import log_call
log_call(['chroot', info.root, install_script, '--nox11']) log_call(['chroot', info.root, install_script, '--nox11'])
# VBoxService process could be running, as it is not affected by DisableDaemonAutostart # VBoxService process could be running, as it is not affected by DisableDaemonAutostart
log_call(['chroot', info.root, 'service', 'vboxadd-service', 'stop']) log_call(['chroot', info.root, 'service', 'vboxadd-service', 'stop'])

View file

@ -1,6 +1,6 @@
from base import Task from bootstrapvz.base import Task
from common import phases from bootstrapvz.common import phases
from common.tasks import apt from bootstrapvz.common.tasks import apt
class DefaultPackages(Task): class DefaultPackages(Task):