Verified Commit 18ce4b24 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

feat(ipam) Update Subnet selection depending on VLAN selection

issue #6039
parent bb4955c7
...@@ -63,7 +63,7 @@ class ipamVlan extends simplePlugin ...@@ -63,7 +63,7 @@ class ipamVlan extends simplePlugin
), ),
new IntAttribute( new IntAttribute(
_('Inner ID'), _('Inner VLAN ID'), _('Inner ID'), _('Inner VLAN ID'),
'fdIpamVlanInnerId', FALSE, 'fdIpamVlanInnerId', TRUE,
1, 4096 1, 4096
), ),
new IntAttribute( new IntAttribute(
......
...@@ -54,11 +54,6 @@ class networkInterface extends simplePlugin ...@@ -54,11 +54,6 @@ class networkInterface extends simplePlugin
_('Mac address'), _('Mac address of this system'), _('Mac address'), _('Mac address of this system'),
'macAddress', FALSE 'macAddress', FALSE
), ),
new ObjectSelectAttribute(
_('Subnet'), _('Subnet'),
'fdNetworkInterfaceSubnetDN', FALSE,
['ipamSubnet']
),
new SetAttribute( new SetAttribute(
new IPAttribute( new IPAttribute(
_('IP address'), _('IP addresses this system uses (v4 or v6)'), _('IP address'), _('IP addresses this system uses (v4 or v6)'),
...@@ -67,8 +62,8 @@ class networkInterface extends simplePlugin ...@@ -67,8 +62,8 @@ class networkInterface extends simplePlugin
), ),
], ],
], ],
'vlan' => [ 'ipam' => [
'name' => _('VLAN information'), 'name' => _('IPAM'),
'attrs' => [ 'attrs' => [
new ObjectSelectAttribute( new ObjectSelectAttribute(
_('VLAN'), _('VLAN'), _('VLAN'), _('VLAN'),
...@@ -79,6 +74,10 @@ class networkInterface extends simplePlugin ...@@ -79,6 +74,10 @@ class networkInterface extends simplePlugin
_('VLAN tag'), _('VLAN tag'), _('VLAN tag'), _('VLAN tag'),
'fdNetworkInterfaceVlanTag', FALSE 'fdNetworkInterfaceVlanTag', FALSE
), ),
new SelectAttribute(
_('Subnet'), _('Subnet'),
'fdNetworkInterfaceSubnetDN', FALSE
),
] ]
], ],
]; ];
...@@ -89,5 +88,22 @@ class networkInterface extends simplePlugin ...@@ -89,5 +88,22 @@ class networkInterface extends simplePlugin
global $config; global $config;
parent::__construct($dn, $object, $parent, $mainTab); parent::__construct($dn, $object, $parent, $mainTab);
$this->attributesAccess['fdNetworkInterfaceVlanId']->setSubmitForm('vlanChanged');
$this->vlanChanged();
}
function vlanChanged()
{
if ($this->fdNetworkInterfaceVlanId != '') {
/* Get the DN of our current VLAN */
$vlans = objects::ls('ipamVlan', ['fdIpamVlanInnerId' => 1], NULL, '(fdIpamVlanInnerId='.ldap_escape_f($this->fdNetworkInterfaceVlanId).')');
$vlanDN = key($vlans);
$subnets = objects::ls('ipamSubnet', ['dn' => 'raw','cn' => 1], NULL, '(fdIpamVlanDN='.$vlanDN.')');
} else {
/* List all the subnets when no VLAN is selected */
$subnets = objects::ls('ipamSubnet', ['dn' => 'raw','cn' => 1]);
}
$this->attributesAccess['fdNetworkInterfaceSubnetDN']->setChoices(array_column($subnets, 'dn'), array_column($subnets, 'cn'));
} }
} }
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