Merge pull request #471 from CMeza99/pylint+imports

Pylint code clean up
This commit is contained in:
Anders Ingemann 2018-06-07 22:09:33 +02:00 committed by GitHub
commit 7e6a7d4267
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
109 changed files with 353 additions and 351 deletions

View file

@ -1,6 +1,6 @@
from phase import Phase from .phase import Phase
from task import Task from .task import Task
from main import main from .main import main
__all__ = ['Phase', 'Task', 'main'] __all__ = ['Phase', 'Task', 'main']

View file

@ -25,7 +25,7 @@ class BootstrapInformation(object):
self.workspace = os.path.join(manifest.bootstrapper['workspace'], self.run_id) self.workspace = os.path.join(manifest.bootstrapper['workspace'], self.run_id)
# Load all the volume information # Load all the volume information
from fs import load_volume from .fs import load_volume
self.volume = load_volume(self.manifest.volume, manifest.system['bootloader']) self.volume = load_volume(self.manifest.volume, manifest.system['bootloader'])
# The default apt mirror # The default apt mirror
@ -40,13 +40,13 @@ class BootstrapInformation(object):
# Keep a list of apt sources, # Keep a list of apt sources,
# so that tasks may add to that list without having to fiddle with apt source list files. # so that tasks may add to that list without having to fiddle with apt source list files.
from pkg.sourceslist import SourceLists from .pkg.sourceslist import SourceLists
self.source_lists = SourceLists(self.manifest_vars) self.source_lists = SourceLists(self.manifest_vars)
# Keep a list of apt preferences # Keep a list of apt preferences
from pkg.preferenceslist import PreferenceLists from .pkg.preferenceslist import PreferenceLists
self.preference_lists = PreferenceLists(self.manifest_vars) self.preference_lists = PreferenceLists(self.manifest_vars)
# Keep a list of packages that should be installed, tasks can add and remove things from this list # Keep a list of packages that should be installed, tasks can add and remove things from this list
from pkg.packagelist import PackageList from .pkg.packagelist import PackageList
self.packages = PackageList(self.manifest_vars, self.source_lists) self.packages = PackageList(self.manifest_vars, self.source_lists)
# These sets should rarely be used and specify which packages the debootstrap invocation # These sets should rarely be used and specify which packages the debootstrap invocation

View file

@ -10,9 +10,9 @@ def load_volume(data, bootloader):
:rtype: Volume :rtype: Volume
""" """
# Map valid partition maps in the manifest and their corresponding classes # Map 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
from partitionmaps.none import NoPartitions from .partitionmaps.none import NoPartitions
partition_map = {'none': NoPartitions, partition_map = {'none': NoPartitions,
'gpt': GPTPartitionMap, 'gpt': GPTPartitionMap,
'msdos': MSDOSPartitionMap, 'msdos': MSDOSPartitionMap,

View file

@ -1,4 +1,4 @@
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 bootstrapvz.common.tools import log_check_call from bootstrapvz.common.tools import log_check_call

View file

@ -1,4 +1,4 @@
from abstract import AbstractPartitionMap from .abstract import AbstractPartitionMap
from ..exceptions import PartitionError from ..exceptions import PartitionError
from ..partitions.msdos import MSDOSPartition from ..partitions.msdos import MSDOSPartition
from ..partitions.msdos_swap import MSDOSSwapPartition from ..partitions.msdos_swap import MSDOSSwapPartition

View file

@ -117,7 +117,7 @@ class AbstractPartition(FSMProxy):
:param list opts: Any options that should be passed to the mount command :param list opts: Any options that should be passed to the mount command
""" """
# Create a new mount object, mount it if the partition is mounted and put it in the mounts dict # Create a new mount object, mount it if the partition is mounted and put it in the mounts dict
from mount import Mount from .mount import Mount
mount = Mount(source, destination, opts) mount = Mount(source, destination, opts)
if self.fsm.current == 'mounted': if self.fsm.current == 'mounted':
mount.mount(self.mount_dir) mount.mount(self.mount_dir)

View file

@ -1,5 +1,5 @@
import os import os
from abstract import AbstractPartition from .abstract import AbstractPartition
from bootstrapvz.common.sectors import Sectors from bootstrapvz.common.sectors import Sectors
@ -52,9 +52,8 @@ class BasePartition(AbstractPartition):
if self.previous is None: if self.previous is None:
# Partitions are 1 indexed # Partitions are 1 indexed
return 1 return 1
else: # Recursive call to the previous partition, walking up the chain...
# Recursive call to the previous partition, walking up the chain... return self.previous.get_index() + 1
return self.previous.get_index() + 1
def get_start(self): def get_start(self):
"""Gets the starting byte of this partition """Gets the starting byte of this partition
@ -64,8 +63,7 @@ class BasePartition(AbstractPartition):
""" """
if self.previous is None: if self.previous is None:
return Sectors(0, self.size.sector_size) return Sectors(0, self.size.sector_size)
else: return self.previous.get_end()
return self.previous.get_end()
def map(self, device_path): def map(self, device_path):
"""Maps the partition to a device_path """Maps the partition to a device_path

View file

@ -1,5 +1,5 @@
from bootstrapvz.common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from base import BasePartition from .base import BasePartition
class GPTPartition(BasePartition): class GPTPartition(BasePartition):

View file

@ -1,5 +1,5 @@
from bootstrapvz.common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from gpt import GPTPartition from .gpt import GPTPartition
class GPTSwapPartition(GPTPartition): class GPTSwapPartition(GPTPartition):

View file

@ -1,4 +1,4 @@
from abstract import AbstractPartition from .abstract import AbstractPartition
import os.path import os.path
from bootstrapvz.common.tools import log_check_call from bootstrapvz.common.tools import log_check_call

View file

@ -1,4 +1,4 @@
from base import BasePartition from .base import BasePartition
class MSDOSPartition(BasePartition): class MSDOSPartition(BasePartition):

View file

@ -1,5 +1,5 @@
from bootstrapvz.common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from msdos import MSDOSPartition from .msdos import MSDOSPartition
class MSDOSSwapPartition(MSDOSPartition): class MSDOSSwapPartition(MSDOSPartition):

View file

@ -1,4 +1,4 @@
from abstract import AbstractPartition from .abstract import AbstractPartition
class SinglePartition(AbstractPartition): class SinglePartition(AbstractPartition):

View file

@ -1,4 +1,4 @@
from base import BasePartition from .base import BasePartition
class UnformattedPartition(BasePartition): class UnformattedPartition(BasePartition):

View file

@ -2,7 +2,7 @@ from abc import ABCMeta
from bootstrapvz.common.fsm_proxy import FSMProxy from bootstrapvz.common.fsm_proxy import FSMProxy
from bootstrapvz.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
class Volume(FSMProxy): class Volume(FSMProxy):
@ -82,7 +82,9 @@ class Volume(FSMProxy):
:raises VolumeError: When a free block device cannot be found. :raises VolumeError: When a free block device cannot be found.
""" """
import os.path import os.path
import string
from bootstrapvz.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)
@ -104,8 +106,7 @@ class Volume(FSMProxy):
major=device_partition['major'], major=device_partition['major'],
minor=device_partition['minor'], minor=device_partition['minor'],
start_sec=start_sector)) start_sec=start_sector))
import string
import os.path
# Figure out the device letter and path # Figure out the device letter and path
for letter in string.ascii_lowercase: for letter in string.ascii_lowercase:
dev_name = 'vd' + letter dev_name = 'vd' + letter

View file

@ -100,5 +100,4 @@ class FileFormatter(SourceFormatter):
"""Formats log statements for output to file """Formats log statements for output to file
Currently this is just a stub Currently this is just a stub
""" """
def format(self, record): pass
return super(FileFormatter, self).format(record)

View file

@ -19,7 +19,7 @@ def main():
setup_loggers(opts) setup_loggers(opts)
# Load the manifest # Load the manifest
from manifest import Manifest from .manifest import Manifest
manifest = Manifest(path=opts['MANIFEST']) manifest = Manifest(path=opts['MANIFEST'])
# Everything has been set up, begin the bootstrapping process # Everything has been set up, begin the bootstrapping process
@ -62,7 +62,7 @@ def setup_loggers(opts):
root = logging.getLogger() root = logging.getLogger()
root.setLevel(logging.NOTSET) root.setLevel(logging.NOTSET)
import log from . import log
# Log to file unless --log is a single dash # Log to file unless --log is a single dash
if opts['--log'] != '-': if opts['--log'] != '-':
import os.path import os.path
@ -95,15 +95,15 @@ def run(manifest, debug=False, pause_on_error=False, dry_run=False):
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# Get the tasklist # Get the tasklist
from tasklist import load_tasks from .tasklist import load_tasks
from tasklist import TaskList from .tasklist import TaskList
log.info('Generating tasklist') log.info('Generating tasklist')
tasks = load_tasks('resolve_tasks', manifest) tasks = load_tasks('resolve_tasks', manifest)
tasklist = TaskList(tasks) tasklist = TaskList(tasks)
# 'resolve_tasks' is the name of the function to call on the provider and plugins # 'resolve_tasks' is the name of the function to call on the provider and plugins
# Create the bootstrap information object that'll be used throughout the bootstrapping process # Create the bootstrap information object that'll be used throughout the bootstrapping process
from bootstrapinfo import BootstrapInformation from .bootstrapinfo import BootstrapInformation
bootstrap_info = BootstrapInformation(manifest=manifest, debug=debug) bootstrap_info = BootstrapInformation(manifest=manifest, debug=debug)
try: try:

View file

@ -22,8 +22,7 @@ class PackageList(object):
""" """
if self.target is None: if self.target is None:
return self.name return self.name
else: return self.name + '/' + self.target
return self.name + '/' + self.target
class Local(object): class Local(object):
"""A local package """A local package
@ -66,7 +65,7 @@ class PackageList(object):
:raises PackageError: When a package of the same name but with a different target has already been added. :raises PackageError: When a package of the same name but with a different target has already been added.
:raises PackageError: When the specified target release could not be found. :raises PackageError: When the specified target release could not be found.
""" """
from exceptions import PackageError from .exceptions import PackageError
name = name.format(**self.manifest_vars) name = name.format(**self.manifest_vars)
if target is not None: if target is not None:
target = target.format(**self.manifest_vars) target = target.format(**self.manifest_vars)

View file

@ -63,7 +63,7 @@ class Source(object):
'(\s+(?P<components>.+\S))?\s*$') '(\s+(?P<components>.+\S))?\s*$')
match = regexp.match(line).groupdict() match = regexp.match(line).groupdict()
if match is None: if match is None:
from exceptions import SourceError from .exceptions import SourceError
raise SourceError('Unable to parse source line: ' + line) raise SourceError('Unable to parse source line: ' + line)
self.type = match['type'] self.type = match['type']
self.options = [] self.options = []

View file

@ -158,7 +158,7 @@ def get_all_tasks(loaded_modules):
# 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):
from task import Task from .task import Task
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

View file

@ -1,4 +1,4 @@
from exceptions import UnitError from .exceptions import UnitError
def onlybytes(msg): def onlybytes(msg):

View file

@ -1,4 +1,4 @@
from qemuvolume import QEMUVolume from .qemuvolume import QEMUVolume
class Qcow2Volume(QEMUVolume): class Qcow2Volume(QEMUVolume):

View file

@ -1,4 +1,4 @@
from loopbackvolume import LoopbackVolume from .loopbackvolume import LoopbackVolume
from bootstrapvz.base.fs.exceptions import VolumeError from bootstrapvz.base.fs.exceptions import VolumeError
from ..tools import log_check_call from ..tools import log_check_call
from . import get_partitions from . import get_partitions
@ -9,7 +9,12 @@ class QEMUVolume(LoopbackVolume):
def _before_create(self, e): def _before_create(self, e):
self.image_path = e.image_path self.image_path = e.image_path
vol_size = str(self.size.bytes.get_qty_in('MiB')) + 'M' vol_size = str(self.size.bytes.get_qty_in('MiB')) + 'M'
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, # pylint: disable=no-member
self.image_path,
vol_size])
def _check_nbd_module(self): def _check_nbd_module(self):
from bootstrapvz.base.fs.partitionmaps.none import NoPartitions from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
@ -62,8 +67,8 @@ class QEMUVolume(LoopbackVolume):
def _module_param(self, module, param): def _module_param(self, module, param):
import os.path import os.path
param_path = os.path.join('/sys/module', module, 'parameters', param) param_path = os.path.join('/sys/module', module, 'parameters', param)
with open(param_path) as param: with open(param_path) as param_file:
return param.read().strip() return param_file.read().strip()
# From http://lists.gnu.org/archive/html/qemu-devel/2011-11/msg02201.html # From http://lists.gnu.org/archive/html/qemu-devel/2011-11/msg02201.html
# Apparently it's not in the current qemu-nbd shipped with wheezy # Apparently it's not in the current qemu-nbd shipped with wheezy

View file

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

View file

@ -1,4 +1,4 @@
from qemuvolume import QEMUVolume from .qemuvolume import QEMUVolume
from ..tools import log_check_call from ..tools import log_check_call

View file

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

View file

@ -58,7 +58,7 @@ def get_release(release_name):
"""Normalizes the release codenames """Normalizes the release codenames
This allows tasks to query for release codenames rather than 'stable', 'unstable' etc. This allows tasks to query for release codenames rather than 'stable', 'unstable' etc.
""" """
from . import releases from . import releases # pylint: disable=import-self
release = getattr(releases, release_name, None) release = getattr(releases, release_name, None)
if release is None or not isinstance(release, _Release): if release is None or not isinstance(release, _Release):
raise UnknownReleaseException('The release `{name}\' is unknown'.format(name=release)) raise UnknownReleaseException('The release `{name}\' is unknown'.format(name=release))

View file

@ -1,5 +1,5 @@
from exceptions import UnitError from .exceptions import UnitError
from bytes import Bytes from .bytes import Bytes
def onlysectors(msg): def onlysectors(msg):

View file

@ -1,22 +1,22 @@
from tasks import workspace from .tasks import workspace
from tasks import packages from .tasks import packages
from tasks import host from .tasks import host
from tasks import grub from .tasks import grub
from tasks import extlinux from .tasks import extlinux
from tasks import bootstrap from .tasks import bootstrap
from tasks import volume from .tasks import volume
from tasks import loopback from .tasks import loopback
from tasks import filesystem from .tasks import filesystem
from tasks import partitioning from .tasks import partitioning
from tasks import cleanup from .tasks import cleanup
from tasks import apt from .tasks import apt
from tasks import security from .tasks import security
from tasks import locale from .tasks import locale
from tasks import network from .tasks import network
from tasks import initd from .tasks import initd
from tasks import ssh from .tasks import ssh
from tasks import kernel from .tasks import kernel
from tasks import folder from .tasks import folder
def get_standard_groups(manifest): def get_standard_groups(manifest):

View file

