[pve-devel] [PATCH v10 pve-manager 06/19] add sdn dns
Alexandre Derumier
aderumier at odiso.com
Tue Jan 5 10:06:56 CET 2021
Signed-off-by: Alexandre Derumier <aderumier at 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
More information about the pve-devel
mailing list