From: hickert Date: Thu, 6 Aug 2009 06:42:08 +0000 (+0000) Subject: Updated FAI partition stuff. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1265f47e96331f109d3a73e0caf5560edfb8c7ef;p=gosa.git Updated FAI partition stuff. -Do not allow to create more than 4 primary partitions, in case of logical partitions only three. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13974 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc index aa0dec8a6..48815b680 100644 --- a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc @@ -217,9 +217,12 @@ class faiDiskEntry extends plugin if($this->dialog instanceOf plugin && isset($_POST['PartitionSave'])){ $this->dialog->save_object(); + $new_partition = $this->dialog->save(); $msgs = $this->dialog->check(); + $msgs = array_merge($this->check_disks($new_partition)); + if(!count($msgs)){ - $this->updatePartition($this->dialog->save()); + $this->updatePartition($new_partition); $this->dialog = null; }else{ msg_dialog::displayChecks($msgs); @@ -514,31 +517,45 @@ class faiDiskEntry extends plugin if(preg_match("/[^a-z0-9_\-]/i",$d)){ $message[] = msgPool::invalid(_("Name"),$d,"/[a-z0-9_\-]/i"); } - - /* check every partition. - * if there is an invalid value defined, append an errorstr to message - */ + return ($message); + } - /* Array that contain every partitionname mountpoint etc already assigned */ - $alreadyUsed = array(); - foreach($this->UsedAttrs as $attrs){ - $alreadyUsed[$attrs] = array(); - } - $cnt = 0; - foreach($this->partitions as $key => $part){ - if($part['FAIpartitionType'] == "primary"){ - $cnt ++ ; + /* Checks the disk combinations. + * + */ + function check_disks($disk_to_add = array()) + { + $msgs = array(); + + /* Check 'disk' combinations. + * - There can be four primary partitions. + * - If there is at least one 'logical' partition, then there can be only + * three 'primary' partitions. + */ + if($this->FAIdiskType == "disk"){ + + $types = array('logical' => array(), 'primary' => array()); + $types[$disk_to_add['FAIpartitionType']][$disk_to_add['FAIpartitionNr']] = 1; + foreach($this->partitions as $key => $part){ + $types[$part['FAIpartitionType']][$part['FAIpartitionNr']] = 1; + } + + // There can only be four primary partitions per disk - without any logical partition. + if(count($types['logical']) == 0){ + if(count($types['primary']) > 4){ + $msgs[] = _("You have more than four primary partition table entries in your configuration, please check your configuration twice."); + } + }else{ + if(count($types['primary']) > 3){ + $msgs[] = _("You cannot have more than three primary partition while using logical partitions, please check your configuration twice."); + } } - } - if($cnt > 3){ - $message[] = _("You have more than 3 primary partition table entries in your configuration, please check your configuration twice."); } - return ($message); - } + return($msgs); + } - /* Return plugin informations for acl handling */ static function plInfo() diff --git a/gosa-plugins/fai/admin/fai/class_faiPartition.inc b/gosa-plugins/fai/admin/fai/class_faiPartition.inc index f305a3d44..4e8ef7eb1 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartition.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartition.inc @@ -38,13 +38,31 @@ class faiPartition extends plugin var $status = ""; var $raidDevices = array(); + // Once we've exceeded the primary partition limit, + // hide the the 'primary' option from the select box. + var $disablePrimary = FALSE; + function __construct($config, $object, $parent,$type) { $this->parent = $parent; $this->status = "new"; $this->FAIdiskType = $type; - + + // Check if we should be able to add primary partitions. + if(!$object || $object['FAIpartitionType'] == "logical"){ + if($this->FAIdiskType == "disk"){ + $types = array('logical' => array(), 'primary' => array()); + foreach($this->parent->partitions as $key => $part){ + $types[$part['FAIpartitionType']][$part['FAIpartitionNr']] = 1; + } + if(count($types['logical']) && count($types['primary']) >= 3){ + $this->disablePrimary = TRUE; + }elseif(count($types['logical']) >= 4){ + $this->disablePrimary = TRUE; + } + } + } // Load attributes from existing partition if($object){ @@ -125,9 +143,16 @@ class faiPartition extends plugin // Create a list of selectable partition types if($this->FAIdiskType == "disk"){ - $types = array( - "primary" => _("Primary"), - "secondary" => _("Logical")); + + if($this->disablePrimary){ + $types = array( + "logical" => _("Logical")); + }else{ + $types = array( + "primary" => _("Primary"), + "logical" => _("Logical")); + } + }elseif($this->FAIdiskType == "raid"){ $types = array( "raid0" => _("RAID 0"), @@ -188,6 +213,7 @@ class faiPartition extends plugin $smarty->assign("plist",$this->getRaidlist()); $smarty->assign("physicalPartitionList",$this->getPartitionlist()); + $smarty->assign("disablePrimary", $this->disablePrimary); foreach($this->attributes as $attr){ $smarty->assign($attr,$this->$attr);