From bb1af61fc803ff4707a5384f7b2d878bf2688e55 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 7 Aug 2009 12:10:58 +0000 Subject: [PATCH] Updated FAI partition handling. -Save primary partition with numbers from 1-4, and logical > 5 git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14002 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_faiPartitionTable.inc | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc index 4f3c269aa..7732843e3 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc @@ -522,8 +522,8 @@ class faiPartitionTable extends plugin /* Save to LDAP */ function save() { - plugin::save(); + /* Save current settings. * 1 : We must save the partition table, with its description and cn * 2 : Append Disk with cn and description. @@ -547,6 +547,11 @@ class faiPartitionTable extends plugin $order[$key] = $disk; } } + + + // Prepare disks to be saved. + $this->prepareDiskToBeSave(); + foreach($this->disks as $key => $disk){ if($disk['status'] != "delete"){ $order[$key] = $disk; @@ -651,6 +656,47 @@ class faiPartitionTable extends plugin } + function prepareDiskToBeSave() + { + foreach($this->disks as $id => $disk){ + + /* Correct FAIpartitionNr. + * If we've only primary partition then set the partition numbers from + * 1 to 4, else set the primary from 1 to 3 and logical >= 5 + * + */ + if($disk['FAIdiskType'] == "disk"){ + $primary = $logical = array(); + foreach($disk['partitions'] as $partid => $part){ + if($part['FAIpartitionType'] == "primary"){ + $primary[$partid] = $part; + }elseif($part['FAIpartitionType'] == "logical"){ + $logical[$partid] = $part; + }else{ + trigger_error("Fatal: unknown disk type? ".$part['FAIpartitionType']); + } + } + $newSetup = array(); + $cnt = 1; + foreach($primary as $part){ + $part['FAIpartitionNr'] = $cnt; + $part['cn'] = $disk['cn'].$cnt; + $newSetup[$cnt] = $part; + $cnt ++; + } + $cnt = 5; + foreach($logical as $part){ + $part['FAIpartitionNr'] = $cnt; + $part['cn'] = $disk['cn'].$cnt; + $newSetup[$cnt] = $part; + $cnt ++; + } + $this->disks[$id]['partitions'] = $newSetup; + } + } + } + + function PrepareForCopyPaste($source) { plugin::PrepareForCopyPaste($source); -- 2.30.2