from .config import CrTplConfiguration
-__version__ = '0.2.3'
+from .handler import CrTplHandler
+
+__version__ = '0.3.1'
LOG = logging.getLogger(__name__)
self.config = CrTplConfiguration(
appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
+ self.handler = CrTplHandler(
+ appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
+
self.post_init()
# -----------------------------------------------------------
h=self.config.vsphere_host, u=self.config.vsphere_user)
self.config.password = getpass.getpass(prompt=prompt)
+ self.handler.config = self.config
+ self.handler.initialized = True
self.initialized = True
# -------------------------------------------------------------------------
"""
LOG.info("Starting ...")
+ self.handler()
# -------------------------------------------------------------------------
def __call__(self):
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@copyright: © 2018 by Frank Brehm, Berlin
+@summary: A handler module for creating the VMWare template
+"""
+from __future__ import absolute_import
+
+# Standard module
+import sys
+import os
+import logging
+
+# Third party modules
+import six
+
+
+# Own modules
+from .errors import FunctionNotImplementedError, PpError
+
+from .obj import PpBaseObject
+
+from .config import CrTplConfiguration
+
+__version__ = '0.1.1'
+LOG = logging.getLogger(__name__)
+
+
+# =============================================================================
+class HandlerError(PpError, RuntimeError):
+ """Base error class for all exceptions happened during
+ execution this handler"""
+
+ pass
+
+
+# =============================================================================
+class CrTplHandler(PpBaseObject):
+ """
+ A handler class for creating a vSphere template.
+ """
+
+ # -------------------------------------------------------------------------
+ def __init__(
+ self, appname=None, verbose=0, version=__version__, base_dir=None,
+ config=None, initialized=False):
+
+ super(CrTplHandler, self).__init__(
+ appname=appname,
+ verbose=verbose,
+ version=version,
+ base_dir=base_dir,
+ initialized=False,
+ )
+
+ self.config = config
+
+ if initialized:
+ self.initialized = True
+
+ # -------------------------------------------------------------------------
+ def __call__(self):
+ """Executing the underlying action."""
+
+ if not self.initialized:
+ raise HandlerError("{}-object not initialized.".format(self.__class__.__name__))
+
+ if not isinstance(self.config, CrTplConfiguration):
+ raise HandlerError((
+ "self.config is not a CrTplConfiguration-instance, but a "
+ "{}-instance instead.").format(self.config.__class__.__name__))
+
+ LOG.debug("Starting ...")
+
+
+# =============================================================================
+
+if __name__ == "__main__":
+
+ pass
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list