From: Alexandre Derumier <aderumier@odiso.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v4 pve-manager 6/8] add sdn dns
Date: Mon, 24 Aug 2020 18:48:45 +0200 [thread overview]
Message-ID: <20200824164847.12490-7-aderumier@odiso.com> (raw)
In-Reply-To: <20200824164847.12490-1-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 5c25f4fb..11761df5 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
next prev parent reply other threads:[~2020-08-24 16:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 16:48 [pve-devel] [PATCH v4 pve-manager 0/8] sdn : add subnets management Alexandre Derumier
2020-08-24 16:48 ` [pve-devel] [PATCH v4 pve-manager 1/8] sdn: vnetedit: add subnets && remove ip/mac Alexandre Derumier
2020-08-24 16:48 ` [pve-devel] [PATCH v4 pve-manager 2/8] add sdn subnets Alexandre Derumier
2020-08-24 16:48 ` [pve-devel] [PATCH v4 pve-manager 3/8] add sdn ipams Alexandre Derumier
2020-08-24 16:48 ` [pve-devel] [PATCH v4 pve-manager 4/8] sdn: add PVEIpam Alexandre Derumier
2020-08-24 16:48 ` [pve-devel] [PATCH v4 pve-manager 5/8] sdn: subnets: ipam is optional Alexandre Derumier
2020-08-24 16:48 ` Alexandre Derumier [this message]
2020-08-24 16:48 ` [pve-devel] [PATCH v4 pve-manager 7/8] subnets: add dns fields Alexandre Derumier
2020-08-24 16:48 ` [pve-devel] [PATCH v4 pve-manager 8/8] add vnet option to subnets and remove subnets list from vnet 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=20200824164847.12490-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 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.