]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Removing system from Cobbler after installing it
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 22 Jun 2020 16:28:00 +0000 (18:28 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 22 Jun 2020 16:28:00 +0000 (18:28 +0200)
lib/cr_vmware_tpl/cobbler.py
lib/cr_vmware_tpl/handler.py

index 7634e8880bff9952942b92e426a8fc0a61cabae9..9ba7442a5db7242062a0037fc30298cd92db7d04 100644 (file)
@@ -40,7 +40,7 @@ from .config import CrTplConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '0.5.12'
+__version__ = '0.6.1'
 
 LOG = logging.getLogger(__name__)
 
@@ -692,7 +692,7 @@ class Cobbler(BaseHandler):
         profile = self.config.cobbler_profile
         os_id = self.config.os_id
 
-        LOG.info(_("Creating new sytem {!r} ...").format(name))
+        LOG.info(_("Creating new system {!r} ...").format(name))
 
         if not comment:
             comment = "VMWare template for creating a {} system.".format(os_id)
@@ -748,6 +748,30 @@ class Cobbler(BaseHandler):
 
         self.sync()
 
+    # -------------------------------------------------------------------------
+    def remove_system(self, name):
+        """Removing the given system."""
+
+        LOG.info(_("Removing system {!r} ...").format(name))
+
+        args = ['system', 'remove']
+        args.append('--name')
+        args.append(name)
+
+        proc = self.exec_cobbler(args)
+
+        if proc.returncode:
+            err = _('No error message')
+            if proc.stderr:
+                err = proc.stderr
+            elif proc.stdout:
+                err = proc.stdout
+            msg = _("Error removing the cobbler system {n!r} - returncode was {rc}: {err}").format(
+                n=name, rc=proc.returncode, err=err)
+            raise ExpectedCobblerError(msg)
+
+        self.sync()
+
     # -------------------------------------------------------------------------
     def sync(self):
         """Executing 'cobbler sync' to apply environment, especially DHCPD configuration."""
index e0ea6bbdbdf441e796bacc6ac713de38d85e9223..30bf86961238cecef1a58a24a387a391f2931e0f 100644 (file)
@@ -42,7 +42,7 @@ from .cobbler import CobblerError, Cobbler
 
 from .xlate import XLATOR
 
-__version__ = '1.7.2'
+__version__ = '1.7.3'
 
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
@@ -310,7 +310,8 @@ class CrTplHandler(BaseHandler):
                     return 10
                 else:
                     self.poweroff_vm()
-#                    self.change_mac_address()
+
+            self.cobbler.remove_system(tpl_sysname)
 
         return 0