[pve-devel] r6229 - in pve-manager/pve2: . www/manager/form www/manager/qemu

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Jul 4 13:59:19 CEST 2011


Author: dietmar
Date: 2011-07-04 13:59:19 +0200 (Mon, 04 Jul 2011)
New Revision: 6229

Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/www/manager/form/BusTypeSelector.js
   pve-manager/pve2/www/manager/qemu/HardwareView.js
Log:
	* www/manager/form/BusTypeSelector.js: add noVirtIO, noScsi options.

	* www/manager/qemu/HardwareView.js: impl. add cdrom, cleanup code,
	impl. remove



Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-07-04 08:50:44 UTC (rev 6228)
+++ pve-manager/pve2/ChangeLog	2011-07-04 11:59:19 UTC (rev 6229)
@@ -1,3 +1,10 @@
+2011-07-04  Proxmox Support Team  <support at proxmox.com>
+
+	* www/manager/form/BusTypeSelector.js: add noVirtIO, noScsi options.
+
+	* www/manager/qemu/HardwareView.js: impl. add cdrom, cleanup code,
+	impl. remove
+
 2011-07-01  Seth Lauzon  <seth.lauzon at gmail.com>
 
 	* www/manager/UserView.js: add modify functionality and disallow

Modified: pve-manager/pve2/www/manager/form/BusTypeSelector.js
===================================================================
--- pve-manager/pve2/www/manager/form/BusTypeSelector.js	2011-07-04 08:50:44 UTC (rev 6228)
+++ pve-manager/pve2/www/manager/form/BusTypeSelector.js	2011-07-04 11:59:19 UTC (rev 6229)
@@ -5,13 +5,17 @@
     initComponent: function() {
 	var me = this;
 
+	var data = [['ide', 'IDE']];
+
+	if (!me.noVirtIO) 
+	    data.push(['virtio', 'VIRTIO']);
+
+	if (!me.noScsi) 
+	    data.push(['scsi', 'SCSI']);
+
 	var store = Ext.create('Ext.data.ArrayStore', {
 	    model: 'KeyValue',
-            data : [ 
-		['ide', 'IDE'], 
-		['virtio', 'VIRTIO'],
-		['scsi', 'SCSI']
-	    ]
+            data : data
         });
 
 	Ext.apply(me, {

Modified: pve-manager/pve2/www/manager/qemu/HardwareView.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-04 08:50:44 UTC (rev 6228)
+++ pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-04 11:59:19 UTC (rev 6229)
@@ -4,11 +4,11 @@
     submit: function(formpanel) {
 	var me = this;
 
-	var field = me.down('field[name=_cache]');
+	var field = me.down('field[name=cache]');
 	var value = field.getValue();
 	me.drive.cache = value ? value : undefined;
 	
-	field = me.down('field[name=_nobackup]');
+	field = me.down('field[name=nobackup]');
 	value = field.getValue();
 	me.drive.backup = value ? 'no' : undefined;
 
@@ -44,21 +44,21 @@
 	    {
 		xtype: 'displayfield',
                 fieldLabel: 'Image',
-                name: '_file'
+                name: 'file'
  	    }
 	];
 
 	me.column2 = [
 	    {
 		xtype: 'CacheTypeSelector',
-		name: '_cache',
+		name: 'cache',
 		value: '',
 		fieldLabel: 'Cache',
 	    },
 	    {
 		xtype: 'pvecheckbox',
                 fieldLabel: 'No backup',
-                name: '_nobackup'
+                name: 'nobackup'
  	    }
 	];
 
@@ -81,16 +81,16 @@
 		    return;
 		}
 
-		var field = me.down('field[name=_file]');
+		var field = me.down('field[name=file]');
 		field.setValue(me.drive.file);
 		field.resetOriginalValue();
 
-		field = me.down('field[name=_cache]');
+		field = me.down('field[name=cache]');
 		field.setValue(me.drive.cache || '');
 		field.resetOriginalValue();
 
 		if (me.drive.backup === 'no') {
-		    field = me.down('field[name=_nobackup]');
+		    field = me.down('field[name=nobackup]');
 		    field.setValue(true);
 		    field.resetOriginalValue();
 		}
@@ -102,42 +102,43 @@
 Ext.define('PVE.qemu.HDCreate', {
     extend: 'PVE.window.Edit',
 
-    create: 1,
+    create: true,
 
+    cdrom: false,
+
     submit: function(formpanel) {
 	var me = this;
 
+	var values = formpanel.getValues();
+
 	var drive = {};
 
-	var controller = me.down('field[name=_controller]').getValue();
-	var deviceid = me.down('field[name=_deviceid]').getValue();
-
-	var confid = '' + controller + deviceid;
+	var confid = '' + values.controller + values.deviceid;
 	
-	var field = me.down('field[name=_disksize]');
-	var hdsize = field.getValue();
-
-	var field = me.down('field[name=_storage]');
-	var value = field.getValue();
-	drive.file = value + ":" + hdsize;
-
-	var field = me.down('field[name=_diskformat]');
-	drive.format = field.getValue();
+	if (me.cdrom) {
+	    drive.media = 'cdrom';
+	    if (values.mediaType  === 'iso') {
+		drive.file = values.cdimage;
+	    } else if (values.mediaType === 'cdrom') {
+		drive.file = 'cdrom';
+	    } else {
+		drive.file = 'none';
+	    }
+	} else {
+	    drive.file = values.storage + ":" + values.hdsize;
+	    drive.format = values.diskformat;
 	
-	var field = me.down('field[name=_cache]');
-	if (value = field.getValue())
-	    drive.cache = value;
-	
-	field = me.down('field[name=_nobackup]');
-	if (value = field.getValue())
-	    drive.backup = 'no';
+	    if (values.cache)
+		drive.cache = values.cache;
+	    
+	    if (values.nobackup)
+		drive.backup = 'no';
+	}
 
 	var params = {};
 
 	params[confid] = PVE.Parser.printQemuDrive(drive);
 
-	console.dir(params);
-
 	PVE.Utils.API2Request({
 	    url: me.url,
 	    method: 'PUT',
@@ -159,96 +160,161 @@
 	if (!nodename) 
 	    throw "no node name specified";	    
 
-	var hdstoragesel = Ext.create('PVE.form.StorageSelector', {
-	    name: '_storage',
-	    nodename: nodename,
-	    fieldLabel: 'Storage',
-	    storageContent: 'images',
-	    allowBlank: false
-	});
-
 	var maxIds = {
 	    ide: 3,
 	    virtio: 15,
 	    scsi: 15
 	};
 
-	me.column1 = [
-	    hdstoragesel,
-	    {
-		xtype: 'numberfield',
-		name: '_disksize',
-		minValue: 1,
-		maxValue: 128*1024,
-		value: 32,
-		fieldLabel: 'Disk size (GB)',
-		allowBlank: false
+	var bussel = Ext.createWidget('fieldcontainer', {
+	    fieldLabel: 'Bus/Device',
+	    layout: 'hbox',
+	    defaults: {
+                flex: 1,
+                hideLabel: true
 	    },
-	    {
-		xtype: 'fieldcontainer',
-		fieldLabel: 'Bus/Device',
-		layout: 'hbox',
-		defaults: {
-                    flex: 1,
-                    hideLabel: true
-		},
-		items: [
-		    {
-			xtype: 'PVE.form.BusTypeSelector',
-			name: '_controller',
-			value: 'ide',
-			allowBlank: false,
-			listeners: {
-			    change: function(t, value) {
-				if (!value)
-				    return;
-				var field = me.down('field[name=_deviceid]');
-				field.setMaxValue(maxIds[value]);
-				field.validate();
-			    }
+	    items: [
+		{
+		    xtype: 'PVE.form.BusTypeSelector',
+		    name: 'controller',
+		    value: 'ide',
+		    noVirtIO: me.cdrom,
+		    allowBlank: false,
+		    listeners: {
+			change: function(t, value) {
+			    if (!me.rendered || !value)
+				return;
+			    var field = me.down('field[name=deviceid]');
+			    field.setMaxValue(maxIds[value]);
+			    field.validate();
 			}
-		    },
-		    {
-			xtype: 'numberfield',
-			name: '_deviceid',
-			minValue: 0,
-			maxValue: maxIds['ide'],
-			value: 0,
-			validator: function(value) {
-			    var controller = me.down('field[name=_controller]').getValue();
-			    var confid = '' + controller + value;
-			    if (Ext.isDefined(me.vmconfig[confid]))
-				return "This device is already in use.";
-			    return true;
-			}
 		    }
-		]
-	    }
-	];
+		},
+		{
+		    xtype: 'numberfield',
+		    name: 'deviceid',
+		    minValue: 0,
+		    maxValue: maxIds['ide'],
+		    value: 0,
+		    validator: function(value) {
+			if (!me.rendered)
+			    return;
+			var field = me.down('field[name=controller]');
+			var controller = field.getValue();
+			var confid = '' + controller + value;
+			if (Ext.isDefined(me.vmconfig[confid]))
+			    return "This device is already in use.";
+			return true;
+		    }
+		}
+	    ]
+	});
 
-	me.column2 = [
-	    {
-		xtype: 'PVE.form.DiskFormatSelector',
-		name: '_diskformat',
-		fieldLabel: 'Image format',
-		value: 'raw',
+	if (me.cdrom) {
+
+	    var cdfilesel = Ext.create('PVE.form.FileSelector', {
+		name: 'cdimage',
+		nodename: nodename,
+		storageContent: 'iso',
+		fieldLabel: 'ISO Image',
+		labelAlign: 'right',
 		allowBlank: false
-	    },
-	    {
-		xtype: 'CacheTypeSelector',
-		name: '_cache',
-		value: '',
-		fieldLabel: 'Cache',
-	    },
-	    {
-		xtype: 'pvecheckbox',
-                fieldLabel: 'No backup',
-                name: '_nobackup'
- 	    }
-	];
+	    });
 
+	    var cdstoragesel = Ext.create('PVE.form.StorageSelector', {
+		name: 'storage',
+		nodename: nodename,
+		fieldLabel: 'Storage',
+		labelAlign: 'right',
+		storageContent: 'iso',
+		allowBlank: false,
+		listeners: {
+		    change: function(f, value) {
+			cdfilesel.setStorage(value);
+		    }
+		}
+	    });
+
+	    me.items = [ 
+		bussel, 
+		{
+		    xtype: 'radiofield',
+		    name: 'mediaType',
+		    inputValue: 'iso',
+		    boxLabel: 'Use CD/DVD disc image file (iso)',
+		    checked: true,
+		    listeners: {
+			change: function(f, value) {
+			    if (!me.rendered)
+				return;
+			    me.down('field[name=storage]').setDisabled(!value);
+			    me.down('field[name=cdimage]').setDisabled(!value);
+			    me.down('field[name=cdimage]').validate();
+			}
+		    }
+		},
+		cdstoragesel, 
+		cdfilesel,
+		{
+		    xtype: 'radiofield',
+		    name: 'mediaType',
+		    inputValue: 'cdrom',
+		    boxLabel: 'Use physical CD/DVD Drive'
+		},
+		{
+		    xtype: 'radiofield',
+		    name: 'mediaType',
+		    inputValue: 'none',
+		    boxLabel: 'Do not use any installation media'
+		}
+	    ];
+
+	} else {
+	    me.column1 = [
+		{
+		    xtype: 'PVE.form.StorageSelector',
+		    name: 'storage',
+		    nodename: nodename,
+		    fieldLabel: 'Storage',
+		    storageContent: 'images',
+		    allowBlank: false
+		},
+		{
+		    xtype: 'numberfield',
+		    name: 'disksize',
+		    minValue: 1,
+		    maxValue: 128*1024,
+		    value: 32,
+		    fieldLabel: 'Disk size (GB)',
+		    allowBlank: false
+		},
+		bussel
+	    ];
+
+	    me.column2 = [
+		{
+		    xtype: 'PVE.form.DiskFormatSelector',
+		    name: 'diskformat',
+		    fieldLabel: 'Image format',
+		    value: 'raw',
+		    allowBlank: false
+		},
+		{
+		    xtype: 'CacheTypeSelector',
+		    name: 'cache',
+		    value: '',
+		    fieldLabel: 'Cache',
+		},
+		{
+		    xtype: 'pvecheckbox',
+                    fieldLabel: 'No backup',
+                    name: 'nobackup'
+ 		}
+	    ];
+	}
+
 	Ext.applyIf(me, {
-	    title: 'Add Harddisk',
+	    title: me.cdrom ? 'Add CD/DVD Drive' : 'Add Harddisk',
 	});
 
 	me.callParent();
@@ -261,12 +327,12 @@
 		if (me.vmconfig.ostype === 'l26') {
 		    controller = 'virtio';
 		}
-		me.down('field[name=_controller]').setValue(controller);
+		me.down('field[name=controller]').setValue(controller);
 		var i;
 		for (i = 0; i <= maxIds[controller]; i++) {
 		    confid = '' + controller + i;
 		    if (!Ext.isDefined(me.vmconfig[confid])) {
-			me.down('field[name=_deviceid]').setValue(i);
+			me.down('field[name=deviceid]').setValue(i);
 			break;
 		    }
 		}
@@ -323,6 +389,7 @@
 	me.load();
     }
 });
+
 Ext.define('PVE.qemu.KeyboardEdit', {
     extend: 'PVE.window.Edit',
 
@@ -572,7 +639,28 @@
 	    text: 'Remove',
 	    disabled: true,
 	    handler: function(){
-		console.log("REMOVE");
+		var sm = me.getSelectionModel();
+		var rec = sm.getSelection()[0];
+
+		if (!rec)
+		    return;
+
+		me.setLoading(true, true);
+		PVE.Utils.API2Request({
+		    url: '/api2/extjs/' + baseurl,
+		    method: 'PUT',
+		    params: {
+			delete: rec.data.key
+		    },
+		    callback: function() {
+			me.setLoading(false);
+			reload();
+		    },
+		    failure: function (response, opts) {
+			Ext.Msg.alert('Error',response.htmlStatus);
+		    }
+		});
+
 	    }
 	});
 
@@ -617,6 +705,13 @@
 				text: 'CD/DVD Drive',
 				iconCls: 'pve-itype-icon-cdrom',
 				handler: function() {
+				    var win = Ext.create('PVE.qemu.HDCreate', {
+					cdrom: true,
+					url: '/api2/extjs/' + baseurl,
+					pveSelNode: me.pveSelNode
+				    });
+				    win.on('destroy', reload);
+				    win.show();
 				}
 			    },
 			    {
@@ -643,7 +738,7 @@
 	me.callParent();
 
 	me.on('show', function() {
-	    me.rstore.load();
+	    reload();
 	});
 
     }




More information about the pve-devel mailing list