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 task import Task
from main import main
from .phase import Phase
from .task import Task
from .main import 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)
# 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'])
# The default apt mirror
@ -40,13 +40,13 @@ class BootstrapInformation(object):
# Keep a list of apt sources,
# 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)
# Keep a list of apt preferences
from pkg.preferenceslist import PreferenceLists
from .pkg.preferenceslist import PreferenceLists
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
from pkg.packagelist import PackageList
from .pkg.packagelist import PackageList
self.packages = PackageList(self.manifest_vars, self.source_lists)
# 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
"""
# Map valid partition maps in the manifest and their corresponding classes
from partitionmaps.gpt import GPTPartitionMap
from partitionmaps.msdos import MSDOSPartitionMap
from partitionmaps.none import NoPartitions
from .partitionmaps.gpt import GPTPartitionMap
from .partitionmaps.msdos import MSDOSPartitionMap
from .partitionmaps.none import NoPartitions
partition_map = {'none': NoPartitions,
'gpt': GPTPartitionMap,
'msdos': MSDOSPartitionMap,

View file

@ -1,4 +1,4 @@
from abstract import AbstractPartitionMap
from .abstract import AbstractPartitionMap
from ..partitions.gpt import GPTPartition
from ..partitions.gpt_swap import GPTSwapPartition
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 ..partitions.msdos import MSDOSPartition
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
"""
# 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)
if self.fsm.current == 'mounted':
mount.mount(self.mount_dir)

View file

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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
from abstract import AbstractPartition
from .abstract import AbstractPartition
import os.path
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):

View file

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

View file

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

View file

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

View file

@ -2,7 +2,7 @@ from abc import ABCMeta
from bootstrapvz.common.fsm_proxy import FSMProxy
from bootstrapvz.common.tools import log_check_call
from .exceptions import VolumeError
from partitionmaps.none import NoPartitions
from .partitionmaps.none import NoPartitions
class Volume(FSMProxy):
@ -82,7 +82,9 @@ class Volume(FSMProxy):
:raises VolumeError: When a free block device cannot be found.
"""
import os.path
import string
from bootstrapvz.common.fs import get_partitions
# Fetch information from /proc/partitions
proc_partitions = get_partitions()
device_name = os.path.basename(self.device_path)
@ -104,8 +106,7 @@ class Volume(FSMProxy):
major=device_partition['major'],
minor=device_partition['minor'],
start_sec=start_sector))
import string
import os.path
# Figure out the device letter and path
for letter in string.ascii_lowercase:
dev_name = 'vd' + letter

View file

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

View file

@ -19,7 +19,7 @@ def main():
setup_loggers(opts)
# Load the manifest
from manifest import Manifest
from .manifest import Manifest
manifest = Manifest(path=opts['MANIFEST'])
# Everything has been set up, begin the bootstrapping process
@ -62,7 +62,7 @@ def setup_loggers(opts):
root = logging.getLogger()
root.setLevel(logging.NOTSET)
import log
from . import log
# Log to file unless --log is a single dash
if opts['--log'] != '-':
import os.path
@ -95,15 +95,15 @@ def run(manifest, debug=False, pause_on_error=False, dry_run=False):
log = logging.getLogger(__name__)
# Get the tasklist
from tasklist import load_tasks
from tasklist import TaskList
from .tasklist import load_tasks
from .tasklist import TaskList
log.info('Generating tasklist')
tasks = load_tasks('resolve_tasks', manifest)
tasklist = TaskList(tasks)
# '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
from bootstrapinfo import BootstrapInformation
from .bootstrapinfo import BootstrapInformation
bootstrap_info = BootstrapInformation(manifest=manifest, debug=debug)
try:

View file

@ -22,8 +22,7 @@ class PackageList(object):
"""
if self.target is None:
return self.name
else:
return self.name + '/' + self.target
return self.name + '/' + self.target
class Local(object):
"""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 the specified target release could not be found.
"""
from exceptions import PackageError
from .exceptions import PackageError
name = name.format(**self.manifest_vars)
if target is not None:
target = target.format(**self.manifest_vars)

View file

