]> git.proxmox.com Git - pve-manager-legacy.git/commitdiff
Qemu GUI: add support to edit SMBIOS settings
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 26 Jun 2014 11:20:45 +0000 (13:20 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 26 Jun 2014 11:20:45 +0000 (13:20 +0200)
www/manager/Makefile
www/manager/Parser.js
www/manager/qemu/Options.js
www/manager/qemu/Smbios1Edit.js [new file with mode: 0644]

index 90b6e2579ae6c00a2e95f4431518397202490646..f0652b05db797523fbeaef769bf8abec77163a29 100644 (file)
@@ -115,6 +115,7 @@ JSSRC=                                                      \
        qemu/BootOrderEdit.js                           \
        qemu/MemoryEdit.js                              \
        qemu/NetworkEdit.js                             \
+       qemu/Smbios1Edit.js                             \
        qemu/CDEdit.js                                  \
        qemu/HDEdit.js                                  \
        qemu/HDResize.js                                \
index aa66e10628e0680c7c052d51a5bd108f6dee49b6..1eefa9a473bbfb8b1bf69fd9ad468031accbfd63 100644 (file)
@@ -260,6 +260,30 @@ Ext.define('PVE.Parser', { statics: {
        }
 
        return arr.join(',');
-    }
+    },
+
+    parseQemuSmbios1: function(value) {
+       var res = {};
+
+       Ext.Array.each(value.split(','), function(p) {
+           var kva = p.split(/=/, 2);
+           res[kva[0]] = kva[1];
+       });
+
+       return res;
+    },
+
+    printQemuSmbios1: function(data) {
+
+       var datastr = '';
+
+       Ext.Object.each(data, function(key, value) {
+           if (value === '') return;
+           datastr += (datastr !== '' ? ',' : '') + key + '=' + value;
+       });
+
+       return datastr;
+    },
+
 
 }});
index 4132ecca99f205d42c737c3d1a807d9ac756eb01..ed7d6f3a1500af059e60d7edfea76b30df359ace 100644 (file)
@@ -232,6 +232,11 @@ Ext.define('PVE.qemu.Options', {
                        allowBlank: true
                    }
                } : undefined
+           },
+           smbios1: {
+               header: gettext('SMBIOS settings (type1)'),
+               defaultValue: '',
+               editor: caps.vms['VM.Config.HWType'] ? 'PVE.qemu.Smbios1Edit' : undefined
            }
        };
 
diff --git a/www/manager/qemu/Smbios1Edit.js b/www/manager/qemu/Smbios1Edit.js
new file mode 100644 (file)
index 0000000..4aa3251
--- /dev/null
@@ -0,0 +1,115 @@
+Ext.define('PVE.qemu.Smbios1InputPanel', {
+    extend: 'PVE.panel.InputPanel',
+    alias: 'widget.PVE.qemu.Smbios1InputPanel',
+
+    insideWizard: false,
+
+    smbios1: {},
+
+    onGetValues: function(values) {
+       var me = this;
+
+       var params = {
+           smbios1: PVE.Parser.printQemuSmbios1(values)
+       };
+
+       return params;
+    },
+
+    setSmbios1: function(data) {
+       var me = this;
+
+       me.smbios1 = data;
+       
+       me.setValues(me.smbios1);
+    },
+
+    initComponent : function() {
+       var me = this;
+
+
+       me.items = [
+           {
+               xtype: 'textfield',
+               fieldLabel: 'UUID',
+               regex: /^[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$/,
+               name: 'uuid',
+           },
+           {
+               xtype: 'textfield',
+               fieldLabel: gettext('Manufacturer'),
+               regex: /^\S+$/,
+               name: 'manufacturer',
+           },
+           {
+               xtype: 'textfield',
+               fieldLabel: gettext('Product'),
+               regex: /^\S+$/,
+               name: 'product',
+           },
+           {
+               xtype: 'textfield',
+               fieldLabel: gettext('version'),
+               regex: /^\S+$/,
+               name: 'version',
+           },
+           {
+               xtype: 'textfield',
+               fieldLabel: gettext('serial'),
+               regex: /^\S+$/,
+               name: 'serial',
+           },
+           {
+               xtype: 'textfield',
+               fieldLabel: gettext('SKU'),
+               regex: /^\S+$/,
+               name: 'sku',
+           },
+           {
+               xtype: 'textfield',
+               fieldLabel: gettext('Family'),
+               regex: /^\S+$/,
+               name: 'family',
+           }
+       ];
+
+       me.callParent();
+    }
+});
+
+Ext.define('PVE.qemu.Smbios1Edit', {
+    extend: 'PVE.window.Edit',
+
+    initComponent : function() {
+       /*jslint confusion: true */
+
+       var me = this;
+
+       var ipanel = Ext.create('PVE.qemu.Smbios1InputPanel', {});
+
+       Ext.applyIf(me, {
+           subject: gettext('SMBIOS settings (type1)'),
+           width: 450,
+           items: ipanel
+       });
+
+       me.callParent();
+
+       me.load({
+           success: function(response, options) {
+               var i, confid;
+               me.vmconfig = response.result.data;
+               var value = me.vmconfig.smbios1;
+               if (value) {
+                   var data = PVE.Parser.parseQemuSmbios1(value);
+                   if (!data) {
+                       Ext.Msg.alert(gettext('Error'), gettext('Unable to parse smbios options'));
+                       me.close();
+                       return;
+                   }
+                   ipanel.setSmbios1(data);
+               }
+           }
+       });
+    }
+});