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
This commit is contained in:
parent
1c0a5d995a
commit
2d2b2725bd
@ -18,7 +18,6 @@ import subprocess
|
|||||||
|
|
||||||
from diskimage_builder.block_device.blockdevice import \
|
from diskimage_builder.block_device.blockdevice import \
|
||||||
BlockDeviceSetupException
|
BlockDeviceSetupException
|
||||||
from diskimage_builder.block_device.plugin_base import NodePluginBase
|
|
||||||
from diskimage_builder.block_device.tree_config import TreeConfig
|
from diskimage_builder.block_device.tree_config import TreeConfig
|
||||||
from diskimage_builder.block_device.utils import parse_abs_size_spec
|
from diskimage_builder.block_device.utils import parse_abs_size_spec
|
||||||
from diskimage_builder.graph.digraph import Digraph
|
from diskimage_builder.graph.digraph import Digraph
|
||||||
@ -27,7 +26,7 @@ from diskimage_builder.graph.digraph import Digraph
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class LocalLoop(NodePluginBase):
|
class LocalLoop(Digraph.Node):
|
||||||
"""Level0: Local loop image device handling.
|
"""Level0: Local loop image device handling.
|
||||||
|
|
||||||
This class handles local loop devices that can be used
|
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."""
|
"""Because this is created without base, there are no edges."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def insert_nodes(self, dg):
|
||||||
|
"""Adds self as a node to the given digraph"""
|
||||||
|
dg.add_node(self)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def image_create(filename, size):
|
def image_create(filename, size):
|
||||||
logger.info("Create image file [%s]" % filename)
|
logger.info("Create image file [%s]" % filename)
|
||||||
|
@ -20,7 +20,6 @@ from subprocess import CalledProcessError
|
|||||||
from diskimage_builder.block_device.blockdevice import \
|
from diskimage_builder.block_device.blockdevice import \
|
||||||
BlockDeviceSetupException
|
BlockDeviceSetupException
|
||||||
from diskimage_builder.block_device.level1.mbr import MBR
|
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.tree_config import TreeConfig
|
||||||
from diskimage_builder.block_device.utils import exec_sudo
|
from diskimage_builder.block_device.utils import exec_sudo
|
||||||
from diskimage_builder.block_device.utils import parse_abs_size_spec
|
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))
|
logger.debug("finished new [%s] complete [%s]" % (nconfig, dconfig))
|
||||||
|
|
||||||
|
|
||||||
class Partitioning(PluginBase):
|
class Partitioning(Digraph.Node):
|
||||||
|
|
||||||
tree_config = PartitioningTreeConfig()
|
tree_config = PartitioningTreeConfig()
|
||||||
|
|
||||||
|
@ -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)
|
|
Loading…
Reference in New Issue
Block a user