[pve-devel] [PATCH 2/5] add rbd storage panel

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


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 www/manager/Makefile           |    1 +
 www/manager/dc/StorageView.js  |   16 ++++-
 www/manager/storage/RBDEdit.js |  137 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 152 insertions(+), 2 deletions(-)
 create mode 100644 www/manager/storage/RBDEdit.js

diff --git a/www/manager/Makefile b/www/manager/Makefile
index a1483d3..286bc51 100644
--- a/www/manager/Makefile
+++ b/www/manager/Makefile
@@ -121,6 +121,7 @@ JSSRC= 				                 	\
 	storage/NFSEdit.js				\
 	storage/IScsiEdit.js				\
 	storage/LVMEdit.js				\
+	storage/RBDEdit.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 865c7a5..9d3dba8 100644
--- a/www/manager/dc/StorageView.js
+++ b/www/manager/dc/StorageView.js
@@ -40,6 +40,8 @@ Ext.define('PVE.dc.StorageView', {
 		editor = 'PVE.storage.LVMEdit';
 	    } else if (type === 'iscsi') {
 		editor = 'PVE.storage.IScsiEdit';
+	    } else if (type === 'rbd') {
+		editor = 'PVE.storage.RBDEdit';
 	    } else {
 		return;
 	    }
@@ -128,7 +130,17 @@ Ext.define('PVE.dc.StorageView', {
 				    win.on('destroy', reload);
 				    win.show();
 				}
-			    }
+			    },
+			    {
+				text: 'RBD',
+				iconCls: 'pve-itype-icon-node',
+				handler: function() {
+				    var win = Ext.create('PVE.storage.RBDEdit', {});
+				    win.on('destroy', reload);
+				    win.show();
+				}
+			    },
+
 			]
 		    })
 		},
@@ -203,4 +215,4 @@ Ext.define('PVE.dc.StorageView', {
 	idProperty: 'storage'
     });
 
-});
\ No newline at end of file
+});
diff --git a/www/manager/storage/RBDEdit.js b/www/manager/storage/RBDEdit.js
new file mode 100644
index 0000000..b3f3a11
--- /dev/null
+++ b/www/manager/storage/RBDEdit.js
@@ -0,0 +1,137 @@
+Ext.define('PVE.storage.RBDInputPanel', {
+    extend: 'PVE.panel.InputPanel',
+
+    onGetValues: function(values) {
+	var me = this;
+
+	if (me.create) {
+	    values.type = 'rbd';
+            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: 'ID',
+		vtype: 'StorageId',
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		height: 22, // hack: set same height as text fields
+		name: 'pool',
+		value: 'rbd',
+		fieldLabel: gettext('Pool'),
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		height: 22, // hack: set same height as text fields
+		name: 'monhost',
+		value: 'X.X.X.X:6789;X.X.X.X:6789;X.X.X.X:6789',
+		fieldLabel: gettext('Monitor Host'),
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		height: 22, // hack: set same height as text fields
+		name: 'username',
+		value: 'admin',
+		fieldLabel: gettext('username'),
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		height: 22, // hack: set same height as text fields
+		name: 'authsupported',
+		value: 'cephx;none',
+		fieldLabel: gettext('authsupported'),
+		allowBlank: false
+	    },
+	];
+
+	me.column2 = [
+	    {
+		xtype: 'pvecheckbox',
+		name: 'enable',
+		checked: true,
+		uncheckedValue: 0,
+		fieldLabel: gettext('Enable')
+	    },
+	];
+
+	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.RBDEdit', {
+    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.RBDInputPanel', {
+	    create: me.create,
+	    storageId: me.storageId
+	});
+
+	Ext.apply(me, {
+            subject: 'RBD 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;
+                    ipanel.setValues(values);
+                }
+            });
+        }
+    }
+});
-- 
1.7.2.5




More information about the pve-devel mailing list