mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 09:50:37 +00:00
Properly fix imports and make bootstrapvz work like a package
This commit is contained in:
parent
2279da3cef
commit
bbb06d717e
74 changed files with 320 additions and 323 deletions
5
bootstrap-vz
Executable file
5
bootstrap-vz
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
if __name__ == '__main__':
|
||||
from bootstrapvz.base import main
|
||||
main()
|
|
@ -1,8 +1,3 @@
|
|||
|
||||
|
||||
__version__ = '0.9'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from base import main
|
||||
sys.exit(main())
|
||||
|
|
|
@ -35,7 +35,7 @@ class BootstrapInformation(object):
|
|||
# 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.
|
||||
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']])
|
||||
|
||||
class DictClass(dict):
|
||||
|
|
|
@ -9,10 +9,10 @@ def load_volume(data, bootloader):
|
|||
Returns:
|
||||
Volume. The volume that represents all information pertaining to the volume we bootstrap on
|
||||
"""
|
||||
from ...common.fs.loopbackvolume import LoopbackVolume
|
||||
from ...providers.ec2.ebsvolume import EBSVolume
|
||||
from ...common.fs.virtualdiskimage import VirtualDiskImage
|
||||
from ...common.fs.virtualmachinedisk import VirtualMachineDisk
|
||||
from bootstrapvz.common.fs.loopbackvolume import LoopbackVolume
|
||||
from bootstrapvz.providers.ec2.ebsvolume import EBSVolume
|
||||
from bootstrapvz.common.fs.virtualdiskimage import VirtualDiskImage
|
||||
from bootstrapvz.common.fs.virtualmachinedisk import VirtualMachineDisk
|
||||
# Create a mapping between valid partition maps in the manifest and their corresponding classes
|
||||
from partitionmaps.gpt import GPTPartitionMap
|
||||
from partitionmaps.msdos import MSDOSPartitionMap
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from abc import ABCMeta
|
||||
from abc import abstractmethod
|
||||
from ....common.tools import log_check_call
|
||||
from ....common.fsm_proxy import FSMProxy
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
from bootstrapvz.common.fsm_proxy import FSMProxy
|
||||
from ..exceptions import PartitionError
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from abstract import AbstractPartitionMap
|
||||
from ..partitions.gpt import GPTPartition
|
||||
from ..partitions.gpt_swap import GPTSwapPartition
|
||||
from ....common.tools import log_check_call
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
|
||||
|
||||
class GPTPartitionMap(AbstractPartitionMap):
|
||||
|
@ -14,7 +14,7 @@ class GPTPartitionMap(AbstractPartitionMap):
|
|||
data (dict): volume.partitions part of the manifest
|
||||
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
|
||||
self.partitions = []
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from abstract import AbstractPartitionMap
|
||||
from ..partitions.msdos import MSDOSPartition
|
||||
from ..partitions.msdos_swap import MSDOSSwapPartition
|
||||
from ....common.tools import log_check_call
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
|
||||
|
||||
class MSDOSPartitionMap(AbstractPartitionMap):
|
||||
|
@ -15,7 +15,7 @@ class MSDOSPartitionMap(AbstractPartitionMap):
|
|||
data (dict): volume.partitions part of the manifest
|
||||
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
|
||||
self.partitions = []
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class NoPartitions(object):
|
|||
data (dict): volume.partitions part of the manifest
|
||||
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'
|
||||
self.root = SinglePartition(Bytes(data['root']['size']),
|
||||
data['root']['filesystem'], data['root'].get('format_command', None))
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from abc import ABCMeta
|
||||
from abc import abstractmethod
|
||||
import os.path
|
||||
from ....common.tools import log_check_call
|
||||
from ....common.fsm_proxy import FSMProxy
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
from bootstrapvz.common.fsm_proxy import FSMProxy
|
||||
|
||||
|
||||
class AbstractPartition(FSMProxy):
|
||||
|
|
|
@ -29,7 +29,7 @@ class BasePartition(AbstractPartition):
|
|||
# By saving the previous partition we have
|
||||
# a linked list that partitions can go backwards in to find the first partition.
|
||||
self.previous = previous
|
||||
from common.bytes import Bytes
|
||||
from bootstrapvz.common.bytes import Bytes
|
||||
# Initialize the offset to 0 bytes, may be changed later
|
||||
self.offset = Bytes(0)
|
||||
# List of flags that parted should put on the partition
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from ....common.tools import log_check_call
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
from base import BasePartition
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from ....common.tools import log_check_call
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
from gpt import GPTPartition
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from ....common.tools import log_check_call
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
from msdos import MSDOSPartition
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,6 @@ class SinglePartition(AbstractPartition):
|
|||
Returns:
|
||||
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
|
||||
return Bytes(0)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from abc import ABCMeta
|
||||
from ...common.fsm_proxy import FSMProxy
|
||||
from ...common.tools import log_check_call
|
||||
from bootstrapvz.common.fsm_proxy import FSMProxy
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
from .exceptions import VolumeError
|
||||
from partitionmaps.none import NoPartitions
|
||||
|
||||
|
@ -90,7 +90,7 @@ class Volume(FSMProxy):
|
|||
VolumeError
|
||||
"""
|
||||
import os.path
|
||||
from ...common.fs import get_partitions
|
||||
from bootstrapvz.common.fs import get_partitions
|
||||
# Fetch information from /proc/partitions
|
||||
proc_partitions = get_partitions()
|
||||
device_name = os.path.basename(self.device_path)
|
||||
|
|
|
@ -3,7 +3,7 @@ to determine which tasks should be added to the tasklist, what arguments various
|
|||
invocations should have etc..
|
||||
.. module:: manifest
|
||||
"""
|
||||
from ..common.tools import load_json
|
||||
from bootstrapvz.common.tools import load_json
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -36,7 +36,7 @@ class Manifest(object):
|
|||
# It strips comments (which are invalid in strict json) before loading the data.
|
||||
self.data = load_json(self.path)
|
||||
# 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))
|
||||
# Create a modules dict that contains the loaded provider and plugins
|
||||
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
|
||||
if 'plugins' in self.data:
|
||||
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))
|
||||
plugin = __import__(modname, fromlist=['plugins'])
|
||||
self.modules['plugins'].append(plugin)
|
||||
|
|
|
@ -18,7 +18,7 @@ class Phase(object):
|
|||
Returns:
|
||||
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)
|
||||
|
||||
def __cmp__(self, other):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
.. module:: tasklist
|
||||
"""
|
||||
|
||||
from ..common.exceptions import TaskListError
|
||||
from bootstrapvz.common.exceptions import TaskListError
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -63,7 +63,7 @@ class TaskList(object):
|
|||
def create_list(self):
|
||||
"""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
|
||||
tasks = self.get_all_tasks()
|
||||
# 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
|
||||
"""
|
||||
# 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)
|
||||
def is_task(obj):
|
||||
|
@ -121,11 +123,12 @@ class TaskList(object):
|
|||
return issubclass(obj, Task) and obj is not Task
|
||||
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
|
||||
|
||||
Args:
|
||||
path (str): Path to the package
|
||||
prefix (str): Name of the package followed by a dot
|
||||
|
||||
Returns:
|
||||
generator. A generator that yields classes
|
||||
|
@ -139,7 +142,7 @@ class TaskList(object):
|
|||
|
||||
def walk_error(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:
|
||||
module = importlib.import_module(module_name)
|
||||
classes = inspect.getmembers(module, inspect.isclass)
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
|
||||
if __name__ == '__main__' and __package__ is None:
|
||||
from base import main
|
||||
main()
|
|
@ -1,5 +1,5 @@
|
|||
from base.fs.volume import Volume
|
||||
from common.tools import log_check_call
|
||||
from bootstrapvz.base.fs.volume import Volume
|
||||
from ..tools import log_check_call
|
||||
|
||||
|
||||
class LoopbackVolume(Volume):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from common.fs.loopbackvolume import LoopbackVolume
|
||||
from base.fs.exceptions import VolumeError
|
||||
from common.tools import log_check_call
|
||||
from common.fs import get_partitions
|
||||
from loopbackvolume import LoopbackVolume
|
||||
from bootstrapvz.base.fs.exceptions import VolumeError
|
||||
from ..tools import log_check_call
|
||||
from . import get_partitions
|
||||
|
||||
|
||||
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])
|
||||
|
||||
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 not self._module_loaded('nbd'):
|
||||
msg = ('The kernel module `nbd\' must be loaded '
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from common.fs.qemuvolume import QEMUVolume
|
||||
from qemuvolume import QEMUVolume
|
||||
|
||||
|
||||
class VirtualDiskImage(QEMUVolume):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from common.fs.qemuvolume import QEMUVolume
|
||||
from qemuvolume import QEMUVolume
|
||||
|
||||
|
||||
class VirtualMachineDisk(QEMUVolume):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from base import Phase
|
||||
from bootstrapvz.base.phase import Phase
|
||||
|
||||
preparation = Phase('Preparation', 'Initializing connections, fetching data etc.')
|
||||
volume_creation = Phase('Volume creation', 'Creating the volume to bootstrap onto')
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
from common.tasks import workspace
|
||||
from common.tasks import packages
|
||||
from common.tasks import host
|
||||
from common.tasks import boot
|
||||
from common.tasks import bootstrap
|
||||
from common.tasks import volume
|
||||
from common.tasks import filesystem
|
||||
from common.tasks import partitioning
|
||||
from common.tasks import cleanup
|
||||
from common.tasks import apt
|
||||
from common.tasks import security
|
||||
from common.tasks import locale
|
||||
from tasks import workspace
|
||||
from tasks import packages
|
||||
from tasks import host
|
||||
from tasks import boot
|
||||
from tasks import bootstrap
|
||||
from tasks import volume
|
||||
from tasks import filesystem
|
||||
from tasks import partitioning
|
||||
from tasks import cleanup
|
||||
from tasks import apt
|
||||
from tasks import security
|
||||
from tasks import locale
|
||||
|
||||
base_set = [workspace.CreateWorkspace,
|
||||
bootstrap.AddRequiredCommands,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tools import log_check_call
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
from ..tools import log_check_call
|
||||
import locale
|
||||
import os
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import apt
|
||||
from common.tasks import filesystem
|
||||
from base.fs import partitionmaps
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
import apt
|
||||
import filesystem
|
||||
from bootstrapvz.base.fs import partitionmaps
|
||||
import os.path
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@ class DisableGetTTYs(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.tools import sed_i
|
||||
from ..tools import sed_i
|
||||
inittab_path = os.path.join(info.root, 'etc/inittab')
|
||||
tty1 = '1:2345:respawn:/sbin/getty 38400 tty1'
|
||||
sed_i(inittab_path, '^' + tty1, '#' + tty1)
|
||||
|
@ -65,13 +65,13 @@ class InstallGrub(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.fs.loopbackvolume import LoopbackVolume
|
||||
from common.tools import log_check_call
|
||||
from ..fs.loopbackvolume import LoopbackVolume
|
||||
from ..tools import log_check_call
|
||||
|
||||
boot_dir = os.path.join(info.root, 'boot')
|
||||
grub_dir = os.path.join(boot_dir, 'grub')
|
||||
|
||||
from common.fs import remount
|
||||
from ..fs import remount
|
||||
p_map = info.volume.partition_map
|
||||
|
||||
def link_fn():
|
||||
|
@ -136,7 +136,7 @@ class InstallExtLinux(Task):
|
|||
|
||||
@classmethod
|
||||
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):
|
||||
bootloader = '/usr/lib/syslinux/gptmbr.bin'
|
||||
else:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.exceptions import TaskError
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
from ..exceptions import TaskError
|
||||
import host
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -45,7 +45,7 @@ class MakeTarball(Task):
|
|||
if os.path.isfile(info.tarball):
|
||||
log.debug('Found matching tarball, skipping download')
|
||||
else:
|
||||
from common.tools import log_call
|
||||
from ..tools import log_call
|
||||
status, out, err = log_call(executable + options + ['--make-tarball=' + info.tarball] + arguments)
|
||||
if status != 1:
|
||||
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'):
|
||||
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)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
@ -28,7 +28,7 @@ class ShredHostkeys(Task):
|
|||
private = [os.path.join(info.root, 'etc/ssh', name) for name in ssh_hostkeys]
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
|
||||
|
||||
class TriggerRollback(Task):
|
||||
|
@ -9,5 +9,5 @@ class TriggerRollback(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.exceptions import TaskError
|
||||
from ..exceptions import TaskError
|
||||
raise TaskError('Trigger rollback')
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tools import log_check_call
|
||||
from bootstrap import Bootstrap
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
from ..tools import log_check_call
|
||||
import apt
|
||||
import bootstrap
|
||||
import host
|
||||
import volume
|
||||
|
||||
|
@ -102,7 +102,7 @@ class MountBoot(Task):
|
|||
class MountSpecials(Task):
|
||||
description = 'Mounting special block devices'
|
||||
phase = phases.os_installation
|
||||
predecessors = [Bootstrap]
|
||||
predecessors = [bootstrap.Bootstrap]
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.exceptions import TaskError
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
from ..exceptions import TaskError
|
||||
|
||||
|
||||
class CheckExternalCommands(Task):
|
||||
|
@ -9,7 +9,7 @@ class CheckExternalCommands(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.tools import log_check_call
|
||||
from ..tools import log_check_call
|
||||
from subprocess import CalledProcessError
|
||||
import re
|
||||
missing_packages = []
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.exceptions import TaskError
|
||||
from common.tools import log_check_call
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
from ..exceptions import TaskError
|
||||
from ..tools import log_check_call
|
||||
from . import assets
|
||||
import os.path
|
||||
|
||||
|
@ -86,7 +86,7 @@ class AdjustExpandRootScript(Task):
|
|||
from base.fs.partitionmaps.none import NoPartitions
|
||||
if not isinstance(info.volume.partition_map, NoPartitions):
|
||||
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')
|
||||
root_idx = info.volume.partition_map.root.get_index()
|
||||
device_path = 'device_path="/dev/xvda{idx}"'.format(idx=root_idx)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
import os.path
|
||||
|
||||
|
||||
|
@ -20,8 +20,8 @@ class GenerateLocale(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.tools import sed_i
|
||||
from common.tools import log_check_call
|
||||
from ..tools import sed_i
|
||||
from ..tools import log_check_call
|
||||
locale_gen = os.path.join(info.root, 'etc/locale.gen')
|
||||
locale_str = '{locale}.{charmap} {charmap}'.format(locale=info.manifest.system['locale'],
|
||||
charmap=info.manifest.system['charmap'])
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
import host
|
||||
import volume
|
||||
|
||||
|
@ -11,11 +11,11 @@ class AddRequiredCommands(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.fs.loopbackvolume import LoopbackVolume
|
||||
from ..fs.loopbackvolume import LoopbackVolume
|
||||
if isinstance(info.volume, LoopbackVolume):
|
||||
info.host_dependencies['qemu-img'] = 'qemu-utils'
|
||||
info.host_dependencies['losetup'] = 'mount'
|
||||
from common.fs.qemuvolume import QEMUVolume
|
||||
from ..fs.qemuvolume import QEMUVolume
|
||||
if isinstance(info.volume, QEMUVolume):
|
||||
info.host_dependencies['losetup'] = 'mount'
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
import os
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ class ConfigureNetworkIF(Task):
|
|||
@classmethod
|
||||
def run(cls, info):
|
||||
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])
|
||||
|
||||
interfaces_path = os.path.join(info.root, 'etc/network/interfaces')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import apt
|
||||
from common.tools import log_check_call
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
import apt
|
||||
from ..tools import log_check_call
|
||||
|
||||
|
||||
class AddManifestPackages(Task):
|
||||
|
@ -41,7 +41,7 @@ class InstallPackages(Task):
|
|||
@classmethod
|
||||
def install_remote(cls, info, remote_packages):
|
||||
import os
|
||||
from common.tools import log_check_call
|
||||
from ..tools import log_check_call
|
||||
from subprocess import CalledProcessError
|
||||
try:
|
||||
env = os.environ.copy()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
import filesystem
|
||||
import host
|
||||
import volume
|
||||
|
@ -12,7 +12,7 @@ class AddRequiredCommands(Task):
|
|||
|
||||
@classmethod
|
||||
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):
|
||||
info.host_dependencies['parted'] = 'parted'
|
||||
info.host_dependencies['kpartx'] = 'kpartx'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
import os.path
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@ class EnableShadowConfig(Task):
|
|||
|
||||
@classmethod
|
||||
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'])
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ class DisableSSHPasswordAuthentication(Task):
|
|||
|
||||
@classmethod
|
||||
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')
|
||||
sed_i(sshd_config_path, '^#PasswordAuthentication yes', 'PasswordAuthentication no')
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import workspace
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
import workspace
|
||||
|
||||
|
||||
class Attach(Task):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from .. import phases
|
||||
|
||||
|
||||
class CreateWorkspace(Task):
|
||||
|
|
|
@ -8,7 +8,7 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
import tasks
|
||||
from providers.ec2.tasks import initd
|
||||
from bootstrapvz.providers.ec2.tasks import initd
|
||||
if initd.AddEC2InitScripts in taskset:
|
||||
taskset.add(tasks.AdminUserCredentials)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks.initd import InstallInitScripts
|
||||
from common.tasks import apt
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks.initd import InstallInitScripts
|
||||
from bootstrapvz.common.tasks import apt
|
||||
import os
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ class CreateAdminUser(Task):
|
|||
|
||||
@classmethod
|
||||
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,
|
||||
'useradd',
|
||||
'--create-home', '--shell', '/bin/bash',
|
||||
|
@ -50,7 +50,7 @@ class AdminUserCredentials(Task):
|
|||
|
||||
@classmethod
|
||||
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')
|
||||
username = info.manifest.plugins['admin_user']['username']
|
||||
sed_i(getcreds_path, 'username=\'root\'', 'username=\'{username}\''.format(username=username))
|
||||
|
@ -63,11 +63,11 @@ class DisableRootLogin(Task):
|
|||
@classmethod
|
||||
def run(cls, info):
|
||||
from subprocess import CalledProcessError
|
||||
from common.tools import log_check_call
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
try:
|
||||
log_check_call(['chroot', info.root,
|
||||
'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')
|
||||
sed_i(sshdconfig_path, 'PermitRootLogin yes', 'PermitRootLogin no')
|
||||
except CalledProcessError:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
|
||||
|
||||
class WriteMetadata(Task):
|
||||
|
|
|
@ -8,8 +8,8 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
import tasks
|
||||
import providers.ec2.tasks.initd as initd_ec2
|
||||
from common.tasks import initd
|
||||
import bootstrapvz.providers.ec2.tasks.initd as initd_ec2
|
||||
from bootstrapvz.common.tasks import initd
|
||||
|
||||
if manifest.system['release'] in ['wheezy', 'stable']:
|
||||
taskset.add(tasks.AddBackports)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tools import log_check_call
|
||||
from common.tasks import apt
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
from bootstrapvz.common.tasks import apt
|
||||
import os.path
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ class SetUsername(Task):
|
|||
|
||||
@classmethod
|
||||
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')
|
||||
username = info.manifest.plugins['cloud_init']['username']
|
||||
search = '^ name: debian$'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
|
||||
|
||||
class ImageExecuteCommand(Task):
|
||||
|
@ -8,7 +8,7 @@ class ImageExecuteCommand(Task):
|
|||
|
||||
@classmethod
|
||||
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']:
|
||||
command = map(lambda part: part.format(root=info.root, **info.manifest_vars), raw_command)
|
||||
log_check_call(command)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import apt
|
||||
from common.tasks import bootstrap
|
||||
from common.tasks import filesystem
|
||||
from common.tasks import host
|
||||
from common.tasks import partitioning
|
||||
from common.tasks import volume
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks import apt
|
||||
from bootstrapvz.common.tasks import bootstrap
|
||||
from bootstrapvz.common.tasks import filesystem
|
||||
from bootstrapvz.common.tasks import host
|
||||
from bootstrapvz.common.tasks import partitioning
|
||||
from bootstrapvz.common.tasks import volume
|
||||
import os
|
||||
|
||||
folders = ['tmp', 'var/lib/apt/lists']
|
||||
|
@ -69,7 +69,7 @@ class Zerofree(Task):
|
|||
|
||||
@classmethod
|
||||
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])
|
||||
|
||||
|
||||
|
@ -80,5 +80,5 @@ class ShrinkVolume(Task):
|
|||
|
||||
@classmethod
|
||||
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])
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common.tasks import apt
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common.tasks import apt
|
||||
from bootstrapvz.common import phases
|
||||
import os
|
||||
|
||||
|
||||
|
|
|
@ -2,15 +2,15 @@ from tasks import Snapshot
|
|||
from tasks import CopyImage
|
||||
from tasks import CreateFromSnapshot
|
||||
from tasks import CreateFromImage
|
||||
from providers.ec2.tasks import ebs
|
||||
from providers.virtualbox.tasks import guest_additions
|
||||
from common.tasks import loopback
|
||||
from common.tasks import volume
|
||||
from common.tasks import locale
|
||||
from common.tasks import apt
|
||||
from common.tasks import bootstrap
|
||||
from common.tasks import filesystem
|
||||
from common.tasks import partitioning
|
||||
from bootstrapvz.providers.ec2.tasks import ebs
|
||||
from bootstrapvz.providers.virtualbox.tasks import guest_additions
|
||||
from bootstrapvz.common.tasks import loopback
|
||||
from bootstrapvz.common.tasks import volume
|
||||
from bootstrapvz.common.tasks import locale
|
||||
from bootstrapvz.common.tasks import apt
|
||||
from bootstrapvz.common.tasks import bootstrap
|
||||
from bootstrapvz.common.tasks import filesystem
|
||||
from bootstrapvz.common.tasks import partitioning
|
||||
|
||||
|
||||
def validate_manifest(data, validator, error):
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import volume
|
||||
from common.tasks import packages
|
||||
from providers.virtualbox.tasks import guest_additions
|
||||
from providers.ec2.tasks import ebs
|
||||
from common.fs import remount
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks import volume
|
||||
from bootstrapvz.common.tasks import packages
|
||||
from bootstrapvz.providers.virtualbox.tasks import guest_additions
|
||||
from bootstrapvz.providers.ec2.tasks import ebs
|
||||
from bootstrapvz.common.fs import remount
|
||||
from shutil import copyfile
|
||||
import os.path
|
||||
import time
|
||||
|
@ -81,7 +81,7 @@ def set_fs_states(volume):
|
|||
|
||||
p_map = volume.partition_map
|
||||
partitions_state = 'attached'
|
||||
from base.fs.partitionmaps.none import NoPartitions
|
||||
from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
|
||||
if isinstance(p_map, NoPartitions):
|
||||
partitions_state = 'formatted'
|
||||
else:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import apt
|
||||
from common.tasks import network
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks import apt
|
||||
from bootstrapvz.common.tasks import network
|
||||
import os
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@ class CheckAssetsPath(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.exceptions import TaskError
|
||||
from bootstrapvz.common.exceptions import TaskError
|
||||
assets = info.manifest.plugins['puppet']['assets']
|
||||
if not os.path.exists(assets):
|
||||
msg = 'The assets directory {assets} does not exist.'.format(assets=assets)
|
||||
|
@ -27,7 +27,7 @@ class CheckManifestPath(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.exceptions import TaskError
|
||||
from bootstrapvz.common.exceptions import TaskError
|
||||
manifest = info.manifest.plugins['puppet']['manifest']
|
||||
if not os.path.exists(manifest):
|
||||
msg = 'The manifest file {manifest} does not exist.'.format(manifest=manifest)
|
||||
|
@ -77,12 +77,12 @@ class ApplyPuppetManifest(Task):
|
|||
copy(pp_manifest, manifest_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,
|
||||
'puppet', 'apply', manifest_path])
|
||||
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')
|
||||
sed_i(hosts_path, '127.0.0.1\s*{hostname}\n?'.format(hostname=hostname), '')
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
from common.tasks.security import DisableSSHPasswordAuthentication
|
||||
from bootstrapvz.common.tasks.security import DisableSSHPasswordAuthentication
|
||||
from tasks import SetRootPassword
|
||||
taskset.discard(DisableSSHPasswordAuthentication)
|
||||
taskset.add(SetRootPassword)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
|
||||
|
||||
class SetRootPassword(Task):
|
||||
|
@ -8,6 +8,6 @@ class SetRootPassword(Task):
|
|||
|
||||
@classmethod
|
||||
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:' + info.manifest.plugins['root_password']['password'])
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import apt
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks import apt
|
||||
|
||||
|
||||
class AddUnattendedUpgradesPackage(Task):
|
||||
|
|
|
@ -8,14 +8,14 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
from common.tasks import security
|
||||
from common.tasks import loopback
|
||||
from common.tasks import network
|
||||
from bootstrapvz.common.tasks import security
|
||||
from bootstrapvz.common.tasks import loopback
|
||||
from bootstrapvz.common.tasks import network
|
||||
taskset.discard(security.DisableSSHPasswordAuthentication)
|
||||
taskset.discard(loopback.MoveImage)
|
||||
taskset.discard(network.RemoveHostname)
|
||||
|
||||
from common.tasks import volume
|
||||
from bootstrapvz.common.tasks import volume
|
||||
taskset.update([tasks.CheckBoxPath,
|
||||
tasks.CreateVagrantBoxDir,
|
||||
tasks.AddPackages,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import workspace
|
||||
from common.tasks import apt
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks import workspace
|
||||
from bootstrapvz.common.tasks import apt
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
@ -18,7 +18,7 @@ class CheckBoxPath(Task):
|
|||
box_name = '{name}.box'.format(name=box_basename)
|
||||
box_path = os.path.join(info.manifest.bootstrapper['workspace'], box_name)
|
||||
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)
|
||||
raise TaskError(msg)
|
||||
info.vagrant = {'box_name': box_name,
|
||||
|
@ -60,7 +60,7 @@ class SetHostname(Task):
|
|||
hostname_file.write(hostname)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ class CreateVagrantUser(Task):
|
|||
|
||||
@classmethod
|
||||
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,
|
||||
'useradd',
|
||||
'--create-home', '--shell', '/bin/bash',
|
||||
|
@ -114,7 +114,7 @@ class AddInsecurePublicKey(Task):
|
|||
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
|
||||
from common.tools import log_check_call
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
log_check_call(['chroot', info.root,
|
||||
'chown', 'vagrant:vagrant',
|
||||
'/home/vagrant/.ssh', '/home/vagrant/.ssh/authorized_keys'])
|
||||
|
@ -126,7 +126,7 @@ class SetRootPassword(Task):
|
|||
|
||||
@classmethod
|
||||
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')
|
||||
|
||||
|
||||
|
@ -142,14 +142,14 @@ class PackageBox(Task):
|
|||
|
||||
import random
|
||||
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)
|
||||
|
||||
metadata_source = os.path.join(assets, 'metadata.json')
|
||||
metadata = os.path.join(info.vagrant['folder'], 'metadata.json')
|
||||
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_link = os.path.join(info.vagrant['folder'], disk_name)
|
||||
log_check_call(['ln', '-s', info.volume.image_path, disk_link])
|
||||
|
|
|
@ -7,17 +7,17 @@ import tasks.filesystem
|
|||
import tasks.boot
|
||||
import tasks.network
|
||||
import tasks.initd
|
||||
from common.tasks import volume
|
||||
from common.tasks import filesystem
|
||||
from common.tasks import boot
|
||||
from common.tasks import network
|
||||
from common.tasks import initd
|
||||
from common.tasks import partitioning
|
||||
from common.tasks import loopback
|
||||
from common.tasks import bootstrap
|
||||
from common.tasks import security
|
||||
from common.tasks import cleanup
|
||||
from common.tasks import workspace
|
||||
from bootstrapvz.common.tasks import volume
|
||||
from bootstrapvz.common.tasks import filesystem
|
||||
from bootstrapvz.common.tasks import boot
|
||||
from bootstrapvz.common.tasks import network
|
||||
from bootstrapvz.common.tasks import initd
|
||||
from bootstrapvz.common.tasks import partitioning
|
||||
from bootstrapvz.common.tasks import loopback
|
||||
from bootstrapvz.common.tasks import bootstrap
|
||||
from bootstrapvz.common.tasks import security
|
||||
from bootstrapvz.common.tasks import cleanup
|
||||
from bootstrapvz.common.tasks import workspace
|
||||
|
||||
|
||||
def initialize():
|
||||
|
@ -30,7 +30,7 @@ def validate_manifest(data, validator, error):
|
|||
import os.path
|
||||
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':
|
||||
volume_size = Bytes(0)
|
||||
for key, partition in data['volume']['partitions'].iteritems():
|
||||
|
@ -51,15 +51,15 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
import common.task_sets
|
||||
taskset.update(common.task_sets.base_set)
|
||||
taskset.update(common.task_sets.mounting_set)
|
||||
taskset.update(common.task_sets.get_apt_set(manifest))
|
||||
taskset.update(common.task_sets.locale_set)
|
||||
taskset.update(common.task_sets.ssh_set)
|
||||
from bootstrapvz.common import task_sets
|
||||
taskset.update(task_sets.base_set)
|
||||
taskset.update(task_sets.mounting_set)
|
||||
taskset.update(task_sets.get_apt_set(manifest))
|
||||
taskset.update(task_sets.locale_set)
|
||||
taskset.update(task_sets.ssh_set)
|
||||
|
||||
if manifest.volume['partitions']['type'] != 'none':
|
||||
taskset.update(common.task_sets.partitioning_set)
|
||||
taskset.update(task_sets.partitioning_set)
|
||||
|
||||
taskset.update([tasks.host.AddExternalCommands,
|
||||
tasks.packages.DefaultPackages,
|
||||
|
@ -91,7 +91,7 @@ def resolve_tasks(taskset, manifest):
|
|||
taskset.add(boot.AddGrubPackage)
|
||||
taskset.add(tasks.boot.ConfigurePVGrub)
|
||||
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,
|
||||
tasks.ebs.Attach,
|
||||
|
@ -113,10 +113,10 @@ def resolve_tasks(taskset, manifest):
|
|||
if manifest.bootstrapper.get('tarball', False):
|
||||
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']:
|
||||
taskset.update(common.task_sets.boot_partition_set)
|
||||
taskset.update(task_sets.boot_partition_set)
|
||||
|
||||
|
||||
def resolve_rollback_tasks(taskset, manifest, counter_task):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base.fs.volume import Volume
|
||||
from base.fs.exceptions import VolumeError
|
||||
from bootstrapvz.base.fs.volume import Volume
|
||||
from bootstrapvz.base.fs.exceptions import VolumeError
|
||||
import time
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.exceptions import TaskError
|
||||
from common.tools import log_check_call
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.exceptions import TaskError
|
||||
from bootstrapvz.common.tools import log_check_call
|
||||
from ebs import Snapshot
|
||||
from common.tasks import workspace
|
||||
from bootstrapvz.common.tasks import workspace
|
||||
from connection import Connect
|
||||
from . import assets
|
||||
import os.path
|
||||
|
@ -118,7 +118,7 @@ class RegisterAMI(Task):
|
|||
else:
|
||||
registration_params['virtualization_type'] = 'paravirtual'
|
||||
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'],
|
||||
info.manifest.system['architecture']])
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from . import assets
|
||||
import os
|
||||
|
||||
|
@ -26,9 +26,9 @@ class ConfigurePVGrub(Task):
|
|||
copy(script_src, script_dst)
|
||||
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):
|
||||
from common.tools import sed_i
|
||||
from bootstrapvz.common.tools import sed_i
|
||||
root_idx = info.volume.partition_map.root.get_index()
|
||||
grub_device = 'GRUB_DEVICE=/dev/xvda{idx}'.format(idx=root_idx)
|
||||
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)
|
||||
|
||||
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')
|
||||
|
||||
from common.tools import sed_i
|
||||
from bootstrapvz.common.tools import sed_i
|
||||
grub_def = os.path.join(info.root, 'etc/default/grub')
|
||||
sed_i(grub_def, '^GRUB_TIMEOUT=[0-9]+', 'GRUB_TIMEOUT=0\n'
|
||||
'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,
|
||||
'ln', '--symbolic', '/boot/grub/grub.cfg', '/boot/grub/menu.lst'])
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
import host
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
|
||||
|
||||
class Create(Task):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
|
||||
|
||||
class S3FStab(Task):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import host
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks import host
|
||||
|
||||
|
||||
class AddExternalCommands(Task):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import initd
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks import initd
|
||||
from . import assets
|
||||
import os.path
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import apt
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks import apt
|
||||
import os.path
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ class EnableDHCPCDDNS(Task):
|
|||
def run(cls, info):
|
||||
# The dhcp client that ships with debian sets the DNS servers per default.
|
||||
# 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')
|
||||
sed_i(dhcpcd, '^#*SET_DNS=.*', 'SET_DNS=\'yes\'')
|
||||
|
||||
|
@ -39,7 +39,7 @@ class InstallEnhancedNetworking(Task):
|
|||
import urllib
|
||||
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',
|
||||
'--extract',
|
||||
'--file', archive,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import apt
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks import apt
|
||||
|
||||
|
||||
class DefaultPackages(Task):
|
||||
|
@ -19,7 +19,7 @@ class DefaultPackages(Task):
|
|||
|
||||
import os.path
|
||||
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,
|
||||
info.manifest.system['architecture']])
|
||||
info.packages.add(kernel_package)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import tasks.packages
|
||||
from common.tasks import volume
|
||||
from common.tasks import loopback
|
||||
from common.tasks import partitioning
|
||||
from common.tasks import filesystem
|
||||
from common.tasks import bootstrap
|
||||
from common.tasks import security
|
||||
from common.tasks import network
|
||||
from common.tasks import initd
|
||||
from common.tasks import cleanup
|
||||
from common.tasks import workspace
|
||||
from bootstrapvz.common.tasks import volume
|
||||
from bootstrapvz.common.tasks import loopback
|
||||
from bootstrapvz.common.tasks import partitioning
|
||||
from bootstrapvz.common.tasks import filesystem
|
||||
from bootstrapvz.common.tasks import bootstrap
|
||||
from bootstrapvz.common.tasks import security
|
||||
from bootstrapvz.common.tasks import network
|
||||
from bootstrapvz.common.tasks import initd
|
||||
from bootstrapvz.common.tasks import cleanup
|
||||
from bootstrapvz.common.tasks import workspace
|
||||
|
||||
|
||||
def initialize():
|
||||
|
@ -25,17 +25,17 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
|
||||
def resolve_tasks(tasklist, manifest):
|
||||
import common.task_sets
|
||||
tasklist.update(common.task_sets.base_set)
|
||||
tasklist.update(common.task_sets.volume_set)
|
||||
tasklist.update(common.task_sets.mounting_set)
|
||||
tasklist.update(common.task_sets.get_apt_set(manifest))
|
||||
tasklist.update(common.task_sets.locale_set)
|
||||
from bootstrapvz.common import task_sets
|
||||
tasklist.update(task_sets.base_set)
|
||||
tasklist.update(task_sets.volume_set)
|
||||
tasklist.update(task_sets.mounting_set)
|
||||
tasklist.update(task_sets.get_apt_set(manifest))
|
||||
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':
|
||||
tasklist.update(common.task_sets.partitioning_set)
|
||||
tasklist.update(task_sets.partitioning_set)
|
||||
|
||||
tasklist.update([tasks.packages.DefaultPackages,
|
||||
|
||||
|
@ -60,10 +60,10 @@ def resolve_tasks(tasklist, manifest):
|
|||
from tasks import 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']:
|
||||
tasklist.update(common.task_sets.boot_partition_set)
|
||||
tasklist.update(task_sets.boot_partition_set)
|
||||
|
||||
|
||||
def resolve_rollback_tasks(tasklist, manifest, counter_task):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import apt
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks import apt
|
||||
|
||||
|
||||
class DefaultPackages(Task):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
import os
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import tasks.packages
|
||||
from common.tasks import volume
|
||||
from common.tasks import loopback
|
||||
from common.tasks import partitioning
|
||||
from common.tasks import filesystem
|
||||
from common.tasks import bootstrap
|
||||
from common.tasks import security
|
||||
from common.tasks import network
|
||||
from common.tasks import initd
|
||||
from common.tasks import cleanup
|
||||
from common.tasks import workspace
|
||||
from bootstrapvz.common.tasks import volume
|
||||
from bootstrapvz.common.tasks import loopback
|
||||
from bootstrapvz.common.tasks import partitioning
|
||||
from bootstrapvz.common.tasks import filesystem
|
||||
from bootstrapvz.common.tasks import bootstrap
|
||||
from bootstrapvz.common.tasks import security
|
||||
from bootstrapvz.common.tasks import network
|
||||
from bootstrapvz.common.tasks import initd
|
||||
from bootstrapvz.common.tasks import cleanup
|
||||
from bootstrapvz.common.tasks import workspace
|
||||
|
||||
|
||||
def initialize():
|
||||
|
@ -25,17 +25,17 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
import common.task_sets
|
||||
taskset.update(common.task_sets.base_set)
|
||||
taskset.update(common.task_sets.volume_set)
|
||||
taskset.update(common.task_sets.mounting_set)
|
||||
taskset.update(common.task_sets.get_apt_set(manifest))
|
||||
taskset.update(common.task_sets.locale_set)
|
||||
from bootstrapvz.common import task_sets
|
||||
taskset.update(task_sets.base_set)
|
||||
taskset.update(task_sets.volume_set)
|
||||
taskset.update(task_sets.mounting_set)
|
||||
taskset.update(task_sets.get_apt_set(manifest))
|
||||
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':
|
||||
taskset.update(common.task_sets.partitioning_set)
|
||||
taskset.update(task_sets.partitioning_set)
|
||||
|
||||
taskset.update([tasks.packages.DefaultPackages,
|
||||
|
||||
|
@ -63,10 +63,10 @@ def resolve_tasks(taskset, manifest):
|
|||
if manifest.bootstrapper.get('tarball', False):
|
||||
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']:
|
||||
taskset.update(common.task_sets.boot_partition_set)
|
||||
taskset.update(task_sets.boot_partition_set)
|
||||
|
||||
|
||||
def resolve_rollback_tasks(taskset, manifest, counter_task):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks.packages import InstallPackages
|
||||
from common.exceptions import TaskError
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks.packages import InstallPackages
|
||||
from bootstrapvz.common.exceptions import TaskError
|
||||
|
||||
|
||||
class CheckGuestAdditionsPath(Task):
|
||||
|
@ -28,7 +28,7 @@ class AddGuestAdditionsPackages(Task):
|
|||
info.packages.add('build-essential')
|
||||
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,
|
||||
'uname', '-r'])
|
||||
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')
|
||||
# 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'])
|
||||
# VBoxService process could be running, as it is not affected by DisableDaemonAutostart
|
||||
log_call(['chroot', info.root, 'service', 'vboxadd-service', 'stop'])
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
from common.tasks import apt
|
||||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from bootstrapvz.common.tasks import apt
|
||||
|
||||
|
||||
class DefaultPackages(Task):
|
||||
|
|
Loading…
Add table
Reference in a new issue