@ -2,7 +2,7 @@ from bootstrapvz.base import Task
from bootstrapvz.common import phases from bootstrapvz.common import phases
from bootstrapvz.common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from bootstrapvz.common.tools import rel_path from bootstrapvz.common.tools import rel_path
import locale from . import locale
import logging import logging
import os import os
@ -142,7 +142,6 @@ class WriteSources(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
if not info.source_lists.target_exists(info.manifest.system['release']): if not info.source_lists.target_exists(info.manifest.system['release']):
import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
log.warn('No default target has been specified in the sources list, ' log.warn('No default target has been specified in the sources list, '
'installing packages may fail') 'installing packages may fail')
@ -182,12 +181,12 @@ class DisableDaemonAutostart(Task):
with open(rc_policy_path, 'w') as rc_policy: with open(rc_policy_path, 'w') as rc_policy:
rc_policy.write(('#!/bin/sh\n' rc_policy.write(('#!/bin/sh\n'
'exit 101')) 'exit 101'))
os.chmod(rc_policy_path, 0755) os.chmod(rc_policy_path, 0o755)
initictl_path = os.path.join(info.root, 'sbin/initctl') initictl_path = os.path.join(info.root, 'sbin/initctl')
with open(initictl_path, 'w') as initctl: with open(initictl_path, 'w') as initctl:
initctl.write(('#!/bin/sh\n' initctl.write(('#!/bin/sh\n'
'exit 0')) 'exit 0'))
os.chmod(initictl_path, 0755) os.chmod(initictl_path, 0o755)
class AptUpdate(Task): class AptUpdate(Task):

View file

@ -1,7 +1,7 @@
from bootstrapvz.base import Task from bootstrapvz.base import Task
from .. import phases from .. import phases
from ..exceptions import TaskError from ..exceptions import TaskError
import host from . import host
import logging import logging
import os.path import os.path
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -1,8 +1,8 @@
from bootstrapvz.base import Task from bootstrapvz.base import Task
from .. import phases from .. import phases
from ..tools import log_check_call from ..tools import log_check_call
import filesystem from . import filesystem
import kernel from . import kernel
from bootstrapvz.base.fs import partitionmaps from bootstrapvz.base.fs import partitionmaps
import os import os

View file

@ -1,9 +1,9 @@
from bootstrapvz.base import Task from bootstrapvz.base import Task
from .. import phases from .. import phases
from ..tools import log_check_call from ..tools import log_check_call
import bootstrap from . import bootstrap
import host from . import host
import volume from . import volume
class AddRequiredCommands(Task): class AddRequiredCommands(Task):

View file

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

View file

@ -2,8 +2,8 @@ from bootstrapvz.base import Task
from ..exceptions import TaskError from ..exceptions import TaskError
from .. import phases from .. import phases
from ..tools import log_check_call from ..tools import log_check_call
import filesystem from . import filesystem
import kernel from . import kernel
from bootstrapvz.base.fs import partitionmaps from bootstrapvz.base.fs import partitionmaps
import os.path import os.path

View file

@ -1,7 +1,7 @@
from bootstrapvz.base import Task from bootstrapvz.base import Task
from bootstrapvz.common import phases from bootstrapvz.common import phases
import host from . import host
import volume from . import volume
class AddRequiredCommands(Task): class AddRequiredCommands(Task):

View file

@ -1,6 +1,6 @@
from bootstrapvz.base import Task from bootstrapvz.base import Task
from .. import phases from .. import phases
import apt from . import apt
from ..tools import log_check_call from ..tools import log_check_call
@ -41,7 +41,6 @@ class InstallPackages(Task):
@classmethod @classmethod
def install_remote(cls, info, remote_packages): def install_remote(cls, info, remote_packages):
import os import os
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,8 +1,8 @@
from bootstrapvz.base import Task from bootstrapvz.base import Task
from bootstrapvz.common import phases from bootstrapvz.common import phases
import filesystem from . import filesystem
import host from . import host
import volume from . import volume
class AddRequiredCommands(Task): class AddRequiredCommands(Task):

View file

@ -3,7 +3,7 @@ from .. import phases
from ..tools import log_check_call from ..tools import log_check_call
import os.path import os.path
from . import assets from . import assets
import initd from . import initd
import shutil import shutil
@ -49,7 +49,7 @@ class AddSSHKeyGeneration(Task):
shutil.copy(ssh_keygen_host_service, ssh_keygen_host_service_dest) shutil.copy(ssh_keygen_host_service, ssh_keygen_host_service_dest)
shutil.copy(ssh_keygen_host_script, ssh_keygen_host_script_dest) shutil.copy(ssh_keygen_host_script, ssh_keygen_host_script_dest)
os.chmod(ssh_keygen_host_script_dest, 0750) os.chmod(ssh_keygen_host_script_dest, 0o750)
# Enable systemd service # Enable systemd service
log_check_call(['chroot', info.root, 'systemctl', 'enable', 'ssh-generate-hostkeys.service']) log_check_call(['chroot', info.root, 'systemctl', 'enable', 'ssh-generate-hostkeys.service'])
@ -134,6 +134,5 @@ 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 ..tools import log_check_call
log_check_call(['shred', '--remove'] + [key for key in private + public log_check_call(['shred', '--remove'] + [key for key in private + public
if os.path.isfile(key)]) if os.path.isfile(key)])

View file

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

View file

@ -1,3 +1,4 @@
from __future__ import print_function
import os import os
@ -67,7 +68,7 @@ def log_call(command, stdin=None, env=None, shell=False, cwd=None):
def sed_i(file_path, pattern, subst, expected_replacements=1): def sed_i(file_path, pattern, subst, expected_replacements=1):
replacement_count = inline_replace(file_path, pattern, subst) replacement_count = inline_replace(file_path, pattern, subst)
if replacement_count != expected_replacements: if replacement_count != expected_replacements:
from exceptions import UnexpectedNumMatchesError from .exceptions import UnexpectedNumMatchesError
msg = ('There were {real} instead of {expected} matches for ' msg = ('There were {real} instead of {expected} matches for '
'the expression `{exp}\' in the file `{path}\'' 'the expression `{exp}\' in the file `{path}\''
.format(real=replacement_count, expected=expected_replacements, .format(real=replacement_count, expected=expected_replacements,
@ -82,7 +83,7 @@ def inline_replace(file_path, pattern, subst):
for line in fileinput.input(files=file_path, inplace=True): for line in fileinput.input(files=file_path, inplace=True):
(replacement, count) = re.subn(pattern, subst, line) (replacement, count) = re.subn(pattern, subst, line)
replacement_count += count replacement_count += count
print replacement, print(replacement, end=' ')
return replacement_count return replacement_count
@ -136,5 +137,4 @@ def copy_tree(from_path, to_path):
def rel_path(base, path): def rel_path(base, path):
import os.path
return os.path.normpath(os.path.join(os.path.dirname(base), path)) return os.path.normpath(os.path.join(os.path.dirname(base), path))

View file

@ -5,7 +5,7 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import logging import logging
import tasks from . import tasks
from bootstrapvz.common.tasks import ssh from bootstrapvz.common.tasks import ssh
from bootstrapvz.common.releases import jessie from bootstrapvz.common.releases import jessie

View file

@ -112,7 +112,7 @@ class AdminUserPublicKey(Task):
# Create the ssh dir if nobody has created it yet # Create the ssh dir if nobody has created it yet
if not os.path.exists(ssh_dir_abs): if not os.path.exists(ssh_dir_abs):
os.mkdir(ssh_dir_abs, 0700) os.mkdir(ssh_dir_abs, 0o700)
# Create (or append to) the authorized keys file (and chmod u=rw,go=) # Create (or append to) the authorized keys file (and chmod u=rw,go=)
import stat import stat

View file

@ -1,4 +1,4 @@
import tasks from . import tasks
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):

View file

@ -4,7 +4,7 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import tasks from . import tasks
taskset.add(tasks.CheckAptProxy) taskset.add(tasks.CheckAptProxy)
taskset.add(tasks.SetAptProxy) taskset.add(tasks.SetAptProxy)
if not manifest.plugins['apt_proxy'].get('persistent', False): if not manifest.plugins['apt_proxy'].get('persistent', False):

View file

@ -16,8 +16,9 @@ class CheckAptProxy(Task):
proxy_url = 'http://{address}:{port}'.format(address=proxy_address, port=proxy_port) proxy_url = 'http://{address}:{port}'.format(address=proxy_address, port=proxy_port)
try: try:
urllib2.urlopen(proxy_url, timeout=5) urllib2.urlopen(proxy_url, timeout=5)
except Exception as e: except urllib2.URLError as e:
# Default response from `apt-cacher-ng` # Default response from `apt-cacher-ng`
# pylint: disable=no-member
if isinstance(e, urllib2.HTTPError) and e.code in [404, 406] and e.msg == 'Usage Information': if isinstance(e, urllib2.HTTPError) and e.code in [404, 406] and e.msg == 'Usage Information':
pass pass
else: else:

View file

@ -1,4 +1,4 @@
import tasks from . import tasks
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):

View file

@ -4,12 +4,11 @@ assets = rel_path(__file__, 'assets')
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):
from bootstrapvz.common.tools import rel_path
validator(data, rel_path(__file__, 'manifest-schema.yml')) validator(data, rel_path(__file__, 'manifest-schema.yml'))
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import tasks from . import tasks
import bootstrapvz.providers.ec2.tasks.initd as initd_ec2 import bootstrapvz.providers.ec2.tasks.initd as initd_ec2
from bootstrapvz.common.tasks import apt from bootstrapvz.common.tasks import apt
from bootstrapvz.common.tasks import initd from bootstrapvz.common.tasks import initd

View file

@ -1,3 +1,5 @@
from __future__ import print_function
from bootstrapvz.base import Task from bootstrapvz.base import Task
from bootstrapvz.common import phases from bootstrapvz.common import phases
from bootstrapvz.common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
@ -98,7 +100,7 @@ class DisableModules(Task):
import fileinput import fileinput
for line in fileinput.input(files=cloud_cfg, inplace=True): for line in fileinput.input(files=cloud_cfg, inplace=True):
if not regex.match(line): if not regex.match(line):
print line, print(line, end=' ')
class EnableModules(Task): class EnableModules(Task):
@ -122,7 +124,7 @@ class EnableModules(Task):
count = count + 1 count = count + 1
if int(entry['position']) == int(count): if int(entry['position']) == int(count):
print(" - %s" % entry['module']) print(" - %s" % entry['module'])
print line, print(line, end=' ')
class SetCloudInitMountOptions(Task): class SetCloudInitMountOptions(Task):
@ -134,4 +136,4 @@ class SetCloudInitMountOptions(Task):
cloud_init_src = os.path.join(assets, 'cloud-init/debian_cloud.cfg') cloud_init_src = os.path.join(assets, 'cloud-init/debian_cloud.cfg')
cloud_init_dst = os.path.join(info.root, 'etc/cloud/cloud.cfg.d/01_debian_cloud.cfg') cloud_init_dst = os.path.join(info.root, 'etc/cloud/cloud.cfg.d/01_debian_cloud.cfg')
copy(cloud_init_src, cloud_init_dst) copy(cloud_init_src, cloud_init_dst)
os.chmod(cloud_init_dst, 0644) os.chmod(cloud_init_dst, 0o644)

View file

@ -6,5 +6,5 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
from tasks import ImageExecuteCommand from .tasks import ImageExecuteCommand
taskset.add(ImageExecuteCommand) taskset.add(ImageExecuteCommand)

View file

@ -7,5 +7,5 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import tasks from . import tasks
taskset.update([tasks.DebconfSetSelections]) taskset.update([tasks.DebconfSetSelections])

View file

@ -1,5 +1,5 @@
from bootstrapvz.common.tools import rel_path from bootstrapvz.common.tools import rel_path
import tasks from . import tasks
from bootstrapvz.common.tasks import apt from bootstrapvz.common.tasks import apt
from bootstrapvz.common.releases import wheezy from bootstrapvz.common.releases import wheezy

View file

@ -38,7 +38,7 @@ class AddDockerBinary(Task):
docker_url += 'latest' docker_url += 'latest'
bin_docker = os.path.join(info.root, 'usr/bin/docker') bin_docker = os.path.join(info.root, 'usr/bin/docker')
log_check_call(['wget', '-O', bin_docker, docker_url]) log_check_call(['wget', '-O', bin_docker, docker_url])
os.chmod(bin_docker, 0755) os.chmod(bin_docker, 0o755)
class AddDockerInit(Task): class AddDockerInit(Task):

View file

@ -4,7 +4,7 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import tasks from . import tasks
taskset.add(tasks.LaunchEC2Instance) taskset.add(tasks.LaunchEC2Instance)
if 'print_public_ip' in manifest.plugins['ec2_launch']: if 'print_public_ip' in manifest.plugins['ec2_launch']:
taskset.add(tasks.PrintPublicIPAddress) taskset.add(tasks.PrintPublicIPAddress)

View file

@ -61,7 +61,7 @@ class PrintPublicIPAddress(Task):
info._ec2['instance'] = conn.describe_instances(InstanceIds=[info._ec2['instance']['InstanceId']])['Reservations'][0]['Instances'][0] info._ec2['instance'] = conn.describe_instances(InstanceIds=[info._ec2['instance']['InstanceId']])['Reservations'][0]['Instances'][0]
logger.info('******* EC2 IP ADDRESS: %s *******' % info._ec2['instance']['PublicIpAddress']) logger.info('******* EC2 IP ADDRESS: %s *******' % info._ec2['instance']['PublicIpAddress'])
f.write(info._ec2['instance']['PublicIpAddress']) f.write(info._ec2['instance']['PublicIpAddress'])
except Exception: except Exception: # pylint: disable=broad-except
logger.error('Could not get IP address for the instance') logger.error('Could not get IP address for the instance')
f.write('') f.write('')

View file

@ -4,7 +4,7 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import tasks from . import tasks
taskset.add(tasks.CopyAmiToRegions) taskset.add(tasks.CopyAmiToRegions)
if 'manifest_url' in manifest.plugins['ec2_publish']: if 'manifest_url' in manifest.plugins['ec2_publish']:
taskset.add(tasks.PublishAmiManifest) taskset.add(tasks.PublishAmiManifest)

View file

@ -1,4 +1,4 @@
import tasks from . import tasks
from bootstrapvz.common.tools import rel_path from bootstrapvz.common.tools import rel_path

View file

@ -46,7 +46,7 @@ class InstallExpandRootScripts(Task):
# Copy files over # Copy files over
shutil.copy(expand_root_script, expand_root_script_dest) shutil.copy(expand_root_script, expand_root_script_dest)
os.chmod(expand_root_script_dest, 0750) os.chmod(expand_root_script_dest, 0o750)
shutil.copy(expand_root_service, expand_root_service_dest) shutil.copy(expand_root_service, expand_root_service_dest)
# Expand out options into expand-root script. # Expand out options into expand-root script.

View file

@ -1,4 +1,4 @@
import tasks from . import tasks
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):

View file

@ -1,4 +1,4 @@
import tasks from . import tasks
from bootstrapvz.common.tools import rel_path from bootstrapvz.common.tools import rel_path

View file

@ -1,8 +1,6 @@
import tasks.mounts from bootstrapvz.common.tasks import locale
import tasks.shrink from .tasks import mounts, shrink, apt, dpkg
import tasks.apt import bootstrapvz.common.tasks.dpkg
import tasks.dpkg
from bootstrapvz.common.tasks import dpkg, locale
def get_shrink_type(plugins): def get_shrink_type(plugins):
@ -33,47 +31,47 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
taskset.update([tasks.mounts.AddFolderMounts, taskset.update([mounts.AddFolderMounts,
tasks.mounts.RemoveFolderMounts, mounts.RemoveFolderMounts,
]) ])
if manifest.plugins['minimize_size'].get('zerofree', False): if manifest.plugins['minimize_size'].get('zerofree', False):
taskset.add(tasks.shrink.AddRequiredZeroFreeCommand) taskset.add(shrink.AddRequiredZeroFreeCommand)
taskset.add(tasks.shrink.Zerofree) taskset.add(shrink.Zerofree)
if get_shrink_type(manifest.plugins) == 'vmware-vdiskmanager': if get_shrink_type(manifest.plugins) == 'vmware-vdiskmanager':
taskset.add(tasks.shrink.AddRequiredVDiskManagerCommand) taskset.add(shrink.AddRequiredVDiskManagerCommand)
taskset.add(tasks.shrink.ShrinkVolumeWithVDiskManager) taskset.add(shrink.ShrinkVolumeWithVDiskManager)
if get_shrink_type(manifest.plugins) == 'qemu-img': if get_shrink_type(manifest.plugins) == 'qemu-img':
taskset.add(tasks.shrink.AddRequiredQemuImgCommand) taskset.add(shrink.AddRequiredQemuImgCommand)
taskset.add(tasks.shrink.ShrinkVolumeWithQemuImg) taskset.add(shrink.ShrinkVolumeWithQemuImg)
if 'apt' in manifest.plugins['minimize_size']: if 'apt' in manifest.plugins['minimize_size']:
apt = manifest.plugins['minimize_size']['apt'] msapt = manifest.plugins['minimize_size']['apt']
if apt.get('autoclean', False): if msapt.get('autoclean', False):
taskset.add(tasks.apt.AutomateAptClean) taskset.add(apt.AutomateAptClean)
if 'languages' in apt: if 'languages' in msapt:
taskset.add(tasks.apt.FilterTranslationFiles) taskset.add(apt.FilterTranslationFiles)
if apt.get('gzip_indexes', False): if msapt.get('gzip_indexes', False):
taskset.add(tasks.apt.AptGzipIndexes) taskset.add(apt.AptGzipIndexes)
if apt.get('autoremove_suggests', False): if msapt.get('autoremove_suggests', False):
taskset.add(tasks.apt.AptAutoremoveSuggests) taskset.add(apt.AptAutoremoveSuggests)
if 'dpkg' in manifest.plugins['minimize_size']: if 'dpkg' in manifest.plugins['minimize_size']:
filter_tasks = [dpkg.CreateDpkgCfg, filter_tasks = [bootstrapvz.common.tasks.dpkg.CreateDpkgCfg,
tasks.dpkg.InitializeBootstrapFilterList, dpkg.InitializeBootstrapFilterList,
tasks.dpkg.CreateBootstrapFilterScripts, dpkg.CreateBootstrapFilterScripts,
tasks.dpkg.DeleteBootstrapFilterScripts, dpkg.DeleteBootstrapFilterScripts,
] ]
msdpkg = manifest.plugins['minimize_size']['dpkg'] msdpkg = manifest.plugins['minimize_size']['dpkg']
if 'locales' in msdpkg: if 'locales' in msdpkg:
taskset.update(filter_tasks) taskset.update(filter_tasks)
taskset.add(tasks.dpkg.FilterLocales) taskset.add(dpkg.FilterLocales)
# If no locales are selected, we don't need the locale package # If no locales are selected, we don't need the locale package
if msdpkg['locales']: if msdpkg['locales']:
taskset.discard(locale.LocaleBootstrapPackage) taskset.discard(locale.LocaleBootstrapPackage)
taskset.discard(locale.GenerateLocale) taskset.discard(locale.GenerateLocale)
if msdpkg.get('exclude_docs', False): if msdpkg.get('exclude_docs', False):
taskset.update(filter_tasks) taskset.update(filter_tasks)
taskset.add(tasks.dpkg.ExcludeDocs) taskset.add(dpkg.ExcludeDocs)
def resolve_rollback_tasks(taskset, manifest, completed, counter_task): def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
counter_task(taskset, tasks.mounts.AddFolderMounts, tasks.mounts.RemoveFolderMounts) counter_task(taskset, mounts.AddFolderMounts, mounts.RemoveFolderMounts)
counter_task(taskset, tasks.dpkg.CreateBootstrapFilterScripts, tasks.dpkg.DeleteBootstrapFilterScripts) counter_task(taskset, dpkg.CreateBootstrapFilterScripts, dpkg.DeleteBootstrapFilterScripts)

View file

@ -48,7 +48,7 @@ class CreateBootstrapFilterScripts(Task):
include_list = '\n'.join(map(lambda p: '.' + p, filter_lists['include'])) include_list = '\n'.join(map(lambda p: '.' + p, filter_lists['include']))
sed_i(filter_script, r'EXCLUDE_PATTERN', exclude_list) sed_i(filter_script, r'EXCLUDE_PATTERN', exclude_list)
sed_i(filter_script, r'INCLUDE_PATHS', include_list) sed_i(filter_script, r'INCLUDE_PATHS', include_list)
os.chmod(filter_script, 0755) os.chmod(filter_script, 0o755)
info.bootstrap_script = bootstrap_script info.bootstrap_script = bootstrap_script
info._minimize_size['filter_script'] = filter_script info._minimize_size['filter_script'] = filter_script

View file

@ -57,7 +57,7 @@ class ShrinkVolumeWithVDiskManager(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
perm = os.stat(info.volume.image_path).st_mode & 0777 perm = os.stat(info.volume.image_path).st_mode & 0o777
log_check_call(['/usr/bin/vmware-vdiskmanager', '-k', info.volume.image_path]) log_check_call(['/usr/bin/vmware-vdiskmanager', '-k', info.volume.image_path])
os.chmod(info.volume.image_path, perm) os.chmod(info.volume.image_path, perm)

View file

@ -4,7 +4,7 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import tasks from . import tasks
taskset.add(tasks.AddNtpPackage) taskset.add(tasks.AddNtpPackage)
if manifest.plugins['ntp'].get('servers', False): if manifest.plugins['ntp'].get('servers', False):
taskset.add(tasks.SetNtpServers) taskset.add(tasks.SetNtpServers)

View file

@ -1,3 +1,5 @@
from __future__ import print_function
from bootstrapvz.base import Task from bootstrapvz.base import Task
from bootstrapvz.common import phases from bootstrapvz.common import phases
@ -27,6 +29,6 @@ class SetNtpServers(Task):
# Will write all the specified servers on the first match, then supress all other default servers # Will write all the specified servers on the first match, then supress all other default servers
if re.match(debian_ntp_server, line): if re.match(debian_ntp_server, line):
while servers: while servers:
print 'server {server_address} iburst'.format(server_address=servers.pop(0)) print('server {server_address} iburst'.format(server_address=servers.pop(0)))
else: else:
print line, print(line, end=' ')

View file

@ -1,7 +1,7 @@
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import tasks from . import tasks
from bootstrapvz.common.tasks import apt from bootstrapvz.common.tasks import apt
from bootstrapvz.common.releases import wheezy from bootstrapvz.common.releases import wheezy
if manifest.release == wheezy: if manifest.release == wheezy:

View file

@ -1,4 +1,4 @@
import tasks from . import tasks
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):

View file

@ -1,4 +1,4 @@
import tasks from . import tasks
from bootstrapvz.providers.ec2.tasks import ebs from bootstrapvz.providers.ec2.tasks import ebs
from bootstrapvz.plugins.minimize_size.tasks import dpkg from bootstrapvz.plugins.minimize_size.tasks import dpkg
from bootstrapvz.providers.virtualbox.tasks import guest_additions from bootstrapvz.providers.virtualbox.tasks import guest_additions
@ -10,6 +10,7 @@ from bootstrapvz.common.tasks import apt
from bootstrapvz.common.tasks import bootstrap from bootstrapvz.common.tasks import bootstrap
from bootstrapvz.common.tasks import filesystem from bootstrapvz.common.tasks import filesystem
from bootstrapvz.common.tasks import partitioning from bootstrapvz.common.tasks import partitioning
import bootstrapvz.common.tasks.dpkg
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):
@ -31,7 +32,7 @@ def resolve_tasks(taskset, manifest):
apt.DisableDaemonAutostart, apt.DisableDaemonAutostart,
dpkg.InitializeBootstrapFilterList, dpkg.InitializeBootstrapFilterList,
dpkg.CreateDpkgCfg, bootstrapvz.common.tasks.dpkg.CreateDpkgCfg,
dpkg.CreateBootstrapFilterScripts, dpkg.CreateBootstrapFilterScripts,
dpkg.FilterLocales, dpkg.FilterLocales,
dpkg.ExcludeDocs, dpkg.ExcludeDocs,

