summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 95b01c1)
raw | patch | inline | side by side (parent: 95b01c1)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 31 Jul 2009 11:45:26 +0000 (11:45 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 31 Jul 2009 11:45:26 +0000 (11:45 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13966 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 a1f0e420e8e9cf34b6938194007111b681e54a00..a3db65c68744f36888bef07d08162cb09be6303a 100644 (file)
if($disk){
// Get devices used in volume base disks.
- if($disk['FAIlvmDevice']){
+ if(isset($disk['FAIlvmDevice'])){
$this->lvmDevices = $disk['FAIlvmDevice'];
}
// Remove partition
if(isset($_POST['addLvmPartition']) && isset($_POST['lvmPartitionAdd'])){
$name = $_POST['lvmPartitionAdd'];
- $this->lvmDevices[$name] = array("name" => $name);
+ $this->lvmDevices[$name] = $name;
}
/* Check all Posts if there is something usefull for us,
}
if($this->dialog instanceOf plugin && isset($_POST['PartitionSave'])){
$this->dialog->save_object();
- $this->updatePartition($this->dialog->save());
- $this->dialog = null;
+
+ $msgs = $this->dialog->check();
+ if(!count($msgs)){
+ $this->updatePartition($this->dialog->save());
+ $this->dialog = null;
+ }else{
+ msg_dialog::displayChecks($msgs);
+ }
}
if($this->dialog instanceOf plugin){
$this->dialog->save_object();
$objs = $disks;
foreach($disks as $disk){
foreach($disk['partitions'] as $id => $part){
- $objs[$disk['cn'].$id] = $part;
+ $objs[$disk['cn']] = $part;
}
}
$array = array();
foreach($this->parent->disks as $disk){
foreach($disk['partitions'] as $key => $part){
- $name = $disk['cn'].$key;
+ $name = $disk['cn'];
if(!isset($this->lvmDevices[$name])){
$array[$name] = $name;
}
{
if(!isset($part['FAIpartitionNr']) || $part['FAIpartitionNr'] == "undefined"){
$part['FAIpartitionNr'] = count($this->partitions) + 1;
- $part['cn'] = count($this->partitions) + 1;
+ $part['cn'] = $this->cn.$part['FAIpartitionNr'];
}
$this->partitions[$part['FAIpartitionNr']] = $part;
}
/* Attach partitions */
foreach($this->partitions as $key=>$val) {
$this->partitions[$key]['FAIpartitionNr']=$key;
- $this->partitions[$key]['cn']=$key;
+ $this->partitions[$key]['cn'] = $this->DISKcn.$key;
}
/* Attach deleted */
diff --git a/gosa-plugins/fai/admin/fai/class_faiPartition.inc b/gosa-plugins/fai/admin/fai/class_faiPartition.inc
index 3b897bcabcb68a45fd09ae30192c0e7b2a62a527..e3ed5dac8dd8bb6f2b900034f0f497eb7410d6b1 100644 (file)
$this->status = $object['status'];
$this->FAIdiskType = $type;
- if($type == "disk"){
+ if($type == "disk" || $type =="lvm"){
/* Prepare size attribute
* This attribute may represent a range, a fixed value
$smarty->assign("preserveType", $this->preserveType);
$smarty->assign("FAIfsTypes", $FAIfsTypes);
+ $smarty->assign("cn", $this->cn);
$smarty->assign("plist",$this->getRaidlist());
$smarty->assign("physicalPartitionList",$this->getPartitionlist());
$array = array();
foreach($this->parent->parent->disks as $disk){
foreach($disk['partitions'] as $key => $part){
- $name = $disk['cn'].$key;
+ $name = $disk['cn'];
if(!isset($this->raidDevices[$name])){
$array[$name] = $name;
}
$objs = $disks;
foreach($disks as $disk){
foreach($disk['partitions'] as $id => $part){
- $objs[$disk['cn'].$id] = $part;
+ $objs[$disk['cn']] = $part;
}
}
}
}
+
+ function check()
+ {
+ $msgs = plugin::check();
+
+ // Check the given partition size.
+ if($this->FAIdiskType == "disk" || $this->FAIdiskType == "lvm"){
+ if($this->FAIpartitionSizeType == "fixed" || $this->FAIpartitionSizeType == "dynamic"){
+ if(!is_numeric($this->sizeStart)){
+ $msgs[] = msgPool::invalid(_("Partition size"),$this->sizeStart,"/[0-9]/i");
+ }
+ }
+ if($this->FAIpartitionSizeType == "dynamic"){
+ if(!is_numeric($this->sizeStop)){
+ $msgs[] = msgPool::invalid(_("Partition size"),$this->sizeStop,"/[0-9]/i");
+ }
+
+ $mp = array(
+ "%" => 1,
+ "KB" => pow(1024,0),
+ "MB" => pow(1024,1),
+ "GB" => pow(1024,2),
+ "TB" => pow(1024,3),
+ "PB" => pow(1024,4));
+ $res1 = $this->sizeStart * $mp[$this->sizeStart_Type];
+ $res2 = $this->sizeStop * $mp[$this->sizeStop_Type];
+ if($res1 > $res2){
+ $msgs[] = msgPool::toobig(_("Partition start size"), "'"._("Partition stop size")."'");
+ }
+ }
+ }
+
+ // check mount point
+ if($this->FAIfsType != "swap"){
+ if(!preg_match("#^/#",$this->FAImountPoint)){
+ $msgs[] = msgPool::invalid(_("Mount point"));
+ }
+ }
+
+ return($msgs);
+ }
+
+
function save()
{
$ret = array();
}
// Save partition size
- if($this->FAIdiskType == "disk"){
+ if($this->FAIdiskType == "disk" || $this->FAIdiskType == "lvm"){
switch($this->FAIpartitionSizeType){
case 'fixed' :
$ret['FAIpartitionSize'] = $this->sizeStart.$this->sizeStart_Type;break;
$ret['FAIpartitionSize'] = trim($ret['FAIpartitionSize'],",");
}
$ret['status'] = $this->status;
+
+ if($this->FAIfsType == "swap"){
+ $ret['FAImountPoint'] = "swap";
+ }
+
return($ret);
}
}
diff --git a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc
index 9534a765e1afef84ca18981a5b89c3b45e717139..8b6a690ecd78468d1276d3b68b1881695bfb2559 100644 (file)
// Transform potential lvm information
if (isset($obj['FAIlvmDevice'])){
- $objects['FAIlvmDevice'] = $obj['FAIlvmDevice'];
+ for($i=0;$i<$obj['FAIlvmDevice']['count'];$i++){
+ $name = $obj['FAIlvmDevice'][$i];
+ $objects['FAIlvmDevice'][$name] = $name;
+ }
}
$objects['dn'] = $obj['dn'];
$partition_dn= "FAIpartitionNr=".$partition_attrs['FAIpartitionNr'].",".$disk_dn;
$partition_attrs['objectClass']= array("top","FAIclass","FAIpartitionEntry");
- $partition_attrs['cn']= $partition_attrs['FAIpartitionNr'];
unset($partition_attrs['status']);
unset($partition_attrs['old_cn']);
diff --git a/gosa-plugins/fai/admin/fai/faiPartition.tpl b/gosa-plugins/fai/admin/fai/faiPartition.tpl
index 8eb88a40595f87218e5e4d04a61744069565f85a..d19511bb8db0a0d7097762b870dde975bd596dc1 100644 (file)
<select name="FAIpartitionType" onChange='document.mainform.submit();'>
{html_options options=$partitionTypes selected=$FAIpartitionType}
</select>
+ {if $cn != "" } ({$cn}){/if}
</td>
{/if}
<td>{t}Description{/t}</td>
{t}Filesystem{/t}
</td>
<td>
- <select name='FAIfsType'>
+ <select name='FAIfsType' onChange="document.mainform.submit();">
{html_options options=$FAIfsTypes selected=$FAIfsType}
</select>
{t}Mount point{/t}
</td>
<td>
- <input name="FAImountPoint" value="{$FAImountPoint}">
+ {if $FAIfsType != "swap"}
+ <input name="FAImountPoint" value="{$FAImountPoint}">
+ {else}
+ <input name="dummy10" value="swap" disabled>
+ {/if}
</td>
<td>
{t}Mount options{/t}