From 4bb51c943a6e9004542380078a7187a30facf6b1 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 30 Jul 2009 11:39:41 +0000 Subject: [PATCH] We can now save volume groups. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13963 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_faiDiskEntry.inc | 35 +++--- .../fai/admin/fai/class_faiPartition.inc | 115 +++++++++--------- gosa-plugins/fai/admin/fai/faiDiskEntry.tpl | 88 +++++++------- gosa-plugins/fai/admin/fai/faiPartition.tpl | 8 +- 4 files changed, 129 insertions(+), 117 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc index 694045765..9d5f8c943 100644 --- a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc @@ -13,9 +13,9 @@ class faiDiskEntry extends plugin var $partitions = array(); var $UsedAttrs = array("cn","description","FAIpartitionType", - "FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize","FAIfsTuneOptions", - "FAIfsCreateOptions", - "FAImountOptions","FAIfsOptions","FAIpartitionFlags","FAIdiskOption"); + "FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize", + "FAIfsTuneOptions", "FAIfsCreateOptions", "FAImountOptions", + "FAIfsOptions","FAIpartitionFlags","FAIdiskOption"); var $is_edit = false; var $old_cn = ""; @@ -23,7 +23,6 @@ class faiDiskEntry extends plugin var $deletePartitions = array(); var $fstabkey = "device"; var $disklabel = "msdos"; - var $FAIstate = ""; var $FAIdiskType = "disk"; @@ -31,12 +30,10 @@ class faiDiskEntry extends plugin { plugin::plugin ($config, $dn); - // Set default attributes $this->parent = $parent; $this->FAIdiskType = $type; $this->status = "new"; - // If disk is not empty, then we are going to edit // an existing disk, load disk info now. @@ -111,7 +108,9 @@ class faiDiskEntry extends plugin if (preg_match("/^bootable:/", $option)){ $bootable = split(",", trim(preg_replace("/^bootable:/","",$option),",")); foreach($bootable as $bootflag){ - $this->partitions[$bootflag]['bootable'] = TRUE; + if(isset($this->partitions[$bootflag])){ + $this->partitions[$bootflag]['bootable'] = TRUE; + } } continue; } @@ -120,7 +119,9 @@ class faiDiskEntry extends plugin if (preg_match("/^resize:/", $option)){ $resize = split(",", trim(preg_replace("/^resize:/","",$option),",")); foreach($resize as $id){ - $this->partitions[$id]['resize'] = TRUE; + if(isset($this->partitions[$bootflag])){ + $this->partitions[$id]['resize'] = TRUE; + } } continue; } @@ -129,8 +130,10 @@ class faiDiskEntry extends plugin if (preg_match("/^preserve_always:/", $option)){ $preserve = split(",", trim(preg_replace("/^preserve_always:/","",$option),",")); foreach($preserve as $presflag){ - $this->partitions[$presflag]['preserve'] = TRUE; - $this->partitions[$presflag]['preserveType'] = 'always'; + if(isset($this->partitions[$bootflag])){ + $this->partitions[$presflag]['preserve'] = TRUE; + $this->partitions[$presflag]['preserveType'] = 'always'; + } } continue; } @@ -139,8 +142,10 @@ class faiDiskEntry extends plugin if (preg_match("/^preserve_reinstall:/", $option)){ $preserve = split(",", trim(preg_replace("/^preserve_reinstall:/","",$option),",")); foreach($preserve as $presflag){ - $this->partitions[$presflag]['preserve'] = TRUE; - $this->partitions[$presflag]['preserveType'] = 'reinstall'; + if(isset($this->partitions[$bootflag])){ + $this->partitions[$presflag]['preserve'] = TRUE; + $this->partitions[$presflag]['preserveType'] = 'reinstall'; + } } continue; } @@ -225,10 +230,12 @@ class faiDiskEntry extends plugin if($this->dialog instanceOf plugin && isset($_POST['PartitionSave'])){ $this->dialog->save_object(); $attrs = $this->dialog->save(); - if(isset($attrs['FAIpartitionNr'])){ + if(isset($attrs['FAIpartitionNr']) && $attrs['FAIpartitionNr'] != ""){ $this->partitions[$attrs['FAIpartitionNr']] = $attrs; }else{ - $this->partitions[] = $attrs; + $attrs['FAIpartitionNr'] = count($this->partitions) + 1; + $attrs['cn'] = &$attrs['FAIpartitionNr']; + $this->partitions[$attrs['FAIpartitionNr']] = $attrs; } $this->dialog = null; } diff --git a/gosa-plugins/fai/admin/fai/class_faiPartition.inc b/gosa-plugins/fai/admin/fai/class_faiPartition.inc index 72942a65d..ced852af9 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartition.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartition.inc @@ -42,66 +42,71 @@ class faiPartition extends plugin { $this->parent = $parent; + $this->status = "new"; + + // Load attributes from existing partition + if($object){ - foreach($this->attributes as $attr){ - if(isset($object[$attr])){ - $this->$attr = $object[$attr]; + foreach($this->attributes as $attr){ + if(isset($object[$attr])){ + $this->$attr = $object[$attr]; + } } - } - $this->status = $object['status']; - $this->FAIdiskType = $type; - - 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"; + $this->status = $object['status']; + $this->FAIdiskType = $type; + + 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"; - } + } - /* Check for encrypted partitions - */ - if(preg_match("/:encrypt$/",$this->FAImountPoint)){ - $this->FAImountPoint = preg_replace("/:encrypt/","",$this->FAImountPoint); - $this->encrypted = TRUE; - } - - }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); + /* Check for encrypted partitions + */ + if(preg_match("/:encrypt$/",$this->FAImountPoint)){ + $this->FAImountPoint = preg_replace("/:encrypt/","",$this->FAImountPoint); + $this->encrypted = TRUE; + } + + }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); + } } } } diff --git a/gosa-plugins/fai/admin/fai/faiDiskEntry.tpl b/gosa-plugins/fai/admin/fai/faiDiskEntry.tpl index 1dc9916a9..b1de5061e 100644 --- a/gosa-plugins/fai/admin/fai/faiDiskEntry.tpl +++ b/gosa-plugins/fai/admin/fai/faiDiskEntry.tpl @@ -3,56 +3,62 @@
- - - + + +
- {$must}  - + + + + + - - - + + + + - -
+ {$must}  + {render acl=$DISKcnACL} - + {/render} -
+
+ + {render acl=$DISKFAIdiskOptionACL} - + {/render} -
-
+ +
- - - + +
-  - + + + + + - - - + + + + - -
+   + {render acl=$DISKdescriptionACL} - + {/render} -
+
+ + {render acl=$DISKFAIdiskOptionACL} - + {/render} -
+
+ +

diff --git a/gosa-plugins/fai/admin/fai/faiPartition.tpl b/gosa-plugins/fai/admin/fai/faiPartition.tpl index 34d78945b..1d33862d6 100644 --- a/gosa-plugins/fai/admin/fai/faiPartition.tpl +++ b/gosa-plugins/fai/admin/fai/faiPartition.tpl @@ -22,7 +22,7 @@ -{if $FAIdiskType == "disk"} +{if $FAIdiskType == "disk" || $FAIdiskType == "lvm"} {t}Size{/t} @@ -114,8 +114,6 @@ {/if} -{if $FAIdiskType == "raid" || $FAIdiskType == "disk"} - {t}Filesystem{/t} @@ -165,10 +163,6 @@ -{/if} - - - -- 2.30.2