[pve-devel] [PATCH manager 05/11] qemu/HDEdit: move diskthrottling to advanced options

Dominik Csapak d.csapak at proxmox.com
Thu Apr 5 16:03:50 CEST 2018


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Makefile             |   1 -
 www/manager6/qemu/HDEdit.js       |  99 ++++++++++++++++++
 www/manager6/qemu/HDThrottle.js   | 209 --------------------------------------
 www/manager6/qemu/HardwareView.js |  27 -----
 4 files changed, 99 insertions(+), 237 deletions(-)
 delete mode 100644 www/manager6/qemu/HDThrottle.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index dc4cebbd..60e8103e 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -114,7 +114,6 @@ JSSRC= 				                 	\
 	qemu/HDEdit.js					\
 	qemu/HDResize.js				\
 	qemu/HDMove.js					\
-	qemu/HDThrottle.js				\
 	qemu/HDEfi.js					\
 	qemu/DisplayEdit.js				\
 	qemu/KeyboardEdit.js				\
diff --git a/www/manager6/qemu/HDEdit.js b/www/manager6/qemu/HDEdit.js
index 4e0001cd..237128e5 100644
--- a/www/manager6/qemu/HDEdit.js
+++ b/www/manager6/qemu/HDEdit.js
@@ -101,6 +101,22 @@ Ext.define('PVE.qemu.HDInputPanel', {
 	    params.scsihw = values.scsihw;
 	}
 
+        var names = ['mbps_rd', 'mbps_wr', 'iops_rd', 'iops_wr'];
+        Ext.Array.each(names, function(name) {
+            if (values[name]) {
+                me.drive[name] = values[name];
+            } else {
+                delete me.drive[name];
+            }
+            var burst_name = name + '_max';
+            if (values[burst_name] && values[name]) {
+                me.drive[burst_name] = values[burst_name];
+            } else {
+                delete me.drive[burst_name];
+            }
+        });
+
+
 	params[confid] = PVE.Parser.printQemuDrive(me.drive);
 
 	return params;
@@ -146,6 +162,15 @@ Ext.define('PVE.qemu.HDInputPanel', {
 	values.discard = (drive.discard === 'on');
 	values.iothread = PVE.Parser.parseBoolean(drive.iothread);
 
+	values.mbps_rd = drive.mbps_rd;
+	values.mbps_wr = drive.mbps_wr;
+	values.iops_rd = drive.iops_rd;
+	values.iops_wr = drive.iops_wr;
+	values.mbps_rd_max = drive.mbps_rd_max;
+	values.mbps_wr_max = drive.mbps_wr_max;
+	values.iops_rd_max = drive.iops_rd_max;
+	values.iops_wr_max = drive.iops_wr_max;
+
 	me.setValues(values);
     },
 
@@ -158,6 +183,8 @@ Ext.define('PVE.qemu.HDInputPanel', {
     initComponent : function() {
 	var me = this;
 
+	var labelWidth = 140;
+
 	me.drive = {};
 
 	me.column1 = [];
@@ -237,6 +264,42 @@ Ext.define('PVE.qemu.HDInputPanel', {
 		labelWidth: labelWidth,
 		reference: 'iothread',
 		name: 'iothread'
+	    },
+	    {
+		xtype: 'numberfield',
+		name: 'mbps_rd',
+		minValue: 1,
+		step: 1,
+		fieldLabel: gettext('Read limit') + ' (MB/s)',
+		labelWidth: labelWidth,
+		emptyText: gettext('unlimited')
+	    },
+	    {
+		xtype: 'numberfield',
+		name: 'mbps_wr',
+		minValue: 1,
+		step: 1,
+		fieldLabel: gettext('Write limit') + ' (MB/s)',
+		labelWidth: labelWidth,
+		emptyText: gettext('unlimited')
+	    },
+	    {
+		xtype: 'proxmoxintegerfield',
+		name: 'iops_rd',
+		minValue: 10,
+		step: 10,
+		fieldLabel: gettext('Read limit') + ' (ops/s)',
+		labelWidth: labelWidth,
+		emptyText: gettext('unlimited')
+	    },
+	    {
+		xtype: 'proxmoxintegerfield',
+		name: 'iops_wr',
+		minValue: 10,
+		step: 10,
+		fieldLabel: gettext('Write limit') + ' (ops/s)',
+		labelWidth: labelWidth,
+		emptyText: gettext('unlimited')
 	    }
 	);
 
@@ -252,6 +315,42 @@ Ext.define('PVE.qemu.HDInputPanel', {
 		fieldLabel: gettext('Skip replication'),
 		labelWidth: labelWidth,
 		name: 'noreplicate'
+	    },
+	    {
+		xtype: 'numberfield',
+		name: 'mbps_rd_max',
+		minValue: 1,
+		step: 1,
+		fieldLabel: gettext('Read max burst') + ' (MB)',
+		labelWidth: labelWidth,
+		emptyText: gettext('default')
+	    },
+	    {
+		xtype: 'numberfield',
+		name: 'mbps_wr_max',
+		minValue: 1,
+		step: 1,
+		fieldLabel: gettext('Write max burst') + ' (MB)',
+		labelWidth: labelWidth,
+		emptyText: gettext('default')
+	    },
+	    {
+		xtype: 'proxmoxintegerfield',
+		name: 'iops_rd_max',
+		minValue: 10,
+		step: 10,
+		fieldLabel: gettext('Read max burst') + ' (ops)',
+		labelWidth: labelWidth,
+		emptyText: gettext('default')
+	    },
+	    {
+		xtype: 'proxmoxintegerfield',
+		name: 'iops_wr_max',
+		minValue: 10,
+		step: 10,
+		fieldLabel: gettext('Write max burst') + ' (ops)',
+		labelWidth: labelWidth,
+		emptyText: gettext('default')
 	    }
 	);
 
diff --git a/www/manager6/qemu/HDThrottle.js b/www/manager6/qemu/HDThrottle.js
deleted file mode 100644
index 11c1edbc..00000000
--- a/www/manager6/qemu/HDThrottle.js
+++ /dev/null
@@ -1,209 +0,0 @@
-Ext.define('PVE.qemu.HDThrottleInputPanel', {
-    extend: 'Proxmox.panel.InputPanel',
-    alias: 'widget.PVE.qemu.HDThrottleInputPanel',
-
-    insideWizard: false,
-
-    unused: false, // ADD usused disk imaged
-
-    vmconfig: {}, // used to select usused disks
-
-    onGetValues: function(values) {
-	var me = this;
-
-	var confid = me.confid;
-	
-        var names = ['mbps_rd', 'mbps_wr', 'iops_rd', 'iops_wr'];
-        Ext.Array.each(names, function(name) {
-            if (values[name]) {
-                me.drive[name] = values[name];
-            } else {
-                delete me.drive[name];
-            }
-            var burst_name = name + '_max';
-            if (values[burst_name] && values[name]) {
-                me.drive[burst_name] = values[burst_name];
-            } else {
-                delete me.drive[burst_name];
-            }
-        });
-
-	var params = {};
-		
-	params[confid] = PVE.Parser.printQemuDrive(me.drive);
-	
-	return params;	
-    },
-
-    setDrive: function(drive) {
-	var me = this;
-
-	me.drive = drive;
-
-	var values = {};
-
-	values.mbps_rd = drive.mbps_rd;
-	values.mbps_wr = drive.mbps_wr;
-	values.iops_rd = drive.iops_rd;
-	values.iops_wr = drive.iops_wr;
-	values.mbps_rd_max = drive.mbps_rd_max;
-	values.mbps_wr_max = drive.mbps_wr_max;
-	values.iops_rd_max = drive.iops_rd_max;
-	values.iops_wr_max = drive.iops_wr_max;
-
-	me.setValues(values);
-    },
-
-    initComponent : function() {
-	var me = this;
-
-	me.drive = {};
-
-	me.column1 = [];
-	me.column2 = [];
-
-	var width2 = 140;
-
-        me.mbps_rd = Ext.widget('numberfield', {
-            name: 'mbps_rd',
-            minValue: 1,
-            step: 1,
-            fieldLabel: gettext('Read limit') + ' (MB/s)',
-            labelWidth: width2,
-            emptyText: gettext('unlimited')
-         });
-
-        me.column1.push(me.mbps_rd);
-
-        me.mbps_rd_max = Ext.widget('numberfield', {
-            name: 'mbps_rd_max',
-            minValue: 1,
-            step: 1,
-            fieldLabel: gettext('Read max burst') + ' (MB)',
-            labelWidth: width2,
-            emptyText: gettext('default')
-        });
-
-        me.column2.push(me.mbps_rd_max);
-
-
-        me.mbps_wr = Ext.widget('numberfield', {
-            name: 'mbps_wr',
-            minValue: 1,
-            step: 1,
-            fieldLabel: gettext('Write limit') + ' (MB/s)',
-            labelWidth: width2,
-            emptyText: gettext('unlimited')
-        });
-
-        me.column1.push(me.mbps_wr);
-
-        me.mbps_wr_max = Ext.widget('numberfield', {
-            name: 'mbps_wr_max',
-            minValue: 1,
-            step: 1,
-            fieldLabel: gettext('Write max burst') + ' (MB)',
-            labelWidth: width2,
-            emptyText: gettext('default')
-        });
-
-        me.column2.push(me.mbps_wr_max);
-
-        me.iops_rd = Ext.widget('proxmoxintegerfield', {
-            name: 'iops_rd',
-            minValue: 10,
-            step: 10,
-            fieldLabel: gettext('Read limit') + ' (ops/s)',
-            labelWidth: width2,
-            emptyText: gettext('unlimited')
-        });
-
-        me.column1.push(me.iops_rd);
-
-        me.iops_rd_max = Ext.widget('proxmoxintegerfield', {
-            name: 'iops_rd_max',
-            minValue: 10,
-            step: 10,
-            fieldLabel: gettext('Read max burst') + ' (ops)',
-            labelWidth: width2,
-            emptyText: gettext('default')
-        });
-
-        me.column2.push(me.iops_rd_max);
-
-        me.iops_wr = Ext.widget('proxmoxintegerfield', {
-            name: 'iops_wr',
-            minValue: 10,
-            step: 10,
-            fieldLabel: gettext('Write limit') + ' (ops/s)',
-            labelWidth: width2,
-            emptyText: gettext('unlimited')
-        });
-
-        me.column1.push(me.iops_wr);
-
-        me.iops_wr_max = Ext.widget('proxmoxintegerfield', {
-            name: 'iops_wr_max',
-            minValue: 10,
-            step: 10,
-            fieldLabel: gettext('Write max burst') + ' (ops)',
-            labelWidth: width2,
-            emptyText: gettext('default')
-        });
-
-        me.column2.push(me.iops_wr_max);
-
-	me.callParent();
-    }
-});
-
-Ext.define('PVE.qemu.HDThrottle', {
-    extend: 'Proxmox.window.Edit',
-
-    isAdd: true,
-
-    initComponent : function() {
-	var me = this;
-
-	var nodename = me.pveSelNode.data.node;
-	if (!nodename) { 
-	    throw "no node name specified";	    
-	}
-
-	var unused = me.confid && me.confid.match(/^unused\d+$/);
-	
-	me.isCreate = me.confid ? unused : true;
-
-	var ipanel = Ext.create('PVE.qemu.HDThrottleInputPanel', {
-	    confid: me.confid,
-	    nodename: nodename
-	});
-
-	var subject;
-	if (unused) {
-	    me.subject = gettext('Unused Disk');
-	} else {
-           me.subject = gettext('Hard Disk') + ' (' + me.confid + ')';
-	}
-
-	me.items = [ ipanel ];
-
-	me.callParent();
-	
-	me.load({
-	    success: function(response, options) {
-		if (me.confid) {
-		    var value = response.result.data[me.confid];
-		    var drive = PVE.Parser.parseQemuDrive(me.confid, value);
-		    if (!drive) {
-			Ext.Msg.alert(gettext('Error'), 'Unable to parse drive options');
-			me.close();
-			return;
-		    }
-		    ipanel.setDrive(drive);
-		    me.isValid(); // trigger validation
-		}
-	    }
-	});
-    }
-});
diff --git a/www/manager6/qemu/HardwareView.js b/www/manager6/qemu/HardwareView.js
index 218f9059..d27f224a 100644
--- a/www/manager6/qemu/HardwareView.js
+++ b/www/manager6/qemu/HardwareView.js
@@ -275,22 +275,6 @@ Ext.define('PVE.qemu.HardwareView', {
 	    win.on('destroy', reload);
 	};
 
-	var run_diskthrottle = function() {
-	    var rec = sm.getSelection()[0];
-	    if (!rec) {
-		return;
-	    }
-
-            var win = Ext.create('PVE.qemu.HDThrottle', {
-		pveSelNode: me.pveSelNode,
-		confid: rec.data.key,
-		url: '/api2/extjs/' + baseurl
-	    });
-
-	    win.show();
-	    win.on('destroy', reload);
-	};
-
 	var run_resize = function() {
 	    var rec = sm.getSelection()[0];
 	    if (!rec) {
@@ -346,13 +330,6 @@ Ext.define('PVE.qemu.HardwareView', {
 	    handler: run_move
 	});
 
-	var diskthrottle_btn = new Proxmox.button.Button({
-	    text: gettext('Disk Throttle'),
-	    selModel: sm,
-	    disabled: true,
-	    handler: run_diskthrottle
-	});
-
 	var remove_btn = new Proxmox.button.Button({
 	    text: gettext('Remove'),
 	    defaultText: gettext('Remove'),
@@ -484,7 +461,6 @@ Ext.define('PVE.qemu.HardwareView', {
 		edit_btn.disable();
 		resize_btn.disable();
 		move_btn.disable();
-		diskthrottle_btn.disable();
 		revert_btn.disable();
 		return;
 	    }
@@ -510,8 +486,6 @@ Ext.define('PVE.qemu.HardwareView', {
 
 	    move_btn.setDisabled(pending || !isUsedDisk);
 
-	    diskthrottle_btn.setDisabled(pending || !isUsedDisk || isEfi);
-
 	    revert_btn.setDisabled(!pending);
 
 	};
@@ -600,7 +574,6 @@ Ext.define('PVE.qemu.HardwareView', {
 		edit_btn,
 		resize_btn,
 		move_btn,
-		diskthrottle_btn,
 		revert_btn
 	    ],
 	    rows: rows,
-- 
2.11.0





More information about the pve-devel mailing list