View file

@ -103,10 +103,10 @@ class CreateFromFolder(Task):
info.volume.fsm.current = 'attached' info.volume.fsm.current = 'attached'
def set_fs_states(volume): def set_fs_states(vol):
volume.fsm.current = 'detached' vol.fsm.current = 'detached'
p_map = volume.partition_map p_map = vol.partition_map
from bootstrapvz.base.fs.partitionmaps.none import NoPartitions from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
if not isinstance(p_map, NoPartitions): if not isinstance(p_map, NoPartitions):
p_map.fsm.current = 'unmapped' p_map.fsm.current = 'unmapped'

View file

@ -1,4 +1,4 @@
import tasks from . import tasks
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):

View file

@ -5,7 +5,6 @@ from bootstrapvz.common.tasks import apt
from bootstrapvz.common.exceptions import TaskError from bootstrapvz.common.exceptions import TaskError
from bootstrapvz.common.releases import jessie, wheezy, stretch from bootstrapvz.common.releases import jessie, wheezy, stretch
from bootstrapvz.common.tools import sed_i, log_check_call, rel_path from bootstrapvz.common.tools import sed_i, log_check_call, rel_path
from __builtin__ import str
ASSETS_DIR_STRETCH = rel_path(__file__, 'assets/gpg-keyrings-PC1/stretch') ASSETS_DIR_STRETCH = rel_path(__file__, 'assets/gpg-keyrings-PC1/stretch')
@ -19,7 +18,6 @@ class CheckRequestedDebianRelease(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from bootstrapvz.common.exceptions import TaskError
if info.manifest.release not in (jessie, wheezy, stretch): if info.manifest.release not in (jessie, wheezy, stretch):
msg = 'Debian {info.manifest.release} is not (yet) available in the Puppetlabs.com APT repository.' msg = 'Debian {info.manifest.release} is not (yet) available in the Puppetlabs.com APT repository.'
raise TaskError(msg) raise TaskError(msg)
@ -32,7 +30,6 @@ class CheckAssetsPath(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
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)

View file

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

View file

@ -1,4 +1,4 @@
import tasks from . import tasks
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):

