From: Alexandre Derumier <aderumier@odiso.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v7 pve-manager 06/15] add sdn dns
Date: Tue, 24 Nov 2020 14:52:12 +0100 [thread overview]
Message-ID: <20201124135221.2856467-7-aderumier@odiso.com> (raw)
In-Reply-To: <20201124135221.2856467-1-aderumier@odiso.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
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 58bf2186..fa809089 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -53,6 +53,7 @@ JSSRC= \
form/SDNControllerSelector.js \
form/SDNZoneSelector.js \
form/SDNIpamSelector.js \
+ form/SDNDnsSelector.js \
form/ScsiHwSelector.js \
form/SecurityGroupSelector.js \
form/SnapshotSelector.js \
@@ -237,6 +238,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 4637929d..8c939536 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 081be7fb..b48eac3c 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
next prev parent reply other threads:[~2020-11-24 13:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 13:52 [pve-devel] [PATCH v7 pve-manager 00/15] sdn: add subnets management Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 01/15] sdn: vnetedit: add subnets && remove ip/mac Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 02/15] add sdn subnets Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 03/15] add sdn ipams Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 04/15] sdn: add PVEIpam Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 05/15] sdn: subnets: ipam is optional Alexandre Derumier
2020-11-24 13:52 ` Alexandre Derumier [this message]
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 07/15] subnets: add dns fields Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 08/15] add vnet option to subnets and remove subnets list from vnet Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 09/15] add vnet panel with vnet + subnets split view Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 10/15] subnets: move ipam/dns in advanced section, and use "pve" as default ipam Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 11/15] sdn: add options panel + move controller/ipam/dns view Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 12/15] sdn: display pending values Alexandre Derumier
2020-11-25 16:17 ` Thomas Lamprecht
2020-11-30 18:15 ` alexandre derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 13/15] move ipams && dns options to zone Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 14/15] sdn: browser: add onlinehelp Alexandre Derumier
2020-11-24 13:52 ` [pve-devel] [PATCH v7 pve-manager 15/15] sdn: evpn improvments Alexandre Derumier
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=20201124135221.2856467-7-aderumier@odiso.com \
--to=aderumier@odiso.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox