From 936c55bf38f06e4a9c419ec8849458c77c54d96b Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 7 Aug 2009 13:12:35 +0000 Subject: [PATCH] Updated FAIpartition handling. -Only display unsued partitions in raid editor. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14003 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_faiPartition.inc | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_faiPartition.inc b/gosa-plugins/fai/admin/fai/class_faiPartition.inc index 059ebda2b..673d263fa 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartition.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartition.inc @@ -239,18 +239,44 @@ class faiPartition extends plugin */ function getPartitionList() { - $array = array(); + $may = $used = array(); foreach($this->parent->parent->disks as $disk){ - if($disk['FAIdiskType'] != "raid"){ - foreach($disk['partitions'] as $key => $part){ + + // Skip ourselves + if($disk['cn'] == $this->parent->DISKcn) continue; + + // Add partition from lvm combinations + if($disk['FAIdiskType'] == "lvm"){ + $used = array_merge($used,$disk['FAIlvmDevice']); + } + + foreach($disk['partitions'] as $key => $part){ + + // Add disks of raid arrays, to the used list. + if($disk['FAIdiskType'] == "raid"){ + foreach(split(",",$part['FAIpartitionSize']) as $rDevice){ + $used[] = preg_replace("/:.*$/i","",$rDevice); + } + } + + // Collect all available disks + if($disk['FAIdiskType'] == "disk"){ $name = $part['cn']; if(!isset($this->raidDevices[$name])){ - $array[$name] = $name." (".$disk['cn'].")"; + $may[] = $name; } } } } - return($array); + + // Check which of the available disks are unused. + $ret = array(); + foreach($may as $val){ + if(!in_array($val,$used)){ + $ret[$val] = $val; + } + } + return($ret); } -- 2.30.2