]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
put checking for a remote directory into a seperate method
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 29 May 2020 10:52:25 +0000 (12:52 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 29 May 2020 10:52:25 +0000 (12:52 +0200)
lib/cr_vmware_tpl/cobbler.py

index 1130864bf0a237005466d0a77899c7e7078b2557..4d960b50cb135eb077af9d1880ec9df7f4abfe00 100644 (file)
@@ -35,7 +35,7 @@ from .config import CrTplConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '0.3.8'
+__version__ = '0.3.9'
 
 LOG = logging.getLogger(__name__)
 
@@ -242,7 +242,13 @@ class Cobbler(BaseHandler):
         cobbler_version = re.sub(r'^\s*cobbler\s+', '', first_line, flags=re.IGNORECASE).strip()
         LOG.info(_("Version of {} is:").format("Cobbler") + " {!r}".format(cobbler_version))
 
-        rdir = self.config.cobbler_rootdir
+        self.check_remote_directory(self.config.cobbler_rootdir, _('Cobbler root directory'))
+
+        return cobbler_version
+
+    # -------------------------------------------------------------------------
+    def check_remote_directory(self, rdir, desc=None):
+
         if self.verbose > 1:
             msg = _("Checking existence of remote directory {!r} ...").format(str(rdir))
             LOG.debug(msg)
@@ -256,12 +262,15 @@ class Cobbler(BaseHandler):
 
         proc = self.exec_ssh(cmd)
         if proc.returncode != 0:
+            dsc = _('Remote directory')
+            if desc:
+                dsc = desc
             msg = _(
-                "Cobbler root directory {rdir!r} on host {host!r} does not "
-                "exists or is not a directory.").format(rdir=str(rdir), host=self.host)
+                "{dsc} {rdir!r} on host {host!r} does not exists or is not a directory.").format(
+                    dsc=dsc, rdir=str(rdir), host=self.host)
             raise ExpectedCobblerError(msg)
 
-        return cobbler_version
+
 
     # -------------------------------------------------------------------------
     def get_distro_list(self):