@ -63,7 +63,7 @@ class Source(object):
'(\s+(?P<components>.+\S))?\s*$')
match = regexp.match(line).groupdict()
if match is None:
from exceptions import SourceError
from .exceptions import SourceError
raise SourceError('Unable to parse source line: ' + line)
self.type = match['type']
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)
def is_task(obj):
from task import Task
from .task import Task
return issubclass(obj, Task) and obj is not Task
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):

View file

@ -1,4 +1,4 @@
from qemuvolume import QEMUVolume
from .qemuvolume import 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 ..tools import log_check_call
from . import get_partitions
@ -9,7 +9,12 @@ class QEMUVolume(LoopbackVolume):
def _before_create(self, e):
self.image_path = e.image_path
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):
from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
@ -62,8 +67,8 @@ class QEMUVolume(LoopbackVolume):
def _module_param(self, module, param):
import os.path
param_path = os.path.join('/sys/module', module, 'parameters', param)
with open(param_path) as param:
return param.read().strip()
with open(param_path) as param_file:
return param_file.read().strip()
# 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

View file

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

View file

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

View file

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

View file

@ -58,7 +58,7 @@ def get_release(release_name):
"""Normalizes the release codenames
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)
if release is None or not isinstance(release, _Release):
raise UnknownReleaseException('The release `{name}\' is unknown'.format(name=release))

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,7 +3,7 @@ from .. import phases
from ..tools import log_check_call
import os.path
from . import assets
import initd
from . import initd
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_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
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]
public = [path + '.pub' for path in private]
from ..tools import log_check_call
log_check_call(['shred', '--remove'] + [key for key in private + public
if os.path.isfile(key)])

View file

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

View file

@ -1,3 +1,4 @@
from __future__ import print_function
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):
replacement_count = inline_replace(file_path, pattern, subst)
if replacement_count != expected_replacements:
from exceptions import UnexpectedNumMatchesError
from .exceptions import UnexpectedNumMatchesError
msg = ('There were {real} instead of {expected} matches for '
'the expression `{exp}\' in the file `{path}\''
.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):
(replacement, count) = re.subn(pattern, subst, line)
replacement_count += count
print replacement,
print(replacement, end=' ')
return replacement_count
@ -136,5 +137,4 @@ def copy_tree(from_path, to_path):
def rel_path(base, path):
import os.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):
import logging
import tasks
from . import tasks
from bootstrapvz.common.tasks import ssh
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
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=)
import stat

View file

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

View file

@ -4,7 +4,7 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest):
import tasks
from . import tasks
taskset.add(tasks.CheckAptProxy)
taskset.add(tasks.SetAptProxy)
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)
try:
urllib2.urlopen(proxy_url, timeout=5)
except Exception as e:
except urllib2.URLError as e:
# 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':
pass
else:

View file

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

View file

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

View file

@ -1,3 +1,5 @@
from __future__ import print_function
from bootstrapvz.base import Task
from bootstrapvz.common import phases
from bootstrapvz.common.tools import log_check_call
@ -98,7 +100,7 @@ class DisableModules(Task):
import fileinput
for line in fileinput.input(files=cloud_cfg, inplace=True):
if not regex.match(line):
print line,
print(line, end=' ')
class EnableModules(Task):
@ -122,7 +124,7 @@ class EnableModules(Task):
count = count + 1
if int(entry['position']) == int(count):
print(" - %s" % entry['module'])
print line,
print(line, end=' ')
class SetCloudInitMountOptions(Task):
@ -134,4 +136,4 @@ class SetCloudInitMountOptions(Task):
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')
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):
from tasks import ImageExecuteCommand
from .tasks import ImageExecuteCommand
taskset.add(ImageExecuteCommand)

View file

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

View file

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

View file

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

View file

@ -4,7 +4,7 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest):
import tasks
from . import tasks
taskset.add(tasks.LaunchEC2Instance)
if 'print_public_ip' in manifest.plugins['ec2_launch']:
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]
logger.info('******* EC2 IP ADDRESS: %s *******' % 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')
f.write('')

View file

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

View file

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

View file

@ -46,7 +46,7 @@ class InstallExpandRootScripts(Task):
# Copy files over
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)
# Expand out options into expand-root script.

View file

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

View file

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

View file

@ -1,8 +1,6 @@
import tasks.mounts
import tasks.shrink
import tasks.apt
import tasks.dpkg
from bootstrapvz.common.tasks import dpkg, locale
from bootstrapvz.common.tasks import locale
from .tasks import mounts, shrink, apt, dpkg
import bootstrapvz.common.tasks.dpkg
def get_shrink_type(plugins):
@ -33,47 +31,47 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest):
taskset.update([tasks.mounts.AddFolderMounts,
tasks.mounts.RemoveFolderMounts,
taskset.update([mounts.AddFolderMounts,
mounts.RemoveFolderMounts,
])
if manifest.plugins['minimize_size'].get('zerofree', False):
taskset.add(tasks.shrink.AddRequiredZeroFreeCommand)
taskset.add(tasks.shrink.Zerofree)
taskset.add(shrink.AddRequiredZeroFreeCommand)
taskset.add(shrink.Zerofree)
if get_shrink_type(manifest.plugins) == 'vmware-vdiskmanager':
taskset.add(tasks.shrink.AddRequiredVDiskManagerCommand)
taskset.add(tasks.shrink.ShrinkVolumeWithVDiskManager)
taskset.add(shrink.AddRequiredVDiskManagerCommand)
taskset.add(shrink.ShrinkVolumeWithVDiskManager)
if get_shrink_type(manifest.plugins) == 'qemu-img':
taskset.add(tasks.shrink.AddRequiredQemuImgCommand)
taskset.add(tasks.shrink.ShrinkVolumeWithQemuImg)
taskset.add(shrink.AddRequiredQemuImgCommand)
taskset.add(shrink.ShrinkVolumeWithQemuImg)
if 'apt' in manifest.plugins['minimize_size']:
apt = manifest.plugins['minimize_size']['apt']
if apt.get('autoclean', False):
taskset.add(tasks.apt.AutomateAptClean)
if 'languages' in apt:
taskset.add(tasks.apt.FilterTranslationFiles)
if apt.get('gzip_indexes', False):
taskset.add(tasks.apt.AptGzipIndexes)
if apt.get('autoremove_suggests', False):
taskset.add(tasks.apt.AptAutoremoveSuggests)
msapt = manifest.plugins['minimize_size']['apt']
if msapt.get('autoclean', False):
taskset.add(apt.AutomateAptClean)
if 'languages' in msapt:
taskset.add(apt.FilterTranslationFiles)
if msapt.get('gzip_indexes', False):
taskset.add(apt.AptGzipIndexes)
if msapt.get('autoremove_suggests', False):
taskset.add(apt.AptAutoremoveSuggests)
if 'dpkg' in manifest.plugins['minimize_size']:
filter_tasks = [dpkg.CreateDpkgCfg,
tasks.dpkg.InitializeBootstrapFilterList,
tasks.dpkg.CreateBootstrapFilterScripts,
tasks.dpkg.DeleteBootstrapFilterScripts,
filter_tasks = [bootstrapvz.common.tasks.dpkg.CreateDpkgCfg,
dpkg.InitializeBootstrapFilterList,
dpkg.CreateBootstrapFilterScripts,
dpkg.DeleteBootstrapFilterScripts,
]
msdpkg = manifest.plugins['minimize_size']['dpkg']
if 'locales' in msdpkg:
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 msdpkg['locales']:
taskset.discard(locale.LocaleBootstrapPackage)
taskset.discard(locale.GenerateLocale)
if msdpkg.get('exclude_docs', False):
taskset.update(filter_tasks)
taskset.add(tasks.dpkg.ExcludeDocs)
taskset.add(dpkg.ExcludeDocs)
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
counter_task(taskset, tasks.mounts.AddFolderMounts, tasks.mounts.RemoveFolderMounts)
counter_task(taskset, tasks.dpkg.CreateBootstrapFilterScripts, tasks.dpkg.DeleteBootstrapFilterScripts)
counter_task(taskset, mounts.AddFolderMounts, mounts.RemoveFolderMounts)
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']))
sed_i(filter_script, r'EXCLUDE_PATTERN', exclude_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._minimize_size['filter_script'] = filter_script

View file

@ -57,7 +57,7 @@ class ShrinkVolumeWithVDiskManager(Task):
@classmethod
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])
os.chmod(info.volume.image_path, perm)

View file

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

View file

@ -1,3 +1,5 @@
from __future__ import print_function
from bootstrapvz.base import Task
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
if re.match(debian_ntp_server, line):
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:
print line,
print(line, end=' ')

View file

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

View file

@ -1,4 +1,4 @@
import tasks
from . import tasks
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.plugins.minimize_size.tasks import dpkg
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 filesystem
from bootstrapvz.common.tasks import partitioning
import bootstrapvz.common.tasks.dpkg
def validate_manifest(data, validator, error):
@ -31,7 +32,7 @@ def resolve_tasks(taskset, manifest):
apt.DisableDaemonAutostart,
dpkg.InitializeBootstrapFilterList,
dpkg.CreateDpkgCfg,
bootstrapvz.common.tasks.dpkg.CreateDpkgCfg,
dpkg.CreateBootstrapFilterScripts,
dpkg.FilterLocales,
dpkg.ExcludeDocs,

View file

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

View file

@ -1,4 +1,4 @@
import tasks
from . import tasks
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.releases import jessie, wheezy, stretch
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')
@ -19,7 +18,6 @@ class CheckRequestedDebianRelease(Task):
@classmethod
def run(cls, info):
from bootstrapvz.common.exceptions import TaskError
if info.manifest.release not in (jessie, wheezy, stretch):
msg = 'Debian {info.manifest.release} is not (yet) available in the Puppetlabs.com APT repository.'
raise TaskError(msg)
@ -32,7 +30,6 @@ class CheckAssetsPath(Task):
@classmethod
def run(cls, info):
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)

View file

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

View file

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

View file

@ -1,5 +1,5 @@
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):

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -44,7 +44,7 @@ class CreatePVGrubCustomRule(Task):
script_src = os.path.join(assets, 'grub.d/40_custom')
script_dst = os.path.join(info.root, 'etc/grub.d/40_custom')
copy(script_src, script_dst)
os.chmod(script_dst, 0755)
os.chmod(script_dst, 0o755)
from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
if not isinstance(info.volume.partition_map, NoPartitions):

View file

@ -1,6 +1,6 @@
from bootstrapvz.base import Task
from bootstrapvz.common import phases
import host
from . import host
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.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/network-scripts'), 0755)
os.mkdir(os.path.join(script_dst, 'sysconfig'), 0o755)
os.mkdir(os.path.join(script_dst, 'sysconfig/network-scripts'), 0o755)
copy(os.path.join(script_src, '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)

View file

@ -14,7 +14,7 @@ class TuneSystem(Task):
sysctl_src = os.path.join(assets, 'sysctl.d/tuning.conf')
sysctl_dst = os.path.join(info.root, 'etc/sysctl.d/01_ec2.conf')
copy(sysctl_src, sysctl_dst)
os.chmod(sysctl_dst, 0644)
os.chmod(sysctl_dst, 0o644)
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
import tasks.apt
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
from .tasks import apt, boot, configuration, image, packages
def validate_manifest(data, validator, error):
@ -15,30 +13,30 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest):
taskset.update(task_groups.get_standard_groups(manifest))
taskset.update([apt.AddBackports,
apt.AddDefaultSources,
taskset.update([bootstrapvz.common.tasks.apt.AddBackports,
bootstrapvz.common.tasks.apt.AddDefaultSources,
loopback.AddRequiredCommands,
loopback.Create,
tasks.packages.DefaultPackages,
tasks.configuration.GatherReleaseInformation,
tasks.boot.ConfigureGrub,
packages.DefaultPackages,
configuration.GatherReleaseInformation,
boot.ConfigureGrub,
initd.InstallInitScripts,
boot.BlackListModules,
boot.UpdateInitramfs,
bootstrapvz.common.tasks.boot.BlackListModules,
bootstrapvz.common.tasks.boot.UpdateInitramfs,
ssh.AddSSHKeyGeneration,
ssh.DisableSSHPasswordAuthentication,
ssh.DisableRootLogin,
tasks.apt.AddBaselineAptCache,
image.MoveImage,
tasks.image.CreateTarball,
apt.AddBaselineAptCache,
bootstrapvz.common.tasks.image.MoveImage,
image.CreateTarball,
volume.Delete,
])
taskset.discard(grub.SetGrubConsolOutputDeviceToSerial)
if 'gcs_destination' in manifest.provider:
taskset.add(tasks.image.UploadImage)
taskset.add(image.UploadImage)
if 'gce_project' in manifest.provider:
taskset.add(tasks.image.RegisterImage)
taskset.add(image.RegisterImage)
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):

View file

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

View file

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

View file

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

View file

@ -16,4 +16,4 @@ class Connect(Task):
container=info.manifest.provider['container'],
)
# 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
import tasks.packages
import tasks.boot
from bootstrapvz.common.tasks import image
from bootstrapvz.common.tasks import loopback
from .tasks import packages, boot
def validate_manifest(data, validator, error):
@ -13,15 +12,15 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest):
taskset.update(task_groups.get_standard_groups(manifest))
taskset.update([tasks.packages.DefaultPackages,
tasks.boot.AddVirtualConsoleGrubOutputDevice,
taskset.update([packages.DefaultPackages,
boot.AddVirtualConsoleGrubOutputDevice,
loopback.AddRequiredCommands,
loopback.Create,
image.MoveImage,
])
if manifest.provider.get('guest_additions', False):
from tasks import guest_additions
from .tasks import guest_additions
taskset.update([guest_additions.CheckGuestAdditionsPath,
guest_additions.AddGuestAdditionsPackages,
guest_additions.InstallGuestAdditions,

View file

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

View file

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

View file

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

View file

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

View file

@ -18,7 +18,7 @@ def setup_logging():
root = logging.getLogger()
root.setLevel(logging.NOTSET)
from log import LogForwarder
from .log import LogForwarder
log_forwarder = LogForwarder()
root.addHandler(log_forwarder)
@ -69,6 +69,7 @@ class Server(object):
@Pyro4.expose
def ping(self):
if hasattr(self, 'connection_timeout'):
# pylint: disable=no-member
self.connection_timeout.cancel()
del self.connection_timeout
return 'pong'
@ -114,7 +115,7 @@ class Server(object):
try:
bootstrap_info = run(manifest, debug=debug, dry_run=dry_run)
queue.put(bootstrap_info)
except (Exception, KeyboardInterrupt) as e:
except (Exception, KeyboardInterrupt) as e: # pylint: disable=broad-except
queue.put(e)
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
# either give multiple identifier separated by comma (,) or put this option
# multiple time.
enable=W0401,W0611
enable=
# 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
# 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
# C0111 mssing-docstring
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
# W0511 fixme
# C0111 missing-docstring
# I0011 locally-disabled
# I0020 suppressed-message
# R0801 duplicate-code
#TODO
# E0632(unbalanced-tuple-unpacking)
# E1101(no-member)
# E1121(too-many-function-args)
# E1601(print-statement)
# E1608(old-octal-literal)
# W0102(dangerous-default-value)
# 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)
# C0411(wrong-import-order)
# 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)
# R0401(cyclic-import)
# R0914(too-many-locals)
# R1704(redefined-argument-from-local)
# R1705(no-else-return)
# R1710(inconsistent-return-statements)
# W all warnings
[REPORTS]
@ -190,7 +199,7 @@ ignore-mixin-members=yes
# List of classes names for which member attributes should not be checked
# (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
# to generated-members.

View file

@ -4,6 +4,6 @@
def recursive_glob(path, pattern):
import fnmatch
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):
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 tools import boot_manifest
from .manifests import merge_manifest_data
from .tools import boot_manifest
partials = {'docker': '''
provider:
@ -26,4 +26,4 @@ def test_stable():
custom_partials = [partials['docker']]
manifest_data = merge_manifest_data(std_partials, custom_partials)
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 tools import boot_manifest
from .manifests import merge_manifest_data
from .tools import boot_manifest
# pylint: disable=print-statement
partials = {'ebs_hvm': '''
provider:

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