diff --git a/lago/export.py b/lago/export.py index b4c73397..15d51880 100644 --- a/lago/export.py +++ b/lago/export.py @@ -1,3 +1,4 @@ +from future.builtins import super from abc import ABCMeta, abstractmethod import logging import functools @@ -154,8 +155,7 @@ class TemplateExportManager(DiskExportManager): """ def __init__(self, dst, disk_type, disk, do_compress, *args, **kwargs): - super(TemplateExportManager, - self).__init__(dst, disk_type, disk, do_compress) + super().__init__(dst, disk_type, disk, do_compress) self.standalone = kwargs['standalone'] self.src_qemu_info = utils.get_qemu_info(self.src, backing_chain=True) @@ -204,7 +204,7 @@ def rebase(self): ) def update_lago_metadata(self): - super(TemplateExportManager, self).update_lago_metadata() + super().update_lago_metadata() if self.standalone: self.exported_metadata['base'] = 'None' @@ -241,8 +241,7 @@ class FileExportManager(DiskExportManager): """ def __init__(self, dst, disk_type, disk, do_compress, *args, **kwargs): - super(FileExportManager, - self).__init__(dst, disk_type, disk, do_compress) + super().__init__(dst, disk_type, disk, do_compress) def export(self): """ diff --git a/lago/log_utils.py b/lago/log_utils.py index 72c14d75..95e004ba 100644 --- a/lago/log_utils.py +++ b/lago/log_utils.py @@ -1,5 +1,5 @@ # -# Copyright 2015 Red Hat, Inc. +# Copyright 2015-2017 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ """ This module defines the special logging tools that lago uses """ +from future.builtins import super import logging import logging.config import os @@ -110,7 +111,7 @@ def format(self, record): else: color = self.DEFAULT - message = super(ColorFormatter, self).format(record) + message = super().format(record) if record.args: try: message = message % record.args @@ -224,7 +225,7 @@ def __init__( level=logging.NOTSET, formatter=ColorFormatter, ): - super(TaskHandler, self).__init__() + super().__init__() self.formatter = formatter self.initial_depth = initial_depth self.tasks_by_thread = {} @@ -521,8 +522,8 @@ def pretty_emit(self, record, is_header=False, task_level=None): ' ' * (task_level - 1) + extra_prefix + str(record.msg) ) - super(TaskHandler, self).emit(record) - super(TaskHandler, self).flush() + super().emit(record) + super().flush() def emit(self, record): """ diff --git a/lago/providers/libvirt/network.py b/lago/providers/libvirt/network.py index 9b6e1dcb..2c82d673 100644 --- a/lago/providers/libvirt/network.py +++ b/lago/providers/libvirt/network.py @@ -17,7 +17,7 @@ # # Refer to the README and COPYING files for full details of the license # - +from future.builtins import super from collections import defaultdict import functools import logging @@ -301,11 +301,11 @@ def start(self): brctl.create(self._libvirt_name()) try: - super(BridgeNetwork, self).start() + super().start() except: brctl.destroy(self._libvirt_name()) def stop(self): - super(BridgeNetwork, self).stop() + super().stop() if brctl.exists(self._libvirt_name()): brctl.destroy(self._libvirt_name()) diff --git a/lago/providers/libvirt/vm.py b/lago/providers/libvirt/vm.py index e2246758..4e02fc02 100644 --- a/lago/providers/libvirt/vm.py +++ b/lago/providers/libvirt/vm.py @@ -18,6 +18,7 @@ # Refer to the README and COPYING files for full details of the license # +from future.builtins import super import functools import logging import os @@ -51,7 +52,7 @@ class LocalLibvirtVMProvider(vm_plugin.VMProviderPlugin): def __init__(self, vm): - super(LocalLibvirtVMProvider, self).__init__(vm) + super().__init__(vm) self._has_guestfs = 'lago.guestfs_tools' in sys.modules libvirt_url = config.get('libvirt_url') self.libvirt_con = libvirt_utils.get_libvirt_connection( @@ -75,7 +76,7 @@ def __del__(self): self.libvirt_con.close() def start(self): - super(LocalLibvirtVMProvider, self).start() + super().start() if not self.defined(): # the wait_suspend method is a work around for: # https://bugzilla.redhat.com/show_bug.cgi?id=1411025 @@ -155,7 +156,7 @@ def _createXML(self, dom_xml, flags=0): return dom def stop(self): - super(LocalLibvirtVMProvider, self).stop() + super().stop() if self.defined(): self.vm._ssh_client = None with LogTask('Destroying VM %s' % self.vm.name()): @@ -164,7 +165,7 @@ def stop(self): ).destroy() def shutdown(self, *args, **kwargs): - super(LocalLibvirtVMProvider, self).shutdown(*args, **kwargs) + super().shutdown(*args, **kwargs) self._shutdown( libvirt_cmd=libvirt.virDomain.shutdown, @@ -182,7 +183,7 @@ def shutdown(self, *args, **kwargs): ) def reboot(self, *args, **kwargs): - super(LocalLibvirtVMProvider, self).reboot(*args, **kwargs) + super().reboot(*args, **kwargs) self._shutdown( libvirt_cmd=libvirt.virDomain.reboot, @@ -336,7 +337,7 @@ def extract_paths(self, paths, ignore_nopath): try: - super(LocalLibvirtVMProvider, self).extract_paths( + super().extract_paths( paths=paths, ignore_nopath=ignore_nopath, ) diff --git a/lago/sdk.py b/lago/sdk.py index b11bb9e9..5db2c4ad 100644 --- a/lago/sdk.py +++ b/lago/sdk.py @@ -1,4 +1,5 @@ from __future__ import print_function +from future.builtins import super from lago import cmd from lago.config import config as lago_config from lago.lago_ansible import LagoAnsible @@ -117,7 +118,7 @@ def __init__(self, workdir, prefix): def __getattr__(self, name): try: - attr = super(SDK, self).__getattr__(name) + attr = super().__getattr__(name) except AttributeError: attr = getattr(self._pprefix, name) return attr diff --git a/lago/service.py b/lago/service.py index aef7bb35..f9f01d0e 100644 --- a/lago/service.py +++ b/lago/service.py @@ -17,6 +17,8 @@ # # Refer to the README and COPYING files for full details of the license # + +from future.builtins import super from lago.plugins.service import ( ServicePlugin, ServiceState, @@ -27,11 +29,11 @@ class SystemdService(ServicePlugin): BIN_PATH = '/usr/bin/systemctl' def _request_start(self): - super(SystemdService, self)._request_start() + super()._request_start() return self._vm.ssh([self.BIN_PATH, 'start', self._name]) def _request_stop(self): - super(SystemdService, self)._request_stop() + super()._request_stop() return self._vm.ssh([self.BIN_PATH, 'stop', self._name]) def state(self): @@ -52,11 +54,11 @@ class SysVInitService(ServicePlugin): BIN_PATH = '/sbin/service' def _request_start(self): - super(SysVInitService, self)._request_start() + super()._request_start() return self._vm.ssh([self.BIN_PATH, self._name, 'start']) def _request_stop(self): - super(SysVInitService, self)._request_stop() + super()._request_stop() return self._vm.ssh([self.BIN_PATH, self._name, 'stop']) def state(self): @@ -76,7 +78,7 @@ class SystemdContainerService(ServicePlugin): HOST_BIN_PATH = '/usr/bin/systemctl' def _request_start(self): - super(SystemdContainerService, self)._request_start() + super()._request_start() ret = self._vm.ssh( [self.BIN_PATH, 'exec vdsmc systemctl start', self._name] ) @@ -87,7 +89,7 @@ def _request_start(self): return self._vm.ssh([self.HOST_BIN_PATH, 'start', self._name]) def _request_stop(self): - super(SystemdContainerService, self)._request_stop() + super()._request_stop() ret = self._vm.ssh( [self.BIN_PATH, 'exec vdsmc systemctl stop', self._name] )