From 3c23c0258b2e3d26ee48b6fc135b8e3bb5dced83 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 5 Sep 2017 16:23:48 +0200 Subject: [PATCH] add new "RBD (PVE)" storage choice this is for adding a pve managed ceph rbd storage, so that the user just has to select the pool, and does not need to write the monitor hosts and copy the keyring the old "RBD" is renamed to "RBD (external)" Signed-off-by: Dominik Csapak --- www/manager6/Utils.js | 9 ++++- www/manager6/dc/StorageView.js | 14 ++++++- www/manager6/storage/RBDEdit.js | 70 +++++++++++++++++++++------------ 3 files changed, 65 insertions(+), 28 deletions(-) diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index fecf9aff..3874db76 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -775,7 +775,10 @@ Ext.define('PVE.Utils', { utilities: { return Ext.Date.format(date, "Y-m-d"); }, - format_storage_type: function(value) { + format_storage_type: function(value, md, record) { + if (value === 'rbd' && record && !record.get('monhost')) { + value = 'pveceph'; + } if (value === 'dir') { return PVE.Utils.directoryText; } else if (value === 'nfs') { @@ -789,7 +792,9 @@ Ext.define('PVE.Utils', { utilities: { } else if (value === 'iscsi') { return 'iSCSI'; } else if (value === 'rbd') { - return 'RBD'; + return 'RBD (external)'; + } else if (value === 'pveceph') { + return 'RBD (PVE)'; } else if (value === 'sheepdog') { return 'Sheepdog'; } else if (value === 'zfs') { diff --git a/www/manager6/dc/StorageView.js b/www/manager6/dc/StorageView.js index 2940a98f..b1334178 100644 --- a/www/manager6/dc/StorageView.js +++ b/www/manager6/dc/StorageView.js @@ -62,7 +62,8 @@ Ext.define('PVE.dc.StorageView', { return; } var win = Ext.create(editor, { - storageId: rec.data.storage + storageId: rec.data.storage, + pveceph: !rec.data.monhost }); win.show(); @@ -165,6 +166,17 @@ Ext.define('PVE.dc.StorageView', { win.show(); } }, + { + text: PVE.Utils.format_storage_type('pveceph'), + iconCls: 'fa fa-fw fa-building', + handler: function() { + var win = Ext.create('PVE.storage.RBDEdit', { + pveceph: 1 + }); + win.on('destroy', reload); + win.show(); + } + }, { text: PVE.Utils.format_storage_type('rbd'), iconCls: 'fa fa-fw fa-building', diff --git a/www/manager6/storage/RBDEdit.js b/www/manager6/storage/RBDEdit.js index 64776e6e..55ac8541 100644 --- a/www/manager6/storage/RBDEdit.js +++ b/www/manager6/storage/RBDEdit.js @@ -19,6 +19,9 @@ Ext.define('PVE.storage.RBDInputPanel', { initComponent : function() { var me = this; + if (!me.nodename) { + me.nodename = 'localhost'; + } me.column1 = [ { @@ -28,32 +31,47 @@ Ext.define('PVE.storage.RBDInputPanel', { fieldLabel: 'ID', vtype: 'StorageId', allowBlank: false - }, - { - xtype: me.isCreate ? 'textfield' : 'displayfield', - name: 'pool', - value: 'rbd', - fieldLabel: gettext('Pool'), - allowBlank: false - }, - { - xtype: me.isCreate ? 'textfield' : 'displayfield', - name: 'monhost', - vtype: 'HostList', - value: '', - fieldLabel: 'Monitor(s)', - allowBlank: false - }, - { - xtype: me.isCreate ? 'textfield' : 'displayfield', - name: 'username', - value: me.isCreate ? 'admin': '', - fieldLabel: gettext('User name'), - allowBlank: true } ]; - // here value is an array, + if (me.pveceph) { + me.column1.push( + { + xtype: me.isCreate ? 'pveCephPoolSelector' : 'displayfield', + nodename: me.nodename, + name: 'pool', + fieldLabel: gettext('Pool'), + allowBlank: false + } + ); + } else { + me.column1.push( + { + xtype: me.isCreate ? 'textfield' : 'displayfield', + name: 'pool', + value: 'rbd', + fieldLabel: gettext('Pool'), + allowBlank: false + }, + { + xtype: me.isCreate ? 'textfield' : 'displayfield', + name: 'monhost', + vtype: 'HostList', + value: '', + fieldLabel: 'Monitor(s)', + allowBlank: false + }, + { + xtype: me.isCreate ? 'textfield' : 'displayfield', + name: 'username', + value: me.isCreate ? 'admin': '', + fieldLabel: gettext('User name'), + allowBlank: true + } + ); + } + + // here value is an array, // while before it was a string /*jslint confusion: true*/ me.column2 = [ @@ -116,11 +134,13 @@ Ext.define('PVE.storage.RBDEdit', { var ipanel = Ext.create('PVE.storage.RBDInputPanel', { isCreate: me.isCreate, - storageId: me.storageId + storageId: me.storageId, + nodename: me.nodename, + pveceph: me.pveceph }); Ext.apply(me, { - subject: PVE.Utils.format_storage_type('rbd'), + subject: PVE.Utils.format_storage_type(me.pveceph?'pveceph':'rbd'), isAdd: true, items: [ ipanel ] });