]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Applying flake8 rules
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 23 Jun 2020 16:16:05 +0000 (18:16 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 23 Jun 2020 16:16:05 +0000 (18:16 +0200)
lib/cr_vmware_tpl/cobbler.py
lib/cr_vmware_tpl/config.py
lib/cr_vmware_tpl/handler.py

index e12e8e73cbc1e4e1488ea37a5e53b13d7ad042ad..b1bba839c72cb8b5730d21c911ff8bb74596a1c8 100644 (file)
@@ -40,7 +40,7 @@ from .config import CrTplConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '0.6.2'
+__version__ = '0.6.3'
 
 LOG = logging.getLogger(__name__)
 
@@ -190,7 +190,6 @@ class Cobbler(BaseHandler):
     def scp_to(self, local_file, remote_file):
 
         ssh = None
-        proc = None
 
         try:
 
@@ -313,8 +312,8 @@ class Cobbler(BaseHandler):
             elif proc.stdout:
                 err = proc.stdout
             msg = _(
-                    "{dsc} {rdir!r} on host {host!r} could not be created: {err}").format(
-                    dsc=dsc, rdir=str(rdir), host=self.host, err=err)
+                "{dsc} {rdir!r} on host {host!r} could not be created: {err}").format(
+                dsc=dsc, rdir=str(rdir), host=self.host, err=err)
             raise ExpectedCobblerError(msg)
 
     # -------------------------------------------------------------------------
@@ -323,7 +322,6 @@ class Cobbler(BaseHandler):
 
         distro_list = []
         proc = self.exec_cobbler(('distro', 'list'), no_simulate=True)
-        lines = proc.stdout.splitlines()
         for line in proc.stdout.splitlines():
             distro = line.strip()
             if distro:
@@ -339,7 +337,6 @@ class Cobbler(BaseHandler):
 
         profile_list = []
         proc = self.exec_cobbler(('profile', 'list'), no_simulate=True)
-        lines = proc.stdout.splitlines()
         for line in proc.stdout.splitlines():
             profile = line.strip()
             if profile:
@@ -464,7 +461,6 @@ class Cobbler(BaseHandler):
         """Ensure correctnes of an existing profile."""
 
         profile = self.config.cobbler_profile
-        distro = self.config.cobbler_distro
 
         LOG.debug(_("Checking existing profile {!r} ...").format(profile))
         remote_file = (
@@ -551,7 +547,6 @@ class Cobbler(BaseHandler):
         """Creating a new profile."""
 
         profile = self.config.cobbler_profile
-        distro = self.config.cobbler_distro
 
         LOG.info(_("Creating new profile {!r} ...").format(profile))
 
@@ -868,7 +863,7 @@ class Cobbler(BaseHandler):
                     cur_ip = str(ip)
                 except ValueError as e:
                     msg = _("Found invalid IP address {ip!r} in leases file: {err}").format(
-                            ip=match.group(1), err=e)
+                        ip=match.group(1), err=e)
                     LOG.error(msg)
                 continue
 
@@ -885,6 +880,7 @@ class Cobbler(BaseHandler):
             return assigments[mac]
         return None
 
+
 # =============================================================================
 if __name__ == "__main__":
 
index 3c6a696e8e5023d82bcc3cb5dac349dc4bdf6824..db34fe28c490d02fe18fab8b0b04c3b51c7ace74 100644 (file)
@@ -22,7 +22,7 @@ from fb_tools.config import ConfigError, BaseConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '1.5.7'
+__version__ = '1.5.8'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -588,8 +588,9 @@ class CrTplConfiguration(BaseConfiguration):
                 else:
                     msg = _(
                         "The value of {what!r} must be one of {valid!r}, "
-                        "but found {val!r}.").format(what='system_status',
-                        valid=self.valid_system_status, val=value)
+                        "but found {val!r}.").format(
+                            what='system_status',
+                            valid=self.valid_system_status, val=value)
                     LOG.error(msg)
                 continue
 
@@ -615,6 +616,7 @@ class CrTplConfiguration(BaseConfiguration):
 
         return pwd_hash
 
+
 # =============================================================================
 if __name__ == "__main__":
 
index 35a807faa55f5958443d19c7ee054a4852db9f05..e99e39150ae934af1739f4dad520e5f14f1e19da 100644 (file)
@@ -38,11 +38,11 @@ from fb_tools.vsphere.iface import VsphereVmInterface
 
 from .config import CrTplConfiguration
 
-from .cobbler import CobblerError, Cobbler
+from .cobbler import Cobbler
 
 from .xlate import XLATOR
 
-__version__ = '1.7.5'
+__version__ = '1.7.6'
 
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
@@ -288,9 +288,6 @@ class CrTplHandler(BaseHandler):
             LOG.info(_("Using MAC address of template VM: {!r}").format(self.tpl_macaddress))
 
             tpl_sysname = 'template-' + self.tpl_vm_hostname
-            status = 'development'
-            if self.config.vsphere_host == 'vcs01.ppbrln.internal':
-                status = 'production'
             self.cobbler.add_system(
                 name=tpl_sysname, fqdn=self.tpl_vm_fqdn, mac_address=self.tpl_macaddress)
 
@@ -648,6 +645,18 @@ class CrTplHandler(BaseHandler):
 
         ssh = None
 
+        logfiles = (
+            '/var/log/boot.log',
+            '/var/log/cron',
+            '/var/log/dnf*.log',
+            '/var/log/hawkey.log',
+            '/var/log/messages',
+            '/var/log/secure',
+            '/var/log/wtmp',
+            '/var/log/vmware-*.log*',
+            '/var/log/yum*.log',
+        )
+
         cmd = textwrap.dedent("""\
         printf "Current host FQDN: "
         hostname -f
@@ -670,7 +679,7 @@ class CrTplHandler(BaseHandler):
             echo "File /root/anakonda-ks.cfg not found."
         fi
 
-        for f in /var/log/boot.log /var/log/cron /var/log/dnf*.log /var/log/hawkey.log /var/log/messages /var/log/secure /var/log/wtmp /var/log/vmware-*.log* ; do
+        for f in @@@LOGFILES@@@ ; do
             if [ -f "${f}" ] ; then
                 echo "Truncating ${f} ..."
                 cp /dev/null "${f}"
@@ -695,7 +704,7 @@ class CrTplHandler(BaseHandler):
             echo
         fi
 
-        """)
+        """).replace('@@@LOGFILES@@@', ' '.join(logfiles))
 
         try: