[pve-devel] r6368 - in pve-manager/pve2: . www/manager www/manager/dc www/manager/form www/manager/storage

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Jul 27 12:33:05 CEST 2011


Author: dietmar
Date: 2011-07-27 12:33:05 +0200 (Wed, 27 Jul 2011)
New Revision: 6368

Added:
   pve-manager/pve2/www/manager/storage/LVMEdit.js
Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/www/manager/Makefile.am
   pve-manager/pve2/www/manager/dc/StorageView.js
   pve-manager/pve2/www/manager/form/FileSelector.js
Log:
	* www/manager/storage/LVMEdit.js: impl.

	* www/manager/form/FileSelector.js: better display format for
	iscsi LUNs.



Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-07-26 10:34:38 UTC (rev 6367)
+++ pve-manager/pve2/ChangeLog	2011-07-27 10:33:05 UTC (rev 6368)
@@ -1,3 +1,10 @@
+2011-07-27  Proxmox Support Team  <support at proxmox.com>
+
+	* www/manager/storage/LVMEdit.js: impl.
+
+	* www/manager/form/FileSelector.js: better display format for
+	iscsi LUNs.
+
 2011-07-26  Proxmox Support Team  <support at proxmox.com>
 
 	* www/manager/storage/IScsiEdit.js: impl.

Modified: pve-manager/pve2/www/manager/Makefile.am
===================================================================
--- pve-manager/pve2/www/manager/Makefile.am	2011-07-26 10:34:38 UTC (rev 6367)
+++ pve-manager/pve2/www/manager/Makefile.am	2011-07-27 10:33:05 UTC (rev 6368)
@@ -86,6 +86,7 @@
 	storage/DirEdit.js				\
 	storage/NFSEdit.js				\
 	storage/IScsiEdit.js				\
+	storage/LVMEdit.js				\
 	dc/StorageView.js				\
 	dc/UserEdit.js					\
 	dc/UserView.js					\

Modified: pve-manager/pve2/www/manager/dc/StorageView.js
===================================================================
--- pve-manager/pve2/www/manager/dc/StorageView.js	2011-07-26 10:34:38 UTC (rev 6367)
+++ pve-manager/pve2/www/manager/dc/StorageView.js	2011-07-27 10:33:05 UTC (rev 6368)
@@ -35,6 +35,8 @@
 		editor = 'PVE.storage.DirEdit';
 	    } else if (type === 'nfs') {
 		editor = 'PVE.storage.NFSEdit';
+	    } else if (type === 'lvm') {
+		editor = 'PVE.storage.LVMEdit';
 	    } else if (type === 'iscsi') {
 		editor = 'PVE.storage.IScsiEdit';
 	    } else {
@@ -124,7 +126,12 @@
 
 			    },
 			    {
-				text: 'LVM group'
+				text: 'LVM group',
+				handler: function() {
+				    var win = Ext.create('PVE.storage.LVMEdit', {});
+				    win.on('destroy', reload);
+				    win.show();
+				}
 			    },
 			    {
 				text: 'NFS share',

Modified: pve-manager/pve2/www/manager/form/FileSelector.js
===================================================================
--- pve-manager/pve2/www/manager/form/FileSelector.js	2011-07-26 10:34:38 UTC (rev 6367)
+++ pve-manager/pve2/www/manager/form/FileSelector.js	2011-07-27 10:33:05 UTC (rev 6368)
@@ -4,7 +4,7 @@
 	'Ext.data.Store', 
 	'PVE.RestProxy'
     ],