View file

@ -1,5 +1,5 @@
from bootstrapvz.common.tasks.workspace import CreateWorkspace, DeleteWorkspace from bootstrapvz.common.tasks.workspace import CreateWorkspace, DeleteWorkspace
from tasks import CreateTmpFsWorkspace, MountTmpFsWorkspace, UnmountTmpFsWorkspace, DeleteTmpFsWorkspace from .tasks import CreateTmpFsWorkspace, MountTmpFsWorkspace, UnmountTmpFsWorkspace, DeleteTmpFsWorkspace
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):

View file

@ -6,6 +6,6 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
import tasks from . import tasks
taskset.add(tasks.AddUnattendedUpgradesPackage) taskset.add(tasks.AddUnattendedUpgradesPackage)
taskset.add(tasks.EnablePeriodicUpgrades) taskset.add(tasks.EnablePeriodicUpgrades)

View file

@ -1,4 +1,4 @@
import tasks from . import tasks
from bootstrapvz.common import task_groups from bootstrapvz.common import task_groups
from bootstrapvz.common.tasks import image, ssh, volume from bootstrapvz.common.tasks import image, ssh, volume
from bootstrapvz.common.tools import rel_path from bootstrapvz.common.tools import rel_path

View file

@ -1,12 +1,11 @@
from bootstrapvz.common import task_groups from bootstrapvz.common import task_groups
import tasks.packages
import tasks.boot
from bootstrapvz.common.tasks import image from bootstrapvz.common.tasks import image
from bootstrapvz.common.tasks import loopback from bootstrapvz.common.tasks import loopback
from bootstrapvz.common.tasks import initd from bootstrapvz.common.tasks import initd
from bootstrapvz.common.tasks import ssh from bootstrapvz.common.tasks import ssh
from bootstrapvz.common.tasks import apt from bootstrapvz.common.tasks import apt
from bootstrapvz.common.tasks import grub from bootstrapvz.common.tasks import grub
from .tasks import packages, boot
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):
@ -17,7 +16,7 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
taskset.update(task_groups.get_standard_groups(manifest)) taskset.update(task_groups.get_standard_groups(manifest))
taskset.update([apt.AddBackports, taskset.update([apt.AddBackports,
tasks.packages.DefaultPackages, packages.DefaultPackages,
loopback.AddRequiredCommands, loopback.AddRequiredCommands,
loopback.Create, loopback.Create,
image.MoveImage, image.MoveImage,
@ -25,9 +24,9 @@ def resolve_tasks(taskset, manifest):
ssh.AddOpenSSHPackage, ssh.AddOpenSSHPackage,
ssh.ShredHostkeys, ssh.ShredHostkeys,
ssh.AddSSHKeyGeneration, ssh.AddSSHKeyGeneration,
tasks.packages.Waagent, packages.Waagent,
tasks.boot.ConfigureGrub, boot.ConfigureGrub,
tasks.boot.PatchUdev, boot.PatchUdev,
]) ])
taskset.discard(grub.SetGrubConsolOutputDeviceToSerial) taskset.discard(grub.SetGrubConsolOutputDeviceToSerial)

View file

@ -1,9 +1,7 @@
from bootstrapvz.common import task_groups from bootstrapvz.common import task_groups
from bootstrapvz.common.tasks import apt, dpkg, folder, filesystem from bootstrapvz.common.tasks import apt, dpkg, folder, filesystem
from bootstrapvz.common.tools import rel_path from bootstrapvz.common.tools import rel_path
import tasks.commands from .tasks import commands, image, settings
import tasks.image
import tasks.settings
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):
@ -28,17 +26,17 @@ def resolve_tasks(taskset, manifest):
# Let the autostart of daemons by apt remain disabled # Let the autostart of daemons by apt remain disabled
taskset.discard(apt.EnableDaemonAutostart) taskset.discard(apt.EnableDaemonAutostart)
taskset.update([tasks.commands.AddRequiredCommands, taskset.update([commands.AddRequiredCommands,
tasks.image.CreateDockerfileEntry, image.CreateDockerfileEntry,
tasks.image.CreateImage, image.CreateImage,
tasks.settings.DpkgUnsafeIo, settings.DpkgUnsafeIo,
tasks.settings.AutoRemoveKernel, settings.AutoRemoveKernel,
tasks.settings.SystemdContainer settings.SystemdContainer
]) ])
if 'labels' in manifest.provider: if 'labels' in manifest.provider:
taskset.add(tasks.image.PopulateLabels) taskset.add(image.PopulateLabels)
if 'dockerfile' in manifest.provider: if 'dockerfile' in manifest.provider:
taskset.add(tasks.image.AppendManifestDockerfile) taskset.add(image.AppendManifestDockerfile)
def resolve_rollback_tasks(taskset, manifest, completed, counter_task): def resolve_rollback_tasks(taskset, manifest, completed, counter_task):

View file

