Merge "Remove PluginBase/NodePluginBase class"

This commit is contained in:
Jenkins 2017-05-18 00:24:33 +00:00 committed by Gerrit Code Review
commit 812563f90c
3 changed files with 6 additions and 56 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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)