[pve-devel] [PATCH v5 manager 5/5] added basic ability to install ceph via gui
Tim Marx
t.marx at proxmox.com
Fri Feb 8 12:17:03 CET 2019
Signed-off-by: Tim Marx <t.marx at proxmox.com>
---
changes since v4:
* added window to all submenus
* changed ceph window component to viewmodel approach
* added css class to style install window
* added check to avoid adding multiple window to same component
www/css/ext6-pve.css | 5 +++
www/manager6/Makefile | 2 ++
www/manager6/Utils.js | 29 ++++++++++++++++
www/manager6/ceph/Config.js | 13 +++++++
www/manager6/ceph/Crush.js | 12 +++++++
www/manager6/ceph/FS.js | 36 ++++++++++++++++++--
www/manager6/ceph/Log.js | 70 ++++++++++++++++++++++++++++++++++++++
www/manager6/ceph/Monitor.js | 16 ++++++++-
www/manager6/ceph/OSD.js | 19 ++++++++++-
www/manager6/ceph/Pool.js | 15 +++++++-
www/manager6/ceph/Status.js | 18 +++++++++-
www/manager6/node/Config.js | 5 +--
www/manager6/window/CephInstall.js | 57 +++++++++++++++++++++++++++++++
13 files changed, 289 insertions(+), 8 deletions(-)
create mode 100644 www/manager6/ceph/Log.js
create mode 100644 www/manager6/window/CephInstall.js
diff --git a/www/css/ext6-pve.css b/www/css/ext6-pve.css
index a7edbfd9..df9a97c5 100644
--- a/www/css/ext6-pve.css
+++ b/www/css/ext6-pve.css
@@ -574,3 +574,8 @@ table.osds td:first-of-type {
right: 0px;
background-color: #555;
}
+
+.install-mask {
+ background-color: rgb(245, 245, 245);
+ color: #000;
+}
\ No newline at end of file
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index e75f0de6..394c0ae5 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -83,6 +83,7 @@ JSSRC= \
window/BackupConfig.js \
window/Settings.js \
window/StartupEdit.js \
+ window/CephInstall.js \
panel/NotesView.js \
grid/ResourceGrid.js \
grid/PoolMembers.js \
@@ -101,6 +102,7 @@ JSSRC= \
ceph/Status.js \
ceph/StatusDetail.js \
ceph/Config.js \
+ ceph/Log.js \
node/Disks.js \
node/LVM.js \
node/LVMThin.js \
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index e96760a1..268f3f9f 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1089,6 +1089,35 @@ Ext.define('PVE.Utils', { utilities: {
return;
}
}
+ },
+
+ handleStoreErrorOrMask: function(me, store, regex, callback) {
+
+ if(!(store.proxy instanceof Proxmox.RestProxy)) throw "Proxy must implement afterload event!";
+
+ me.mon(store.proxy, 'afterload', function (proxy, request, success) {
+
+ if (success) {
+ Proxmox.Utils.setErrorMask(me, false);
+ return;
+ }
+ var msg;
+ /*jslint nomen: true */
+ var operation = request._operation;
+ var error = operation.getError();
+
+ if (error.statusText) {
+ if (error.statusText.match(regex)) {
+ callback(me, error);
+ return;
+ } else {
+ msg = error.statusText + ' (' + error.status + ')';
+ }
+ } else {
+ msg = gettext('Connection error');
+ }
+ Proxmox.Utils.setErrorMask(me, msg);
+ });
}
},
diff --git a/www/manager6/ceph/Config.js b/www/manager6/ceph/Config.js
index 04124684..ef3511bf 100644
--- a/www/manager6/ceph/Config.js
+++ b/www/manager6/ceph/Config.js
@@ -14,6 +14,19 @@ Ext.define('PVE.node.CephConfig', {
waitMsgTarget: me,
failure: function(response, opts) {
me.update(gettext('Error') + " " + response.htmlStatus);
+ if (Proxmox.UserName === 'root at pam') {
+ me.ownerCt.el.mask();
+
+ if (!me.ownerCt.down('pveCephInstallWindow')){
+ var win = Ext.create('PVE.ceph.Install', {
+ nodename: me.pveSelNode.data.node,
+ });
+ me.ownerCt.add(win);
+ win.show();
+ }
+ } else {
+ me.ownerCt.mask(Ext.String.format(gettext('{0} not installed.') + gettext(' Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
+ }
},
success: function(response, opts) {
var data = response.result.data;
diff --git a/www/manager6/ceph/Crush.js b/www/manager6/ceph/Crush.js
index ebd46c83..7ed3cc02 100644
--- a/www/manager6/ceph/Crush.js
+++ b/www/manager6/ceph/Crush.js
@@ -15,6 +15,18 @@ Ext.define('PVE.node.CephCrushMap', {
waitMsgTarget: me,
failure: function(response, opts) {
me.update(gettext('Error') + " " + response.htmlStatus);
+ if (Proxmox.UserName === 'root at pam') {
+ me.ownerCt.el.mask();
+ if (!me.ownerCt.down('pveCephInstallWindow')){
+ var win = Ext.create('PVE.ceph.Install', {
+ nodename: me.pveSelNode.data.node,
+ });
+ me.ownerCt.add(win);
+ win.show();
+ }
+ } else {
+ me.ownerCt.mask(Ext.String.format(gettext('{0} not installed.') + gettext(' Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
+ }
},
success: function(response, opts) {
var data = response.result.data;
diff --git a/www/manager6/ceph/FS.js b/www/manager6/ceph/FS.js
index a1c34d73..470f591a 100644
--- a/www/manager6/ceph/FS.js
+++ b/www/manager6/ceph/FS.js
@@ -161,7 +161,23 @@ Ext.define('PVE.NodeCephFSPanel', {
order: 'DESC'
}
}));
- Proxmox.Utils.monStoreErrors(view, view.rstore);
+ var regex = new RegExp("not installed", "i");
+ PVE.Utils.handleStoreErrorOrMask(view, view.rstore, regex, function(me, error){
+ me.rstore.stopUpdate();
+ if (Proxmox.UserName === 'root at pam') {
+ me.ownerCt.el.mask();
+
+ if (!me.ownerCt.down('pveCephInstallWindow')){
+ var win = Ext.create('PVE.ceph.Install', {
+ nodename: view.nodename,
+ });
+ me.ownerCt.add(win);
+ win.show();
+ }
+ } else {
+ me.ownerCt.mask(Ext.String.format(gettext('{0} not installed.') + gettext(' Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
+ }
+ });
view.rstore.on('load', this.onLoad, this);
view.on('destroy', view.rstore.stopUpdate);
},
@@ -244,7 +260,23 @@ Ext.define('PVE.NodeCephFSPanel', {
order: 'DESC'
}
}));
- Proxmox.Utils.monStoreErrors(view, view.rstore);
+ var regex = new RegExp("not installed", "i");
+ PVE.Utils.handleStoreErrorOrMask(view, view.rstore, regex, function(me, error){
+ me.rstore.stopUpdate();
+ if (Proxmox.UserName === 'root at pam') {
+ me.ownerCt.el.mask();
+
+ if (!me.ownerCt.down('pveCephInstallWindow')){
+ var win = Ext.create('PVE.ceph.Install', {
+ nodename: view.nodename,
+ });
+ me.ownerCt.add(win);
+ win.show();
+ }
+ } else {
+ me.ownerCt.mask(Ext.String.format(gettext('{0} not installed.') + gettext(' Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
+ }
+ });
view.rstore.on('load', this.onLoad, this);
view.on('destroy', view.rstore.stopUpdate);
},
diff --git a/www/manager6/ceph/Log.js b/www/manager6/ceph/Log.js
new file mode 100644
index 00000000..0dcd4fe0
--- /dev/null
+++ b/www/manager6/ceph/Log.js
@@ -0,0 +1,70 @@
+Ext.define('PVE.ceph.Log', {
+ extend: 'Proxmox.panel.LogView',
+ xtype: 'cephLogView',
+ nodename: undefined,
+ doAttemptLoad: function(start) {
+ var me = this;
+
+ var req_params = {
+ start: start,
+ limit: me.pageSize
+ };
+
+ if (me.log_select_timespan) {
+ // always show log until the end of the selected day
+ req_params.until = Ext.Date.format(me.until_date, 'Y-m-d') + ' 23:59:59';
+ req_params.since = Ext.Date.format(me.since_date, 'Y-m-d');
+ }
+
+ Proxmox.Utils.API2Request({
+ url: me.url,
+ params: req_params,
+ method: 'GET',
+ success: function(response) {
+ Proxmox.Utils.setErrorMask(me, false);
+ var list = response.result.data;
+ var total = response.result.total;
+ var first = 0, last = 0;
+ var text = '';
+ Ext.Array.each(list, function(item) {
+ if (!first|| item.n < first) {
+ first = item.n;
+ }
+ if (!last || item.n > last) {
+ last = item.n;
+ }
+ text = text + Ext.htmlEncode(item.t) + "<br>";
+ });
+
+ if (first && last && total) {
+ me.updateView(first -1 , last -1, total, text);
+ } else {
+ me.updateView(0, 0, 0, '');
+ }
+ },
+ failure: function(response) {
+ var msg = response.htmlStatus;
+ var regex = new RegExp("not installed", "i");
+ if (msg.match(regex)) {
+ if (Proxmox.UserName === 'root at pam') {
+ me.el.mask();
+
+ if (!me.down('pveCephInstallWindow')){
+ var win = Ext.create('PVE.ceph.Install', {
+ nodename: me.nodename,
+ });
+ me.add(win);
+ win.show();
+ }
+
+ } else {
+ me.mask(Ext.String.format(gettext('{0} not installed.') + gettext(' Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
+ }
+
+ } else {
+ Proxmox.Utils.setErrorMask(me, msg);
+ }
+ }
+ });
+ }
+});
\ No newline at end of file
diff --git a/www/manager6/ceph/Monitor.js b/www/manager6/ceph/Monitor.js
index a3a18a83..b09e8c43 100644
--- a/www/manager6/ceph/Monitor.js
+++ b/www/manager6/ceph/Monitor.js
@@ -82,7 +82,6 @@ Ext.define('PVE.node.CephMonList', {
sorters: [{ property: 'name'}]
});
- Proxmox.Utils.monStoreErrors(me, rstore);
var service_cmd = function(cmd) {
var rec = sm.getSelection()[0];
@@ -211,6 +210,21 @@ Ext.define('PVE.node.CephMonList', {
}
});
+ var regex = new RegExp("not installed", "i");
+ PVE.Utils.handleStoreErrorOrMask(me, rstore, regex, function(me, error){
+ me.store.rstore.stopUpdate();
+ if (Proxmox.UserName === 'root at pam') {
+ me.el.mask();
+ var win = Ext.create('PVE.ceph.Install', {
+ nodename: nodename,
+ });
+ me.add(win);
+ win.show();
+ } else {
+ me.el.mask(Ext.String.format(gettext('{0} not installed.') + gettext(' Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
+ }
+ });
+
me.callParent();
}
}, function() {
diff --git a/www/manager6/ceph/OSD.js b/www/manager6/ceph/OSD.js
index 144fab7e..85ec56b3 100644
--- a/www/manager6/ceph/OSD.js
+++ b/www/manager6/ceph/OSD.js
@@ -281,7 +281,24 @@ Ext.define('PVE.node.CephOsdTree', {
waitMsgTarget: me,
method: 'GET',
failure: function(response, opts) {
- Proxmox.Utils.setErrorMask(me, response.htmlStatus);
+ var msg = response.htmlStatus;
+ var regex = new RegExp("not installed", "i");
+ if (msg.match(regex)) {
+ if (Proxmox.UserName === 'root at pam') {
+ me.el.mask();
+ if (!me.down('pveCephInstallWindow')){
+ var win = Ext.create('PVE.ceph.Install', {
+ nodename: me.pveSelNode.data.node,
+ });
+ me.add(win);
+ win.show();
+ }
+ } else {
+ me.mask(Ext.String.format(gettext('{0} not installed.') + gettext(' Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
+ }
+ } else {
+ Proxmox.Utils.setErrorMask(me, msg);
+ }
},
success: function(response, opts) {
sm.deselectAll();
diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js
index 27eba024..6c70aead 100644
--- a/www/manager6/ceph/Pool.js
+++ b/www/manager6/ceph/Pool.js
@@ -164,7 +164,20 @@ Ext.define('PVE.node.CephPoolList', {
var store = Ext.create('Proxmox.data.DiffStore', { rstore: rstore });
- Proxmox.Utils.monStoreErrors(me, rstore);
+ var regex = new RegExp("not installed", "i");
+ PVE.Utils.handleStoreErrorOrMask(me, rstore, regex, function(me, error){
+ me.store.rstore.stopUpdate();
+ if (Proxmox.UserName === 'root at pam') {
+ me.el.mask();
+ var win = Ext.create('PVE.ceph.Install', {
+ nodename: nodename,
+ });
+ me.add(win);
+ win.show();
+ } else {
+ me.el.mask(Ext.String.format(gettext('{0} not installed.') + gettext(' Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
+ }
+ });
var create_btn = new Ext.Button({
text: gettext('Create'),
diff --git a/www/manager6/ceph/Status.js b/www/manager6/ceph/Status.js
index 78fa1cf8..f4805409 100644
--- a/www/manager6/ceph/Status.js
+++ b/www/manager6/ceph/Status.js
@@ -308,7 +308,23 @@ Ext.define('PVE.node.CephStatus', {
me.version = me.sp.get('ceph-version');
me.change_version(me.version);
- Proxmox.Utils.monStoreErrors(me,me.store);
+ var regex = new RegExp("not installed", "i");
+ PVE.Utils.handleStoreErrorOrMask(me, me.store, regex, function(me, error){
+ me.store.stopUpdate();
+ if (Proxmox.UserName === 'root at pam') {
+ me.el.mask();
+ if (!me.down('PVE.ceph.Install')){
+ var win = Ext.create('PVE.ceph.Install', {
+ nodename: nodename
+ });
+ me.add(win);
+ win.show();
+ }
+ } else {
+ me.el.mask(Ext.String.format(gettext('{0} not installed.') + gettext(' Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
+ }
+ });
+
me.mon(me.store, 'load', me.updateAll, me);
me.on('destroy', me.store.stopUpdate);
me.store.startUpdate();
diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
index f9a62670..831d2e02 100644
--- a/www/manager6/node/Config.js
+++ b/www/manager6/node/Config.js
@@ -375,8 +375,9 @@ Ext.define('PVE.node.Config', {
iconCls: 'fa fa-list',
groups: ['ceph'],
onlineHelp: 'chapter_pveceph',
- xtype: 'proxmoxLogView',
- url: "/api2/extjs/nodes/" + nodename + "/ceph/log"
+ xtype: 'cephLogView',
+ url: "/api2/extjs/nodes/" + nodename + "/ceph/log",
+ nodename: nodename
});
}
diff --git a/www/manager6/window/CephInstall.js b/www/manager6/window/CephInstall.js
new file mode 100644
index 00000000..9a74d6d4
--- /dev/null
+++ b/www/manager6/window/CephInstall.js
@@ -0,0 +1,57 @@
+/*jslint confusion: true*/
+Ext.define('PVE.ceph.Install', {
+ extend: 'Ext.window.Window',
+ xtype: 'pveCephInstallWindow',
+ mixins: ['Proxmox.Mixin.CBind'],
+
+ width: 220,
+ header: false,
+ resizable: false,
+ draggable: false,
+ modal: true,
+ nodename: undefined,
+ shadow: false,
+ border: false,
+ bodyBorder: false,
+ closable: false,
+ cls: 'install-mask',
+ bodyCls: 'install-mask',
+ layout: {
+ align: 'stretch',
+ pack: 'center',
+ type: 'vbox'
+ },
+ viewModel: {
+ parent: null,
+ data: {
+ cephVersion: 'luminous'
+ },
+ formulas: {
+ buttonText: function (get){
+ return gettext('Install Ceph-') + get('cephVersion');
+ }
+ }
+ },
+ items: [
+ {
+ html: '<p class="install-mask">' + Ext.String.format(gettext('{0} is not installed on this node.'), 'Ceph') + '<br>' +
+ gettext('Would you like to install it now?') + '</p>',
+ border: false,
+ padding: 5,
+ bodyCls: 'install-mask'
+
+ },
+ {
+ xtype: 'pveConsoleButton',
+ disabled: Proxmox.UserName !== 'root at pam',
+ consoleType: 'cmd',
+ bind: {
+ text: '{buttonText}'
+ },
+ cmd: "ceph_install",
+ cbind: {
+ nodename: '{nodename}'
+ }
+ }
+ ]
+});
--
2.11.0
More information about the pve-devel
mailing list