]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Minor changes on generating and ensuring authorized keys for root
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 23 Jan 2023 17:41:07 +0000 (18:41 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 23 Jan 2023 17:41:07 +0000 (18:41 +0100)
lib/cr_vmware_tpl/cobbler.py
lib/cr_vmware_tpl/handler.py

index be91bf7f824387004d64e36d8aac53f9744e4049..38c64c430db52e79380fc07bc0f97eb1d34580fa 100644 (file)
@@ -45,7 +45,7 @@ from .config import CrTplConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '0.9.1'
+__version__ = '0.9.2'
 
 LOG = logging.getLogger(__name__)
 
@@ -436,10 +436,9 @@ class Cobbler(BaseHandler):
         if check_parent:
             self.check_remote_directory(remote_file.parent)
 
-        if self.verbose > 1:
-            msg = _("Checking remote file {rfile!r} based on local {lfile!r} ...").format(
-                rfile=str(remote_file), lfile=str(local_file))
-            LOG.debug(msg)
+        msg = _("Checking remote file {rfile!r} based on local {lfile!r} ...").format(
+            rfile=str(remote_file), lfile=str(local_file))
+        LOG.debug(msg)
 
         if not local_file.exists() or not local_file.is_file():
             msg = _("Local file {!r} either not exists or is not a regular file.").format(
index c8194860750246630709966af1e7b20d339b3f8f..2b386356652cff37b5e91038e4ba94133a9b4c0d 100644 (file)
@@ -54,7 +54,7 @@ from .cobbler import Cobbler
 
 from .xlate import XLATOR
 
-__version__ = '2.3.1'
+__version__ = '2.3.2'
 
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
@@ -354,7 +354,7 @@ class CrTplHandler(BaseHandler):
         self.create_root_authkeys()
         self.cobbler.ensure_profile()
         self.cobbler.ensure_webroot()
-        self.cobbler.ensure_root_authkeys(self.auth_keys_file)
+        self.cobbler.ensure_root_authkeys(self.auth_keys_file)
         self.cobbler.ensure_rsyslog_cfg_files()
         self.cobbler.ensure_snippets()
 
@@ -1307,6 +1307,8 @@ class CrTplHandler(BaseHandler):
 
         LOG.info(_("Creating authorized keys of root from LDAP ..."))
 
+        print_section_start(
+            'create_root_authkeys', "Generating authorized_keys of root.", collapsed=True)
         prefix = 'tmp.authorized_keys.root.'
         (fh, tmp_keys_file) = tempfile.mkstemp(prefix=prefix, text=True)
         self.auth_keys_file = Path(tmp_keys_file)
@@ -1334,14 +1336,14 @@ class CrTplHandler(BaseHandler):
                     auth_keys += used_key + '\n'
                     auth_keys += line
 
-            if self.verbose > 2:
-                msg = _("Generated authorized keys for root:") + '\n' + auth_keys
-                LOG.debug(msg)
+            msg = _("Generated authorized keys for root:") + '\n' + auth_keys
+            LOG.debug(msg)
 
         finally:
             self.disconnect_ldap()
 
         self.auth_keys_file.write_text(auth_keys)
+        print_section_end('create_root_authkeys')
 
     # -------------------------------------------------------------------------
     def get_ldap_admins(self):
@@ -1359,10 +1361,9 @@ class CrTplHandler(BaseHandler):
         msg = _("Trying to get a list of all DPX admins with their public SSH keys ...")
         LOG.debug(msg)
 
-        if self.verbose > 1:
-            msg = _("LDAP search starting in {!r} with filter:").format(ldap_config.base_dn)
-            msg += '\n' + fltr
-            LOG.debug(msg)
+        msg = _("LDAP search starting in {!r} with filter:").format(ldap_config.base_dn)
+        msg += '\n' + fltr
+        LOG.debug(msg)
 
         status, result, response, request = self.ldap.search(
             search_base=ldap_config.base_dn, search_scope=ldap3.SUBTREE, search_filter=fltr,