-    alias: ['widget.PVE.form.FileSelector'],
+    alias: ['widget.pveFileSelector'],
 
     setStorage: function(storage, nodename) {
 	var me = this;
@@ -43,13 +43,22 @@
 	var store = Ext.create('Ext.data.Store', {
 	    fields: [ 
 		'volid', 'format', 'size', 'used', 'vmid',
+		'channel', 'id', 'lun',
 		{	
 		    name: 'text', 
 		    convert: function(value, record) {
 			if (value) {
 			    return value;
 			}
-			return record.data.volid.replace(/^.*:.*\//,'');
+			var data = record.data;
+			if (Ext.isDefined(data.channel) &&
+			    Ext.isDefined(data.id) &&
+			    Ext.isDefined(data.lun)) {
+			    return "CH " + 
+				Ext.String.leftPad(data.channel,2, '0') + 
+				" ID " + data.id + " LUN " + data.lun;
+			}
+			return data.volid.replace(/^.*:.*\//,'');
 		    }
 		}
 	    ]

Added: pve-manager/pve2/www/manager/storage/LVMEdit.js
===================================================================
--- pve-manager/pve2/www/manager/storage/LVMEdit.js	                        (rev 0)
+++ pve-manager/pve2/www/manager/storage/LVMEdit.js	2011-07-27 10:33:05 UTC (rev 6368)
@@ -0,0 +1,237 @@
+Ext.define('PVE.storage.VgSelector', {
+    extend: 'Ext.form.field.ComboBox',
+    alias: 'widget.pveVgSelector',
+
+    initComponent : function() {
+	var me = this;
+
+	if (!me.nodename) {
+	    me.nodename = 'localhost';
+	}
+
+	var store = Ext.create('Ext.data.Store', {
+	    autoLoad: true,
+	    fields: [ 'vg', 'size', 'free' ],
+	    proxy: {
+		type: 'pve',
+		url: '/api2/json/nodes/' + me.nodename + '/scan/lvm'
+	    }
+	});
+
+	Ext.apply(me, {
+	    store: store,
+	    valueField: 'vg',
+	    displayField: 'vg',
+	    queryMode: 'local',
+	    editable: false,
+	    listConfig: {
+		loadingText: 'Scanning...',
+	    }
+	});
+
+	me.callParent();
+    }
+});
+
+Ext.define('PVE.storage.BaseStorageSelector', {
+    extend: 'Ext.form.field.ComboBox',
+    alias: 'widget.pveBaseStorageSelector',
+
+    initComponent : function() {
+	var me = this;
+
+	var store = Ext.create('Ext.data.Store', {
+	    autoLoad: {
+		addRecords: true,
+		params: {
+		    type: 'iscsi'
+		}
+	    },
+	    fields: [ 'storage', 'type', 'content',
+		      {
+			  name: 'text',
+			  convert: function(value, record) {
+			      if (record.data.storage) {
+				  return record.data.storage + " (iSCSI)";
+			      } else {
+				  return "Existing volume groups";
+			      }
+			  }
+		      }],
+	    proxy: {
+		type: 'pve',
+		url: '/api2/json/storage/',
+	    }
+	});
+
+	store.loadData([{ storage: '' }], true);
+
+	Ext.apply(me, {
+	    store: store,
+	    queryMode: 'local',
+	    editable: false,
+	    value: '',
+	    valueField: 'storage',
+	    displayField: 'text'
+	});
+
+	me.callParent();
+    }
+});
+
+Ext.define('PVE.storage.LVMInputPanel', {
+    extend: 'PVE.panel.InputPanel',
+
+    onGetValues: function(values) {
+	var me = this;
+
+	if (me.create) {
+	    values.type = 'lvm';
+	    values.content = 'images';
+	} else {
+	    delete values.storage;
+	}
+
+	values.disable = values.enable ? 0 : 1;	    
+	delete values.enable;
+	
+	return values;
+    },
+
+    initComponent : function() {
+	var me = this;
+
+	me.column1 = [
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		name: 'storage',
+		height: 22, // hack: set same height as text fields
+		value: me.storageId || '',
+		fieldLabel: 'Storage ID',
+		vtype: 'StorageId',
+		submitValue: me.create,
+		allowBlank: false
+	    }
+	];
+
+	var vgnameField = Ext.createWidget(me.create ? 'textfield' : 'displayfield', {
+	    height: 22, // hack: set same height as text fields
+	    name: 'vgname',
+	    hidden: me.create,
+	    disabled: me.create,
+	    value: '',
+	    fieldLabel: 'VG name',
+	    allowBlank: false
+	});
+
+	if (me.create) {
+	    var vgField = Ext.create('PVE.storage.VgSelector', {
+		name: 'vgname',
+		fieldLabel: 'Volume group',
+		allowBlank: false
+	    });
+
+	    var baseField = Ext.createWidget('pveFileSelector', {
+		name: 'base',
+		hidden: true,
+		disabled: true,
+		nodename: 'localhost',
+		storageContent: 'images',
+		fieldLabel: 'Base volume',
+		allowBlank: false
+	    });
+
+	    me.column1.push({
+		xtype: 'pveBaseStorageSelector',
+		name: 'basesel',
+		fieldLabel: 'Base storage',
+		submitValue: false,
+		listeners: {
+		    change: function(f, value) {
+			if (value) {
+			    vgnameField.setVisible(true);
+			    vgnameField.setDisabled(false);
+			    vgField.setVisible(false);
+			    vgField.setDisabled(true);
+			    baseField.setVisible(true);
+			    baseField.setDisabled(false);
+			} else {
+			    vgnameField.setVisible(false);
+			    vgnameField.setDisabled(true);
+			    vgField.setVisible(true);
+			    vgField.setDisabled(false);
+			    baseField.setVisible(false);
+			    baseField.setDisabled(true);
+			}
+			baseField.setStorage(value);
+		    }
+		}
+	    });
+
+	    me.column1.push(baseField);
+
+	    me.column1.push(vgField);
+	}
+
+	me.column1.push(vgnameField);
+
+	me.column2 = [
+	    {
+		xtype: 'pvecheckbox',
+		name: 'enable',
+		checked: true,
+		uncheckedValue: 0,
+		fieldLabel: 'Enable'
+	    },
+	    {
+		xtype: 'pvecheckbox',
+		name: 'shared',
+		uncheckedValue: 0,
+		fieldLabel: 'Shared'
+	    }
+	];
+
+	me.callParent();
+    }
+});
+
+Ext.define('PVE.storage.LVMEdit', {
+    extend: 'PVE.window.Edit',
+
+    initComponent : function() {
+	var me = this;
+ 
+	me.create = !me.storageId;
+
+	if (me.create) {
+            me.url = '/api2/extjs/storage';
+            me.method = 'POST';
+        } else {
+            me.url = '/api2/extjs/storage/' + me.storageId;
+            me.method = 'PUT';
+        }
+
+	var ipanel = Ext.create('PVE.storage.LVMInputPanel', {
+	    create: me.create,
+	    storageId: me.storageId
+	});
+	
+	Ext.apply(me, {
+	    title: me.create ? "Create LVM storage" :
+		"Edit LVM storage '" + me.storageId + "'",
+	    items: [ ipanel ]
+	});
+
+	me.callParent();
+
+	if (!me.create) {
+	    me.load({
+		success:  function(response, options) {
+		    var values = response.result.data;
+		    values.enable = values.disable ? 0 : 1;
+		    ipanel.setValues(values);
+		}
+	    });
+	}
+    }
+});



More information about the pve-devel mailing list