[plugins] move old plugin code from molecule-core to molecule-plugins
This commit is contained in:
+22
-5
@@ -29,10 +29,18 @@ from molecule.specs.skel import GenericExecutionStep, GenericSpec
|
||||
|
||||
import molecule.utils
|
||||
|
||||
class BuiltinHandlerMixin:
|
||||
|
||||
class BuiltinHandlerMixin(object):
|
||||
"""
|
||||
This class contains code in common between built-in handler classes.
|
||||
"""
|
||||
|
||||
def _export_generic_info(self):
|
||||
os.environ['RELEASE_STRING'] = self.metadata.get('release_string', '')
|
||||
os.environ['RELEASE_VERSION'] = self.metadata.get('release_version', '')
|
||||
os.environ['RELEASE_DESC'] = self.metadata.get('release_desc', '')
|
||||
os.environ['PRECHROOT'] = ' '.join(self.metadata.get('prechroot', []))
|
||||
|
||||
def _run_error_script(self, source_chroot_dir, chroot_dir, cdroot_dir,
|
||||
env = None):
|
||||
|
||||
@@ -96,6 +104,7 @@ class BuiltinHandlerMixin:
|
||||
)
|
||||
return rc
|
||||
|
||||
|
||||
class MirrorHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
|
||||
_mirror_syncer = "/usr/bin/rsync"
|
||||
@@ -105,7 +114,8 @@ class MirrorHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
"--recursive", "-d", "-A", "-H"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
GenericExecutionStep.__init__(self, *args, **kwargs)
|
||||
super(MirrorHandler, self).__init__(*args, **kwargs)
|
||||
self._export_generic_info()
|
||||
|
||||
def setup(self):
|
||||
# creating destination chroot dir
|
||||
@@ -199,10 +209,12 @@ class MirrorHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
class ChrootHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
GenericExecutionStep.__init__(self, *args, **kwargs)
|
||||
super(ChrootHandler, self).__init__(*args, **kwargs)
|
||||
self._export_generic_info()
|
||||
|
||||
def setup(self):
|
||||
self.source_dir = self.metadata['source_chroot']
|
||||
@@ -373,6 +385,7 @@ class ChrootHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
class CdrootHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
|
||||
_chroot_compressor_builtin_args = ["-noappend", "-no-progress"]
|
||||
@@ -380,7 +393,8 @@ class CdrootHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
chroot_compressor_output_file = "livecd.squashfs"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
GenericExecutionStep.__init__(self, *args, **kwargs)
|
||||
super(CdrootHandler, self).__init__(*args, **kwargs)
|
||||
self._export_generic_info()
|
||||
|
||||
def setup(self):
|
||||
self.source_chroot = os.path.join(
|
||||
@@ -503,6 +517,7 @@ class CdrootHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
class IsoHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
|
||||
MD5_EXT = ".md5"
|
||||
@@ -520,7 +535,8 @@ class IsoHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
"-boot-load-size", "4", "-udf", "-boot-info-table"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
GenericExecutionStep.__init__(self, *args, **kwargs)
|
||||
super(IsoHandler, self).__init__(*args, **kwargs)
|
||||
self._export_generic_info()
|
||||
|
||||
def setup(self):
|
||||
# setup paths
|
||||
@@ -669,6 +685,7 @@ class IsoHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
class LivecdSpec(GenericSpec):
|
||||
|
||||
PLUGIN_API_VERSION = 0
|
||||
|
||||
+4
-2
@@ -43,7 +43,8 @@ class ImageHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
DEFAULT_IMAGE_UMOUNTER = ["/bin/umount"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
GenericExecutionStep.__init__(self, *args, **kwargs)
|
||||
super(ImageHandler, self).__init__(*args, **kwargs)
|
||||
self._export_generic_info()
|
||||
|
||||
# init variables
|
||||
self.loop_device = None
|
||||
@@ -430,7 +431,8 @@ class FinalImageHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
IMAGE_EXT = ".img"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
GenericExecutionStep.__init__(self, *args, **kwargs)
|
||||
super(FinalImageHandler, self).__init__(*args, **kwargs)
|
||||
self._export_generic_info()
|
||||
self._loop_device_killed = False
|
||||
self._loop_device_file_removed = False
|
||||
|
||||
|
||||
+6
-3
@@ -32,7 +32,8 @@ from .builtin_plugin import BuiltinHandlerMixin
|
||||
class ChrootHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
GenericExecutionStep.__init__(self, *args, **kwargs)
|
||||
super(ChrootHandler, self).__init__(*args, **kwargs)
|
||||
self._export_generic_info()
|
||||
self.source_dir = None
|
||||
|
||||
def setup(self):
|
||||
@@ -137,7 +138,8 @@ class ImageHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
MB_IN_BYTES = 1024000
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
GenericExecutionStep.__init__(self, *args, **kwargs)
|
||||
super(ImageHandler, self).__init__(*args, **kwargs)
|
||||
self._export_generic_info()
|
||||
# init variables
|
||||
self.image_mb = 0
|
||||
self._tmp_image_file_fd = None
|
||||
@@ -275,7 +277,8 @@ class FinalImageHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
MD5_EXT = ".md5"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
GenericExecutionStep.__init__(self, *args, **kwargs)
|
||||
super(FinalImageHandler, self).__init__(*args, **kwargs)
|
||||
self._export_generic_info()
|
||||
self.image_name = None
|
||||
self.dest_path = None
|
||||
self._tmp_image_file = None
|
||||
|
||||
@@ -32,6 +32,7 @@ from .builtin_plugin import CdrootHandler as BuiltinCdrootHandler
|
||||
from .builtin_plugin import IsoHandler as BuiltinIsoHandler
|
||||
from .builtin_plugin import BuiltinHandlerMixin
|
||||
|
||||
|
||||
class IsoUnpackHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
|
||||
_iso_mounter = ["/bin/mount", "-o", "loop,ro", "-t", "iso9660"]
|
||||
@@ -41,7 +42,8 @@ class IsoUnpackHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
_squash_umounter = ["/bin/umount"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
GenericExecutionStep.__init__(self, *args, **kwargs)
|
||||
super(IsoUnpackHandler, self).__init__(*args, **kwargs)
|
||||
self._export_generic_info()
|
||||
|
||||
self.tmp_mount = molecule.utils.mkdtemp()
|
||||
self.tmp_squash_mount = molecule.utils.mkdtemp()
|
||||
|
||||
+2
-1
@@ -39,7 +39,8 @@ class TarHandler(GenericExecutionStep, BuiltinHandlerMixin):
|
||||
MD5_EXT = ".md5"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
GenericExecutionStep.__init__(self, *args, **kwargs)
|
||||
super(TarHandler, self).__init__(*args, **kwargs)
|
||||
self._export_generic_info()
|
||||
|
||||
def _get_tar_comp_method(self):
|
||||
comp_method = self.metadata.get('compression_method', "gz")
|
||||
|
||||
Reference in New Issue
Block a user