summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3e4b56a)
raw | patch | inline | side by side (parent: 3e4b56a)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 6 Aug 2009 06:42:08 +0000 (06:42 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 6 Aug 2009 06:42:08 +0000 (06:42 +0000) |
-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
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13974 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc | patch | blob | history | |
gosa-plugins/fai/admin/fai/class_faiPartition.inc | patch | blob | history |
diff --git a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc
index aa0dec8a6900ba02a20c57e69dfa8cb1b789f38b..48815b6806bd9d57c4a17d9bace34f3411e47612 100644 (file)
if($this->dialog instanceOf plugin && isset($_POST['PartitionSave'])){
$this->dialog->save_object();
if($this->dialog instanceOf plugin && isset($_POST['PartitionSave'])){
$this->dialog->save_object();
+ $new_partition = $this->dialog->save();
$msgs = $this->dialog->check();
$msgs = $this->dialog->check();
+ $msgs = array_merge($this->check_disks($new_partition));
+
if(!count($msgs)){
if(!count($msgs)){
- $this->updatePartition($this->dialog->save());
+ $this->updatePartition($new_partition);
$this->dialog = null;
}else{
msg_dialog::displayChecks($msgs);
$this->dialog = null;
}else{
msg_dialog::displayChecks($msgs);
if(preg_match("/[^a-z0-9_\-]/i",$d)){
$message[] = msgPool::invalid(_("Name"),$d,"/[a-z0-9_\-]/i");
}
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()
/* 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 f305a3d4462b12f63cd12ec1cf47bc1f2682d0d6..4e8ef7eb12794a49cef746a664b44535cf976f63 100644 (file)
var $status = "";
var $raidDevices = array();
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;
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){
// Load attributes from existing partition
if($object){
// Create a list of selectable partition types
if($this->FAIdiskType == "disk"){
// 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"),
}elseif($this->FAIdiskType == "raid"){
$types = array(
"raid0" => _("RAID 0"),
$smarty->assign("plist",$this->getRaidlist());
$smarty->assign("physicalPartitionList",$this->getPartitionlist());
$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);
foreach($this->attributes as $attr){
$smarty->assign($attr,$this->$attr);