@ -1,16 +1,10 @@
from bootstrapvz.common import task_groups from bootstrapvz.common import task_groups
import tasks.packages from .tasks import packages, connection, host, ami, ebs, filesystem, boot, network, initd, tuning
import tasks.connection import bootstrapvz.common.tasks.boot
import tasks.host import bootstrapvz.common.tasks.filesystem
import tasks.ami import bootstrapvz.common.tasks.grub
import tasks.ebs import bootstrapvz.common.tasks.initd
import tasks.filesystem from bootstrapvz.common.tasks import apt, kernel, loopback, volume
import tasks.boot
import tasks.network
import tasks.initd
import tasks.tuning
from bootstrapvz.common.tasks import apt, boot, filesystem, grub, initd
from bootstrapvz.common.tasks import kernel, loopback, volume
from bootstrapvz.common.tools import rel_path from bootstrapvz.common.tools import rel_path
@ -57,94 +51,94 @@ def resolve_tasks(taskset, manifest):
taskset.update(task_groups.get_standard_groups(manifest)) taskset.update(task_groups.get_standard_groups(manifest))
taskset.update(task_groups.ssh_group) taskset.update(task_groups.ssh_group)
taskset.update([tasks.host.AddExternalCommands, taskset.update([host.AddExternalCommands,
tasks.packages.DefaultPackages, packages.DefaultPackages,
tasks.connection.SilenceBotoDebug, connection.SilenceBotoDebug,
tasks.connection.GetCredentials, connection.GetCredentials,
tasks.ami.AMIName, ami.AMIName,
tasks.connection.Connect, connection.Connect,
tasks.tuning.TuneSystem, tuning.TuneSystem,
tasks.tuning.BlackListModules, tuning.BlackListModules,
boot.BlackListModules, bootstrapvz.common.tasks.boot.BlackListModules,
boot.DisableGetTTYs, bootstrapvz.common.tasks.boot.DisableGetTTYs,
tasks.boot.AddXenGrubConsoleOutputDevice, boot.AddXenGrubConsoleOutputDevice,
grub.WriteGrubConfig, bootstrapvz.common.tasks.grub.WriteGrubConfig,
tasks.boot.UpdateGrubConfig, boot.UpdateGrubConfig,
initd.AddExpandRoot, bootstrapvz.common.tasks.initd.AddExpandRoot,
initd.RemoveHWClock, bootstrapvz.common.tasks.initd.RemoveHWClock,
initd.InstallInitScripts, bootstrapvz.common.tasks.initd.InstallInitScripts,
tasks.ami.RegisterAMI, ami.RegisterAMI,
]) ])
if manifest.release > wheezy: if manifest.release > wheezy:
taskset.add(tasks.network.InstallNetworkingUDevHotplugAndDHCPSubinterface) taskset.add(network.InstallNetworkingUDevHotplugAndDHCPSubinterface)
if manifest.release <= wheezy: if manifest.release <= wheezy:
# The default DHCP client `isc-dhcp' doesn't work properly on wheezy and earlier # The default DHCP client `isc-dhcp' doesn't work properly on wheezy and earlier
taskset.add(tasks.network.InstallDHCPCD) taskset.add(network.InstallDHCPCD)
taskset.add(tasks.network.EnableDHCPCDDNS) taskset.add(network.EnableDHCPCDDNS)
if manifest.release >= jessie: if manifest.release >= jessie:
taskset.add(tasks.packages.AddWorkaroundGrowpart) taskset.add(packages.AddWorkaroundGrowpart)
taskset.add(initd.AdjustGrowpartWorkaround) taskset.add(bootstrapvz.common.tasks.initd.AdjustGrowpartWorkaround)
if manifest.system['bootloader'] == 'grub': if manifest.system['bootloader'] == 'grub':
taskset.add(grub.EnableSystemd) taskset.add(bootstrapvz.common.tasks.grub.EnableSystemd)
if manifest.release <= stable: if manifest.release <= stable:
taskset.add(apt.AddBackports) taskset.add(apt.AddBackports)
if manifest.provider.get('install_init_scripts', True): if manifest.provider.get('install_init_scripts', True):
taskset.add(tasks.initd.AddEC2InitScripts) taskset.add(initd.AddEC2InitScripts)
if manifest.volume['partitions']['type'] != 'none': if manifest.volume['partitions']['type'] != 'none':
taskset.add(initd.AdjustExpandRootScript) taskset.add(bootstrapvz.common.tasks.initd.AdjustExpandRootScript)
if manifest.system['bootloader'] == 'pvgrub': if manifest.system['bootloader'] == 'pvgrub':
taskset.add(grub.AddGrubPackage) taskset.add(bootstrapvz.common.tasks.grub.AddGrubPackage)
taskset.update([grub.AddGrubPackage, taskset.update([bootstrapvz.common.tasks.grub.AddGrubPackage,
grub.InitGrubConfig, bootstrapvz.common.tasks.grub.InitGrubConfig,
grub.SetGrubTerminalToConsole, bootstrapvz.common.tasks.grub.SetGrubTerminalToConsole,
grub.SetGrubConsolOutputDeviceToSerial, bootstrapvz.common.tasks.grub.SetGrubConsolOutputDeviceToSerial,
grub.RemoveGrubTimeout, bootstrapvz.common.tasks.grub.RemoveGrubTimeout,
grub.DisableGrubRecovery, bootstrapvz.common.tasks.grub.DisableGrubRecovery,
tasks.boot.CreatePVGrubCustomRule, boot.CreatePVGrubCustomRule,
tasks.boot.ConfigurePVGrub, boot.ConfigurePVGrub,
grub.WriteGrubConfig, bootstrapvz.common.tasks.grub.WriteGrubConfig,
tasks.boot.UpdateGrubConfig, boot.UpdateGrubConfig,
tasks.boot.LinkGrubConfig]) boot.LinkGrubConfig])
if manifest.volume['backing'].lower() == 'ebs': if manifest.volume['backing'].lower() == 'ebs':
taskset.update([tasks.host.GetInstanceMetadata, taskset.update([host.GetInstanceMetadata,
tasks.ebs.Create, ebs.Create,
tasks.ebs.Snapshot, ebs.Snapshot,
]) ])
taskset.add(tasks.ebs.Attach) taskset.add(ebs.Attach)
taskset.discard(volume.Attach) taskset.discard(volume.Attach)
if manifest.volume['backing'].lower() == 's3': if manifest.volume['backing'].lower() == 's3':
taskset.update([loopback.AddRequiredCommands, taskset.update([loopback.AddRequiredCommands,
tasks.host.SetRegion, host.SetRegion,
loopback.Create, loopback.Create,
tasks.filesystem.S3FStab, filesystem.S3FStab,
tasks.ami.BundleImage, ami.BundleImage,
tasks.ami.UploadImage, ami.UploadImage,
tasks.ami.RemoveBundle, ami.RemoveBundle,
]) ])
taskset.discard(filesystem.FStab) taskset.discard(bootstrapvz.common.tasks.filesystem.FStab)
if manifest.provider.get('enhanced_networking', None) == 'simple': if manifest.provider.get('enhanced_networking', None) == 'simple':
taskset.update([kernel.AddDKMSPackages, taskset.update([kernel.AddDKMSPackages,
tasks.network.InstallEnhancedNetworking, network.InstallEnhancedNetworking,
tasks.network.InstallENANetworking, network.InstallENANetworking,
kernel.UpdateInitramfs]) kernel.UpdateInitramfs])
taskset.update([filesystem.Format, taskset.update([bootstrapvz.common.tasks.filesystem.Format,
volume.Delete, volume.Delete,
]) ])
def resolve_rollback_tasks(taskset, manifest, completed, counter_task): def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
taskset.update(task_groups.get_standard_rollback_tasks(completed)) taskset.update(task_groups.get_standard_rollback_tasks(completed))
counter_task(taskset, tasks.ebs.Create, volume.Delete) counter_task(taskset, ebs.Create, volume.Delete)
counter_task(taskset, tasks.ebs.Attach, volume.Detach) counter_task(taskset, ebs.Attach, volume.Detach)
counter_task(taskset, tasks.ami.BundleImage, tasks.ami.RemoveBundle) counter_task(taskset, ami.BundleImage, ami.RemoveBundle)

View file

@ -2,9 +2,9 @@ from bootstrapvz.base import Task
from bootstrapvz.common import phases from bootstrapvz.common import phases
from bootstrapvz.common.exceptions import TaskError from bootstrapvz.common.exceptions import TaskError
from bootstrapvz.common.tools import log_check_call, rel_path from bootstrapvz.common.tools import log_check_call, rel_path
from ebs import Snapshot from .ebs import Snapshot
from bootstrapvz.common.tasks import workspace from bootstrapvz.common.tasks import workspace
import connection from . import connection
from . import assets from . import assets
import os.path import os.path

View file

@ -44,7 +44,7 @@ class CreatePVGrubCustomRule(Task):
script_src = os.path.join(assets, 'grub.d/40_custom') script_src = os.path.join(assets, 'grub.d/40_custom')
script_dst = os.path.join(info.root, 'etc/grub.d/40_custom') script_dst = os.path.join(info.root, 'etc/grub.d/40_custom')
copy(script_src, script_dst) copy(script_src, script_dst)
os.chmod(script_dst, 0755) os.chmod(script_dst, 0o755)
from bootstrapvz.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):

View file

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

View file

@ -57,8 +57,8 @@ class InstallNetworkingUDevHotplugAndDHCPSubinterface(Task):
os.path.join(script_dst, 'udev/rules.d/53-ec2-network-interfaces.rules')) os.path.join(script_dst, 'udev/rules.d/53-ec2-network-interfaces.rules'))
os.chmod(os.path.join(script_dst, 'udev/rules.d/53-ec2-network-interfaces.rules'), rwxr_xr_x) os.chmod(os.path.join(script_dst, 'udev/rules.d/53-ec2-network-interfaces.rules'), rwxr_xr_x)
os.mkdir(os.path.join(script_dst, 'sysconfig'), 0755) os.mkdir(os.path.join(script_dst, 'sysconfig'), 0o755)
os.mkdir(os.path.join(script_dst, 'sysconfig/network-scripts'), 0755) os.mkdir(os.path.join(script_dst, 'sysconfig/network-scripts'), 0o755)
copy(os.path.join(script_src, 'ec2net.hotplug'), copy(os.path.join(script_src, 'ec2net.hotplug'),
os.path.join(script_dst, 'sysconfig/network-scripts/ec2net.hotplug')) os.path.join(script_dst, 'sysconfig/network-scripts/ec2net.hotplug'))
os.chmod(os.path.join(script_dst, 'sysconfig/network-scripts/ec2net.hotplug'), rwxr_xr_x) os.chmod(os.path.join(script_dst, 'sysconfig/network-scripts/ec2net.hotplug'), rwxr_xr_x)

