From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 344DB605C4 for ; Thu, 24 Sep 2020 10:42:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 552BBE933 for ; Thu, 24 Sep 2020 10:41:25 +0200 (CEST) Received: from kvmformation1.odiso.net (globalOdiso.M6Lille.odiso.net [89.248.211.242]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8A095E831 for ; Thu, 24 Sep 2020 10:41:06 +0200 (CEST) Received: by kvmformation1.odiso.net (Postfix, from userid 0) id 72187E89BE; Thu, 24 Sep 2020 10:41:06 +0200 (CEST) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Date: Thu, 24 Sep 2020 10:41:00 +0200 Message-Id: <20200924084105.611791-7-aderumier@odiso.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200924084105.611791-1-aderumier@odiso.com> References: <20200924084105.611791-1-aderumier@odiso.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.622 Adjusted score from AWL reputation of From: address HEADER_FROM_DIFFERENT_DOMAINS 0.249 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods KHOP_HELO_FCRDNS 0.399 Relay HELO differs from its IP's reverse DNS NO_DNS_FOR_FROM 0.379 Envelope sender has no MX or A DNS records SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH v5 pve-manager 06/11] add sdn dns X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2020 08:42:05 -0000 Signed-off-by: Alexandre Derumier --- www/manager6/Makefile | 4 + www/manager6/Utils.js | 20 ++++ www/manager6/dc/Config.js | 8 ++ www/manager6/form/SDNDnsSelector.js | 52 +++++++++++ www/manager6/sdn/DnsView.js | 131 +++++++++++++++++++++++++++ www/manager6/sdn/dns/Base.js | 73 +++++++++++++++ www/manager6/sdn/dns/PowerdnsEdit.js | 52 +++++++++++ 7 files changed, 340 insertions(+) create mode 100644 www/manager6/form/SDNDnsSelector.js create mode 100644 www/manager6/sdn/DnsView.js create mode 100644 www/manager6/sdn/dns/Base.js create mode 100644 www/manager6/sdn/dns/PowerdnsEdit.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index 90bf75c7..33cb080f 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -101,6 +101,7 @@ JSSRC= \ form/SDNControllerSelector.js \ form/SDNZoneSelector.js \ form/SDNIpamSelector.js \ + form/SDNDnsSelector.js \ form/ScsiHwSelector.js \ form/SecurityGroupSelector.js \ form/SnapshotSelector.js \ @@ -219,6 +220,9 @@ JSSRC= \ sdn/ipams/NetboxEdit.js \ sdn/ipams/PVEIpamEdit.js \ sdn/ipams/PhpIpamEdit.js \ + sdn/DnsView.js \ + sdn/dns/Base.js \ + sdn/dns/PowerdnsEdit.js \ sdn/zones/Base.js \ sdn/zones/EvpnEdit.js \ sdn/zones/QinQEdit.js \ diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index 20417841..0823510c 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -823,6 +823,18 @@ Ext.define('PVE.Utils', { utilities: { }, }, + sdndnsSchema: { + dns: { + name: 'dns', + hideAdd: true + }, + powerdns: { + name: 'powerdns', + ipanel: 'PowerdnsInputPanel', + faIcon: 'th' + }, + }, + format_sdnvnet_type: function(value, md, record) { var schema = PVE.Utils.sdnvnetSchema[value]; if (schema) { @@ -855,6 +867,14 @@ Ext.define('PVE.Utils', { utilities: { return Proxmox.Utils.unknownText; }, + format_sdndns_type: function(value, md, record) { + var schema = PVE.Utils.sdndnsSchema[value]; + if (schema) { + return schema.name; + } + return Proxmox.Utils.unknownText; + }, + format_storage_type: function(value, md, record) { if (value === 'rbd') { value = (!record || record.get('monhost') ? 'rbd' : 'pveceph'); diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js index f92bb24b..d525c93d 100644 --- a/www/manager6/dc/Config.js +++ b/www/manager6/dc/Config.js @@ -192,6 +192,14 @@ Ext.define('PVE.dc.Config', { hidden: true, iconCls: 'fa fa-network-wired', itemId: 'sdnipam' + }, + { + xtype: 'pveSDNDnsView', + groups: ['sdn'], + title: gettext('Dns'), + hidden: true, + iconCls: 'fa fa-network-wired', + itemId: 'sdndns' }); } diff --git a/www/manager6/form/SDNDnsSelector.js b/www/manager6/form/SDNDnsSelector.js new file mode 100644 index 00000000..7abb1f01 --- /dev/null +++ b/www/manager6/form/SDNDnsSelector.js @@ -0,0 +1,52 @@ +Ext.define('PVE.form.SDNDnsSelector', { + extend: 'Proxmox.form.ComboGrid', + alias: ['widget.pveSDNDnsSelector'], + + allowBlank: false, + valueField: 'dns', + displayField: 'dns', + + initComponent: function() { + var me = this; + + var store = new Ext.data.Store({ + model: 'pve-sdn-dns', + sorters: { + property: 'dns', + order: 'DESC' + }, + }); + + Ext.apply(me, { + store: store, + autoSelect: false, + listConfig: { + columns: [ + { + header: gettext('dns'), + sortable: true, + dataIndex: 'dns', + flex: 1 + }, + ] + } + }); + + me.callParent(); + + store.load(); + } + +}, function() { + + Ext.define('pve-sdn-dns', { + extend: 'Ext.data.Model', + fields: [ 'dns' ], + proxy: { + type: 'proxmox', + url: "/api2/json/cluster/sdn/dns" + }, + idProperty: 'dns' + }); + +}); diff --git a/www/manager6/sdn/DnsView.js b/www/manager6/sdn/DnsView.js new file mode 100644 index 00000000..6d47e38f --- /dev/null +++ b/www/manager6/sdn/DnsView.js @@ -0,0 +1,131 @@ +Ext.define('PVE.sdn.DnsView', { + extend: 'Ext.grid.GridPanel', + alias: ['widget.pveSDNDnsView'], + + stateful: true, + stateId: 'grid-sdn-dns', + + createSDNEditWindow: function(type, sid) { + let schema = PVE.Utils.sdndnsSchema[type]; + if (!schema || !schema.ipanel) { + throw "no editor registered for dns type: " + type; + } + + Ext.create('PVE.sdn.dns.BaseEdit', { + paneltype: 'PVE.sdn.dns.' + schema.ipanel, + type: type, + dns: sid, + autoShow: true, + listeners: { + destroy: this.reloadStore + } + }); + }, + + initComponent : function() { + let me = this; + + let store = new Ext.data.Store({ + model: 'pve-sdn-dns', + proxy: { + type: 'proxmox', + url: "/api2/json/cluster/sdn/dns" + }, + sorters: { + property: 'dns', + order: 'DESC' + }, + }); + + let reload = function() { + store.load(); + }; + + let sm = Ext.create('Ext.selection.RowModel', {}); + + let run_editor = function() { + let rec = sm.getSelection()[0]; + if (!rec) { + return; + } + let type = rec.data.type, + dns = rec.data.dns; + + me.createSDNEditWindow(type, dns); + }; + + let edit_btn = new Proxmox.button.Button({ + text: gettext('Edit'), + disabled: true, + selModel: sm, + handler: run_editor + }); + + let remove_btn = Ext.create('Proxmox.button.StdRemoveButton', { + selModel: sm, + baseurl: '/cluster/sdn/dns/', + callback: reload + }); + + // else we cannot dynamically generate the add menu handlers + let addHandleGenerator = function(type) { + return function() { me.createSDNEditWindow(type); }; + }; + let addMenuItems = [], type; + + for (type in PVE.Utils.sdndnsSchema) { + let dns = PVE.Utils.sdndnsSchema[type]; + if (dns.hideAdd) { + continue; + } + addMenuItems.push({ + text: PVE.Utils.format_sdndns_type(type), + iconCls: 'fa fa-fw fa-' + dns.faIcon, + handler: addHandleGenerator(type) + }); + } + + Ext.apply(me, { + store: store, + reloadStore: reload, + selModel: sm, + viewConfig: { + trackOver: false + }, + tbar: [ + { + text: gettext('Add'), + menu: new Ext.menu.Menu({ + items: addMenuItems + }) + }, + remove_btn, + edit_btn, + ], + columns: [ + { + header: 'ID', + flex: 2, + dataIndex: 'dns' + }, + { + header: gettext('Type'), + flex: 1, + dataIndex: 'type', + renderer: PVE.Utils.format_sdndns_type + }, + { + header: 'url', + flex: 1, + dataIndex: 'url', + }, + ], + listeners: { + activate: reload, + itemdblclick: run_editor + } + }); + + me.callParent(); + } +}); diff --git a/www/manager6/sdn/dns/Base.js b/www/manager6/sdn/dns/Base.js new file mode 100644 index 00000000..d3a3720b --- /dev/null +++ b/www/manager6/sdn/dns/Base.js @@ -0,0 +1,73 @@ +Ext.define('PVE.panel.SDNDnsBase', { + extend: 'Proxmox.panel.InputPanel', + + type: '', + + onGetValues: function(values) { + var me = this; + + if (me.isCreate) { + values.type = me.type; + } else { + delete values.dns; + } + + return values; + }, + + initComponent : function() { + var me = this; + + me.callParent(); + } +}); + +Ext.define('PVE.sdn.dns.BaseEdit', { + extend: 'Proxmox.window.Edit', + + initComponent : function() { + var me = this; + + me.isCreate = !me.dns; + + if (me.isCreate) { + me.url = '/api2/extjs/cluster/sdn/dns'; + me.method = 'POST'; + } else { + me.url = '/api2/extjs/cluster/sdn/dns/' + me.dns; + me.method = 'PUT'; + } + + var ipanel = Ext.create(me.paneltype, { + type: me.type, + isCreate: me.isCreate, + dns: me.dns + }); + + Ext.apply(me, { + subject: PVE.Utils.format_sdndns_type(me.type), + isAdd: true, + items: [ ipanel ] + }); + + me.callParent(); + + if (!me.isCreate) { + me.load({ + success: function(response, options) { + var values = response.result.data; + var ctypes = values.content || ''; + + values.content = ctypes.split(','); + + if (values.nodes) { + values.nodes = values.nodes.split(','); + } + values.enable = values.disable ? 0 : 1; + + ipanel.setValues(values); + } + }); + } + } +}); diff --git a/www/manager6/sdn/dns/PowerdnsEdit.js b/www/manager6/sdn/dns/PowerdnsEdit.js new file mode 100644 index 00000000..5aa289fa --- /dev/null +++ b/www/manager6/sdn/dns/PowerdnsEdit.js @@ -0,0 +1,52 @@ +Ext.define('PVE.sdn.dns.PowerdnsInputPanel', { + extend: 'PVE.panel.SDNDnsBase', + + //onlineHelp: 'pvesdn_dns_plugin_pve', // FIXME uncomment once doc-gen is updated + + onGetValues: function(values) { + var me = this; + + if (me.isCreate) { + values.type = me.type; + } else { + delete values.dns; + } + + return values; + }, + + initComponent : function() { + var me = this; + + me.items = [ + { + xtype: me.isCreate ? 'textfield' : 'displayfield', + name: 'dns', + maxLength: 10, + value: me.dns || '', + fieldLabel: 'ID', + allowBlank: false + }, + { + xtype: 'textfield', + name: 'url', + fieldLabel: 'url', + allowBlank: false, + }, + { + xtype: 'textfield', + name: 'key', + fieldLabel: gettext('api key'), + allowBlank: false, + }, + { + xtype: 'proxmoxintegerfield', + name: 'ttl', + fieldLabel: 'ttl', + allowBlank: true + }, + ]; + + me.callParent(); + } +}); -- 2.20.1