mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 11:26:13 +00:00
dhcp: offer KEA as DHCPv4 alternative - high-availabilty and control agent (https://github.com/opnsense/core/issues/6971)
Offer configuration access for the kea control agent needed for high availabilty and basic peer setup. o add Control Agent menu item with basic settings o split dhcpv4 settings in general and ha o add peer configuration
This commit is contained in:
parent
3f25fa25ab
commit
6cd5d2e67b
12
plist
12
plist
@ -402,13 +402,16 @@
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Interfaces/forms/dialogVip.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Interfaces/forms/dialogVlan.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Interfaces/forms/dialogVxlan.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/Api/CtrlAgentController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/Api/Dhcpv4Controller.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/Api/Leases4Controller.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/Api/ServiceController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/DhcpController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/forms/dialogReservation.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/forms/dialogSubnet.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/forms/generalSettings.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/forms/agentSettings.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/forms/dialogPeer4.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/forms/dialogReservation4.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/forms/dialogSubnet4.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Kea/forms/generalSettings4.xml
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Monit/Api/ServiceController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Monit/Api/SettingsController.php
|
||||
/usr/local/opnsense/mvc/app/controllers/OPNsense/Monit/Api/StatusController.php
|
||||
@ -712,6 +715,8 @@
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Interfaces/VxLan.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Kea/ACL/ACL.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Kea/FieldTypes/KeaPoolsField.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Kea/KeaCtrlAgent.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Kea/KeaCtrlAgent.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Kea/KeaDhcpv4.php
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Kea/KeaDhcpv4.xml
|
||||
/usr/local/opnsense/mvc/app/models/OPNsense/Kea/Menu/Menu.xml
|
||||
@ -831,6 +836,7 @@
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Interface/vip.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Interface/vlan.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Interface/vxlan.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Kea/ctrl_agent.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Kea/dhcpv4.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Kea/leases4.volt
|
||||
/usr/local/opnsense/mvc/app/views/OPNsense/Monit/index.volt
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2023 Deciso B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Kea\Api;
|
||||
|
||||
use OPNsense\Base\ApiMutableModelControllerBase;
|
||||
|
||||
class CtrlAgentController extends ApiMutableModelControllerBase
|
||||
{
|
||||
protected static $internalModelName = 'ctrlagent';
|
||||
protected static $internalModelClass = 'OPNsense\Kea\KeaCtrlAgent';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getAction()
|
||||
{
|
||||
$data = parent::getAction();
|
||||
return [
|
||||
self::$internalModelName => [
|
||||
'general' => $data[self::$internalModelName]['general']
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -29,6 +29,7 @@
|
||||
namespace OPNsense\Kea\Api;
|
||||
|
||||
use OPNsense\Base\ApiMutableModelControllerBase;
|
||||
use OPNsense\Core\Config;
|
||||
|
||||
class Dhcpv4Controller extends ApiMutableModelControllerBase
|
||||
{
|
||||
@ -43,7 +44,9 @@ class Dhcpv4Controller extends ApiMutableModelControllerBase
|
||||
$data = parent::getAction();
|
||||
return [
|
||||
self::$internalModelName => [
|
||||
'general' => $data[self::$internalModelName]['general']
|
||||
'general' => $data[self::$internalModelName]['general'],
|
||||
'ha' => $data[self::$internalModelName]['ha'],
|
||||
'this_hostname' => (string)Config::getInstance()->object()->system->hostname
|
||||
]
|
||||
];
|
||||
}
|
||||
@ -101,4 +104,30 @@ class Dhcpv4Controller extends ApiMutableModelControllerBase
|
||||
{
|
||||
return $this->delBase("reservations.reservation", $uuid);
|
||||
}
|
||||
|
||||
public function searchPeerAction()
|
||||
{
|
||||
return $this->searchBase("ha_peers.peer", ['name', 'role'], "name");
|
||||
}
|
||||
|
||||
public function setPeerAction($uuid)
|
||||
{
|
||||
return $this->setBase("peer", "ha_peers.peer", $uuid);
|
||||
}
|
||||
|
||||
public function addPeerAction()
|
||||
{
|
||||
return $this->addBase("peer", "ha_peers.peer");
|
||||
}
|
||||
|
||||
public function getPeerAction($uuid = null)
|
||||
{
|
||||
return $this->getBase("peer", "ha_peers.peer", $uuid);
|
||||
}
|
||||
|
||||
public function delPeerAction($uuid)
|
||||
{
|
||||
return $this->delBase("ha_peers.peer", $uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -40,12 +40,19 @@ class DhcpController extends \OPNsense\Base\IndexController
|
||||
]);
|
||||
}
|
||||
|
||||
public function ctrlAgentAction()
|
||||
{
|
||||
$this->view->pick('OPNsense/Kea/ctrl_agent');
|
||||
$this->view->formGeneralSettings = $this->getForm("agentSettings");
|
||||
}
|
||||
|
||||
public function v4Action()
|
||||
{
|
||||
$this->view->pick('OPNsense/Kea/dhcpv4');
|
||||
$this->view->formGeneralSettings = $this->getForm("generalSettings");
|
||||
$this->view->formDialogSubnet = $this->getForm("dialogSubnet");
|
||||
$this->view->formDialogReservation = $this->getForm("dialogReservation");
|
||||
$this->view->formGeneralSettings = $this->getForm("generalSettings4");
|
||||
$this->view->formDialogSubnet = $this->getForm("dialogSubnet4");
|
||||
$this->view->formDialogReservation = $this->getForm("dialogReservation4");
|
||||
$this->view->formDialogPeer = $this->getForm("dialogPeer4");
|
||||
}
|
||||
|
||||
public function leases4Action()
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>ctrlagent.general.enabled</id>
|
||||
<label>Enabled</label>
|
||||
<type>checkbox</type>
|
||||
<help>Enable control agent.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>ctrlagent.general.http_host</id>
|
||||
<label>Bind address</label>
|
||||
<type>text</type>
|
||||
<help>Address on which the RESTful interface should be available</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>ctrlagent.general.http_port</id>
|
||||
<label>Bind port</label>
|
||||
<type>text</type>
|
||||
<help>Portnumber to use for the RESTful interface</help>
|
||||
</field>
|
||||
</form>
|
||||
@ -0,0 +1,21 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>peer.name</id>
|
||||
<label>Name</label>
|
||||
<type>text</type>
|
||||
<help>Peer name, there should be one entry matching this machines "This server name"</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>peer.role</id>
|
||||
<label>Role</label>
|
||||
<type>dropdown</type>
|
||||
<help>This peers role</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>peer.url</id>
|
||||
<label>Url</label>
|
||||
<type>text</type>
|
||||
<help>This specifies the URL of our server instance, which should use a different port than the control agent.
|
||||
For example http://192.0.2.1:8001/</help>
|
||||
</field>
|
||||
</form>
|
||||
@ -1,20 +0,0 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>dhcpv4.general.enabled</id>
|
||||
<label>Enabled</label>
|
||||
<type>checkbox</type>
|
||||
<help>Enable DHCPv4 server.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dhcpv4.general.interfaces</id>
|
||||
<label>Interfaces</label>
|
||||
<type>select_multiple</type>
|
||||
<help>Select interfaces to listen on.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dhcpv4.general.valid_lifetime</id>
|
||||
<label>Valid lifetime</label>
|
||||
<type>text</type>
|
||||
<help>Defines how long the addresses (leases) given out by the server are valid (in seconds)</help>
|
||||
</field>
|
||||
</form>
|
||||
@ -0,0 +1,42 @@
|
||||
<form>
|
||||
<field>
|
||||
<type>header</type>
|
||||
<label>General settings</label>
|
||||
</field>
|
||||
<field>
|
||||
<id>dhcpv4.general.enabled</id>
|
||||
<label>Enabled</label>
|
||||
<type>checkbox</type>
|
||||
<help>Enable DHCPv4 server.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dhcpv4.general.interfaces</id>
|
||||
<label>Interfaces</label>
|
||||
<type>select_multiple</type>
|
||||
<help>Select interfaces to listen on.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dhcpv4.general.valid_lifetime</id>
|
||||
<label>Valid lifetime</label>
|
||||
<type>text</type>
|
||||
<help>Defines how long the addresses (leases) given out by the server are valid (in seconds)</help>
|
||||
</field>
|
||||
<field>
|
||||
<type>header</type>
|
||||
<label>High Availability</label>
|
||||
</field>
|
||||
<field>
|
||||
<id>dhcpv4.ha.enabled</id>
|
||||
<label>Enabled</label>
|
||||
<type>checkbox</type>
|
||||
<help>Enable High availability hook, requires the Control Agent to be enabled as well.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dhcpv4.ha.this_server_name</id>
|
||||
<label>This server name</label>
|
||||
<type>text</type>
|
||||
<help>The name of this server, should match with one of the entries in the HA peers.
|
||||
Leave empty to use this machines hostname
|
||||
</help>
|
||||
</field>
|
||||
</form>
|
||||
35
src/opnsense/mvc/app/models/OPNsense/Kea/KeaCtrlAgent.php
Normal file
35
src/opnsense/mvc/app/models/OPNsense/Kea/KeaCtrlAgent.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2023 Deciso B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Kea;
|
||||
|
||||
use OPNsense\Base\BaseModel;
|
||||
|
||||
class KeaCtrlAgent extends BaseModel
|
||||
{
|
||||
}
|
||||
23
src/opnsense/mvc/app/models/OPNsense/Kea/KeaCtrlAgent.xml
Normal file
23
src/opnsense/mvc/app/models/OPNsense/Kea/KeaCtrlAgent.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<model>
|
||||
<mount>//OPNsense/Kea/ctrl_agent</mount>
|
||||
<version>0.0.1</version>
|
||||
<description>Kea Control Agent configuration</description>
|
||||
<items>
|
||||
<general>
|
||||
<enabled type="BooleanField">
|
||||
<Default>0</Default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<http_host type="NetworkField">
|
||||
<NetMaskAllowed>N</NetMaskAllowed>
|
||||
<AddressFamily>ipv4</AddressFamily>
|
||||
<Default>127.0.0.1</Default>
|
||||
<Required>Y</Required>
|
||||
</http_host>
|
||||
<http_port type="PortField">
|
||||
<Required>Y</Required>
|
||||
<Default>8000</Default>
|
||||
</http_port>
|
||||
</general>
|
||||
</items>
|
||||
</model>
|
||||
@ -16,6 +16,15 @@
|
||||
<Required>Y</Required>
|
||||
</valid_lifetime>
|
||||
</general>
|
||||
<ha>
|
||||
<enabled type="BooleanField">
|
||||
<Default>0</Default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<this_server_name type="TextField">
|
||||
<Mask>/^([0-9a-zA-Z.\:\-,_]){0,1024}$/u</Mask>
|
||||
</this_server_name>
|
||||
</ha>
|
||||
<subnets>
|
||||
<subnet4 type="ArrayField">
|
||||
<subnet type="NetworkField">
|
||||
@ -61,11 +70,11 @@
|
||||
<reservation type="ArrayField">
|
||||
<subnet type="ModelRelationField">
|
||||
<Model>
|
||||
<pipes>
|
||||
<subnets>
|
||||
<source>OPNsense.Kea.KeaDhcpv4</source>
|
||||
<items>subnets.subnet4</items>
|
||||
<display>subnet</display>
|
||||
</pipes>
|
||||
</subnets>
|
||||
</Model>
|
||||
<ValidationMessage>Related subnet not found</ValidationMessage>
|
||||
<Required>Y</Required>
|
||||
@ -83,5 +92,35 @@
|
||||
</description>
|
||||
</reservation>
|
||||
</reservations>
|
||||
<ha_peers>
|
||||
<peer type="ArrayField">
|
||||
<name type="TextField">
|
||||
<Required>Y</Required>
|
||||
<Constraints>
|
||||
<check001>
|
||||
<ValidationMessage>Duplicate entry exists</ValidationMessage>
|
||||
<type>UniqueConstraint</type>
|
||||
</check001>
|
||||
</Constraints>
|
||||
</name>
|
||||
<role type="OptionField">
|
||||
<Default>primary</Default>
|
||||
<Required>Y</Required>
|
||||
<OptionValues>
|
||||
<primary>primary</primary>
|
||||
<standby>standby</standby>
|
||||
</OptionValues>
|
||||
</role>
|
||||
<url type="UrlField">
|
||||
<Required>Y</Required>
|
||||
<Constraints>
|
||||
<check001>
|
||||
<ValidationMessage>Duplicate entry exists</ValidationMessage>
|
||||
<type>UniqueConstraint</type>
|
||||
</check001>
|
||||
</Constraints>
|
||||
</url>
|
||||
</peer>
|
||||
</ha_peers>
|
||||
</items>
|
||||
</model>
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
<menu>
|
||||
<Services>
|
||||
<KeaDHCP VisibleName="Kea DHCP [new]" cssClass="fa fa-bullseye fa-fw">
|
||||
<Keav4 order="5" VisibleName="Kea DHCPv4" url="/ui/kea/dhcp/v4"/>
|
||||
<ControlAgent order="5" VisibleName="Control Agent" url="/ui/kea/dhcp/ctrl_agent"/>
|
||||
<Keav4 order="10" VisibleName="Kea DHCPv4" url="/ui/kea/dhcp/v4"/>
|
||||
<Leases4 order="50" VisibleName="Leases DHCPv4" url="/ui/kea/dhcp/leases4"/>
|
||||
<LogFile order="100" VisibleName="Log File" url="/ui/diagnostics/log/core/kea"/>
|
||||
</KeaDHCP>
|
||||
|
||||
74
src/opnsense/mvc/app/views/OPNsense/Kea/ctrl_agent.volt
Normal file
74
src/opnsense/mvc/app/views/OPNsense/Kea/ctrl_agent.volt
Normal file
@ -0,0 +1,74 @@
|
||||
{#
|
||||
|
||||
OPNsense® is Copyright © 2023 by Deciso B.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#}
|
||||
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
let data_get_map = {'frm_generalsettings':"/api/kea/ctrl_agent/get"};
|
||||
mapDataToFormUI(data_get_map).done(function(){
|
||||
formatTokenizersUI();
|
||||
$('.selectpicker').selectpicker('refresh');
|
||||
updateServiceControlUI('kea');
|
||||
});
|
||||
|
||||
$("#reconfigureAct").SimpleActionButton({
|
||||
onPreAction: function() {
|
||||
const dfObj = new $.Deferred();
|
||||
saveFormToEndpoint("/api/kea/ctrl_agent/set", 'frm_generalsettings', function () { dfObj.resolve(); }, true, function () { dfObj.reject(); });
|
||||
return dfObj;
|
||||
},
|
||||
onAction: function(data, status) {
|
||||
updateServiceControlUI('kea');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
|
||||
<li class="active"><a data-toggle="tab" href="#settings" id="settings_tab">{{ lang._('Settings') }}</a></li>
|
||||
</ul>
|
||||
<div class="tab-content content-box">
|
||||
<div id="settings" class="tab-pane fade in active">
|
||||
{{ partial("layout_partials/base_form",['fields':formGeneralSettings,'id':'frm_generalsettings'])}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="page-content-main">
|
||||
<div class="content-box">
|
||||
<div class="col-md-12">
|
||||
<br/>
|
||||
<button class="btn btn-primary" id="reconfigureAct"
|
||||
data-endpoint='/api/kea/service/reconfigure'
|
||||
data-label="{{ lang._('Apply') }}"
|
||||
data-error-title="{{ lang._('Error reconfiguring DHCPv4') }}"
|
||||
type="button"
|
||||
></button>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -29,7 +29,15 @@
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
let data_get_map = {'frm_generalsettings':"/api/kea/dhcpv4/get"};
|
||||
mapDataToFormUI(data_get_map).done(function(){
|
||||
mapDataToFormUI(data_get_map).done(function(data){
|
||||
try {
|
||||
$("#dhcpv4\\.ha\\.this_server_name").attr(
|
||||
"placeholder",
|
||||
data.frm_generalsettings.dhcpv4.this_hostname
|
||||
);
|
||||
} catch (e) {
|
||||
null;
|
||||
}
|
||||
formatTokenizersUI();
|
||||
$('.selectpicker').selectpicker('refresh');
|
||||
updateServiceControlUI('kea');
|
||||
@ -54,6 +62,15 @@
|
||||
}
|
||||
);
|
||||
|
||||
$("#grid-ha-peers").UIBootgrid(
|
||||
{ search:'/api/kea/dhcpv4/search_peer',
|
||||
get:'/api/kea/dhcpv4/get_peer/',
|
||||
set:'/api/kea/dhcpv4/set_peer/',
|
||||
add:'/api/kea/dhcpv4/add_peer/',
|
||||
del:'/api/kea/dhcpv4/del_peer/'
|
||||
}
|
||||
);
|
||||
|
||||
$("#reconfigureAct").SimpleActionButton({
|
||||
onPreAction: function() {
|
||||
const dfObj = new $.Deferred();
|
||||
@ -68,15 +85,17 @@
|
||||
</script>
|
||||
|
||||
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
|
||||
<li class="active"><a data-toggle="tab" href="#settings" id="settings_tab">{{ lang._('Settings') }}</a></li>
|
||||
<li class="active"><a data-toggle="tab" href="#settings" id="tab_settings">{{ lang._('Settings') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#subnets" id="tab_pools"> {{ lang._('Subnets') }} </a></li>
|
||||
<li><a data-toggle="tab" href="#reservations" id="tab_pools"> {{ lang._('Reservations') }} </a></li>
|
||||
<li><a data-toggle="tab" href="#reservations" id="tab_reservations"> {{ lang._('Reservations') }} </a></li>
|
||||
<li><a data-toggle="tab" href="#ha-peers" id="tab_ha-peers"> {{ lang._('HA Peers') }} </a></li>
|
||||
</ul>
|
||||
<div class="tab-content content-box">
|
||||
<!-- general settings -->
|
||||
<div id="settings" class="tab-pane fade in active">
|
||||
{{ partial("layout_partials/base_form",['fields':formGeneralSettings,'id':'frm_generalsettings'])}}
|
||||
</div>
|
||||
<!-- -->
|
||||
<!-- subnets / pools -->
|
||||
<div id="subnets" class="tab-pane fade in">
|
||||
<table id="grid-subnets" class="table table-condensed table-hover table-striped" data-editDialog="DialogSubnet">
|
||||
<thead>
|
||||
@ -98,7 +117,7 @@
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<!-- -->
|
||||
<!-- reservations -->
|
||||
<div id="reservations" class="tab-pane fade in">
|
||||
<table id="grid-reservations" class="table table-condensed table-hover table-striped" data-editDialog="DialogReservation">
|
||||
<thead>
|
||||
@ -124,6 +143,30 @@
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<!-- HA - peers -->
|
||||
<div id="ha-peers" class="tab-pane fade in">
|
||||
<table id="grid-ha-peers" class="table table-condensed table-hover table-striped" data-editDialog="DialogPeer">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
|
||||
<th data-column-id="name" data-type="string">{{ lang._('Name') }}</th>
|
||||
<th data-column-id="role" data-type="string">{{ lang._('Role') }}</th>
|
||||
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<button data-action="add" type="button" class="btn btn-xs btn-primary pull-right"><span class="fa fa-fw fa-plus"></span></button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<section class="page-content-main">
|
||||
@ -143,3 +186,4 @@
|
||||
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogSubnet,'id':'DialogSubnet','label':lang._('Edit Subnet')])}}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogReservation,'id':'DialogReservation','label':lang._('Edit Reservation')])}}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogPeer,'id':'DialogPeer','label':lang._('Edit Peer')])}}
|
||||
|
||||
@ -1,34 +1,7 @@
|
||||
// This is a basic configuration for the Kea Control Agent.
|
||||
//
|
||||
// This is just a very basic configuration. Kea comes with large suite (over 30)
|
||||
// of configuration examples and extensive Kea User's Guide. Please refer to
|
||||
// those materials to get better understanding of what this software is able to
|
||||
// do. Comments in this configuration file sometimes refer to sections for more
|
||||
// details. These are section numbers in Kea User's Guide. The version matching
|
||||
// your software should come with your Kea package, but it is also available
|
||||
// in ISC's Knowledgebase (https://kea.readthedocs.io; the direct link for
|
||||
// the stable version is https://kea.readthedocs.io/).
|
||||
//
|
||||
// This configuration file contains only Control Agent's configuration.
|
||||
// If configurations for other Kea services are also included in this file they
|
||||
// are ignored by the Control Agent.
|
||||
{
|
||||
|
||||
// This is a basic configuration for the Kea Control Agent.
|
||||
// RESTful interface to be available at http://127.0.0.1:8000/
|
||||
"Control-agent": {
|
||||
"http-host": "127.0.0.1",
|
||||
// If enabling HA and multi-threading, the 8000 port is used by the HA
|
||||
// hook library http listener. When using HA hook library with
|
||||
// multi-threading to function, make sure the port used by dedicated
|
||||
// listener is different (e.g. 8001) than the one used by CA. Note
|
||||
// the commands should still be sent via CA. The dedicated listener
|
||||
// is specifically for HA updates only.
|
||||
"http-port": 8000,
|
||||
|
||||
// Specify location of the files to which the Control Agent
|
||||
// should connect to forward commands to the DHCPv4, DHCPv6
|
||||
// and D2 servers via unix domain sockets.
|
||||
"http-host": "{{ OPNsense.Kea.ctrl_agent.general.http_host|default('127.0.0.1')}}",
|
||||
"http-port": {{ OPNsense.Kea.ctrl_agent.general.http_port|default('8000')}},
|
||||
"control-sockets": {
|
||||
"dhcp4": {
|
||||
"socket-type": "unix",
|
||||
@ -43,61 +16,15 @@
|
||||
"socket-name": "/var/run/kea-ddns-ctrl-socket"
|
||||
}
|
||||
},
|
||||
|
||||
// Specify hooks libraries that are attached to the Control Agent.
|
||||
// Such hooks libraries should support 'control_command_receive'
|
||||
// hook point. This is currently commented out because it has to
|
||||
// point to the existing hooks library. Otherwise the Control
|
||||
// Agent will fail to start.
|
||||
"hooks-libraries": [
|
||||
// {
|
||||
// "library": "/usr/local/lib/kea/hooks/control-agent-commands.so",
|
||||
// "parameters": {
|
||||
// "param1": "foo"
|
||||
// }
|
||||
// }
|
||||
],
|
||||
|
||||
// Logging configuration starts here. Kea uses different loggers to log various
|
||||
// activities. For details (e.g. names of loggers), see Chapter 18.
|
||||
"loggers": [
|
||||
{
|
||||
// This specifies the logging for Control Agent daemon.
|
||||
"name": "kea-ctrl-agent",
|
||||
"output_options": [
|
||||
{
|
||||
// Specifies the output file. There are several special values
|
||||
// supported:
|
||||
// - stdout (prints on standard output)
|
||||
// - stderr (prints on standard error)
|
||||
// - syslog (logs to syslog)
|
||||
// - syslog:name (logs to syslog using specified name)
|
||||
// Any other value is considered a name of the file
|
||||
"output": "syslog"
|
||||
|
||||
// Shorter log pattern suitable for use with systemd,
|
||||
// avoids redundant information
|
||||
// "pattern": "%-5p %m\n"
|
||||
|
||||
// This governs whether the log output is flushed to disk after
|
||||
// every write.
|
||||
// "flush": false,
|
||||
|
||||
// This specifies the maximum size of the file before it is
|
||||
// rotated.
|
||||
// "maxsize": 1048576,
|
||||
|
||||
// This specifies the maximum number of rotated files to keep.
|
||||
// "maxver": 8
|
||||
}
|
||||
],
|
||||
// This specifies the severity of log messages to keep. Supported values
|
||||
// are: FATAL, ERROR, WARN, INFO, DEBUG
|
||||
"severity": "INFO",
|
||||
|
||||
// If DEBUG level is specified, this value is used. 0 is least verbose,
|
||||
// 99 is most verbose. Be cautious, Kea can generate lots and lots
|
||||
// of logs if told to do so.
|
||||
"debuglevel": 0
|
||||
}
|
||||
]
|
||||
|
||||
@ -52,14 +52,47 @@
|
||||
{% for reservation in helpers.toList('OPNsense.Kea.dhcp4.reservations.reservation') if reservation.subnet == subnet['@uuid'] %}
|
||||
{
|
||||
{% for res_key, res_prop in reservation_fields.items() if reservation[res_prop]|length > 1 %}
|
||||
"{{res_key}}": "{{reservation[res_prop]}}"{% if not loop.last %},{% endif +%}
|
||||
"{{res_key}}": {{reservation[res_prop]|tojson}}{% if not loop.last %},{% endif +%}
|
||||
{% endfor %}
|
||||
}{% if not loop.last %},{% endif +%}
|
||||
{% endfor %}
|
||||
]
|
||||
}{% if not loop.last %},{% endif +%}
|
||||
{% endfor %}
|
||||
],
|
||||
{% if not helpers.empty('OPNsense.Kea.ctrl_agent.general.enabled') %}
|
||||
"hooks-libraries": [
|
||||
{
|
||||
"library": "/usr/local/lib/kea/hooks/libdhcp_lease_cmds.so",
|
||||
"parameters": { }
|
||||
},
|
||||
{% if not helpers.empty('OPNsense.Kea.dhcp4.ha.enabled') %}
|
||||
{
|
||||
"library": "/usr/local/lib/kea/hooks/libdhcp_ha.so",
|
||||
"parameters": {
|
||||
"high-availability": [ {
|
||||
"this-server-name": {{OPNsense.Kea.dhcp4.ha.this_server_name|default(system.hostname)|tojson}},
|
||||
"mode": "hot-standby",
|
||||
"heartbeat-delay": 10000,
|
||||
"max-response-delay": 60000,
|
||||
"max-ack-delay": 5000,
|
||||
"max-unacked-clients": 5,
|
||||
"sync-timeout": 60000,
|
||||
"peers": [
|
||||
{% for peer in helpers.toList('OPNsense.Kea.dhcp4.ha_peers.peer') %}
|
||||
{
|
||||
"name": {{peer.name|tojson}},
|
||||
"role": {{peer.role|tojson}},
|
||||
"url": {{peer.url|default('')|tojson}}
|
||||
}{% if not loop.last %},{% endif +%}
|
||||
{% endfor %}
|
||||
]
|
||||
} ]
|
||||
}
|
||||
}
|
||||
{% endif %}
|
||||
]
|
||||
{% endif %}
|
||||
}
|
||||
}
|
||||
{%- endif -%}
|
||||
|
||||
@ -28,7 +28,7 @@ ctrl_agent_srv="${exec_prefix}/sbin/kea-ctrl-agent"
|
||||
netconf_srv="${exec_prefix}/sbin/kea-netconf"
|
||||
|
||||
# Start DHCPv4 server?
|
||||
dhcp4=yes
|
||||
dhcp4={% if not helpers.empty('OPNsense.Kea.dhcp4.general.enabled') %}yes{% else %}no{% endif %}
|
||||
|
||||
# Start DHCPv6 server?
|
||||
dhcp6=no
|
||||
@ -37,7 +37,7 @@ dhcp6=no
|
||||
dhcp_ddns=no
|
||||
|
||||
# Start Control Agent?
|
||||
ctrl_agent=no
|
||||
ctrl_agent={% if not helpers.empty('OPNsense.Kea.ctrl_agent.general.enabled') %}yes{% else %}no{% endif %}
|
||||
|
||||
# Start Netconf?
|
||||
netconf=no
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user