[pve-devel] [PATCH 5/5] add nexenta storage panel

Alexandre Derumier aderumier at odiso.com
Fri Aug 17 15:51:23 CEST 2012


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 www/manager/Makefile               |    1 +
 www/manager/dc/StorageView.js      |   11 +++
 www/manager/storage/NexentaEdit.js |  166 ++++++++++++++++++++++++++++++++++++
 3 files changed, 178 insertions(+), 0 deletions(-)
 create mode 100644 www/manager/storage/NexentaEdit.js

diff --git a/www/manager/Makefile b/www/manager/Makefile
index 1f94bd5..de30bbf 100644
--- a/www/manager/Makefile
+++ b/www/manager/Makefile
@@ -123,6 +123,7 @@ JSSRC= 				                 	\
 	storage/LVMEdit.js				\
 	storage/RBDEdit.js				\
 	storage/SheepdogEdit.js				\
+	storage/NexentaEdit.js				\
 	dc/Summary.js					\
 	dc/OptionView.js				\
 	dc/StorageView.js				\
diff --git a/www/manager/dc/StorageView.js b/www/manager/dc/StorageView.js
index a9473ed..0e78d15 100644
--- a/www/manager/dc/StorageView.js
+++ b/www/manager/dc/StorageView.js
@@ -44,6 +44,8 @@ Ext.define('PVE.dc.StorageView', {
 		editor = 'PVE.storage.RBDEdit';
 	    } else if (type === 'sheepdog') {
 		editor = 'PVE.storage.SheepdogEdit';
+	    } else if (type === 'nexenta') {
+		editor = 'PVE.storage.NexentaEdit';
 	    } else {
 		return;
 	    }
@@ -151,6 +153,15 @@ Ext.define('PVE.dc.StorageView', {
 				    win.show();
 				}
 			    },
+			    {
+				text: 'Nexenta',
+				iconCls: 'pve-itype-icon-node',
+				handler: function() {
+				    var win = Ext.create('PVE.storage.NexentaEdit', {});
+				    win.on('destroy', reload);
+				    win.show();
+				}
+			    },
 
 			]
 		    })
diff --git a/www/manager/storage/NexentaEdit.js b/www/manager/storage/NexentaEdit.js
new file mode 100644
index 0000000..d64533f
--- /dev/null
+++ b/www/manager/storage/NexentaEdit.js
@@ -0,0 +1,166 @@
+Ext.define('PVE.storage.NexentaInputPanel', {
+    extend: 'PVE.panel.InputPanel',
+
+    onGetValues: function(values) {
+	var me = this;
+
+	if (me.create) {
+	    values.type = 'nexenta';
+            values.content = 'images';
+
+	} else {
+	    delete values.storage;
+	}
+
+	values.disable = values.enable ? 0 : 1;	    
+	delete values.enable;
+
+	values.ssl = values.enablessl ? 1 : 0;	    
+	delete values.enablessl;
+
+	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: 'ID',
+		vtype: 'StorageId',
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		name: 'portal',
+		height: 22, // hack: set same height as text fields
+		value: '',
+		fieldLabel: gettext('Portal'),
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		name: 'target',
+		height: 22, // hack: set same height as text fields
+		value: 'iqn.1986-03.com.sun:02:....',
+		fieldLabel: gettext('Target'),
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		name: 'pool',
+		height: 22, // hack: set same height as text fields
+		value: '',
+		fieldLabel: gettext('Pool'),
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		name: 'login',
+		height: 22, // hack: set same height as text fields
+		value: '',
+		fieldLabel: gettext('Login'),
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		name: 'password',
+		height: 22, // hack: set same height as text fields
+		value: '',
+		fieldLabel: gettext('Password'),
+		allowBlank: false
+	    },
+
+	];
+
+	me.column2 = [
+	    {
+		xtype: 'pvecheckbox',
+		name: 'enable',
+		checked: true,
+		uncheckedValue: 0,
+		fieldLabel: gettext('Enable')
+	    },
+	    {
+		xtype: 'pvecheckbox',
+		name: 'enablessl',
+		checked: true,
+		uncheckedValue: 0,
+		fieldLabel: gettext('ssl')
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		name: 'blocksize',
+		height: 22, // hack: set same height as text fields
+		value: '4K',
+		fieldLabel: gettext('Block Size'),
+		allowBlank: false
+	    },
+
+	];
+
+	if (me.create || me.storageId !== 'local') {
+	    me.column2.unshift({
+		xtype: 'PVE.form.NodeSelector',
+		name: 'nodes',
+		fieldLabel: gettext('Nodes'),
+		emptyText: gettext('All') + ' (' + 
+		    gettext('No restrictions') +')',
+		multiSelect: true,
+		autoSelect: false
+	    });
+	}
+
+	me.callParent();
+    }
+});
+
+Ext.define('PVE.storage.NexentaEdit', {
+    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.NexentaInputPanel', {
+	    create: me.create,
+	    storageId: me.storageId
+	});
+
+	Ext.apply(me, {
+            subject: 'Nexenta Storage',
+	    isAdd: true,
+	    items: [ ipanel ]
+	});
+	
+	me.callParent();
+
+        if (!me.create) {
+            me.load({
+                success:  function(response, options) {
+                    var values = response.result.data;
+                    if (values.nodes) {
+                        values.nodes = values.nodes.split(',');
+                    }
+                    values.enable = values.disable ? 0 : 1;
+                    values.enablessl = values.ssl ? 1 : 0;
+                    ipanel.setValues(values);
+                }
+            });
+        }
+    }
+});
-- 
1.7.2.5




More information about the pve-devel mailing list