[icinga-checkins] icinga.org: icingaweb2-module-director/master: KickstartHelper: handle renamed zones...

git at icinga.org git at icinga.org
Thu Oct 6 18:47:27 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 081ea724978b1185e7ede15223ec2c587ca83836
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=081ea724978b1185e7ede15223ec2c587ca83836

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Oct  6 16:20:25 2016 +0000

KickstartHelper: handle renamed zones...

...when triggered multiple times

---

 library/Director/KickstartHelper.php |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/library/Director/KickstartHelper.php b/library/Director/KickstartHelper.php
index 0961612..4908dbb 100644
--- a/library/Director/KickstartHelper.php
+++ b/library/Director/KickstartHelper.php
@@ -27,6 +27,8 @@ class KickstartHelper
 
     protected $loadedZones;
 
+    protected $removeZones;
+
     protected $config = array(
         'endpoint' => null,
         'host'     => null,
@@ -101,6 +103,7 @@ class KickstartHelper
              ->loadZones()
              ->storeZones()
              ->storeEndpoints()
+             ->removeZones()
              ->importCommands();
 
         $this->apiUser()->store();
@@ -178,6 +181,7 @@ class KickstartHelper
     {
         $db = $this->db;
         $existing = $db->listExternal('zone');
+
         foreach ($this->loadedZones as $name => $zone) {
             if ($zone::exists($name, $db)) {
                 $zone = $zone::load($name, $db)->replaceWith($zone);
@@ -185,7 +189,17 @@ class KickstartHelper
             $zone->store();
             unset($existing[$name]);
         }
-        foreach ($existing as $name) {
+
+        $this->removeZones = $existing;
+
+        return $this;
+    }
+
+    protected function removeZones()
+    {
+        $db = $this->db;
+
+        foreach ($this->removeZones as $name) {
             IcingaZone::load($name, $db)->delete();
         }
 



More information about the icinga-checkins mailing list