Code

Updated FAI migration
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 17 May 2010 13:21:32 +0000 (13:21 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 17 May 2010 13:21:32 +0000 (13:21 +0000)
-Seems to work now.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18518 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiManagement.inc
gosa-plugins/fai/admin/fai/migration/class_migrate_faiBaseRDN.inc

index c4b1a27c2efcd305098de87aa6a431318c9aff35..4cedda04a6badaded4848223d1b8958be74b4744 100644 (file)
@@ -1223,7 +1223,7 @@ class faiManagement extends management
                           "check"         => "gosaProperty::isRdn",
                           "migrate"       => "migrate_faiBaseRDN",
                           "group"         => "plugin",
-                          "mandatory"     => FALSE
+                          "mandatory"     => TRUE
                           ),
                       array(
                           "name"          => "defaultFaiRelease",
index 86380dc89970fc9419d245358e38d2078daa19bf..3719e586540c311e488289748d137ca47da74438 100644 (file)
@@ -3,40 +3,35 @@ class migrate_faiBaseRDN extends migrateFaiRDN implements propertyMigration
 {
     protected $filter = "(&(objectClass=nothing)%s)";
 
-
-
     function checkForIssues()
     {
-    
-        // Check every single property which is connected to this property.
-        $ret = array('add' => array(), 'move' => array());
-        foreach(array(
-                    'faiScript'=> 'faiScriptRDN',
-                    'faiHook'=> 'faiHookRDN',
-                    'faiTemplate'=> 'faiTemplateRDN',
-                    'faiVariable'=> 'faiVariableRDN',
-                    'faiProfile'=> 'faiProfileRDN',
-                    'faiPartitionTable'=> 'faiPartitionRDN',
-                    'faiPackage'=> 'faiPackageRDN') as $class => $name){
+        $this->found = array();
+        $ldap= $this->config->get_ldap_link();
+        $ldap->cd($this->config->current['BASE']);
 
-            if($this->config->configRegistry->propertyExists($class,$name)){
-                $prop = $this->config->configRegistry->getProperty($class,$name);
-                if($prop->migrationRequired()){
-                    $migrator = $prop->getMigrationClass();
-                    if($migrator){
-                        $tmp = $migrator->getChanges();
-                        if(isset($tmp['add'])){
-                            $ret['add'] = array_merge($tmp['add'],$ret['add']);
-                        }
-                        if(isset($tmp['move'])){
-                            $ret['move'] = array_merge($tmp['move'],$ret['move']);
-                        }
-                    }
-                }
+        $initialValue = $this->prefix.$this->property->getValue().$this->suffix;
+        $targetValue = $this->prefix.$this->property->getValue(TRUE).$this->suffix;
+        $from = $initialValue.$this->config->current['BASE'];
+        $to = $targetValue.$this->config->current['BASE'];
+
+        if($initialValue != $targetValue && $ldap->dn_exists($from)){
+            $toParent = preg_replace("/^[^,]*+,/","",$to);
+            if(!$ldap->dn_exists($toParent)){
+                $this->found['add'][$toParent] = array();
             }
+            $this->found['move'][] = array('from'=>$from, 'to'=>$to);
+            return(TRUE);
         }
-        $this->found = $ret;
-        return(count($ret['add']) || count($ret['move']));
+        return(FALSE);
     }
+
+    function execute()
+    {
+        $str = "<h3>"._("The storage position for FAI object has changed!")."</h3>";
+       # $str.= _("Unfortunately, GOsa can not perform the necessary steps automatically to migrate the FAI objects. You have to do this manually, to keep the System deployment in a usable state!");
+        $str .= migrateFaiRDN::execute();
+        return($str);
+    }
+
 }
 ?>