From f7bf7d7d68217cca457af41c1fbda3eb5f090a61 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 7 Aug 2009 13:58:13 +0000 Subject: [PATCH] Updated FAI partition handling. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14005 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_faiDiskEntry.inc | 44 +++++++++++++++---- .../fai/admin/fai/class_faiPartition.inc | 3 ++ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc index b07b37715..77a6adc0a 100644 --- a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc @@ -294,7 +294,7 @@ class faiDiskEntry extends plugin /* Creates a human readable list, that contains all physical - * devices that are used by a volume group. + * devices that are used by the volume group. * This list will then be displayed in a html select box. * (lvm) */ @@ -361,22 +361,48 @@ class faiDiskEntry extends plugin */ function getAvailablePartitions() { - $array = array(); + + $may = $used = array(); foreach($this->parent->disks as $disk){ - // We can't add ourselves to the available partitions - if($disk['cn'] == $this->old_cn) continue; + // Skip ourselves + if($disk['cn'] == $this->DISKcn) continue; + if($disk['status'] == "delete") continue; + + // Add partition from lvm combinations + if($disk['FAIdiskType'] == "lvm"){ + $used = array_merge($used,$disk['FAIlvmDevice']); + } - // Add partitions to the list. foreach($disk['partitions'] as $key => $part){ - $name = $part['cn']; - if(!isset($this->lvmDevices[$name])){ - $array[$name] = $name; + + if($part['status'] == "delete") continue; + + // 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->lvmDevices[$name])){ + $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); } diff --git a/gosa-plugins/fai/admin/fai/class_faiPartition.inc b/gosa-plugins/fai/admin/fai/class_faiPartition.inc index 673d263fa..dc5220b47 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartition.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartition.inc @@ -244,6 +244,7 @@ class faiPartition extends plugin // Skip ourselves if($disk['cn'] == $this->parent->DISKcn) continue; + if($disk['status'] == "delete") continue; // Add partition from lvm combinations if($disk['FAIdiskType'] == "lvm"){ @@ -252,6 +253,8 @@ class faiPartition extends plugin foreach($disk['partitions'] as $key => $part){ + if($part['status'] == "delete") continue; + // Add disks of raid arrays, to the used list. if($disk['FAIdiskType'] == "raid"){ foreach(split(",",$part['FAIpartitionSize']) as $rDevice){ -- 2.30.2