Make base class for data drivers more granular

Some data drivers may not have properties, defined in
the base, also data driver may implement its own
abstract classes.

For example Dynamic Allocator provides a driver
which implements partition_scheme property.

Change-Id: Ifc005db73a7b52c7bf3a5038d28f17e7de05aa98
blueprint: pluggable-do-actions
This commit is contained in:
Evgeniy L 2016-01-18 16:53:08 +03:00
parent ab03c375d8
commit 7d14377eba
2 changed files with 33 additions and 6 deletions

View File

@ -29,22 +29,38 @@ class BaseDataDriver(object):
def __init__(self, data):
self.data = copy.deepcopy(data)
@six.add_metaclass(abc.ABCMeta)
class PartitioningDataDriverMixin(object):
@abc.abstractproperty
def partition_scheme(self):
"""Retruns instance of PartionScheme object"""
@six.add_metaclass(abc.ABCMeta)
class ProvisioningDataDriverMixin(object):
@abc.abstractproperty
def image_scheme(self):
"""Returns instance of ImageScheme object"""
@abc.abstractproperty
def grub(self):
"""Returns instance of Grub object"""
@abc.abstractproperty
def operating_system(self):
"""Returns instance of OperatingSystem object"""
@six.add_metaclass(abc.ABCMeta)
class ConfigDriveDataDriverMixin(object):
@abc.abstractproperty
def configdrive_scheme(self):
"""Returns instance of ConfigDriveScheme object"""
@six.add_metaclass(abc.ABCMeta)
class GrubBootloaderDataDriverMixin(object):
@abc.abstractproperty
def grub(self):
"""Returns instance of Grub object"""

View File

@ -24,6 +24,10 @@ from six.moves.urllib.parse import urlsplit
import yaml
from bareon.drivers.base import BaseDataDriver
from bareon.drivers.base import ConfigDriveDataDriverMixin
from bareon.drivers.base import GrubBootloaderDataDriverMixin
from bareon.drivers.base import PartitioningDataDriverMixin
from bareon.drivers.base import ProvisioningDataDriverMixin
from bareon.drivers import ks_spaces_validator
from bareon import errors
from bareon import objects
@ -71,7 +75,11 @@ def match_device(hu_disk, ks_disk):
return False
class Nailgun(BaseDataDriver):
class Nailgun(BaseDataDriver,
PartitioningDataDriverMixin,
ProvisioningDataDriverMixin,
ConfigDriveDataDriverMixin,
GrubBootloaderDataDriverMixin):
"""Driver for parsing regular volumes metadata from Nailgun."""
def __init__(self, data):
@ -624,7 +632,10 @@ class Ironic(Nailgun):
return super(Ironic, self).parse_partition_scheme()
class NailgunBuildImage(BaseDataDriver):
class NailgunBuildImage(BaseDataDriver,
ProvisioningDataDriverMixin,
ConfigDriveDataDriverMixin,
GrubBootloaderDataDriverMixin):
# TODO(kozhukalov):
# This list of packages is used by default only if another