Merge "Make base class for data drivers more granular"

This commit is contained in:
Jenkins 2016-01-20 17:13:40 +00:00 committed by Gerrit Code Review
commit ddaa32235b
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