Commit 3bb554a1 authored by Côme Chilliet's avatar Côme Chilliet

🚑 fix(fai) Make sure only one each of raid,lvm,cryptsetup are added

Also makes sure the cn matches the type so that argonaut-ldap2fai works
 correctly.

issue #5821
parent ef147a66
......@@ -295,6 +295,8 @@ class faiDiskEntry extends simplePlugin
if ($this->FAIdiskType != 'disk') {
$this->attributesAccess['disklabel']->setDisabled(TRUE);
$this->attributesAccess['disklabel']->setVisible(FALSE);
$this->attributesAccess['cn']->setDisabled(TRUE);
$this->attributesAccess['cn']->setValue($this->FAIdiskType);
}
if ($this->FAIdiskType == 'cryptsetup') {
$this->attributesAccess['fstabkey']->setDisabled(TRUE);
......
......@@ -101,23 +101,37 @@ class PartitionTableAttribute extends DialogOrderedArrayAttribute
function renderButtons ()
{
$id = $this->getHtmlId();
return $this->renderInputField(
$buttons = $this->renderInputField(
'submit',
'add'.$id.'_dialog',
array('value' => '{msgPool type=addButton}')
).$this->renderInputField(
'submit',
'add'.$id.'_dialog_raid',
array('value' => _('Add RAID'))
).$this->renderInputField(
'submit',
'add'.$id.'_dialog_lvm',
array('value' => _('Add LVM'))
).$this->renderInputField(
'submit',
'add'.$id.'_dialog_cryptsetup',
array('value' => _('Add cryptsetup'))
array('value' => _('Add disk'))
);
if (!isset($this->value['raid'])) {
$buttons .= $this->renderInputField(
'submit',
'add'.$id.'_dialog_raid',
array('value' => _('Add RAID'))
);
}
if (!isset($this->value['lvm'])) {
$buttons .= $this->renderInputField(
'submit',
'add'.$id.'_dialog_lvm',
array('value' => _('Add LVM'))
);
}
if (!isset($this->value['cryptsetup'])) {
$buttons .= $this->renderInputField(
'submit',
'add'.$id.'_dialog_cryptsetup',
array('value' => _('Add cryptsetup'))
);
}
return $buttons;
}
function loadPostValue ()
......@@ -157,6 +171,9 @@ class PartitionTableAttribute extends DialogOrderedArrayAttribute
$diskInfos[$attr] = $subattrs[$attr][0];
}
}
if ($diskInfos['FAIdiskType'] != 'disk') {
$diskInfos['cn'] = $diskInfos['FAIdiskType'];
}
// Get disk options, without 'count' index.
$diskInfos['FAIdiskOption'] = array();
......@@ -175,8 +192,8 @@ class PartitionTableAttribute extends DialogOrderedArrayAttribute
}
$diskInfos['dn'] = $subattrs['dn'];
$this->value[$diskInfos['dn']] = $diskInfos;
$this->value[$diskInfos['dn']]['partitions'] = array();
$this->value[$diskInfos['cn']] = $diskInfos;
$this->value[$diskInfos['cn']]['partitions'] = array();
}
/* Fetch partitions */
foreach ($this->value as $name => $disk) {
......@@ -276,8 +293,6 @@ class PartitionTableAttribute extends DialogOrderedArrayAttribute
function diskConfigured ($disk)
{
if (isset($disk['rename'])) {
unset($this->value[$disk['rename']['from']]);
$disk['cn'] = $disk['rename']['to'];
unset($disk['rename']);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment