[pve-devel] [PATCH manager v2 2/2] ui/qemu: Extend Qemu Guest agent

Stoiko Ivanov s.ivanov at proxmox.com
Wed Aug 1 20:29:07 CEST 2018


Change to agent now being a property_string, and including  fstrim_cloned_disks.

Co-Authored-By: Thomas Lamprecht <t.lamprecht at proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 www/manager6/Makefile                     |  1 +
 www/manager6/Utils.js                     | 26 ++++++++++++++++++
 www/manager6/form/AgentFeatureSelector.js | 44 +++++++++++++++++++++++++++++++
 www/manager6/qemu/Options.js              | 10 +++----
 4 files changed, 74 insertions(+), 7 deletions(-)
 create mode 100644 www/manager6/form/AgentFeatureSelector.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 3cc6990f..28d21fa7 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -49,6 +49,7 @@ JSSRC= 				                 	\
 	form/SnapshotSelector.js			\
 	form/ContentTypeSelector.js			\
 	form/HotplugFeatureSelector.js			\
+	form/AgentFeatureSelector.js			\
 	form/iScsiProviderSelector.js			\
 	form/DayOfWeekSelector.js			\
 	form/BackupModeSelector.js			\
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 3ff5ef67..912cd3f7 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -175,6 +175,32 @@ Ext.define('PVE.Utils', { utilities: {
 	return fa.join(', ');
     },
 
+    render_qga_features: function(value) {
+	if (!value) {
+	    return Proxmox.Utils.defaultText + ' (' + Proxmox.Utils.disabledText  + ')';
+	}
+	var props = PVE.Parser.parsePropertyString(value, 'enabled');
+	if (!PVE.Parser.parseBoolean(props.enabled)) {
+	    return Proxmox.Utils.disabledText;
+	}
+
+	delete props.enabled;
+	var agentstring = Proxmox.Utils.enabledText;
+
+	Ext.Object.each(props, function(key, value) {
+	    var keystring = '' ;
+	    agentstring += ', ' + key + ': ';
+
+	    if (PVE.Parser.parseBoolean(value)) {
+		agentstring += Proxmox.Utils.enabledText;
+	    } else {
+		agentstring += Proxmox.Utils.disabledText;
+	    }
+	});
+
+	return agentstring;
+    },
+
     render_qemu_bios: function(value) {
 	if (!value) {
 	    return Proxmox.Utils.defaultText + ' (SeaBIOS)';
diff --git a/www/manager6/form/AgentFeatureSelector.js b/www/manager6/form/AgentFeatureSelector.js
new file mode 100644
index 00000000..e297aed8
--- /dev/null
+++ b/www/manager6/form/AgentFeatureSelector.js
@@ -0,0 +1,44 @@
+Ext.define('PVE.form.AgentFeatureSelector', {
+    extend: 'Proxmox.panel.InputPanel',
+    alias: ['widget.pveAgentFeatureSelector'],
+
+    initComponent: function() {
+	var me = this;
+	me.items= [
+	    {
+		xtype: 'proxmoxcheckbox',
+		boxLabel: gettext('Qemu Agent'),
+		name: 'enabled',
+		uncheckedValue: 0,
+		listeners: {
+		    change: function(f, value, old) {
+			var gtcb = me.down('proxmoxcheckbox[name=fstrim_cloned_disks]');
+			if (value) {
+			    gtcb.setDisabled(false);
+			} else {
+			    gtcb.setDisabled(true);
+			}
+		    }
+		}
+	    },
+	    {
+		xtype: 'proxmoxcheckbox',
+		boxLabel: gettext('Run guest-trim after clone disk'),
+		name: 'fstrim_cloned_disks',
+		disabled: true
+	    }
+	];
+	me.callParent();
+    },
+
+    onGetValues: function(values) {
+	var agentstr = PVE.Parser.printPropertyString(values, 'enabled');
+	return { agent: agentstr };
+    },
+
+    setValues: function(values) {
+	var agent = values.agent || '';
+	var res = PVE.Parser.parsePropertyString(agent, 'enabled');
+	this.callParent([res]);
+    }
+});
diff --git a/www/manager6/qemu/Options.js b/www/manager6/qemu/Options.js
index 6f0b2511..4ee28ff9 100644
--- a/www/manager6/qemu/Options.js
+++ b/www/manager6/qemu/Options.js
@@ -266,17 +266,13 @@ Ext.define('PVE.qemu.Options', {
 	    agent: {
 		header: gettext('Qemu Agent'),
 		defaultValue: false,
-		renderer: Proxmox.Utils.format_boolean,
+		renderer: PVE.Utils.render_qga_features,
 		editor: caps.vms['VM.Config.Options'] ? {
 		    xtype: 'proxmoxWindowEdit',
 		    subject: gettext('Qemu Agent'),
 		    items: {
-			xtype: 'proxmoxcheckbox',
-			name: 'agent',
-			uncheckedValue: 0,
-			defaultValue: 0,
-			deleteDefaultValue: true,
-			fieldLabel: gettext('Enabled')
+			xtype: 'pveAgentFeatureSelector',
+			name: 'agent'
 		    }
 		} : undefined
 	    },
-- 
2.11.0





More information about the pve-devel mailing list