From: psc Date: Fri, 3 Jul 2009 09:05:45 +0000 (+0000) Subject: Make sure CoW objects in subreleases are properly created when the main X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=05860bbb315cfaaa6bec5b667faedf4bbf4c019d;p=gosa.git Make sure CoW objects in subreleases are properly created when the main object gets modified and check that the parent object is not marked as removed in is_child_of_cow_parent() git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13879 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc b/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc index 605acb8df..0278c5a17 100644 --- a/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc +++ b/trunk/gosa-plugins/fai/admin/fai/class_FAI.inc @@ -501,12 +501,13 @@ class FAI } foreach($r as $key ){ - if(DEBUG_FAI_FUNC) { - echo "Create an empty placeholder in follwing release ".$key; - print_a($objectAttrs); - } - /* Only save removed parent objects, not their children */ - if (FAI::is_parent_object($Current_DN)){ + /* Only save removed parent objects, not their children, unless + they are a child of a copy-on-write parent in a subrelease */ + if (FAI::is_parent_object($Current_DN) || FAI::is_child_of_cow_parent($key)){ + if(DEBUG_FAI_FUNC) { + echo "Create an empty placeholder in follwing release ".$key; + print_a($objectAttrs); + } FAI::save_FAI_object($key,$objectAttrs); } } @@ -529,8 +530,8 @@ class FAI */ $rTag = FAI::get_release_tag(FAI::get_release_dn($key)); $parent_attrs['FAIstate'] = $rTag; - FAI::save_FAI_object($key,$parent_attrs); } + FAI::save_FAI_object($key,$parent_attrs); } } @@ -1323,8 +1324,9 @@ class FAI return $children; } - /* Get the DN of the parent object; e.g. the FAIpartitionTable of a FAIpartitionDisk */ - static function get_parent_object($dn) + /* Get the DN of the parent object; e.g. the FAIpartitionTable of a FAIpartitionDisk. + If $check is false, do not check whether the parent actually exists in LDAP */ + static function get_parent_object($dn, $check=true) { global $config; $Current_DN = $dn; @@ -1350,12 +1352,15 @@ class FAI $parent_dn = join($parent_dn, ','); if ($parent_dn != $Current_DN){ - $ldap = $config->get_ldap_link(); - $ldap->cd($config->current['BASE']); - $ldap->cat($parent_dn); - if($ldap->count()){ - return $parent_dn; + if($check){ + $ldap = $config->get_ldap_link(); + $ldap->cd($config->current['BASE']); + $ldap->cat($parent_dn); + if(!$ldap->count()){ + return ""; + } } + return $parent_dn; } return ""; } @@ -1380,6 +1385,35 @@ class FAI } return false; } + + /* Check whether this is a child object of a Copy-on-Write parent */ + static function is_child_of_cow_parent($dn) + { + global $config; + $Current_DN = $dn; + $parent_dn = ""; + + if (!FAI::is_parent_object($Current_DN)){ + + /* This is a child object; check that the parent object is not + marked as removed */ + $cow_parent_dn = FAI::get_parent_object($Current_DN, false); + if ($cow_parent_dn && !FAI::parent_is_removed($Current_DN)){ + + /* This is a child object, check whether the parent object in + the main release exists */ + $main_parent_dn = FAI::get_parent_release_object($cow_parent_dn); + $ldap = $config->get_ldap_link(); + $ldap->cd($config->current['BASE']); + $ldap->cat($main_parent_dn); + if($ldap->count()){ + return true; + } + } + } + return false; + } + }