Ext.define('PVE.CephCreateService', {
extend: 'Proxmox.window.Edit',
+ mixins: ['Proxmox.Mixin.CBind'],
xtype: 'pveCephCreateService',
+ method: 'POST',
+ isCreate: true,
showProgress: true,
+ width: 450,
- setNode: function(nodename) {
+ setNode: function(node) {
let me = this;
- me.nodename = nodename;
- me.url = `/nodes/${nodename}/ceph/${me.type}/${nodename}`;
+ me.nodename = node;
+ me.updateUrl();
},
+ setExtraID: function(extraID) {
+ let me = this;
+ me.extraID = me.type === 'mds' ? `-${extraID}` : '';
+ me.updateUrl();
+ },
+ updateUrl: function() {
+ let me = this;
- method: 'POST',
- isCreate: true,
+ let extraID = me.extraID ?? '';
+ let node = me.nodename;
+
+ me.url = `/nodes/${node}/ceph/${me.type}/${node}${extraID}`;
+ },
+ defaults: {
+ labelWidth: 75,
+ },
items: [
{
xtype: 'pveNodeSelector',
- submitValue: false,
fieldLabel: gettext('Host'),
selectCurNode: true,
allowBlank: false,
+ submitValue: false,
listeners: {
change: function(f, value) {
let view = this.up('pveCephCreateService');
},
},
},
+ {
+ xtype: 'textfield',
+ fieldLabel: gettext('Extra ID'),
+ regex: /[a-zA-Z0-9]+/,
+ regexText: gettext('ID may only consist of alphanumeric characters'),
+ submitValue: false,
+ emptyText: Proxmox.Utils.NoneText,
+ cbind: {
+ disabled: get => get('type') !== 'mds',
+ hidden: get => get('type') !== 'mds',
+ },
+ listeners: {
+ change: function(f, value) {
+ let view = this.up('pveCephCreateService');
+ view.setExtraID(value);
+ },
+ },
+ },
+ {
+ xtype: 'component',
+ border: false,
+ padding: '5 2',
+ style: {
+ fontSize: '12px',
+ },
+ userCls: 'pmx-hint',
+ cbind: {
+ hidden: get => get('type') !== 'mds',
+ },
+ html: gettext('The Extra ID allows creating multiple MDS per node, which increases redundancy with more than one CephFS.'),
+ },
],
initComponent: function() {
Ext.Msg.alert(gettext('Error'), "entry has no host");
return;
}
- Proxmox.Utils.API2Request({
- url: `/nodes/${rec.data.host}/ceph/${cmd}`,
- method: 'POST',
- params: { service: view.type + '.' + rec.data.name },
- success: function(response, options) {
- Ext.create('Proxmox.window.TaskProgress', {
- autoShow: true,
- upid: response.result.data,
- taskDone: () => view.rstore.load(),
- });
- },
- failure: (response, _opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
- });
+ let doRequest = function() {
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${rec.data.host}/ceph/${cmd}`,
+ method: 'POST',
+ params: { service: view.type + '.' + rec.data.name },
+ success: function(response, options) {
+ Ext.create('Proxmox.window.TaskProgress', {
+ autoShow: true,
+ upid: response.result.data,
+ taskDone: () => view.rstore.load(),
+ });
+ },
+ failure: (response, _opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+ });
+ };
+ if (cmd === "stop" && ['mon', 'mds'].includes(view.type)) {
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${rec.data.host}/ceph/cmd-safety`,
+ params: {
+ service: view.type,
+ id: rec.data.name,
+ action: 'stop',
+ },
+ method: 'GET',
+ success: function({ result: { data } }) {
+ let stopText = {
+ mon: gettext('Stop MON'),
+ mds: gettext('Stop MDS'),
+ };
+ if (!data.safe) {
+ Ext.Msg.show({
+ title: gettext('Warning'),
+ message: data.status,
+ icon: Ext.Msg.WARNING,
+ buttons: Ext.Msg.OKCANCEL,
+ buttonText: { ok: stopText[view.type] },
+ fn: function(selection) {
+ if (selection === 'ok') {
+ doRequest();
+ }
+ },
+ });
+ } else {
+ doRequest();
+ }
+ },
+ failure: (response, _opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+ });
+ } else {
+ doRequest();
+ }
},
onChangeService: function(button) {
let me = this;
taskDone: () => view.rstore.load(),
});
},
+ handler: function(btn, event, rec) {
+ let me = this;
+ let view = me.up('grid');
+ let doRequest = function() {
+ Proxmox.button.StdRemoveButton.prototype.handler.call(me, btn, event, rec);
+ };
+ if (view.type === 'mon') {
+ Proxmox.Utils.API2Request({
+ url: `/nodes/${rec.data.host}/ceph/cmd-safety`,
+ params: {
+ service: view.type,
+ id: rec.data.name,
+ action: 'destroy',
+ },
+ method: 'GET',
+ success: function({ result: { data } }) {
+ if (!data.safe) {
+ Ext.Msg.show({
+ title: gettext('Warning'),
+ message: data.status,
+ icon: Ext.Msg.WARNING,
+ buttons: Ext.Msg.OKCANCEL,
+ buttonText: { ok: gettext('Destroy MON') },
+ fn: function(selection) {
+ if (selection === 'ok') {
+ doRequest();
+ }
+ },
+ });
+ } else {
+ doRequest();
+ }
+ },
+ failure: (response, _opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+ });
+ } else {
+ doRequest();
+ }
+ },
+
},
'-',
{
});
});
+Ext.define('PVE.node.CephMDSServiceController', {
+ extend: 'PVE.node.CephServiceController',
+ alias: 'controller.CephServiceMDSList',
+
+ render_status: (value, mD, rec) => rec.data.fs_name ? `${value} (${rec.data.fs_name})` : value,
+});
+
Ext.define('PVE.node.CephMDSList', {
extend: 'PVE.node.CephServiceList',
xtype: 'pveNodeCephMDSList',
controller: {
- type: 'CephServiceList',
- render_status: (value, mD, rec) => rec.data.fs_name ? `${value} (${rec.data.fs_name})` : value,
+ type: 'CephServiceMDSList',
},
});