summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4aa959e)
raw | patch | inline | side by side (parent: 4aa959e)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 22 Sep 2006 03:22:55 +0000 (03:22 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 22 Sep 2006 03:22:55 +0000 (03:22 +0000) |
Entry index was broken when a partition was deleted/edited sometimes.
Adding/removing an entry caused ldap errors.
If an entry was removed and a new was added again -
The new entry was saved, but directly removed from the delete command.
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4760 594d385d-05f5-0310-b6e9-bd551577e9d8
Adding/removing an entry caused ldap errors.
If an entry was removed and a new was added again -
The new entry was saved, but directly removed from the delete command.
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4760 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/fai/class_faiPartitionTable.inc | patch | blob | history | |
plugins/admin/fai/class_faiPartitionTableEntry.inc | patch | blob | history |
diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc
index efc90856b669f60b3235cec13dc789bc13935d77..64604d971970b42c4b78f5aab606f88a2a8b3d98 100644 (file)
$this->handle_object_tagging($disk_dn, $this->gosaUnitTag);
- if($disk['status']!="delete")
- /* Add all partitions */
- foreach($disk['partitions'] as $key => $partition){
- $partition_attrs = array();
-
- foreach($partition as $key => $value){
- if(!empty($value)){
- $partition_attrs[$key]=$value;
- }else{
- unset($partition_attrs[$key]);
+ /* Collect all opperations. Delete first than add new entries .*/
+ $Todo['delete'] = array();
+ $Todo['rest'] = array();
+
+ /* Skip partition handling if current disk is marked as deleted */
+ if($disk['status']!="delete"){
+
+ /* Add all partitions */
+ foreach($disk['partitions'] as $key => $partition){
+
+ /* Create attribute array */
+ $partition_attrs = array();
+ foreach($partition as $key => $value){
+ if(!empty($value)){
+ $partition_attrs[$key]=$value;
+ }else{
+ unset($partition_attrs[$key]);
+ }
}
- }
- $partition_dn= "FAIpartitionNr=".$partition_attrs['FAIpartitionNr'].",".$disk_dn;
- $partition_attrs['objectClass']= array("top","FAIclass","FAIpartitionEntry");
- $partition_attrs['cn']= $partition_attrs['FAIpartitionNr'];
-
- unset($partition_attrs['status']);
- unset($partition_attrs['old_cn']);
-
- if($partition['status']=="new"){
- $ldap->cat($partition_dn,array("objectClass"));
- if($ldap->count()){
- $partition['status']="edited";
+ /* Create partition dn and add necessary attributes */
+ $partition_dn= "FAIpartitionNr=".$partition_attrs['FAIpartitionNr'].",".$disk_dn;
+ $partition_attrs['objectClass']= array("top","FAIclass","FAIpartitionEntry");
+ $partition_attrs['cn']= $partition_attrs['FAIpartitionNr'];
+
+ /* Unset status attributes */
+ unset($partition_attrs['status']);
+ unset($partition_attrs['old_cn']);
+
+ /* Check if this partition is realy new .. */
+ if($partition['status']=="new"){
+ $ldap->cat($partition_dn,array("objectClass"));
+ if($ldap->count()){
+ $partition['status']="edited";
+ }
}
- }
- if((!isset($partition['FAImountPoint']))||(empty($partition['FAImountPoint']))){
- $partition_attrs['FAImountPoint']="swap";
- }
+ /* Set mount point top swap if it is emtpy */
+ if((!isset($partition['FAImountPoint']))||(empty($partition['FAImountPoint']))){
+ $partition_attrs['FAImountPoint']="swap";
+ }
- /* Fix problem with missing objectClass "gosaAdministrativeUnitTag" for partitions */
- $ldap->cat($partition_dn,array("objectClass"));
- $attrs = $ldap->fetch();
- if(isset($attrs['objectClass']) && in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
- $partition_attrs['objectClass'][] = "gosaAdministrativeUnitTag";
+ /* Collect all operations */
+ if(($partition['status'] == "delete")&&($disk['status']!="new")){
+ $Todo['delete'][$partition_dn] = $partition_attrs;
+ }elseif($partition['status'] == "new"){
+ $Todo['rest'][$partition_dn] = $partition_attrs;
+ }elseif($partition['status'] == "edited"){
+ $Todo['rest'][$partition_dn] = $partition_attrs;
+ }
}
+ }
- if(($partition['status'] == "delete")&&($disk['status']!="new")){
+ /* First of all, delete old entries */
+ foreach($Todo['delete'] as $partition_dn => $attrs){
$ldap->cd($partition_dn);
$ldap->rmdir_recursive($partition_dn);
show_ldap_error($ldap->get_error(), _("Removing FAI partition table entry failed"));
- }elseif($partition['status'] == "new"){
- if(empty($partition_attrs['description'])){
- unset($partition_attrs['description']);
+ }
+
+ /* Add/edit entries */
+ foreach($Todo['rest'] as $partition_dn => $partition_attrs){
+
+ /* Check if entry exists */
+ $ldap->cat($partition_dn);
+ if($ldap->count()){
+
+ /* Fix problem with missing objectClass "gosaAdministrativeUnitTag" for partitions */
+ $attrs = $ldap->fetch();
+ if(isset($attrs['objectClass']) && in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
+ $partition_attrs['objectClass'][] = "gosaAdministrativeUnitTag";
}
- $ldap->cd($this->config->current['BASE']);
- $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $partition_dn));
- $ldap->cd($partition_dn);
- $ldap->add($partition_attrs);
- show_ldap_error($ldap->get_error(), _("Saving FAI partition table entry failed"));
- }elseif($partition['status'] == "edited"){
if(empty($partition_attrs['description'])){
$partition_attrs['description']=array();
}
$this->cleanup();
$ldap->modify ($partition_attrs);
show_ldap_error($ldap->get_error(), _("Saving FAI partition table entry failed"));
- }
+ }else{
+
+ if(empty($partition_attrs['description'])){
+ unset($partition_attrs['description']);
+ }
- $this->handle_object_tagging($partition_dn, $this->gosaUnitTag);
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $partition_dn));
+ $ldap->cd($partition_dn);
+ $ldap->add($partition_attrs);
+ show_ldap_error($ldap->get_error(), _("Saving FAI partition table entry failed"));
+ }
}
+ $this->handle_object_tagging($partition_dn, $this->gosaUnitTag);
}
$this->handle_post_events("add");
}
diff --git a/plugins/admin/fai/class_faiPartitionTableEntry.inc b/plugins/admin/fai/class_faiPartitionTableEntry.inc
index b3d849cd31c4045810312247f9315fdb3e3c14db..09d85eafb5a9fdb29afa23ed17c889b50022f4d0 100644 (file)
*/
if($s_action == "remove"){
if($this->partitions[$s_entry]['status'] == "edited"){
- $this->deletePartitions[$s_entry]= $this->partitions[$s_entry];
- $this->deletePartitions[$s_entry]['FAIpartitionNr']=$s_entry;
+ $this->deletePartitions[] = $this->partitions[$s_entry];
unset($this->partitions[$s_entry]);
}else{
unset($this->partitions[$s_entry]);
* array to the already defined partitions.
*/
if(isset($_POST['AddPartition'])){
+
+ /* FAIpartitionNr is used to indentify an entry.
+ (The index of an entry may vary)
+ Walk through the given entries and check for a free FAIpartitionNr. */
+ $ids = array();
+ foreach($this->partitions as $part){
+ $ids[$part['FAIpartitionNr']] = $part['FAIpartitionNr'];
+ }
+ $new_nr = 1 ;
+ while(isset($ids[$new_nr]) && $new_nr < 100){
+ $new_nr ++ ;
+ }
+
+ /* Add empty attributes */
foreach($this->UsedAttrs as $attr){
$tmp[$attr] = "";
}
$tmp["old_cn"] = "";
- $tmp['status']="new";
- $this->partitions[count($this->partitions)+1]=$tmp;
+ $tmp['status'] ="new";
+ $tmp['FAIpartitionNr'] = $new_nr;
+ $this->partitions[]=$tmp;
}
/* $setup contains a table with the partitions.
$tmp = array();
$tmp['cn'] = $this->DISK_cn;
- /* Attach partitions */
- foreach($this->partitions as $key=>$val) {
- $this->partitions[$key]['FAIpartitionNr']=$key;
- }
-
/* Attach deleted */
foreach($this->deletePartitions as $key=>$val) {
- $this->partitions[$key."-delete"]=$val;
- $this->partitions[$key."-delete"]['status']="delete";
+ $this->partitions[$val['FAIpartitionNr']."-delete"]=$val;
+ $this->partitions[$val['FAIpartitionNr']."-delete"]['status']="delete";
}
$tmp['description'] = $this->DISK_description;
foreach($this->partitions as $key => $part){
foreach($this->UsedAttrs as $attrs){
- if(isset($_POST[$attrs."_".$key])){
- $this->partitions[$key][$attrs] = $_POST[$attrs."_".$key];
- }else{
- $this->partitions[$key][$attrs] = false;
+
+ if(!in_array_ics($attrs,array("FAIpartitionNr"))){
+ if(isset($_POST[$attrs."_".$key])){
+ $this->partitions[$key][$attrs] = $_POST[$attrs."_".$key];
+ }else{
+ $this->partitions[$key][$attrs] = false;
+ }
}
}
}