parseQemuCpu: function(value) {
if (!value) {
- return;
+ return {};
}
var res = {};
printQemuCpu: function(cpu) {
var cpustr = cpu.cputype;
+ var optstr = '';
Ext.Object.each(cpu, function(key, value) {
if (!Ext.isDefined(value) || key === 'cputype') {
return; // continue
}
- cpustr += ',' + key + '=' + value;
+ optstr += ',' + key + '=' + value;
});
- return cpustr;
- },
+ if (!cpustr) {
+ if (optstr)
+ return 'kvm64' + optstr;
+ return;
+ }
+ return cpustr + optstr;
+ },
}});
onGetValues: function(values) {
var me = this;
+
+ // build the cpu options:
me.cpu.cputype = values['cputype'];
- return {
- cpu: PVE.Parser.printQemuCpu(me.cpu)
- };
+ delete values['cputype'];
+ var cpustring = PVE.Parser.printQemuCpu(me.cpu);
+
+ // remove cputype delete request:
+ var del = values['delete'];
+ delete values['delete'];
+ if (del) {
+ del = del.split(',');
+ Ext.Array.remove(del, 'cputype');
+ } else {
+ del = [];
+ }
+ console.log(del);
+
+ if (cpustring) {
+ values['cpu'] = cpustring;
+ } else {
+ del.push('cpu');
+ }
+
+ del = del.join(',');
+ if (del) {
+ values['delete'] = del;
+ }
+
+ return values;
},
initComponent : function() {
var value = response.result.data['cpu'];
var cpu = PVE.Parser.parseQemuCpu(value);
ipanel.cpu = cpu;
- me.setValues({ cputype: cpu.cputype });
+ if (value)
+ me.setValues({ cputype: cpu.cputype });
}
});
}