From cc5e84595fb868133f82c451c4bf60a5aab1ecb8 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 30 Jul 2009 08:55:54 +0000 Subject: [PATCH] Updated lvm partition handling -We can save now, but nothing is checked or validated right now. -Volumes are missing completely right now. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13961 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_faiDiskEntry.inc | 77 ++++++++++++++++++- .../fai/admin/fai/class_faiPartition.inc | 20 ++++- .../fai/admin/fai/class_faiPartitionTable.inc | 6 +- gosa-plugins/fai/admin/fai/faiPartition.tpl | 4 +- 4 files changed, 98 insertions(+), 9 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc index 4a656e60c..bacf5e123 100644 --- a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc @@ -30,7 +30,8 @@ class faiDiskEntry extends plugin $this->parent = $parent; $this->UsedAttrs = array("cn","description","FAIpartitionType", - "FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize", + "FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize","FAIfsTuneOptions", + "FAIfsCreateOptions", "FAImountOptions","FAIfsOptions","FAIpartitionFlags","FAIdiskOption"); /* Set disk type */ @@ -106,7 +107,30 @@ class faiDiskEntry extends plugin foreach($bootable as $bootflag){ $this->partitions[$bootflag]['bootable'] = TRUE; } - break; + continue; + } + if (preg_match("/^resize:/", $option)){ + $resize = split(",", trim(preg_replace("/^resize:/","",$option),",")); + foreach($resize as $id){ + $this->partitions[$id]['resize'] = TRUE; + } + continue; + } + 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'; + } + continue; + } + 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'; + } + continue; } } } else { @@ -314,6 +338,51 @@ class faiDiskEntry extends plugin $tmp['rename']['from'] = $this->old_cn; $tmp['rename']['to'] = $this->DISKcn; } + + // Build up disk options + $bootable = ""; + $resize = ""; + $preserve_always = ""; + $preserve_reinstall = ""; + + foreach($tmp['partitions'] as $id => $part){ + if(isset($part['bootable']) && $part['bootable']){ + $bootable .= $id.","; + } + if(isset($part['resize']) && $part['resize']){ + $resize .= $id.","; + } + if(isset($part['preserve']) && $part['preserve']){ + if($part['preserveType'] == "always"){ + $preserve_always .= $id.","; + }else{ + $preserve_reinstall .= $id.","; + } + } + $tmp['partitions'][$id]['status'] = $part['status']; + + // Unset non valid attributes + foreach(array("bootable","encrypted","preserve","preserveType","resize","FAIdiskType") as $attr){ + if(isset($tmp['partitions'][$id][$attr])){ + unset($tmp['partitions'][$id][$attr]); + } + } + } + + if(!empty($bootable)){ + $tmp['FAIdiskOption'][] = "bootable:".trim($bootable,","); + } + if(!empty($resize)){ + $tmp['FAIdiskOption'][] = "resize:".trim($resize,","); + } + if(!empty($preserve_always)){ + $tmp['FAIdiskOption'][] = "preserve_always:".trim($preserve_always,","); + } + if(!empty($preserve_reinstall)){ + $tmp['FAIdiskOption'][] = "preserve_reinstall:".trim($preserve_reinstall,","); + } + + $tmp['status'] = $this->status; return($tmp); } @@ -403,7 +472,9 @@ class faiDiskEntry extends plugin } foreach($this->UsedAttrs as $attrs){ - $alreadyUsed[$attrs][$key] = $part[$attrs]; + if(isset($part[$attrs])){ + $alreadyUsed[$attrs][$key] = $part[$attrs]; + } } } diff --git a/gosa-plugins/fai/admin/fai/class_faiPartition.inc b/gosa-plugins/fai/admin/fai/class_faiPartition.inc index c6c901e2d..72942a65d 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartition.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartition.inc @@ -35,6 +35,7 @@ class faiPartition extends plugin var $preserveType = "always"; var $encrypted = false; + var $status = ""; var $raidDevices = array(); function __construct($config, $object, $parent,$type) @@ -48,6 +49,7 @@ class faiPartition extends plugin } } + $this->status = $object['status']; $this->FAIdiskType = $type; if($type == "disk"){ @@ -80,6 +82,14 @@ class faiPartition extends plugin $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); @@ -154,9 +164,6 @@ class faiPartition extends plugin "xfs" => _("Xfs"), "btrfs" => _("Btrfs")); - - - $smarty->assign("partitionTypes", $types); $smarty->assign("partitionSizeTypes", $partitionSizeTypes); $smarty->assign("FAIpartitionSizeType", $this->FAIpartitionSizeType); @@ -288,6 +295,12 @@ class faiPartition extends plugin $ret['FAIpartitionSize'] = "-";break; default: trigger_error("Unknown partition size!"); } + + // Add encryption flag to partition mount point + if($this->encrypted){ + $ret['FAImountPoint'] .= ":encrypt"; + } + }elseif($this->FAIdiskType == "raid"){ $ret['FAIpartitionSize'] = ""; foreach($this->raidDevices as $device){ @@ -302,6 +315,7 @@ class faiPartition extends plugin } $ret['FAIpartitionSize'] = trim($ret['FAIpartitionSize'],","); } + $ret['status'] = $this->status; return($ret); } } diff --git a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc index 2890e2ead..8c0a4d533 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPartitionTable.inc @@ -8,7 +8,7 @@ class faiPartitionTable extends plugin var $objectclasses = array("top","FAIclass","FAIpartitionTable"); var $subAttributes = array("cn","description"); - var $subPartAttributes = array("cn","FAIpartitionNr","FAIpartitionSize","FAImountPoint","FAIfsType","FAIpartitionType","FAImountOptions","FAIfsOptions","FAIpartitionFlags","description"); + var $subPartAttributes = array("cn","FAIpartitionNr","FAIpartitionSize","FAImountPoint","FAIfsType","FAIpartitionType","FAImountOptions","FAIfsOptions","FAIpartitionFlags","description","FAIfsCreateOptions","FAIfsTuneOptions"); var $sub64coded = array(); var $subBinary = array(); @@ -545,6 +545,9 @@ class faiPartitionTable extends plugin if(isset($disk['FAIdiskType'])){ $disk_attrs['FAIdiskType'] = $disk['FAIdiskType']; } + if(isset($disk['FAIdiskOption'])){ + $disk_attrs['FAIdiskOption'] = $disk['FAIdiskOption']; + } if(empty($disk_attrs['description']) && $disk['status'] == "edited"){ $disk_attrs['description'] = array(); @@ -574,6 +577,7 @@ class faiPartitionTable extends plugin } if($disk['status']!="delete") + /* Add all partitions */ foreach($disk['partitions'] as $key => $partition){ $partition_attrs = array(); diff --git a/gosa-plugins/fai/admin/fai/faiPartition.tpl b/gosa-plugins/fai/admin/fai/faiPartition.tpl index a6f8536e4..34d78945b 100644 --- a/gosa-plugins/fai/admin/fai/faiPartition.tpl +++ b/gosa-plugins/fai/admin/fai/faiPartition.tpl @@ -9,7 +9,7 @@ {else} - {t}Name{/t} + {t}Type{/t} - {html_options options=preserveType selected=$preserveType} + {html_options options=$preserveTypes selected=$preserveType} -- 2.30.2