X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Ffai%2Fadmin%2Ffai%2Fclass_FAI.inc;h=b6ef2a6125cae94dd430be037d543df5d9b1cd45;hb=cb773874cb502bc0f01aeefc43849e0522e1a4d9;hp=9b25238f752e7cd07c03eb51274781071fa1c598;hpb=c4dfca36a6acd068bfc877302236b5d56dd2aa0d;p=gosa.git
diff --git a/gosa-plugins/fai/admin/fai/class_FAI.inc b/gosa-plugins/fai/admin/fai/class_FAI.inc
index 9b25238f7..b6ef2a612 100644
--- a/gosa-plugins/fai/admin/fai/class_FAI.inc
+++ b/gosa-plugins/fai/admin/fai/class_FAI.inc
@@ -8,6 +8,21 @@ class FAI
/* TEST PHASE .... */
+ static function get_all_objects_for_given_object($dn,$filter,$detailed = false)
+ {
+ $res = FAI::get_all_objects_for_given_base($dn,$filter,$detailed);
+ $name = preg_replace("/,ou=.*$/","",$dn);
+ $entries = array();
+ foreach($res as $entry_dn => $data){
+ if(!preg_match("/,".$name.",/",$entry_dn)) continue;
+ $entries[$entry_dn] = $data;
+ }
+ return($entries);
+ }
+
+
+
+
/* Returns all object for the given release.
This function resolves the releases
from base up to the given dn.
@@ -21,7 +36,7 @@ class FAI
$tmp = array();
if(!FAI::is_release_department($Current_DN)) {
- return($res);
+# return($res);
}
/* Collect some basic informations and initialize some variables */
@@ -48,14 +63,14 @@ class FAI
foreach($deps_to_search as $fai_base){
/* Ldap search for fai classes specified in this release */
- $attributes = array("dn","objectClass","FAIstate","cn");
- $res_tmp = get_list($filter,"fai",$fai_base,$attributes,GL_SUBSEARCH | GL_SIZELIMIT);
+ $attributes = array("dn","objectClass","FAIstate","cn","FAIdiskType","FAIlvmDevice","FAIdiskOption");
+ $res_tmp = get_list($filter,"fai",$fai_base,$attributes,GL_SUBSEARCH);
/* check the returned objects, and add/replace them in our return variable */
foreach($res_tmp as $attr){
$buffer = array();
- $name = preg_replace("/".normalizePreg($release)."/i","",$attr['dn']);
+ $name = preg_replace("/".preg_quote($release, '/')."/i","",$attr['dn']);
if(isset($attr['FAIstate'][0])){
if(preg_match("/removed$/",$attr['FAIstate'][0])){
@@ -68,14 +83,33 @@ class FAI
/* Seems to be an inherited class, apply current FAIstate to this classes
*/
- if(!preg_match("/".normalizePreg($base_release)."$/i",$attr['dn'])){
+ if(!preg_match("/".preg_quote($base_release, '/')."$/i",$attr['dn'])){
$buffer['FAIstate'] = $FAIstate;
}else{
/* Seems to be created within this release department.
This indicates - it can't be of state "freeze"
- */
- $buffer['FAIstate'] = "branch";
+ */
+ if(isset($attr['FAIstate'])){
+ $buffer['FAIstate'] = $attr['FAIstate'][0];
+ }else{
+ $buffer['FAIstate'] = "branch";
+ }
+ }
+
+ if(isset($attr['FAIdiskType'])){
+ $buffer['FAIdiskType'] = $attr['FAIdiskType'][0];
+ } else {
+ $buffer['FAIdiskType'] = "old";
+ }
+
+ if(isset($attr['FAIdiskOption'])){
+ $buffer['FAIdiskOption'] = $attr['FAIdiskOption'];
+ } else {
+ $buffer['FAIdiskOption'] = null;
+ }
+ if(isset($attr['FAIlvmDevice'])){
+ $buffer['FAIlvmDevice'] = $attr['FAIlvmDevice'];
}
/* In detailed mode are some additonal informations visible */
@@ -132,8 +166,8 @@ class FAI
{
global $config;
- if(!preg_match("/".normalizePreg(get_ou('faiou'))."/",$dn)){
- $base = get_ou('faiou').$dn;
+ if(!preg_match("/".preg_quote(get_ou('faiBaseRDN'), '/')."/i",$dn)){
+ $base = get_ou('faiBaseRDN').$dn;
}else{
$base = $dn;
}
@@ -144,7 +178,7 @@ class FAI
$ldap->search("(objectClass=FAIbranch)",array("ou","dn"));
while($attrs = $ldap->fetch()){
if($appendedName){
- $res[$attrs['dn']] = convert_department_dn(preg_replace("/,".normalizePreg(get_ou('faiou')).".*$/","",$attrs['dn']));
+ $res[$attrs['dn']] = convert_department_dn(preg_replace("/,".preg_quote(get_ou('faiBaseRDN'), '/').".*$/i","",$attrs['dn']));
}else{
$res[$attrs['dn']] = $attrs['ou'][0];
}
@@ -188,7 +222,7 @@ class FAI
/* Dont't try to modify non FAIclasses
*/
- if(!preg_match("/[^,]+,".normalizePreg(get_ou("faiou"))."/",$obj_dn)){
+ if(!preg_match("/[^,]+,".preg_quote(get_ou("faiBaseRDN"), '/')."/i",$obj_dn)){
trigger_error("PLEASE check fai class handling in ".__LINE__." -> ".__FILE__);
echo "
-->".$Current_DN."
";
echo "
-->".$obj_dn."
";
@@ -209,8 +243,7 @@ class FAI
$classes = FAI::get_all_objects_for_given_base(FAI::get_release_dn($Current_DN),
"(&(objectClass=FAIclass)(cn=".$cn."))");
- /* Check if this is the last class with this name.
- */
+ /* Check if this is the last class with this name */
if(count($classes) == 1){
/* Get all FAI Profiles
@@ -228,8 +261,8 @@ class FAI
/* Check if this Profile uses the source class ($cn)
*/
- if(preg_match("/".normalizePreg($cn)."/",$attrs['FAIclass'])){
- $attrs['FAIclass'] = preg_replace("/[ ]*".normalizePreg($cn)."[ ]*/i"," ",$attrs['FAIclass']);
+ if(preg_match("/".preg_quote($cn, '/')."/",$attrs['FAIclass'])){
+ $attrs['FAIclass'] = preg_replace("/[ ]*".preg_quote($cn, '/')."[ ]*/i"," ",$attrs['FAIclass']);
if(empty($attrs['FAIclass'])){
$attrs['FAIclass'] = array();
}
@@ -365,9 +398,9 @@ class FAI
/* Get some basic informations */
$base_release = FAI::get_release_dn($Current_DN);
- $sub_releases = FAI:: get_sub_releases_of_this_release($base_release,true);
+ $sub_releases = FAI::get_sub_releases_of_this_release($base_release,true);
$parent_obj = FAI::get_parent_release_object($Current_DN);
- $following_releases = FAI:: get_sub_releases_of_this_release($base_release,true);
+ $following_releases = $sub_releases;
/* Check if given dn exists or if is a new entry */
$ldap->cat($Current_DN);
@@ -491,11 +524,24 @@ class FAI
/* check if we must patch the follwing release */
if(!empty($r)){
+
foreach($r as $key ){
if(DEBUG_FAI_FUNC) {
echo "Copy current objects original attributes to next release ".$key;
print_a($parent_attrs);
}
+
+ /* Append FAIstate tag to ensure that freezed objects stay freezed
+ */
+ $rTag = FAI::get_release_tag(FAI::get_release_dn($key));
+ $parent_attrs['FAIstate'] = $rTag;
+
+ /* FAItemplateFile can be binary, therefore it needs to be fetched with
+ * $ldap->get_attribute */
+ if (isset($parent_attrs['FAItemplateFile'])) {
+ $parent_attrs['FAItemplateFile'] = $ldap->get_attribute($parent_obj, 'FAItemplateFile');
+ }
+
FAI::save_FAI_object($key,$parent_attrs);
}
}
@@ -522,7 +568,7 @@ class FAI
$evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
$tmp = new $evt['CLASS_NAME']($config);
$tmp->set_type(TRIGGERED_EVENT);
- $tmp->add_targets(array("GOsa"));
+ $tmp->add_targets(array("GOSA"));
$o_queue = new gosaSupportDaemon();
if(!$o_queue->append($tmp)){
msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
@@ -570,7 +616,7 @@ class FAI
$buffer = array();
# $name = str_ireplace($release,"",$attr['dn']);
- $name = preg_replace("/".normalizePreg($release)."/i","",$attr['dn']);
+ $name = preg_replace("/".preg_quote($release, '/')."/i","",$attr['dn']);
if(isset($attr['FAIstate'][0])&&(preg_match("/removed$/",$attr['FAIstate'][0]))){
@@ -678,7 +724,7 @@ class FAI
/* Get dn suffix. Example "FAIvairableEntry=keksdose,FAIvariable=Keksregal," */
# $dn_suffix = str_ireplace($base_release,"",$dn);
- $dn_suffix = preg_replace("/".normalizePreg($base_release)."/i","",$dn);
+ $dn_suffix = preg_replace("/".preg_quote($base_release, '/')."/i","",$dn);
/* Check if given object also exists whitin one of these releases */
foreach($sub_releases as $p_release => $name){
@@ -719,7 +765,7 @@ class FAI
/* Get dn suffix. Example "FAIvairableEntry=keksdose,FAIvariable=Keksregal," */
# $dn_suffix = str_ireplace($base_release,"",$dn);
- $dn_suffix = preg_replace("/".normalizePreg($base_release)."/i","",$dn);
+ $dn_suffix = preg_replace("/".preg_quote($base_release, '/')."/i","",$dn);
/* Check if given object also exists whitin one of these releases */
foreach($previous_releases as $p_release){
@@ -743,7 +789,7 @@ class FAI
$ret = array();
/* Explode dns into pieces, to be able to build parent dns */
- $dns_to_check = gosa_ldap_explode_dn(preg_replace("/".normalizePreg(",".$config->current['BASE'])."/i","",$dn));
+ $dns_to_check = gosa_ldap_explode_dn(preg_replace("/".preg_quote(",".$config->current['BASE'], '/')."/i","",$dn));
if(!is_array($dns_to_check)){
return;
@@ -846,12 +892,12 @@ class FAI
$start = microtime(TRUE);
$source_release = trim($source_release,"/");
- echo "
"; + echo "