[pve-devel] [PATCH] Added support for ZFS Storage Plugin

mir at datanom.net mir at datanom.net
Fri May 24 20:53:22 CEST 2013


From: Michael Rasmussen <mir at datanom.net>


Signed-off-by: Michael Rasmussen <mir at datanom.net>
---
 www/manager/Makefile           |    1 +
 www/manager/Utils.js           |    2 +
 www/manager/dc/StorageView.js  |   11 +++
 www/manager/qemu/Clone.js      |    3 +-
 www/manager/qemu/HDEdit.js     |    3 +-
 www/manager/storage/ZFSEdit.js |  172 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 190 insertions(+), 2 deletions(-)
 create mode 100644 www/manager/storage/ZFSEdit.js

diff --git a/www/manager/Makefile b/www/manager/Makefile
index 013e762..27ef431 100644
--- a/www/manager/Makefile
+++ b/www/manager/Makefile
@@ -132,6 +132,7 @@ JSSRC= 				                 	\
 	storage/RBDEdit.js				\
 	storage/SheepdogEdit.js				\
 	storage/NexentaEdit.js				\
+	storage/ZFSEdit.js				\
 	dc/Summary.js					\
 	dc/OptionView.js				\
 	dc/StorageView.js				\
diff --git a/www/manager/Utils.js b/www/manager/Utils.js
index 48ffade..aab95f7 100644
--- a/www/manager/Utils.js
+++ b/www/manager/Utils.js
@@ -642,6 +642,8 @@ Ext.define('PVE.Utils', { statics: {
 	    return 'Sheepdog';
 	} else if (value === 'nexenta') {
 	    return 'Nexenta';
+	} else if (value === 'zfs') {
+	    return 'ZFS';
 	} else if (value === 'iscsidirect') {
 	    return 'iSCSIDirect';
 	} else {
diff --git a/www/manager/dc/StorageView.js b/www/manager/dc/StorageView.js
index 2c81c0b..2bfa831 100644
--- a/www/manager/dc/StorageView.js
+++ b/www/manager/dc/StorageView.js
@@ -46,6 +46,8 @@ Ext.define('PVE.dc.StorageView', {
 		editor = 'PVE.storage.SheepdogEdit';
 	    } else if (type === 'nexenta') {
 		editor = 'PVE.storage.NexentaEdit';
+	    } else if (type === 'zfs') {
+		editor = 'PVE.storage.ZFSEdit';
 	    } else {
 		return;
 	    }
@@ -164,6 +166,15 @@ Ext.define('PVE.dc.StorageView', {
 				    win.show();
 				}
 			    },
+			    {
+				text: 'ZFS',
+				iconCls: 'pve-itype-icon-node',
+				handler: function() {
+				    var win = Ext.create('PVE.storage.ZFSEdit', {});
+				    win.on('destroy', reload);
+				    win.show();
+				}
+			    }
 */
 			]
 		    })
diff --git a/www/manager/qemu/Clone.js b/www/manager/qemu/Clone.js
index 58b1ee7..4ad7a0d 100644
--- a/www/manager/qemu/Clone.js
+++ b/www/manager/qemu/Clone.js
@@ -65,7 +65,8 @@ Ext.define('PVE.window.Clone', {
             rec.data.type === 'rbd' ||
             rec.data.type === 'iscsi' ||
             rec.data.type === 'sheepdog' ||
-            rec.data.type === 'nexenta'
+            rec.data.type === 'nexenta' ||
+			rec.data.type === 'zfs'
            ) {
             me.formatsel.setValue('raw');
             me.formatsel.setDisabled(true);
diff --git a/www/manager/qemu/HDEdit.js b/www/manager/qemu/HDEdit.js
index 66a823c..6b2cf8d 100644
--- a/www/manager/qemu/HDEdit.js
+++ b/www/manager/qemu/HDEdit.js
@@ -192,7 +192,8 @@ Ext.define('PVE.qemu.HDInputPanel', {
 			} else if (rec.data.type === 'lvm' || 
 				   rec.data.type === 'rbd' ||
 				   rec.data.type === 'sheepdog' ||
-				   rec.data.type === 'nexenta') {
+				   rec.data.type === 'nexenta' ||
+				   rec.data.type === 'zfs') {
 			    me.hdfilesel.setDisabled(true);
 			    me.hdfilesel.setVisible(false);
 			    me.formatsel.setValue('raw');
diff --git a/www/manager/storage/ZFSEdit.js b/www/manager/storage/ZFSEdit.js
new file mode 100644
index 0000000..0432386
--- /dev/null
+++ b/www/manager/storage/ZFSEdit.js
@@ -0,0 +1,172 @@
+Ext.define('PVE.storage.ZFSInputPanel', {
+    extend: 'PVE.panel.InputPanel',
+
+    onGetValues: function(values) {
+		var me = this;
+	
+		if (me.create) {
+			values.type = 'zfs';
+				values.content = 'images';
+	
+		} else {
+			delete values.storage;
+		}
+	
+		values.disable = values.enable ? 0 : 1;	    
+		delete values.enable;
+	
+		values.sudo = values.enablesudo ? 1 : 0;	    
+		delete values.enablesudo;
+	
+		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.2010-09.org.openindiana:omnios:....',
+			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: 'chap',
+			height: 22, // hack: set same height as text fields
+			value: '',
+			fieldLabel: gettext('Chap'),
+			allowBlank: true
+	    },
+	    {
+			xtype: me.create ? 'textfield' : 'displayfield',
+			name: 'pwd',
+			height: 22, // hack: set same height as text fields
+			value: '',
+			fieldLabel: gettext('Password'),
+			allowBlank: true
+	    }
+	];
+
+	me.column2 = [
+	    {
+			xtype: 'pvecheckbox',
+			name: 'enable',
+			checked: true,
+			uncheckedValue: 0,
+			fieldLabel: gettext('Enable')
+	    },
+	    {
+			xtype: 'pvecheckbox',
+			name: 'enablesudo',
+			checked: false,
+			uncheckedValue: 0,
+			fieldLabel: gettext('sudo')
+	    },
+	    {
+			xtype: me.create ? 'textfield' : 'displayfield',
+			name: 'bsize',
+			height: 22, // hack: set same height as text fields
+			value: '8k',
+			fieldLabel: gettext('Block Size'),
+			allowBlank: false
+	    },
+	    {
+			xtype: me.create ? 'textfield' : 'displayfield',
+			name: 'iscsiprovider',
+			height: 22, // hack: set same height as text fields
+			value: 'Comstar',
+			fieldLabel: gettext('iSCSI Provider'),
+			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.ZFSEdit', {
+    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.ZFSInputPanel', {
+	    create: me.create,
+	    storageId: me.storageId
+	});
+
+	Ext.apply(me, {
+            subject: 'ZFS 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.enablesudo = values.sudo ? 1 : 0;
+                    ipanel.setValues(values);
+                }
+            });
+        }
+    }
+});
-- 
1.7.10.4




More information about the pve-devel mailing list