View file

@ -14,7 +14,7 @@ class TuneSystem(Task):
sysctl_src = os.path.join(assets, 'sysctl.d/tuning.conf') sysctl_src = os.path.join(assets, 'sysctl.d/tuning.conf')
sysctl_dst = os.path.join(info.root, 'etc/sysctl.d/01_ec2.conf') sysctl_dst = os.path.join(info.root, 'etc/sysctl.d/01_ec2.conf')
copy(sysctl_src, sysctl_dst) copy(sysctl_src, sysctl_dst)
os.chmod(sysctl_dst, 0644) os.chmod(sysctl_dst, 0o644)
class BlackListModules(Task): class BlackListModules(Task):

View file

@ -1,11 +1,9 @@
import bootstrapvz.common.tasks.apt
import bootstrapvz.common.tasks.boot
import bootstrapvz.common.tasks.image
from bootstrapvz.common.tasks import loopback, initd, ssh, volume, grub
from bootstrapvz.common import task_groups from bootstrapvz.common import task_groups
import tasks.apt from .tasks import apt, boot, configuration, image, packages
import tasks.boot
import tasks.configuration
import tasks.image
import tasks.packages
from bootstrapvz.common.tasks import apt, boot, image, loopback, initd
from bootstrapvz.common.tasks import ssh, volume, grub
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):
@ -15,30 +13,30 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
taskset.update(task_groups.get_standard_groups(manifest)) taskset.update(task_groups.get_standard_groups(manifest))
taskset.update([apt.AddBackports, taskset.update([bootstrapvz.common.tasks.apt.AddBackports,
apt.AddDefaultSources, bootstrapvz.common.tasks.apt.AddDefaultSources,
loopback.AddRequiredCommands, loopback.AddRequiredCommands,
loopback.Create, loopback.Create,
tasks.packages.DefaultPackages, packages.DefaultPackages,
tasks.configuration.GatherReleaseInformation, configuration.GatherReleaseInformation,
tasks.boot.ConfigureGrub, boot.ConfigureGrub,
initd.InstallInitScripts, initd.InstallInitScripts,
boot.BlackListModules, bootstrapvz.common.tasks.boot.BlackListModules,
boot.UpdateInitramfs, bootstrapvz.common.tasks.boot.UpdateInitramfs,
ssh.AddSSHKeyGeneration, ssh.AddSSHKeyGeneration,
ssh.DisableSSHPasswordAuthentication, ssh.DisableSSHPasswordAuthentication,
ssh.DisableRootLogin, ssh.DisableRootLogin,
tasks.apt.AddBaselineAptCache, apt.AddBaselineAptCache,
image.MoveImage, bootstrapvz.common.tasks.image.MoveImage,
tasks.image.CreateTarball, image.CreateTarball,
volume.Delete, volume.Delete,
]) ])
taskset.discard(grub.SetGrubConsolOutputDeviceToSerial) taskset.discard(grub.SetGrubConsolOutputDeviceToSerial)
if 'gcs_destination' in manifest.provider: if 'gcs_destination' in manifest.provider:
taskset.add(tasks.image.UploadImage) taskset.add(image.UploadImage)
if 'gce_project' in manifest.provider: if 'gce_project' in manifest.provider:
taskset.add(tasks.image.RegisterImage) taskset.add(image.RegisterImage)
def resolve_rollback_tasks(taskset, manifest, completed, counter_task): def resolve_rollback_tasks(taskset, manifest, completed, counter_task):

View file

@ -1,7 +1,6 @@
from bootstrapvz.common import task_groups from bootstrapvz.common import task_groups
import tasks.packages
import tasks.boot
from bootstrapvz.common.tasks import image, loopback, initd, ssh, logicalvolume from bootstrapvz.common.tasks import image, loopback, initd, ssh, logicalvolume
from .tasks import packages, boot
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):
@ -12,7 +11,7 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
taskset.update(task_groups.get_standard_groups(manifest)) taskset.update(task_groups.get_standard_groups(manifest))
taskset.update([tasks.packages.DefaultPackages, taskset.update([packages.DefaultPackages,
initd.InstallInitScripts, initd.InstallInitScripts,
ssh.AddOpenSSHPackage, ssh.AddOpenSSHPackage,
ssh.ShredHostkeys, ssh.ShredHostkeys,
@ -29,17 +28,17 @@ def resolve_tasks(taskset, manifest):
]) ])
if manifest.provider.get('virtio', []): if manifest.provider.get('virtio', []):
from tasks import virtio from .tasks import virtio
taskset.update([virtio.VirtIO]) taskset.update([virtio.VirtIO])
if manifest.provider.get('console', False): if manifest.provider.get('console', False):
if manifest.provider['console'] == 'virtual': if manifest.provider['console'] == 'virtual':
taskset.update([tasks.boot.SetGrubConsolOutputDeviceToVirtual]) taskset.update([boot.SetGrubConsolOutputDeviceToVirtual])
from bootstrapvz.common.releases import jessie from bootstrapvz.common.releases import jessie
if manifest.release >= jessie: if manifest.release >= jessie:
taskset.update([tasks.boot.SetGrubConsolOutputDeviceToVirtual, taskset.update([boot.SetGrubConsolOutputDeviceToVirtual,
tasks.boot.SetSystemdTTYVTDisallocate, boot.SetSystemdTTYVTDisallocate,
]) ])

View file

@ -39,5 +39,5 @@ class SetSystemdTTYVTDisallocate(Task):
src = os.path.join(assets, 'noclear.conf') src = os.path.join(assets, 'noclear.conf')
dst_dir = os.path.join(info.root, 'etc/systemd/system/getty@tty1.service.d') dst_dir = os.path.join(info.root, 'etc/systemd/system/getty@tty1.service.d')
dst = os.path.join(dst_dir, 'noclear.conf') dst = os.path.join(dst_dir, 'noclear.conf')
os.mkdir(dst_dir, 0755) os.mkdir(dst_dir, 0o755)
copy(src, dst) copy(src, dst)

View file

@ -1,9 +1,7 @@
import bootstrapvz.common.tasks.image
from bootstrapvz.common import task_groups from bootstrapvz.common import task_groups
from bootstrapvz.common.tasks import image, loopback, ssh, volume from bootstrapvz.common.tasks import loopback, ssh, volume
import tasks.api from .tasks import api, image, network, packages
import tasks.image
import tasks.network
import tasks.packages
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):
@ -26,20 +24,20 @@ def resolve_tasks(taskset, manifest):
taskset.update([loopback.AddRequiredCommands, taskset.update([loopback.AddRequiredCommands,
loopback.Create, loopback.Create,
image.MoveImage, bootstrapvz.common.tasks.image.MoveImage,
ssh.DisableRootLogin, ssh.DisableRootLogin,
volume.Delete, volume.Delete,
tasks.image.CreateImageTarball, image.CreateImageTarball,
tasks.network.InstallDHCPCD, network.InstallDHCPCD,
tasks.packages.DefaultPackages, packages.DefaultPackages,
]) ])
if 'credentials' in manifest.provider: if 'credentials' in manifest.provider:
taskset.add(tasks.api.Connect) taskset.add(api.Connect)
taskset.add(tasks.image.UploadImageTarball) taskset.add(image.UploadImageTarball)
if manifest.provider.get('verify', False): if manifest.provider.get('verify', False):
taskset.add(tasks.image.DownloadImageTarball) taskset.add(image.DownloadImageTarball)
taskset.add(tasks.image.CompareImageTarballs) taskset.add(image.CompareImageTarballs)
def resolve_rollback_tasks(taskset, manifest, completed, counter_task): def resolve_rollback_tasks(taskset, manifest, completed, counter_task):

View file

@ -16,4 +16,4 @@ class Connect(Task):
container=info.manifest.provider['container'], container=info.manifest.provider['container'],
) )
# Try to fetch the token, so it will fail early if the credentials are wrong # Try to fetch the token, so it will fail early if the credentials are wrong
info._oracle['client'].auth_token info._oracle['client'].auth_token # pylint: disable=pointless-statement

View file

