From: "DERUMIER, Alexandre" <alexandre.derumier@groupe-cyllene.com>
To: "pve-devel@lists.proxmox.com" <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [WIP v3 pve-manager 18/22] sdn: dhcp: add view for DHCP mappings
Date: Wed, 15 Nov 2023 12:09:24 +0000 [thread overview]
Message-ID: <a1666fc47d2d37e6412cff4050c7b9f3573a82a0.camel@groupe-cyllene.com> (raw)
In-Reply-To: <20231114180620.2635449-19-s.hanreich@proxmox.com>
I think that this panel could be named "Ipam" instead "Dhcp Mappings"
As it's don't manage dhcp mapping of dhcp server, but ips in ipam
database
-------- Message initial --------
De: Stefan Hanreich <s.hanreich@proxmox.com>
Répondre à: Proxmox VE development discussion <pve-
devel@lists.proxmox.com>
À: pve-devel@lists.proxmox.com
Objet: [pve-devel] [WIP v3 pve-manager 18/22] sdn: dhcp: add view for
DHCP mappings
Date: 14/11/2023 19:06:16
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
www/css/ext6-pve.css | 10 +-
www/manager6/Makefile | 2 +
www/manager6/dc/Config.js | 12 +-
www/manager6/sdn/MappingEdit.js | 65 ++++++++++
www/manager6/tree/DhcpTree.js | 215 ++++++++++++++++++++++++++++++++
5 files changed, 296 insertions(+), 8 deletions(-)
create mode 100644 www/manager6/sdn/MappingEdit.js
create mode 100644 www/manager6/tree/DhcpTree.js
diff --git a/www/css/ext6-pve.css b/www/css/ext6-pve.css
index e18b173f5..e5e616832 100644
--- a/www/css/ext6-pve.css
+++ b/www/css/ext6-pve.css
@@ -510,23 +510,21 @@ div.right-aligned {
content: ' ';
}
-.fa-sdn:before {
+.x-fa-sdn-treelist:before {
width: 14px;
height: 14px;
position: absolute;
left: 1px;
top: 4px;
+}
+
+.fa-sdn:before {
background-image:url(../images/icon-sdn.svg);
background-size: 14px 14px;
content: ' ';
}
.fa-network-wired:before {
- width: 14px;
- height: 14px;
- position: absolute;
- left: 1px;
- top: 4px;
background-image:url(../images/icon-fa-network-wired.svg);
background-size: 14px 14px;
content: ' ';
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index dccd2ba1c..d226c8faa 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -108,6 +108,7 @@
JSSRC= \
tree/ResourceTree.js \
tree/SnapshotTree.js \
tree/ResourceMapTree.js \
+ tree/DhcpTree.js \
window/Backup.js \
window/BackupConfig.js \
window/BulkAction.js \
@@ -274,6 +275,7 @@
JSSRC= \
sdn/ZoneContentView.js \
sdn/ZoneContentPanel.js \
sdn/ZoneView.js \
+ sdn/MappingEdit.js \
sdn/OptionsPanel.js \
sdn/controllers/Base.js \
sdn/controllers/EvpnEdit.js \
diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
index 7d01da5fb..0e3948ef4 100644
--- a/www/manager6/dc/Config.js
+++ b/www/manager6/dc/Config.js
@@ -195,7 +195,7 @@ Ext.define('PVE.dc.Config', {
groups: ['sdn'],
title: gettext('Zones'),
hidden: true,
- iconCls: 'fa fa-th',
+ iconCls: 'fa fa-th x-fa-sdn-treelist',
itemId: 'sdnzone',
},
{
@@ -203,7 +203,7 @@ Ext.define('PVE.dc.Config', {
groups: ['sdn'],
title: 'VNets',
hidden: true,
- iconCls: 'fa fa-network-wired',
+ iconCls: 'fa fa-network-wired x-fa-sdn-treelist',
itemId: 'sdnvnet',
},
{
@@ -213,6 +213,14 @@ Ext.define('PVE.dc.Config', {
hidden: true,
iconCls: 'fa fa-gear',
itemId: 'sdnoptions',
+ },
+ {
+ xtype: 'pveDhcpTree',
+ groups: ['sdn'],
+ title: 'Dhcp Mappings',
+ hidden: true,
+ iconCls: 'fa fa-gear',
+ itemId: 'sdnmappings',
});
}
diff --git a/www/manager6/sdn/MappingEdit.js
b/www/manager6/sdn/MappingEdit.js
new file mode 100644
index 000000000..533fc6249
--- /dev/null
+++ b/www/manager6/sdn/MappingEdit.js
@@ -0,0 +1,65 @@
+Ext.define('PVE.sdn.DhcpMappingInputPanel', {
+ extend: 'Proxmox.panel.InputPanel',
+ mixins: ['Proxmox.Mixin.CBind'],
+
+ isCreate: false,
+
+ items: [
+ {
+ xtype: 'pmxDisplayEditField',
+ name: 'vmid',
+ fieldLabel: gettext('VMID'),
+ allowBlank: false,
+ editable: false,
+ },
+ {
+ xtype: 'pmxDisplayEditField',
+ name: 'mac',
+ fieldLabel: gettext('MAC'),
+ allowBlank: false,
+ cbind: {
+ editable: '{isCreate}',
+ },
+ },
+ {
+ xtype: 'proxmoxtextfield',
+ name: 'ip',
+ fieldLabel: gettext('IP'),
+ allowBlank: false,
+ },
+ ],
+});
+
+Ext.define('PVE.sdn.MappingEdit', {
+ extend: 'Proxmox.window.Edit',
+
+ subject: gettext('DHCP Mapping'),
+ width: 350,
+
+ isCreate: false,
+ mapping: {},
+
+ submitUrl: function(url, values) {
+ return `${url}/${values.vnet}/${values.mac}`;
+ },
+
+ initComponent: function() {
+ var me = this;
+
+ me.method = me.isCreate ? 'POST' : 'PUT';
+
+ let ipanel = Ext.create('PVE.sdn.DhcpMappingInputPanel', {
+ isCreate: me.isCreate,
+ });
+
+ Ext.apply(me, {
+ items: [
+ ipanel,
+ ],
+ });
+
+ me.callParent();
+
+ ipanel.setValues(me.mapping);
+ },
+});
diff --git a/www/manager6/tree/DhcpTree.js
b/www/manager6/tree/DhcpTree.js
new file mode 100644
index 000000000..c714f0ff0
--- /dev/null
+++ b/www/manager6/tree/DhcpTree.js
@@ -0,0 +1,215 @@
+Ext.define('PVE.sdn.DhcpTree', {
+ extend: 'Ext.tree.Panel',
+ xtype: 'pveDhcpTree',
+
+ layout: 'fit',
+ rootVisible: false,
+ animate: false,
+
+ store: {
+ sorters: ['ip', 'name'],
+ },
+
+ controller: {
+ xclass: 'Ext.app.ViewController',
+ reload: function() {
+ let me = this;
+
+ Proxmox.Utils.API2Request({
+ url: `/cluster/sdn/ipam`,
+ method: 'GET',
+ success: function(response, opts) {
+ let root = {
+ name: '__root',
+ expanded: true,
+ children: [],
+ };
+
+ let zones = {};
+ let vnets = {};
+ let subnets = {};
+
+ response.result.data.forEach((element) => {
+ element.leaf = true;
+
+ if (!(element.zone in zones)) {
+ let zone = {
+ name: element.zone,
+ type: 'zone',
+ iconCls: 'fa fa-th',
+ expanded: true,
+ children: [],
+ };
+
+ zones[element.zone] = zone;
+ root.children.push(zone);
+ }
+
+ if (!(element.vnet in vnets)) {
+ let vnet = {
+ name: element.vnet,
+ type: 'vnet',
+ iconCls: 'fa fa-network-wired',
+ expanded: true,
+ children: [],
+ };
+
+ vnets[element.vnet] = vnet;
+ zones[element.zone].children.push(vnet);
+ }
+
+ if (!(element.subnet in subnets)) {
+ let subnet = {
+ name: element.subnet,
+ type: 'subnet',
+ expanded: true,
+ children: [],
+ };
+
+ subnets[element.subnet] = subnet;
+ vnets[element.vnet].children.push(subnet);
+ }
+
+ element.type = 'mapping';
+ subnets[element.subnet].children.push(element)
;
+ });
+
+ me.getView().setRootNode(root);
+ },
+ });
+ },
+ init: function(view) {
+ let me = this;
+ me.reload();
+ },
+ onDelete: function(table, rI, cI, item, e, { data }) {
+ let me = this;
+ let view = me.getView();
+
+ Ext.Msg.show({
+ title: gettext('Confirm'),
+ icon: Ext.Msg.WARNING,
+ message: gettext('Are you sure you want to remove DHCP
mapping {0}'),
+ buttons: Ext.Msg.YESNO,
+ defaultFocus: 'no',
+ callback: function(btn) {
+ if (btn !== 'yes') {
+ return;
+ }
+
+ Proxmox.Utils.API2Request({
+ url:
`/cluster/sdn/ipam/${data.vnet}/${data.mac}`,
+ method: 'DELETE',
+ waitMsgTarget: view,
+ failure: function(response, opts) {
+ Ext.Msg.alert(gettext('Error'),
response.htmlStatus);
+ },
+ callback: me.reload.bind(me),
+ });
+ },
+ });
+ },
+ },
+
+ columns: [
+ {
+ xtype: 'treecolumn',
+ text: 'Name / VMID',
+ dataIndex: 'name',
+ width: 200,
+ renderer: function(value, meta, record) {
+ if (record.get('gateway')) {
+ return 'Gateway';
+ }
+
+ return record.get('name') ?? record.get('vmid') ?? '';
+ },
+ },
+ {
+ text: 'IP',
+ dataIndex: 'ip',
+ width: 200,
+ },
+ {
+ text: 'MAC',
+ dataIndex: 'mac',
+ width: 200,
+ },
+ {
+ text: 'Gateway',
+ dataIndex: 'gateway',
+ width: 200,
+ },
+ {
+ header: gettext('Actions'),
+ xtype: 'actioncolumn',
+ dataIndex: 'text',
+ width: 150,
+ items: [
+ {
+ handler: function(table, rI, cI, item, e, { data
}) {
+ let me = this;
+
+ let win = Ext.create('PVE.sdn.MappingEdit', {
+ autoShow: true,
+ mapping: {},
+ url: `/cluster/sdn/ipam`,
+ method: 'POST',
+ isCreate: true,
+ extraRequestParams: {
+ vnet: data.name,
+ },
+ });
+
+ win.on('destroy', me.reload);
+ },
+ getTip: (v, m, rec) => gettext('Add'),
+ getClass: (v, m, { data }) => {
+ if (data.type === 'vnet') {
+ return 'fa fa-plus-square';
+ }
+
+ return 'pmx-hidden';
+ },
+ },
+ {
+ handler: function(table, rI, cI, item, e, { data
}) {
+ let me = this;
+
+ let win = Ext.create('PVE.sdn.MappingEdit', {
+ autoShow: true,
+ mapping: data,
+ url: `/cluster/sdn/ipam`,
+ method: 'PUT',
+ extraRequestParams: {
+ vmid: data.vmid,
+ vnet: data.vnet,
+ },
+ });
+
+ win.on('destroy', me.reload);
+ },
+ getTip: (v, m, rec) => 'Edit',
+ getClass: (v, m, { data }) => {
+ if (data.type === 'mapping' && !data.gateway)
{
+ return 'fa fa-pencil fa-fw';
+ }
+
+ return 'pmx-hidden';
+ },
+ },
+ {
+ handler: 'onDelete',
+ getTip: (v, m, rec) => 'Delete',
+ getClass: (v, m, { data }) => {
+ if (data.type === 'mapping' && !data.gateway)
{
+ return 'fa critical fa-trash-o';
+ }
+
+ return 'pmx-hidden';
+ },
+ },
+ ],
+ },
+ ],
+});
next prev parent reply other threads:[~2023-11-15 12:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-14 18:05 [pve-devel] [WIP v3 cluster/network/manager/qemu-server 00/22] Add support for DHCP servers to SDN Stefan Hanreich
2023-11-14 18:05 ` [pve-devel] [WIP v3 pve-cluster 01/22] add priv/macs.db Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 02/22] sdn: preparations for DHCP plugin Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 03/22] subnet: add dhcp options Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 04/22] sdn: zone: " Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 05/22] sdn: subnet: vnet: refactor IPAM related methods Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 06/22] ipam: plugins: preparations for DHCP Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 07/22] dhcp: add abstract class for DHCP plugins Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 08/22] sdn: dhcp: add dnsmasq plugin Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 09/22] sdn: dhcp: add helper for creating DHCP leases Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 10/22] api: add IPAM endpoints Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 11/22] api: subnet: add dhcp ranges Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 12/22] api: zone: add dhcp options Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 13/22] dhcp: regenerate config for DHCP servers on reload Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-network 14/22] sdn: fix tests Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-manager 15/22] sdn: regenerate DHCP config on reload Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-manager 16/22] sdn: add DHCP option to Zone dialogue Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-manager 17/22] sdn: subnet: add panel for editing DHCP ranges Stefan Hanreich
2023-11-15 13:09 ` DERUMIER, Alexandre
2023-11-15 13:24 ` Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 pve-manager 18/22] sdn: dhcp: add view for DHCP mappings Stefan Hanreich
2023-11-15 12:09 ` DERUMIER, Alexandre [this message]
2023-11-15 12:17 ` Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 qemu-server 19/22] vmnic add|remove : add|del ip in ipam Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 qemu-server 20/22] vm_start : vm-network-scripts: get ip from ipam and add dhcp reservation Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 qemu-server 21/22] api2: create|restore|clone: add_free_ip Stefan Hanreich
2023-11-14 18:06 ` [pve-devel] [WIP v3 qemu-server 22/22] vm_destroy: delete ip from ipam && dhcp Stefan Hanreich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a1666fc47d2d37e6412cff4050c7b9f3573a82a0.camel@groupe-cyllene.com \
--to=alexandre.derumier@groupe-cyllene.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal