From 2d2b2725bde58fc0b8bcae70adf6070ca1f4f252 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Mon, 15 May 2017 15:47:16 +1000 Subject: [PATCH] Remove PluginBase/NodePluginBase class A majority of the "plugins" aren't implementing the plugin class. Clearly we need some refactoring of the ideas here. Remove for simplicity. Change-Id: If399a371b171f4fd17cfa5856fe55daca4c86e60 --- .../block_device/level0/localloop.py | 7 ++- .../block_device/level1/partitioning.py | 3 +- diskimage_builder/block_device/plugin_base.py | 52 ------------------- 3 files changed, 6 insertions(+), 56 deletions(-) delete mode 100644 diskimage_builder/block_device/plugin_base.py diff --git a/diskimage_builder/block_device/level0/localloop.py b/diskimage_builder/block_device/level0/localloop.py index e71c9601b..4df7af2b9 100644 --- a/diskimage_builder/block_device/level0/localloop.py +++ b/diskimage_builder/block_device/level0/localloop.py @@ -18,7 +18,6 @@ import subprocess from diskimage_builder.block_device.blockdevice import \ BlockDeviceSetupException -from diskimage_builder.block_device.plugin_base import NodePluginBase from diskimage_builder.block_device.tree_config import TreeConfig from diskimage_builder.block_device.utils import parse_abs_size_spec from diskimage_builder.graph.digraph import Digraph @@ -27,7 +26,7 @@ from diskimage_builder.graph.digraph import Digraph logger = logging.getLogger(__name__) -class LocalLoop(NodePluginBase): +class LocalLoop(Digraph.Node): """Level0: Local loop image device handling. This class handles local loop devices that can be used @@ -56,6 +55,10 @@ class LocalLoop(NodePluginBase): """Because this is created without base, there are no edges.""" pass + def insert_nodes(self, dg): + """Adds self as a node to the given digraph""" + dg.add_node(self) + @staticmethod def image_create(filename, size): logger.info("Create image file [%s]" % filename) diff --git a/diskimage_builder/block_device/level1/partitioning.py b/diskimage_builder/block_device/level1/partitioning.py index 937379cba..f690aba06 100644 --- a/diskimage_builder/block_device/level1/partitioning.py +++ b/diskimage_builder/block_device/level1/partitioning.py @@ -20,7 +20,6 @@ from subprocess import CalledProcessError from diskimage_builder.block_device.blockdevice import \ BlockDeviceSetupException from diskimage_builder.block_device.level1.mbr import MBR -from diskimage_builder.block_device.plugin_base import PluginBase from diskimage_builder.block_device.tree_config import TreeConfig from diskimage_builder.block_device.utils import exec_sudo from diskimage_builder.block_device.utils import parse_abs_size_spec @@ -136,7 +135,7 @@ class PartitioningTreeConfig(object): logger.debug("finished new [%s] complete [%s]" % (nconfig, dconfig)) -class Partitioning(PluginBase): +class Partitioning(Digraph.Node): tree_config = PartitioningTreeConfig() diff --git a/diskimage_builder/block_device/plugin_base.py b/diskimage_builder/block_device/plugin_base.py deleted file mode 100644 index 29cbdc178..000000000 --- a/diskimage_builder/block_device/plugin_base.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2017 Andreas Florath (andreas@florath.net) -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import abc -import six - -from diskimage_builder.graph.digraph import Digraph - - -@six.add_metaclass(abc.ABCMeta) -class PluginBase(object): - """Abstract base class for block device plugins""" - - def __init__(self, name): - """All plugins must have a name""" - self.name = name - - @abc.abstractmethod - def create(self, state, rollback): - """Create the block device plugin - - :param state: a dictionary to store results for this plugin. - These are used in two scenarios: other plugins - can use this to get information about the - result of the plugin and it can be used in - later runs of dib-block-device for cleaning up. - :type state: dict(str:?) - - :param rollback: a list of python functions that will be - called in reversed order to cleanup if there - occurs an error later within the same - dib-block-device run. - :type rollback: list(function) - """ - - -class NodePluginBase(PluginBase, Digraph.Node): - - def insert_nodes(self, dg): - """Adds self as a node to the given digraph""" - dg.add_node(self)