@ -1,8 +1,7 @@
from bootstrapvz.common import task_groups from bootstrapvz.common import task_groups
import tasks.packages
import tasks.boot
from bootstrapvz.common.tasks import image from bootstrapvz.common.tasks import image
from bootstrapvz.common.tasks import loopback from bootstrapvz.common.tasks import loopback
from .tasks import packages, boot
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):
@ -13,15 +12,15 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
taskset.update(task_groups.get_standard_groups(manifest)) taskset.update(task_groups.get_standard_groups(manifest))
taskset.update([tasks.packages.DefaultPackages, taskset.update([packages.DefaultPackages,
tasks.boot.AddVirtualConsoleGrubOutputDevice, boot.AddVirtualConsoleGrubOutputDevice,
loopback.AddRequiredCommands, loopback.AddRequiredCommands,
loopback.Create, loopback.Create,
image.MoveImage, image.MoveImage,
]) ])
if manifest.provider.get('guest_additions', False): if manifest.provider.get('guest_additions', False):
from tasks import guest_additions from .tasks import guest_additions
taskset.update([guest_additions.CheckGuestAdditionsPath, taskset.update([guest_additions.CheckGuestAdditionsPath,
guest_additions.AddGuestAdditionsPackages, guest_additions.AddGuestAdditionsPackages,
guest_additions.InstallGuestAdditions, guest_additions.InstallGuestAdditions,

View file

@ -25,12 +25,13 @@ def pick_build_server(build_servers, manifest, preferences={}):
for name, settings in build_servers.iteritems(): for name, settings in build_servers.iteritems():
if not matches(name, settings): if not matches(name, settings):
continue continue
if settings['type'] == 'local': if settings['type'] == 'local': # pylint: disable=no-else-return
from local import LocalBuildServer from .local import LocalBuildServer
return LocalBuildServer(name, settings) return LocalBuildServer(name, settings)
else: else:
from remote import RemoteBuildServer from .remote import RemoteBuildServer
return RemoteBuildServer(name, settings) return RemoteBuildServer(name, settings)
raise Exception('Unable to find a build server that matches your preferences.') raise Exception('Unable to find a build server that matches your preferences.')

View file

@ -22,7 +22,7 @@ class CallbackServer(object):
self.thread.start() self.thread.start()
return self return self
def __exit__(self, type, value, traceback): def __exit__(self, exception_type, exception_value, traceback):
log.debug('Shutting down callback server') log.debug('Shutting down callback server')
self.daemon.shutdown() self.daemon.shutdown()
self.thread.join() self.thread.join()
@ -31,7 +31,6 @@ class CallbackServer(object):
def handle_log(self, pickled_record): def handle_log(self, pickled_record):
import pickle import pickle
record = pickle.loads(pickled_record) record = pickle.loads(pickled_record)
log = logging.getLogger()
record.extra = getattr(record, 'extra', {}) record.extra = getattr(record, 'extra', {})
record.extra['source'] = 'remote' record.extra['source'] = 'remote'
log.handle(record) log.handle(record)

View file

@ -1,4 +1,4 @@
from build_server import BuildServer from .build_server import BuildServer
from contextlib import contextmanager from contextlib import contextmanager

View file

@ -1,4 +1,4 @@
from build_server import BuildServer from .build_server import BuildServer
from bootstrapvz.common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from contextlib import contextmanager from contextlib import contextmanager
import logging import logging
@ -21,7 +21,7 @@ class RemoteBuildServer(BuildServer):
with self.spawn_server() as forwards: with self.spawn_server() as forwards:
args = {'listen_port': forwards['local_callback_port'], args = {'listen_port': forwards['local_callback_port'],
'remote_port': forwards['remote_callback_port']} 'remote_port': forwards['remote_callback_port']}
from callback import CallbackServer from .callback import CallbackServer
with CallbackServer(**args) as callback_server: with CallbackServer(**args) as callback_server:
with connect_pyro('localhost', forwards['local_server_port']) as connection: with connect_pyro('localhost', forwards['local_server_port']) as connection:
connection.set_callback_server(callback_server) connection.set_callback_server(callback_server)

View file

@ -15,7 +15,7 @@ def main():
# load the build servers file # load the build servers file
build_servers = load_data(opts['--servers']) build_servers = load_data(opts['--servers'])
# Pick a build server # Pick a build server
from build_servers import pick_build_server from .build_servers import pick_build_server
preferences = {} preferences = {}
if opts['--name'] is not None: if opts['--name'] is not None:
preferences['name'] = opts['--name'] preferences['name'] = opts['--name']

View file

@ -18,7 +18,7 @@ def setup_logging():
root = logging.getLogger() root = logging.getLogger()
root.setLevel(logging.NOTSET) root.setLevel(logging.NOTSET)
from log import LogForwarder from .log import LogForwarder
log_forwarder = LogForwarder() log_forwarder = LogForwarder()
root.addHandler(log_forwarder) root.addHandler(log_forwarder)
@ -69,6 +69,7 @@ class Server(object):
@Pyro4.expose @Pyro4.expose
def ping(self): def ping(self):
if hasattr(self, 'connection_timeout'): if hasattr(self, 'connection_timeout'):
# pylint: disable=no-member
self.connection_timeout.cancel() self.connection_timeout.cancel()
del self.connection_timeout del self.connection_timeout
return 'pong' return 'pong'
@ -114,7 +115,7 @@ class Server(object):
try: try:
bootstrap_info = run(manifest, debug=debug, dry_run=dry_run) bootstrap_info = run(manifest, debug=debug, dry_run=dry_run)
queue.put(bootstrap_info) queue.put(bootstrap_info)
except (Exception, KeyboardInterrupt) as e: except (Exception, KeyboardInterrupt) as e: # pylint: disable=broad-except
queue.put(e) queue.put(e)
from multiprocessing import Queue from multiprocessing import Queue

View file

@ -27,23 +27,35 @@ load-plugins=
# Enable the message, report, category or checker with the given id(s). You can # Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option # either give multiple identifier separated by comma (,) or put this option
# multiple time. # multiple time.
enable=W0401,W0611 enable=
# Disable the message, report, category or checker with the given id(s). You # Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option # can either give multiple identifier separated by comma (,) or put this option
# multiple time. # multiple time.
disable=C0111,I0011,I0020,R0201,R0801,R0914,R1704,R1705,R1710,W,E0632,E1101,E1121,E1601,E1608,C0103,C0301,C0325,C0326,C0330,C0411,R0401 disable=W0511,C0111,I0011,I0020,R0201,R0801,E0632,E1121,W0102,W0106,W0108,W0110,W0201,W0212,W0311,W0402,W0612,W0613,W0640,W1201,W1202,W1401,C0103,C0301,C0325,C0326,C0330,C0411,R0401,R0914,R1710
# C0111 mssing-docstring # W0511 fixme
# C0111 missing-docstring
# I0011 locally-disabled # I0011 locally-disabled
# I0020 suppressed-message # I0020 suppressed-message
# R0801 duplicate-code # R0801 duplicate-code
#TODO #TODO
# E0632(unbalanced-tuple-unpacking) # E0632(unbalanced-tuple-unpacking)
# E1101(no-member)
# E1121(too-many-function-args) # E1121(too-many-function-args)
# E1601(print-statement) # W0102(dangerous-default-value)
# E1608(old-octal-literal) # W0106(expression-not-assigned)
# W0108(unnecessary-lambda)
# W0110(deprecated-lambda)
# W0201(attribute-defined-outside-init)
# W0212(protected-access)
# W0311(bad-indentation)
# W0402(deprecated-module)
# W0612(unused-variable)
# W0613(unused-argument)
# W0640(cell-var-from-loop)
# W1201(logging-not-lazy)
# W1202(logging-format-interpolation)
# W1401(anomalous-backslash-in-string)
# C0103(invalid-name) # C0103(invalid-name)
# C0411(wrong-import-order) # C0411(wrong-import-order)
# C0301(line-too-long) # C0301(line-too-long)
@ -53,10 +65,7 @@ disable=C0111,I0011,I0020,R0201,R0801,R0914,R1704,R1705,R1710,W,E0632,E1101,E112
# R0201(no-self-use) # R0201(no-self-use)
# R0401(cyclic-import) # R0401(cyclic-import)
# R0914(too-many-locals) # R0914(too-many-locals)
# R1704(redefined-argument-from-local)
# R1705(no-else-return)
# R1710(inconsistent-return-statements) # R1710(inconsistent-return-statements)
# W all warnings
[REPORTS] [REPORTS]
@ -190,7 +199,7 @@ ignore-mixin-members=yes
# List of classes names for which member attributes should not be checked # List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set). # (useful for classes with attributes dynamically set).
ignored-classes=SQLObject ignored-classes=Fysom,AbstractPartitionMap,OracleStorageAPIClient
# When zope mode is activated, add a predefined set of Zope acquired attributes # When zope mode is activated, add a predefined set of Zope acquired attributes
# to generated-members. # to generated-members.

View file

@ -4,6 +4,6 @@
def recursive_glob(path, pattern): def recursive_glob(path, pattern):
import fnmatch import fnmatch
import os import os
for path, dirnames, filenames in os.walk(path): for root, dirnames, filenames in os.walk(path):
for filename in fnmatch.filter(filenames, pattern): for filename in fnmatch.filter(filenames, pattern):
yield os.path.join(path, filename) yield os.path.join(root, filename)

View file

@ -1,5 +1,5 @@
from manifests import merge_manifest_data from .manifests import merge_manifest_data
from tools import boot_manifest from .tools import boot_manifest
partials = {'docker': ''' partials = {'docker': '''
provider: provider:
@ -26,4 +26,4 @@ def test_stable():
custom_partials = [partials['docker']] custom_partials = [partials['docker']]
manifest_data = merge_manifest_data(std_partials, custom_partials) manifest_data = merge_manifest_data(std_partials, custom_partials)
with boot_manifest(manifest_data) as instance: with boot_manifest(manifest_data) as instance:
print('\n'.join(instance.run(['echo', 'test']))) print('\n'.join(instance.run(['echo', 'test']))) # pylint: disable=print-statement

View file

@ -1,5 +1,7 @@
from manifests import merge_manifest_data from .manifests import merge_manifest_data
from tools import boot_manifest from .tools import boot_manifest
# pylint: disable=print-statement
partials = {'ebs_hvm': ''' partials = {'ebs_hvm': '''
provider: provider:

Some files were not shown because too many files have changed in this diff Show more