From: hickert Date: Wed, 29 Jul 2009 09:29:55 +0000 (+0000) Subject: Added new FAI partition class. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=daec00ed271d4614864bb848c0828a1c115db36a;p=gosa.git Added new FAI partition class. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13958 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 c2fcfa107..a0dc78916 100644 --- a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc @@ -23,13 +23,16 @@ class faiDiskEntry extends plugin var $FAIstate = ""; var $FAIdiskType = "disk"; - function faiDiskEntry (&$config, $dn= NULL,$usedDiskNames=array(),$disk=false) + function faiDiskEntry (&$config, $dn= NULL,$usedDiskNames,$disk,$type) { plugin::plugin ($config, $dn); $this->UsedAttrs = array("cn","description","FAIpartitionType", "FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize", "FAImountOptions","FAIfsOptions","FAIpartitionFlags","FAIdiskOption"); + /* Set disk type */ + $this->FAIdiskType = $type; + /* Default status is new */ $this->status = "new"; @@ -62,6 +65,7 @@ class faiDiskEntry extends plugin } $disk['partitions'][$name]['old_cn']= $disk['partitions'][$name]['cn']; + $disk['partitions'][$name]['FAIdiskType']= $this->FAIdiskType; /* Assign empty attributes, if attribute is missing */ foreach($this->UsedAttrs as $attr){ @@ -182,13 +186,13 @@ class faiDiskEntry extends plugin $id = preg_replace("/^EditPartition_/","",$name); $id = preg_replace("/_.*$/","",$id); if(isset($this->partitions[$id])){ - $this->dialog = new faiPartition($this->config,"disk",$this->partitions[$id]); + $this->dialog = new faiPartition($this->config,$this->partitions[$id], $this->FAIdiskType); break; } } } if(isset($_POST['AddPartition']) && !preg_match("/freeze/i",$this->FAIstate)){ - $this->dialog = new faiPartition($this->config,"disk"); + $this->dialog = new faiPartition($this->config, array(), $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 new file mode 100644 index 000000000..755158144 --- /dev/null +++ b/gosa-plugins/fai/admin/fai/class_faiPartition.inc @@ -0,0 +1,197 @@ +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"; + } + } + + function execute() + { + plugin::execute(); + $smarty = get_smarty(); + + // Create a list of selectable partition types + if($this->FAIdiskType == "disk"){ + $types = array( + "primary" => _("Primary"), + "secondary" => _("Secondary")); + }elseif($this->FAIdiskType == "raid"){ + $types = array( + "raid0" => _("Raid 0"), + "raid1" => _("Raid 1"), + "raid5" => _("Raid 5"), + "raid6" => _("Raid 6")); + }else{ + $types = ""; + } + + + // Create a list of all size options + $partitionSizeTypes = array( + "fixed" => _("Fixed"), + "dynamic" => _("Dynamic"), + "remaining" => _("Use remaining space") + ); + + // Create a list of all size options + $sizeTypes = array( + "KB" => _("KB"), + "MB" => _("MB"), + "GB" => _("GB"), + "TB" => _("TB"), + "PB" => _("PB"), + "%" => _("Percent") + ); + + // Preserve types + $preserveTypes = array( + "always" => _("Always"), + "reinstall" => _("Reinstall")); + + $FAIfsTypes = array( + "swap" => _("Swap"), + "ext2" => _("Ext 2"), + "ext3" => _("Ext 3"), + "ext4" => _("Ext 4"), + "reiserfs" => _("Reiser fs"), + "xfs" => _("Xfs"), + "btrfs" => _("Btrfs")); + + $smarty->assign("partitionTypes", $types); + $smarty->assign("partitionSizeTypes", $partitionSizeTypes); + $smarty->assign("FAIpartitionSizeType", $this->FAIpartitionSizeType); + $smarty->assign("sizeTypes", $sizeTypes); + + $smarty->assign("sizeStart_Type", $this->sizeStart_Type); + $smarty->assign("sizeStop_Type", $this->sizeStop_Type); + $smarty->assign("sizeStart", $this->sizeStart); + $smarty->assign("sizeStop", $this->sizeStop); + + $smarty->assign("preserveTypes", $preserveTypes); + $smarty->assign("preserveType", $this->preserveType); + + $smarty->assign("FAIfsTypes", $FAIfsTypes); + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("faiPartition.tpl", TRUE, dirname(__FILE__)))); + } + + function save_object() + { + if(isset($_POST['faiPartition'])){ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = get_post($attr); + } + } + foreach(array("FAIpartitionSizeType","sizeStart","sizeStop","sizeStart_Type","sizeStop_Type") as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = get_post($attr); + } + } + foreach(array("bootable","preserve","resize","encrypted") as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = TRUE; + }else{ + $this->$attr = FALSE; + } + } + } + } + + function save() + { + $ret = array(); + foreach($this->attributes as $attr){ + $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!"); + } + + return($ret); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc index 8146b5cfe..3b44c41e3 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc @@ -125,51 +125,26 @@ class faiPartitionTable extends plugin * This code adds a new HDD to the disks * A new Dialog will be opened */ - if(isset($_POST['AddDisk']) && !preg_match("/freeze/i",$this->FAIstate)){ + if((isset($_POST['AddDisk']) || isset($_POST['AddRaid']) || isset($_POST['AddVolgroup'])) && + !preg_match("/freeze/i",$this->FAIstate)){ $usedDiskNames =array(); foreach($this->disks as $key=>$disk){ $usedDiskNames[]= $key; } if ($this->FAIpartitionMethod == "setup-storage") { - $this->dialog = new faiDiskEntry($this->config,$this->dn,$usedDiskNames); + 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); } else { $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames); } - $this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn)); - $this->dialog->set_acl_category("fai"); - $this->dialog->FAIstate = $this->FAIstate; - $this->is_dialog = true; - } - /* Add Disk to this Partitionset - * This code adds a new HDD to the disks - * A new Dialog will be opened - */ - if(isset($_POST['AddRaid']) && !preg_match("/freeze/i",$this->FAIstate)){ - $usedDiskNames =array(); - foreach($this->disks as $key=>$disk){ - $usedDiskNames[]= $key; - } - $this->dialog = new faiRaidEntry($this->config,$this->dn,$usedDiskNames); $this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn)); $this->dialog->set_acl_category("fai"); $this->dialog->FAIstate = $this->FAIstate; - $this->is_dialog = true; - } - /* Add Disk to this Partitionset - * This code adds a new HDD to the disks - * A new Dialog will be opened - */ - if(isset($_POST['AddVolgroup']) && !preg_match("/freeze/i",$this->FAIstate)){ - $usedDiskNames =array(); - foreach($this->disks as $key=>$disk){ - $usedDiskNames[]= $key; - } - $this->dialog = new faiLvmEntry($this->config,$this->dn,$usedDiskNames); - $this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn)); - $this->dialog->set_acl_category("fai"); - $this->dialog->FAIstate = $this->FAIstate; + $this->is_dialog = true; } @@ -286,16 +261,11 @@ class faiPartitionTable extends plugin if(isset($this->disks[$Udisk]['FAIdiskType'])){ switch($this->disks[$Udisk]['FAIdiskType']){ case 'raid': - $this->dialog = new faiRaidEntry( - $this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]); - break; case 'lvm': - $this->dialog = new faiLvmEntry( - $this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]); - break; case 'disk': $this->dialog = new faiDiskEntry( - $this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]); + $this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk], + $this->disks[$Udisk]['FAIdiskType']); break; case 'old': $this->dialog = new faiPartitionTableEntry( diff --git a/gosa-plugins/fai/admin/fai/faiPartition.tpl b/gosa-plugins/fai/admin/fai/faiPartition.tpl new file mode 100644 index 000000000..edf6f54eb --- /dev/null +++ b/gosa-plugins/fai/admin/fai/faiPartition.tpl @@ -0,0 +1,139 @@ + +

{t}Partition{/t}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{t}Type{/t} + + {t}Description{/t} + +
{t}Size{/t} + + {if $FAIpartitionSizeType != "remaining"} + + + {else} + + + {/if} +  -  + {if $FAIpartitionSizeType != "fixed" && $FAIpartitionSizeType != "remaining"} + + + {else} + + + {/if} +
+

 

+
+ +  {t}Resize{/t} + + +  {t}Bootable{/t} + + +  {t}Preserve{/t} + + +
+

 

+
+ {t}Filesystem{/t} + + +   + +   {t}Encrypted{/t} + + {t}Create options{/t} + + +
+ + {t}Tune options{/t} + + +
+

 

+
+ {t}Mount point{/t} + + + + {t}Mount options{/t} + + +
+ + +

 

+
+ +   + +