summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: daec00e)
raw | patch | inline | side by side (parent: daec00e)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 29 Jul 2009 13:49:42 +0000 (13:49 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 29 Jul 2009 13:49:42 +0000 (13:49 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13959 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 a0dc7891655ea722c2b6a3ab4408761304540918..4a656e60cd87658f8ebdbed11e25e1d5a1bde21a 100644 (file)
var $FAIstate = "";
var $FAIdiskType = "disk";
- function faiDiskEntry (&$config, $dn= NULL,$usedDiskNames,$disk,$type)
+ function faiDiskEntry (&$config, $dn= NULL,$parent,$disk,$type)
{
plugin::plugin ($config, $dn);
+
+ $this->parent = $parent;
+
$this->UsedAttrs = array("cn","description","FAIpartitionType",
"FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize",
"FAImountOptions","FAIfsOptions","FAIpartitionFlags","FAIdiskOption");
$id = preg_replace("/^EditPartition_/","",$name);
$id = preg_replace("/_.*$/","",$id);
if(isset($this->partitions[$id])){
- $this->dialog = new faiPartition($this->config,$this->partitions[$id], $this->FAIdiskType);
+ $this->dialog = new faiPartition($this->config,$this->partitions[$id], $this,$this->FAIdiskType);
break;
}
}
}
if(isset($_POST['AddPartition']) && !preg_match("/freeze/i",$this->FAIstate)){
- $this->dialog = new faiPartition($this->config, array(), $this->FAIdiskType);
+ $this->dialog = new faiPartition($this->config, array(), $this,$this->FAIdiskType);
}
if($this->dialog instanceOf plugin && isset($_POST['PartitionCancel'])){
$this->dialog = null;
diff --git a/gosa-plugins/fai/admin/fai/class_faiPartition.inc b/gosa-plugins/fai/admin/fai/class_faiPartition.inc
index 755158144e54cf254ef3b93dfb57250910a8f9db..c6c901e2d9e37ed8ed897bd177299f7e14a25db1 100644 (file)
var $preserveType = "always";
var $encrypted = false;
- function __construct($config, $object, $type)
+ var $raidDevices = array();
+
+ function __construct($config, $object, $parent,$type)
{
+
+ $this->parent = $parent;
+
foreach($this->attributes as $attr){
if(isset($object[$attr])){
$this->$attr = $object[$attr];
$this->FAIdiskType = $type;
- /* Prepare size attribute
- * This attribute may represent a range, a fixed value
- * or a percentage.
- * fixed is just a number * 500MB
- * range * 500MB-1TB
- * remaining * -
- */
-
- // Fixed
- if(preg_match("/^[0-9]*(KB|MB|GB|TB|PB)$/",$this->FAIpartitionSize)){
- $this->sizeStart = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB)$/","\\1",$this->FAIpartitionSize);
- $this->sizeStart_Type = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB)$/","\\2",$this->FAIpartitionSize);
- $this->FAIpartitionSizeType = "fixed";
- }else
-
- // Dynamic range
- if(preg_match("/^[0-9]*(KB|MB|GB|TB|PB)-[0-9]*(KB|MB|GB|TB|PB)$/",$this->FAIpartitionSize)){
- $this->sizeStart = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB).*$/","\\1",$this->FAIpartitionSize);
- $this->sizeStart_Type = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB).*$/","\\2",$this->FAIpartitionSize);
- $this->sizeStop = preg_replace("/^[^\-]*\-([0-9]*)(KB|MB|GB|TB|PB)$/","\\1",$this->FAIpartitionSize);
- $this->sizeStop_Type = preg_replace("/^[^\-]*\-([0-9]*)(KB|MB|GB|TB|PB)$/","\\2",$this->FAIpartitionSize);
- $this->FAIpartitionSizeType = "dynamic";
- }else
-
- // Dynamic range
- if(preg_match("/^\-$/",$this->FAIpartitionSize)){
- $this->FAIpartitionSizeType = "remaining";
+ if($type == "disk"){
+
+ /* Prepare size attribute
+ * This attribute may represent a range, a fixed value
+ * or a percentage.
+ * fixed is just a number * 500MB
+ * range * 500MB-1TB
+ * remaining * -
+ */
+ // Fixed
+ if(preg_match("/^[0-9]*(KB|MB|GB|TB|PB|%)$/",$this->FAIpartitionSize)){
+ $this->sizeStart = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\1",$this->FAIpartitionSize);
+ $this->sizeStart_Type = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\2",$this->FAIpartitionSize);
+ $this->FAIpartitionSizeType = "fixed";
+ }else
+
+ // Dynamic range
+ if(preg_match("/^[0-9]*(KB|MB|GB|TB|PB|%)-[0-9]*(KB|MB|GB|TB|PB|%)$/",$this->FAIpartitionSize)){
+ $this->sizeStart = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%).*$/","\\1",$this->FAIpartitionSize);
+ $this->sizeStart_Type = preg_replace("/^([0-9]*)(KB|MB|GB|TB|PB|%).*$/","\\2",$this->FAIpartitionSize);
+ $this->sizeStop = preg_replace("/^[^\-]*\-([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\1",$this->FAIpartitionSize);
+ $this->sizeStop_Type = preg_replace("/^[^\-]*\-([0-9]*)(KB|MB|GB|TB|PB|%)$/","\\2",$this->FAIpartitionSize);
+ $this->FAIpartitionSizeType = "dynamic";
+ }else
+
+ // Dynamic range
+ if(preg_match("/^\-$/",$this->FAIpartitionSize)){
+ $this->FAIpartitionSizeType = "remaining";
+
+ }
+ }elseif($type == "raid"){
+
+ $usedDisks = split(",",$this->FAIpartitionSize);
+ foreach($usedDisks as $disk){
+ $name = preg_replace("/:.*$/","",$disk);
+ $spare = preg_match("/:spare/",$disk);
+ $missing = preg_match("/:missing/",$disk);
+ $this->raidDevices[$name] =
+ array(
+ "name" => $name,
+ "spare" => $spare,
+ "missing" => $missing);
+ }
}
}
plugin::execute();
$smarty = get_smarty();
+ // Remove partition
+ if(isset($_POST['addPhysicalPartition']) && isset($_POST['phyiscalPartitionAdd'])){
+ $name = $_POST['phyiscalPartitionAdd'];
+ $this->raidDevices[$name] = array("name" => $name,"spare"=>false,"missing"=>false);
+ }
+
// Create a list of selectable partition types
if($this->FAIdiskType == "disk"){
$types = array(
}else{
$types = "";
}
-
// Create a list of all size options
$partitionSizeTypes = array(
$preserveTypes = array(
"always" => _("Always"),
"reinstall" => _("Reinstall"));
-
+
+ // File system types.
$FAIfsTypes = array(
"swap" => _("Swap"),
"ext2" => _("Ext 2"),
"reiserfs" => _("Reiser fs"),
"xfs" => _("Xfs"),
"btrfs" => _("Btrfs"));
+
+
+
$smarty->assign("partitionTypes", $types);
$smarty->assign("partitionSizeTypes", $partitionSizeTypes);
$smarty->assign("FAIfsTypes", $FAIfsTypes);
+ $smarty->assign("plist",$this->getRaidlist());
+ $smarty->assign("phyiscalPartitionList",$this->getPartitionlist());
+
foreach($this->attributes as $attr){
$smarty->assign($attr,$this->$attr);
}
return($smarty->fetch(get_template_path("faiPartition.tpl", TRUE, dirname(__FILE__))));
}
+
+ function getPartitionList()
+ {
+ $array = array();
+ foreach($this->parent->parent->disks as $disk){
+ foreach($disk['partitions'] as $key => $part){
+ $name = $disk['cn'].$key;
+ if(!isset($this->raidDevices[$name])){
+ $array[$name] = $name;
+ }
+ }
+ }
+ return($array);
+ }
+
+
+ function getRaidList()
+ {
+ $divlist = new divSelectBox("RaidList");
+
+ $disks = $this->parent->parent->disks;
+ $objs = $disks;
+ foreach($disks as $disk){
+ foreach($disk['partitions'] as $id => $part){
+ $objs[$disk['cn'].$id] = $part;
+ }
+ }
+
+ $list = array();
+ foreach($this->raidDevices as $device){
+ $list[$device['name']] = $device['name'];
+
+ if(isset($objs[$device['name']]['FAIpartitionSize'])){
+ $list[$device['name']].= _("Size").": ";
+ $list[$device['name']].= $objs[$device['name']]['FAIpartitionSize'];
+ }
+
+ $list[$device['name']].= " "._("Options").": ";
+ if($device['spare']){
+ $list[$device['name']].= " "._("Spare")." ";
+ }
+ if($device['missing']){
+ $list[$device['name']].= " "._("Missing")." ";
+ }
+ }
+ return($list);
+ }
+
function save_object()
{
if(isset($_POST['faiPartition'])){
$this->$attr = FALSE;
}
}
+
+ // Remove partition
+ if(isset($_POST['delPhysicalPartition']) && isset($_POST['phyiscalPartition'])){
+ unset($this->raidDevices[$_POST['phyiscalPartition']]);
+ }
+
+ // Toggle spare flag for partition entries
+ if(isset($_POST['toggleSpare']) && isset($_POST['phyiscalPartition'])){
+ $this->raidDevices[$_POST['phyiscalPartition']]['spare'] =
+ !$this->raidDevices[$_POST['phyiscalPartition']]['spare'];
+ }
+
+ // Toggle missing flag for partition entries
+ if(isset($_POST['toggleMissing']) && isset($_POST['phyiscalPartition'])){
+ $this->raidDevices[$_POST['phyiscalPartition']]['missing'] =
+ !$this->raidDevices[$_POST['phyiscalPartition']]['missing'];
+ }
}
}
$ret[$attr] = $this->$attr;
}
- // Save partition size
- switch($this->FAIpartitionSizeType){
- case 'fixed' :
- $ret['FAIpartitionSize'] = $this->sizeStart.$this->sizeStart_Type;break;
- case 'dynamic' :
- $ret['FAIpartitionSize'] = $this->sizeStart.$this->sizeStart_Type."-".
- $this->sizeStop.$this->sizeStop_Type;break;
- case 'remaining' :
- $ret['FAIpartitionSize'] = "-";break;
- default: trigger_error("Unknown partition size!");
+ // Save partition size
+ if($this->FAIdiskType == "disk"){
+ switch($this->FAIpartitionSizeType){
+ case 'fixed' :
+ $ret['FAIpartitionSize'] = $this->sizeStart.$this->sizeStart_Type;break;
+ case 'dynamic' :
+ $ret['FAIpartitionSize'] = $this->sizeStart.$this->sizeStart_Type."-".
+ $this->sizeStop.$this->sizeStop_Type;break;
+ case 'remaining' :
+ $ret['FAIpartitionSize'] = "-";break;
+ default: trigger_error("Unknown partition size!");
+ }
+ }elseif($this->FAIdiskType == "raid"){
+ $ret['FAIpartitionSize'] = "";
+ foreach($this->raidDevices as $device){
+ $ret['FAIpartitionSize'] .= $device['name'];
+ if($device['spare']){
+ $ret['FAIpartitionSize'] .= ":spare";
+ }
+ if($device['missing']){
+ $ret['FAIpartitionSize'] .= ":missing";
+ }
+ $ret['FAIpartitionSize'] .= ",";
+ }
+ $ret['FAIpartitionSize'] = trim($ret['FAIpartitionSize'],",");
}
-
return($ret);
}
}
diff --git a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc
index 3b44c41e3a52e7731bc2acd20df5dc55bb81207e..2890e2ead70ef1be1179aabf2510e2240802c8f4 100644 (file)
if(isset($_POST['AddDisk'])) $type = "disk";
if(isset($_POST['AddRaid'])) $type = "raid";
if(isset($_POST['AddAddVolgroup'])) $type = "lvm";
- $this->dialog = new faiDiskEntry($this->config,$this->dn,$usedDiskNames, array(),$type);
+ $this->dialog = new faiDiskEntry($this->config,$this->dn,$this, array(),$type);
} else {
- $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames);
+ $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$this);
}
$this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn));
case 'lvm':
case 'disk':
$this->dialog = new faiDiskEntry(
- $this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk],
+ $this->config,$this->dn,$this,$this->disks[$Udisk],
$this->disks[$Udisk]['FAIdiskType']);
break;
case 'old':
diff --git a/gosa-plugins/fai/admin/fai/faiPartition.tpl b/gosa-plugins/fai/admin/fai/faiPartition.tpl
index edf6f54ebcdd8cff174d59320520dc975b46e14b..a6f8536e444711b2a8424af61aead6150d42acb2 100644 (file)
<table style='width: 100%;' width="100%">
<tr>
- <td>{t}Type{/t}</td>
+{if $FAIdiskType == "lvm"}
+ <td>{t}Name{/t}</td>
+ <td>
+ <input name="FAIpartitionType" value="{$FAIpartitionType}">
+ </td>
+{else}
+ <td>{t}Name{/t}</td>
<td>
<select name="FAIpartitionType" onChange='document.mainform.submit();'>
{html_options options=$partitionTypes selected=$FAIpartitionType}
</select>
</td>
+{/if}
<td>{t}Description{/t}</td>
<td>
<input type="text" value="{$description}" name="description">
</td>
</tr>
+
+{if $FAIdiskType == "disk"}
+
<tr>
<td>{t}Size{/t}</td>
<td colspan=3>
</select>
</td>
</tr>
+
+{/if}
+
+ <tr>
+ <td colspan="4">
+ <p class="seperator"> </p>
+ </td>
+ </tr>
+
+{if $FAIdiskType == "raid"}
+
+ <tr>
+ <td colspan="4">
+ <h2>{t}Combined physical partitions{/t}</h2>
+
+ <select name='phyiscalPartition' size=5 style="width:100%;">
+ {html_options options=$plist}
+ </select>
+ <br>
+ <select name='phyiscalPartitionAdd'>
+ {html_options options=$phyiscalPartitionList}
+ </select>
+ <input type="submit" name='addPhysicalPartition' value="{msgPool type="addButton"}">
+ <input type="submit" name='delPhysicalPartition' value="{msgPool type="delButton"}">
+ <input type="submit" name='toggleMissing' value="{t}Toggle missing{/t}">
+ <input type="submit" name='toggleSpare' value="{t}Toggle spare{/t}">
+ </td>
+ </tr>
<tr>
<td colspan="4">
<p class="seperator"> </p>
</td>
</tr>
+{/if}
+
+{if $FAIdiskType == "raid" || $FAIdiskType == "disk"}
+
<tr>
<td>
{t}Filesystem{/t}
<input name="FAImountOptions" value="{$FAImountOptions}">
</td>
</tr>
-
+
+{/if}
+
+
+
<!-- Table cell sizing -->
<tr>
<td colspan=2 style='width:50%;'></td>