]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Bufixing
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 27 May 2020 16:34:51 +0000 (18:34 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 27 May 2020 16:34:51 +0000 (18:34 +0200)
lib/cr_vmware_tpl/cobbler.py

index 6cc2b7c071c923097ac0006c898b783ba71eb508..c5541033eb19196ee02468f8fe6cc6540463424b 100644 (file)
@@ -32,7 +32,7 @@ from .config import CrTplConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '0.3.0'
+__version__ = '0.3.1'
 
 LOG = logging.getLogger(__name__)
 
@@ -56,6 +56,11 @@ class Cobbler(BaseHandler):
         self, appname=None, verbose=0, version=__version__, base_dir=None,
             config=None, terminal_has_colors=False, simulate=None, force=None, initialized=False):
 
+        if not isinstance(config, CrTplConfiguration):
+            msg = _("{w} is not an instance of {c}, but an instance of {i} instead.").format(
+                w='Parameter config', c='CrTplConfiguration', i=config.__class__.__name__)
+            raise HandlerError(msg)
+
         self.host = CrTplConfiguration.default_cobbler_host
         self.ssh_port = CrTplConfiguration.default_cobbler_ssh_port
         self.ssh_user = CrTplConfiguration.default_cobbler_ssh_user
@@ -63,6 +68,7 @@ class Cobbler(BaseHandler):
         self.ssh = None
         self.ssh_timeout = CrTplConfiguration.default_cobbler_ssh_timeout
         self.root_dir = CrTplConfiguration.default_cobbler_rootdir
+        self.config = config
 
         super(Cobbler, self).__init__(
             appname=appname, verbose=verbose, version=version, base_dir=base_dir,
@@ -72,13 +78,12 @@ class Cobbler(BaseHandler):
 
         self.private_ssh_key = str(self.base_dir.joinpath('keys', CrTplConfiguration.ssh_privkey))
 
-        if config:
-            self.private_ssh_key = config.private_ssh_key
-            self.host = config.cobbler_host
-            self.ssh_port = config.cobbler_ssh_port
-            self.ssh_user = config.cobbler_ssh_user
-            self.ssh_timeout = config.cobbler_ssh_timeout
-            self.root_dir = config.cobbler_rootdir
+        self.private_ssh_key = config.private_ssh_key
+        self.host = config.cobbler_host
+        self.ssh_port = config.cobbler_ssh_port
+        self.ssh_user = config.cobbler_ssh_user
+        self.ssh_timeout = config.cobbler_ssh_timeout
+        self.root_dir = config.cobbler_rootdir
 
         if initialized:
             self.initialized = True