From: hickert Date: Thu, 6 Jul 2006 07:17:11 +0000 (+0000) Subject: FAI release management reworked, only touched faiscript. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c243712e33de546c0733601dc7649b89d47f6786;p=gosa.git FAI release management reworked, only touched faiscript. Do not branch use this release, in order to manage FAI objects. Just for testing. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4033 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/fai/class_askClassName.inc b/plugins/admin/fai/class_askClassName.inc index 727e46ca6..651957f2d 100644 --- a/plugins/admin/fai/class_askClassName.inc +++ b/plugins/admin/fai/class_askClassName.inc @@ -50,6 +50,10 @@ class askClassName extends plugin $base = $faifilter['branch']; } $ldap = $this->config->get_ldap_link(); + + /* Set base to release base */ + $base = key(get_previous_releases_of_this_release(get_release_dn($base),false)); + $res= get_list("(objectClass=organizationalUnit)", $this->ui->subtreeACL, $base, array("cn","description","objectClass"), GL_SIZELIMIT); $used = array(); @@ -57,7 +61,7 @@ class askClassName extends plugin $delete = array(); foreach($res as $objecttypes){ $res2= get_list("(objectClass=*)", $this->ui->subtreeACL, $objecttypes['dn'], - array("cn","description","objectClass","FAIclass"), GL_SIZELIMIT | GL_CONVERT); + array("cn","description","objectClass","FAIclass"), GL_SIZELIMIT | GL_CONVERT | GL_SUBSEARCH); foreach($res2 as $object){ /* skip class names with this name */ @@ -73,7 +77,7 @@ class askClassName extends plugin } } } - + /* Create headline * Depending on the object type we want to create, a different headline will be shown */ diff --git a/plugins/admin/fai/class_faiManagement.inc b/plugins/admin/fai/class_faiManagement.inc index 917bbf539..c64e6285d 100644 --- a/plugins/admin/fai/class_faiManagement.inc +++ b/plugins/admin/fai/class_faiManagement.inc @@ -26,6 +26,7 @@ require "tabsScript.inc"; require "tabsProfile.inc"; require "tabsPackage.inc"; + class faiManagement extends plugin { /* Definitions */ @@ -623,23 +624,17 @@ class faiManagement extends plugin } + /* reload list of objects */ - function reload() - { - /* Create a new list of FAI object - * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... - */ - $ObjectTypes = array( - "FAIpartitionTable" => array("OU"=>"ou=disk," , "CHKBOX"=>"ShowPartitions"), - "FAIpackageList" => array("OU"=>"ou=packages," , "CHKBOX"=>"ShowPackages"), - "FAIscript" => array("OU"=>"ou=scripts," , "CHKBOX"=>"ShowScripts"), - "FAIvariable" => array("OU"=>"ou=variables," , "CHKBOX"=>"ShowVariables"), - "FAIhook" => array("OU"=>"ou=hooks," , "CHKBOX"=>"ShowHooks"), - "FAIprofile" => array("OU"=>"ou=profiles," , "CHKBOX"=>"ShowProfiles"), - "FAItemplate" => array("OU"=>"ou=templates," , "CHKBOX"=>"ShowTemplates")); + function reload() + { + /* Variable initialisation */ + $str = ""; + $Regex = $this->DivListFai->Regex; + $this->objects = array(); - /* Set base for all searches */ - $base = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase; + /* Get base */ + $base = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase; if($this->DivListFai->selectedBranch != "main"){ $br = $this->getBranches(); if(isset($br[$this->DivListFai->selectedBranch])){ @@ -649,49 +644,65 @@ class faiManagement extends plugin } } - $Regex = $this->DivListFai->Regex; - $str = ""; - $objects = array(); - $this->objects = array(); + /* Get resolved release dependencies */ + $tmp = get_all_objects_for_given_base($base,"(&(|(objectClass=FAIpartitionTable)(objectClass=FAIpackageList)(objectClass=FAIscript) + (objectClass=FAIvariable)(objectClass=FAIhook)(objectClass=FAIprofile)(objectClass=FAItemplate))(cn=$Regex))"); + + /* Create a new list of FAI object + * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... + */ + $ObjectTypes = array( + "FAIpartitionTable" => array("OU"=>"ou=disk," , "CHKBOX"=>"ShowPartitions"), + "FAIpackageList" => array("OU"=>"ou=packages," , "CHKBOX"=>"ShowPackages"), + "FAIscript" => array("OU"=>"ou=scripts," , "CHKBOX"=>"ShowScripts"), + "FAIvariable" => array("OU"=>"ou=variables," , "CHKBOX"=>"ShowVariables"), + "FAIhook" => array("OU"=>"ou=hooks," , "CHKBOX"=>"ShowHooks"), + "FAIprofile" => array("OU"=>"ou=profiles," , "CHKBOX"=>"ShowProfiles"), + "FAItemplate" => array("OU"=>"ou=templates," , "CHKBOX"=>"ShowTemplates")); - /* Walk through possible sub departments and fetch all FAI objects */ - foreach($ObjectTypes as $type => $obj){ + /* Ge listed ldap objects */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + foreach($tmp as $entry){ - /* Skip all unchecked types */ - if(! $this->DivListFai->$obj['CHKBOX']){ - continue; - } + /* Get some more informations about the object */ + $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass")); + $object = $ldap->fetch(); - /* Fetch objects from fai sub department */ - $res= get_list("(&(objectClass=".$type.")(cn=$Regex))", $this->ui->subtreeACL, $obj['OU'].$base, - array("cn","description","objectClass","FAIclass","FAIstate"), GL_SIZELIMIT); + /* Walk through possible types */ + foreach($ObjectTypes as $type => $rest){ - /* Walk through objects */ - foreach($res as $object){ + /* Skip all unchecked types */ + if(! $this->DivListFai->$rest['CHKBOX']){ + continue; + } - /* Prepare object */ - unset($object['objectClass']['count']); - if(!isset($object['description'][0])){ - $object['description'][0]=""; - } - - /* Clean up object informations */ - $obj['cn'] = $object['cn'][0]; - $obj['dn'] = $object['dn']; - $obj['description'] = $object['description'][0]; - $obj['objectClass'] = $object['objectClass']; - - /* Append type to this string, to be able to check if the selected - * entry is of type 'freeze' or 'branch' - */ - if(isset($object['FAIstate'])){ - $obj['FAIstate'] = $object['FAIstate'][0]; - $str.="|".$obj['FAIstate']; - }else{ - $obj['FAIstate'] =""; + if(in_array($type,$object['objectClass'])){ + + /* Prepare object */ + unset($object['objectClass']['count']); + if(!isset($object['description'][0])){ + $object['description'][0]=""; + } + + /* Clean up object informations */ + $obj['cn'] = $object['cn'][0]; + $obj['dn'] = $object['dn']; + $obj['description'] = $object['description'][0]; + $obj['objectClass'] = $object['objectClass']; + + /* Append type to this string, to be able to check if the selected + * entry is of type 'freeze' or 'branch' + */ + if(isset($object['FAIstate'])){ + $obj['FAIstate'] = $object['FAIstate'][0]; + $str.="|".$obj['FAIstate']; + }else{ + $obj['FAIstate'] =""; + } + $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj; + $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type; } - $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj; - $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type; } } diff --git a/plugins/admin/fai/class_faiScript.inc b/plugins/admin/fai/class_faiScript.inc index c0cec6b94..73028ecb2 100644 --- a/plugins/admin/fai/class_faiScript.inc +++ b/plugins/admin/fai/class_faiScript.inc @@ -299,9 +299,35 @@ class faiScript extends plugin { $ldap = $this->config->get_ldap_link(); $ldap->cd ($this->dn); - $ldap->rmdir_recursive($this->dn); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of FAI/script with dn '%s' failed."),$this->dn)); - $this->handle_post_events("remove"); + + $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn); + + $attr = prepare_ldap_fetch_to_be_saved($this->attrs); + if(isset($attr['FAIstate'][0])){ + if(!preg_match("/removed$/",$attr['FAIstate'][0])){ + $attr['FAIstate'][0] .= "|removed"; + } + }else{ + $attr['FAIstate'][0] = "|removed"; + } + + prepare_to_save_FAI_object($use_dn,$attr); + + foreach($this->SubObjects as $name => $obj){ + + $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $obj['dn']); + + $ldap->cat($obj['dn']); + $attr = prepare_ldap_fetch_to_be_saved($ldap->fetch()); + if(isset($attr['FAIstate'][0])){ + if(!preg_match("/removed$/",$attr['FAIstate'][0])){ + $attr['FAIstate'][0] .= "|removed"; + } + }else{ + $attr['FAIstate'][0] = "|removed"; + } + prepare_to_save_FAI_object($use_dn,$attr); + } } @@ -336,20 +362,22 @@ class faiScript extends plugin plugin::save(); $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); + + prepare_to_save_FAI_object($this->dn,$this->attrs); + if($ldap->count()!=0){ /* Write FAIscript to ldap*/ $ldap->cd($this->dn); $this->cleanup(); - $ldap->modify ($this->attrs); +// $ldap->modify ($this->attrs); }else{ /* Write FAIscript to ldap*/ $ldap->cd($this->config->current['BASE']); $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); $ldap->cd($this->dn); - $ldap->add($this->attrs); +// $ldap->add($this->attrs); } show_ldap_error($ldap->get_error(), sprintf(_("Creating of FAI/script with dn '%s' failed."),$this->dn)); @@ -417,15 +445,21 @@ class faiScript extends plugin } } + if($obj['status'] == "delete"){ + + $tmp['FAIstate'] = "|removed"; + prepare_to_save_FAI_object($sub_dn,$tmp); + $ldap->cd($sub_dn); - $ldap->rmdir_recursive($sub_dn); + //$ldap->rmdir_recursive($sub_dn); $this->handle_post_events("remove"); show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/script entry with dn '%s' failed."),$this->dn)); }elseif($obj['status'] == "edited"){ $ldap->cd($sub_dn); $this->cleanup(); - $ldap->modify ($tmp); + prepare_to_save_FAI_object($sub_dn,$tmp); + // $ldap->modify ($tmp); $this->handle_post_events("modify"); }elseif($obj['status']=="new"){ @@ -438,7 +472,8 @@ class faiScript extends plugin $ldap->cd($this->config->current['BASE']); $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); $ldap->cd($sub_dn); - $ldap->add($tmp); + prepare_to_save_FAI_object($sub_dn,$tmp); + // $ldap->add($tmp); $this->handle_post_events("add"); show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/script entry with dn '%s' failed."),$this->dn)); } diff --git a/plugins/admin/fai/tabsScript.inc b/plugins/admin/fai/tabsScript.inc index 22a34d2c9..1f51edd97 100644 --- a/plugins/admin/fai/tabsScript.inc +++ b/plugins/admin/fai/tabsScript.inc @@ -33,7 +33,7 @@ class tabsScript extends tabs if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); }else{ - $baseobject->recursive_move($this->dn, $new_dn); +// $baseobject->recursive_move($this->dn, $new_dn); } } $this->dn= $new_dn;