From bfc2ab47708cd8867e387d1b8bf4112bd7ef1d43 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 7 Aug 2009 13:29:53 +0000 Subject: [PATCH] Updated FAIpartition handling. -Do not display removed partitions. -Do not include removed partitions in FAIpartitionNr generation. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14004 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_faiDiskEntry.inc | 148 ++++++++++-------- 1 file changed, 84 insertions(+), 64 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc index 4d4b42968..b07b37715 100644 --- a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc @@ -456,13 +456,30 @@ class faiDiskEntry extends plugin } } + + function get_free_partition_number() + { + $used = array(); + foreach($this->partitions as $key => $part){ + if($part['status'] != "delete"){ + $used[] = $part['FAIpartitionNr']; + } + } + $id = 1; + while(in_array($id,$used) && $id < 16 ){ + $id++; + } + return($id); + } + + /* Add or update a partition */ function updatePartition($part) { if(!isset($part['FAIpartitionNr']) || $part['FAIpartitionNr'] == "undefined"){ - $part['FAIpartitionNr'] = count($this->partitions) + 1; + $part['FAIpartitionNr'] = $this->get_free_partition_number(); } /* Update the disk cn - @@ -504,71 +521,74 @@ class faiDiskEntry extends plugin $divlist = new divSelectBox("DiskEntries"); foreach($this->partitions as $key => $part){ - // Create default table cols - $cn =array( - "string" => "".$part['cn']."", - "attach" => "style='width:160px;'"); - $desc =array( - "string" => "". - $part['description']."", - "attach" => "style='width:200px;'"); - $number =array( - "string" => $part['FAIpartitionNr'], - "attach" => "style='width:20px;'"); - $size =array( - "string" => $part['FAIpartitionSize'], - "attach" => "style='width:100px;'"); - $type =array( - "string" => $part['FAIpartitionType'], - "attach" => "style='width:80px;'"); - - // Remove encryption info from the mount point. - $mnt = $part['FAImountPoint']; - if(preg_match("/:encrypt/", $mnt)){ - $mnt = preg_replace("/:encrypt/","",$mnt); - } - $mntp =array("string" => $mnt); - - // create human readable strings out of the flags. - $opt = ""; - if(isset($part['encrypted']) && $part['encrypted']){ - $opt.= " "._("encrypted").", "; - } - if(isset($part['bootable']) && $part['bootable']){ - $opt.= " "._("bootable").", "; - } - if(isset($part['preserve']) && $part['preserve']){ - $opt.= " "._("preserve").": ".$part['preserveType'].", "; - } - - // Combine options to a single table col. - $opt =array( - "string" => "".preg_replace('/, $/',"",$opt).""); - - // Depending on the FAIstatus (freeze?) we will display different options. - // We can't remove freezed branches -> Hide remove button. - if(!preg_match("/freeze/", $this->FAIstate)){ - $action =array( - "string" => "". - "", - "attach" => "style='width:40px; border-right: 0px;'"); - }else{ - $action =array( - "string" => "", - "attach" => "style='width:40px; border-right: 0px;'"); - } + if($part['status'] != "delete"){ + + // Create default table cols + $cn =array( + "string" => "".$part['cn']."", + "attach" => "style='width:160px;'"); + $desc =array( + "string" => "". + $part['description']."", + "attach" => "style='width:200px;'"); + $number =array( + "string" => $part['FAIpartitionNr'], + "attach" => "style='width:20px;'"); + $size =array( + "string" => $part['FAIpartitionSize'], + "attach" => "style='width:100px;'"); + $type =array( + "string" => $part['FAIpartitionType'], + "attach" => "style='width:80px;'"); + + // Remove encryption info from the mount point. + $mnt = $part['FAImountPoint']; + if(preg_match("/:encrypt/", $mnt)){ + $mnt = preg_replace("/:encrypt/","",$mnt); + } + $mntp =array("string" => $mnt); + + // create human readable strings out of the flags. + $opt = ""; + if(isset($part['encrypted']) && $part['encrypted']){ + $opt.= " "._("encrypted").", "; + } + if(isset($part['bootable']) && $part['bootable']){ + $opt.= " "._("bootable").", "; + } + if(isset($part['preserve']) && $part['preserve']){ + $opt.= " "._("preserve").": ".$part['preserveType'].", "; + } + + // Combine options to a single table col. + $opt =array( + "string" => "".preg_replace('/, $/',"",$opt).""); + + // Depending on the FAIstatus (freeze?) we will display different options. + // We can't remove freezed branches -> Hide remove button. + if(!preg_match("/freeze/", $this->FAIstate)){ + $action =array( + "string" => "". + "", + "attach" => "style='width:40px; border-right: 0px;'"); + }else{ + $action =array( + "string" => "", + "attach" => "style='width:40px; border-right: 0px;'"); + } - // Build up info table, depending on the disk type. - if($this->FAIdiskType == "lvm"){ - $fields = array($cn,$desc,$mntp,$opt,$size, $action); - }elseif($this->FAIdiskType == "raid"){ - $raid_str = $part['FAIpartitionType']." (".$part['FAIpartitionSize'].")"; - $raid = array("string" => $raid_str); - $fields = array($cn,$desc,$raid,$mntp,$opt,$action); - }else{ - $fields = array($number,$desc,$type,$mntp,$opt,$size,$action); + // Build up info table, depending on the disk type. + if($this->FAIdiskType == "lvm"){ + $fields = array($cn,$desc,$mntp,$opt,$size, $action); + }elseif($this->FAIdiskType == "raid"){ + $raid_str = $part['FAIpartitionType']." (".$part['FAIpartitionSize'].")"; + $raid = array("string" => $raid_str); + $fields = array($cn,$desc,$raid,$mntp,$opt,$action); + }else{ + $fields = array($number,$desc,$type,$mntp,$opt,$size,$action); + } + $divlist->AddEntry($fields); } - $divlist->AddEntry($fields); } return($divlist->DrawList()); } -- 2.30.2