summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3b32eb5)
raw | patch | inline | side by side (parent: 3b32eb5)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 10 May 2011 13:39:03 +0000 (13:39 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 10 May 2011 13:39:03 +0000 (13:39 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20798 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/goto/admin/systems/goto/Device/InstallRecipe.tpl b/gosa-plugins/goto/admin/systems/goto/Device/InstallRecipe.tpl
index 5a5d43c80e6fd325f6977b6e768bc0a475624dab..a79e598fb5713cee6b33ed2526fba8b18c17b3b4 100644 (file)
<tr>
<td><LABEL for="installPartitionTable">{t}Partition table{/t}</LABEL></td>
<td>
- <input type='text' name="installPartitionTable" id="installPartitionTable" value="{$installPartitionTable}">
+ <input type='submit' name="edit_installPartitionTable" id="edit_installPartitionTable" value="{t}Edit partition table{/t}">
</td>
</tr>
</table>
diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_DevicePartition.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_DevicePartition.inc
--- /dev/null
@@ -0,0 +1,240 @@
+<?php
+
+
+
+class DevicePartition
+{
+ public $object =NULL;
+ public $partitionString =NULL;
+
+ function __construct($config, $partitionString)
+ {
+ $this->config = &$config;
+ $this->partitionString = $partitionString;
+ }
+
+ function init()
+ {
+ $rpc = $this->config->getRpcHandle();
+ $this->object = $rpc->openObject('libinst.preseed.diskdefinition', '');
+
+ $this->object->addDisk('sda');
+ $this->object->addPartition('/kekse', 2333, NULL, FALSE, TRUE, FALSE, FALSE, 'ext3','ro,user,nosuid' , FALSE, NULL, 'sda');
+ $this->object->addPartition('/wurst', 2000, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
+ $this->object->addPartition('raid.00', 2000, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
+ $this->object->addPartition('raid.01', 2000, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
+ $this->object->addPartition('pv.00', 2333, NULL, FALSE, TRUE, FALSE, FALSE, NULL, NULL, FALSE, NULL, 'sda');
+ $this->object->addRaidDevice('pv.01', 'md0', '0','0', NULL, NULL, TRUE, FALSE, array('raid.00', 'raid.01'));
+ $this->object->addVolumeGroup('garnele', array('pv.00', 'pv.01'));
+ $this->object->addVolume('/home', 'garnele_home', 'garnele', 2000);
+
+ // Prepare lists
+ $this->entryList = new sortableListing();
+ $this->entryList->setDeleteable(false);
+ $this->entryList->setEditable(false);
+ $this->entryList->setWidth("100%");
+ $this->entryList->setHeight("400px");
+ $this->entryList->setHeader(array(_("Type"),_("Target"),_("Size"),_("Uses device")." / "._("Used by"),_("Filesystem"), _("Options")));
+ $this->entryList->setColspecs(array('*','*','*', '*'));
+ $this->entryList->setAcl('rwcdm');
+ $this->entryList->setReorderable(FALSE);
+ $this->entryList->sortingEnabled(FALSE);
+
+ // Receive list informations
+ $disks = $this->object->getDisks();
+ $partitions = $this->object->getPartitions();
+ $raids = $this->object->getRaidDevices();
+ $volumeGroups = $this->object->getVolumeGroups();
+ $volumes = $this->object->getVolumes();
+
+ // Create a mapping that show which partitions was used for which raid.
+ $map_partToRaid = array();
+ $raidTargets = array();
+ foreach($raids as $raid){
+ $raidTargets[] = $raid['target'];
+ foreach($raid['devices'] as $devName){
+ $map_partToRaid[$devName] = $raid['name'];
+ }
+ }
+
+ // Create a mapping that shows which partition was used in which volumeGroup.
+ $map_partToVolumeGroup = array();
+ foreach($volumeGroups as $vol){
+ foreach($vol['partitions'] as $part){
+ $map_partToVolumeGroup[$part] = $vol['name'];
+ }
+ }
+
+ // Create partition name map
+ $partNames = array();
+
+ // Create separators to create a visible indentation
+ $seps = array();
+ $seps[0] = "";
+ $seps[1] = str_pad("", 18, " ");
+ $seps[2] = str_pad("", 36, " ");
+
+ // Prepare images
+ $partitionImg = image('plugins/goto/images/partition.png');
+ $diskImg = image('plugins/goto/images/disk.png');
+ $raidImg = image('plugins/goto/images/raid.png');
+ $volumeGroupImg = image('plugins/goto/images/volumeGroups.png');
+ $volumeImg = image('plugins/goto/images/volume.png');
+
+ // Add raid devices
+ $lData = array();
+ if(count($raids)){
+
+ // Add raid header
+ $lData[] = array("data" => array("<b>"._("Raid devices")."</b>"));
+
+ // Add raids
+ foreach($raids as $id => $raid){
+ $str = "{$seps[1]}{$raidImg} {$raid['name']} ({$raid['level']})";
+
+ $devsStr = "";
+ foreach($raid['devices'] as $devName){
+ $devsStr .= $partitionImg." ".$devName.", ";
+ }
+ $devsStr = rtrim($devsStr, ', ');
+
+ $target = $raid['target'];
+ if(isset($map_partToVolumeGroup[$target])){
+ $target = $volumeGroupImg." ".$target;
+ }
+
+ $lData[] = array("data" => array($str,
+ $target,
+ '',
+ $devsStr,
+ $raid['fsType'],
+ $raid['fsOptions']
+ ));
+ }
+ }
+
+ // Add volume groups
+ if(count($volumeGroups)){
+
+ // Add LVM volume groups header
+ $lData[] = array("data" => array("<b>"._("LVM Volume Groups")."</b>"));
+
+ // Add volume groups
+ foreach($volumeGroups as $id => $vg){
+ $str = "{$seps[1]}{$volumeGroupImg} {$vg['name']}";
+
+ // Build up a list of all used partitions
+ $partStr = "";
+ foreach($vg['partitions'] as $partName){
+ if(in_array($partName, $raidTargets)){
+ $img = $raidImg;
+ }else{
+ $img = $partitionImg;
+ }
+ $partStr .= "{$img} {$partName}, ";
+ }
+ $partStr = rtrim($partStr, ", ");
+
+ // Add entry to the list.
+ $lData[] = array("data" => array($str, '', '', $partStr));
+
+ // Add volumes
+ foreach($volumes as $volume){
+ if($volume['volGroup'] == $vg['name']){
+ $str = "{$seps[2]}{$volumeImg} {$volume['name']}";
+ $lData[] = array("data" => array(
+ $str,
+ $volume['target'],
+ $this->__convertPartSize($volume['size']),
+ '',
+ $volume['fsType'],
+ $volume['fsOptions']
+ ));
+
+
+
+ }
+ }
+ }
+ }
+
+ // Add physical disks to the listing.
+ if(count($disks)){
+
+ // Add disks
+ $lData[] = array("data" => array("<b>"._("Disks")."</b>"));
+ foreach($disks as $id => $disk){
+ $str = "{$seps[1]}{$diskImg} {$disk['device']}";
+ $lData[] = array("data" => array($str));
+
+ // Add partitions
+ foreach($partitions as $pid => $part){
+
+ if($part['onDisk'] == $disk['device']){
+
+ // Prepare columns
+ $str = "{$seps[2]}{$partitionImg} {$part['target']}";
+ $device = "";
+ $fsType = $part['fsType'];
+ $target = "";
+ if(preg_match("/^(swap|\/)/", $part['target'])){
+ $target = $part['target'];
+ }
+
+ // Do we have a raid here? Then update the device column
+ // to point to the raid name
+ if(isset($map_partToRaid[$part['target']])){
+ $device = sprintf(_("Used by: %s"), $raidImg." ".$map_partToRaid[$part['target']]);
+ $fsType.= " "._("Software raid");
+ $fsType = trim($fsType);
+ }elseif(isset($map_partToVolumeGroup[$part['target']])){
+ $device = sprintf(_("Used by: %s"), $volumeGroupImg." ".$map_partToVolumeGroup[$part['target']]);
+ $fsType.= " "._("Physical volume LVM");
+ $fsType = trim($fsType);
+ }
+
+ // Add entry to the listing
+ $lData[] = array("data" => array(
+ $str,
+ $target,
+ $this->__convertPartSize($part['size']),
+ $device,
+ $fsType,
+ $part['fsOptions']));
+ }
+ }
+ }
+ }
+
+ // Updated columns length for all entries to avoid render errors.
+ $length = 6;
+ foreach($lData as $id => $entry){
+ while(count($lData[$id]['data']) < $length){
+ $lData[$id]['data'][] = '';
+ }
+ }
+
+ $this->entryList->setListData($lData, $lData);
+ $this->entryList->update();
+
+
+ }
+
+ function execute()
+ {
+ $this->init();
+ return($this->entryList->render());
+ }
+
+ function save_object()
+ {
+
+ }
+
+ function __convertPartSize($size)
+ {
+ return($size." MB");
+ }
+}
+
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_InstallRecipe.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_InstallRecipe.inc
index 139f80e084e001a05bd9c2ce0835811d0e233d81..1bef6aadac5f0e456e5a9ab5ea8c0527fce1244e 100644 (file)
// Partition table variables
public $installPartitionTable = "";
+ private $partitionEdit = NULL;
// Keyboard-layout attribute
public $installKeyboardlayout = "";
msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
return(NULL);
}
-
+
// Apply received options
$this->is_account = $res == True;
if($this->is_account){
// Convert Bool values to Bool.
$boolean = array("installRootEnabled", "installTimeUTC");
foreach($boolean as $attr){
- $this->$attr = ($this->$attr != FALSE);
+ $this->$attr = ($this->$attr != FALSE && !preg_match("/false/i", $this->$attr));
}
}
Root password hash dialog
***************/
+ $this->dialog = FALSE;
if($this->setPasswordHash){
$this->dialog = TRUE;
$smarty = get_smarty();
return($smarty->fetch(get_template_path('goto/Device/SetPassword.tpl', TRUE)));
}
+
+ if(isset($_POST['edit_installPartitionTable'])){
+ $this->partitionEdit = new DevicePartition($this->config, $this->installPartitionTable);
+ }
+
+ if($this->partitionEdit){
+ $this->partitionEdit->save_object();
+ $this->dialog = TRUE;
+ return($this->partitionEdit->execute());
+ }
+
+
+
/***************
Generate HTML content
***************/
$data['ntp-servers'] = array_values($data['ntp-servers']);
// Save Boolean like a String
- $boolean = array("root-user", "utc");
- foreach($boolean as $attr){
- $data[$attr] = ($data[$attr]) ? $data[$attr] = TRUE : $data[$attr] = FALSE;
+ $boolean = array("root-user" => "installRootEnabled", "utc" => "installTimeUTC");
+ foreach($boolean as $attr => $source){
+ $data[$attr] = ($this->$source) ? $data[$attr] = "TRUE" : $data[$attr] = "FALSE";
}
+ print_a($data);
+
$rpc = $this->config->getRpcHandle();
$res = $rpc->systemSetBaseInstallParameters($this->deviceUUID, $data);