]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/ceph/Services.js
1 Ext
.define('PVE.ceph.Services', {
2 extend
: 'Ext.panel.Panel',
3 alias
: 'widget.pveCephServices',
10 bodyPadding
: '0 5 20',
21 xtype
: 'pveCephServiceList',
23 title
: gettext('Monitors')
27 xtype
: 'pveCephServiceList',
29 title
: gettext('Managers')
33 xtype
: 'pveCephServiceList',
35 title
: gettext('Meta Data Servers')
39 updateAll: function(metadata
, status
) {
58 var reduceFn = function(first
, second
) {
59 return first
+ '\n' + second
.message
;
61 var services
= ['mon','mgr','mds'];
62 var maxversion
= "00.0.00";
63 Object
.values(metadata
.version
|| {}).forEach(function(version
) {
64 if (PVE
.Utils
.compare_ceph_versions(version
, maxversion
) > 0) {
69 var quorummap
= (status
&& status
.quorum_names
) ? status
.quorum_names
: [];
75 Ext
.Object
.each(status
.health
.checks
, function(key
, value
, obj
) {
76 if (!Ext
.String
.startsWith(key
, "MON_")) {
81 for (i
= 0; i
< value
.detail
.length
; i
++) {
82 var match
= value
.detail
[i
].message
.match(/mon.([a-zA-Z0-9\-\.]+)/);
88 if (!monmessages
[monid
]) {
89 monmessages
[monid
] = {
90 worstSeverity
: healthstates
.HEALTH_OK
,
96 monmessages
[monid
].messages
.push(
97 PVE
.Utils
.get_ceph_icon_html(value
.severity
, true) +
98 Ext
.Array
.reduce(value
.detail
, reduceFn
, '')
100 if (healthstates
[value
.severity
] < monmessages
[monid
].worstSeverity
) {
101 monmessages
[monid
].worstSeverity
= healthstates
[value
.severity
];
108 mgrmessages
[status
.mgrmap
.active_name
] = "active";
109 status
.mgrmap
.standbys
.forEach(function(mgr
) {
110 mgrmessages
[mgr
.name
] = "standby";
115 status
.fsmap
.by_rank
.forEach(function(mds
) {
116 mdsmessages
[mds
.name
] = 'rank: ' + mds
.rank
+ "; " + mds
.status
;
123 if (quorummap
.indexOf(mon
.name
) !== -1) {
124 mon
.health
= healthstates
.HEALTH_OK
;
126 mon
.health
= healthstates
.HEALTH_ERR
;
128 if (monmessages
[mon
.name
]) {
129 if (monmessages
[mon
.name
].worstSeverity
< mon
.health
) {
130 mon
.health
= monmessages
[mon
.name
].worstSeverity
;
132 Array
.prototype.push
.apply(mon
.messages
, monmessages
[mon
.name
].messages
);
137 if (mgrmessages
[mgr
.name
] === 'active') {
138 mgr
.title
= '<b>' + mgr
.title
+ '</b>';
139 mgr
.statuses
.push(gettext('Status') + ': <b>active</b>');
140 } else if (mgrmessages
[mgr
.name
] === 'standby') {
141 mgr
.statuses
.push(gettext('Status') + ': standby');
142 } else if (mgr
.health
> healthstates
.HEALTH_WARN
) {
143 mgr
.health
= healthstates
.HEALTH_WARN
;
149 if (mdsmessages
[mds
.name
]) {
150 mds
.title
= '<b>' + mds
.title
+ '</b>';
151 mds
.statuses
.push(gettext('Status') + ': <b>' + mdsmessages
[mds
.name
]+"</b>");
152 } else if (mds
.addr
!== Proxmox
.Utils
.unknownText
) {
153 mds
.statuses
.push(gettext('Status') + ': standby');
160 for (i
= 0; i
< services
.length
; i
++) {
161 var type
= services
[i
];
162 var ids
= Object
.keys(metadata
[type
] || {});
166 for (j
= 0; j
< ids
.length
; j
++) {
168 var tmp
= id
.split('@');
173 health
: healthstates
.HEALTH_OK
,
177 title
: metadata
[type
][id
].name
|| name
,
179 version
: PVE
.Utils
.parse_ceph_version(metadata
[type
][id
]),
180 service
: metadata
[type
][id
].service
,
181 addr
: metadata
[type
][id
].addr
|| metadata
[type
][id
].addrs
|| Proxmox
.Utils
.unknownText
185 gettext('Host') + ": " + result
.host
,
186 gettext('Address') + ": " + result
.addr
190 result
= checks
[type
](result
);
193 if (result
.service
&& !result
.version
) {
194 result
.messages
.push(
195 PVE
.Utils
.get_ceph_icon_html('HEALTH_UNKNOWN', true) +
198 result
.health
= healthstates
.HEALTH_UNKNOWN
;
201 if (!result
.version
&& result
.addr
=== Proxmox
.Utils
.unknownText
) {
202 result
.health
= healthstates
.HEALTH_UNKNOWN
;
205 if (result
.version
) {
206 result
.statuses
.push(gettext('Version') + ": " + result
.version
);
208 if (result
.version
!= maxversion
) {
209 if (result
.health
> healthstates
.HEALTH_OLD
) {
210 result
.health
= healthstates
.HEALTH_OLD
;
212 result
.messages
.push(
213 PVE
.Utils
.get_ceph_icon_html('HEALTH_OLD', true) +
214 gettext('Not Current Version, please upgrade')
219 result
.statuses
.push(''); // empty line
220 result
.text
= result
.statuses
.concat(result
.messages
).join('<br>');
222 result
.health
= healthmap
[result
.health
];
224 me
[type
][id
] = result
;
228 me
.getComponent('mons').updateAll(Object
.values(me
.mon
));
229 me
.getComponent('mgrs').updateAll(Object
.values(me
.mgr
));
230 me
.getComponent('mdss').updateAll(Object
.values(me
.mds
));
234 Ext
.define('PVE.ceph.ServiceList', {
235 extend
: 'Ext.container.Container',
236 xtype
: 'pveCephServiceList',
239 'text-align':'center'
244 'text-align':'center'
254 tpl
: '<h3>{title}</h3>'
258 updateAll: function(list
) {
260 me
.suspendLayout
= true;
263 list
.sort(function(a
,b
) {
264 return a
.id
> b
.id
? 1 : a
.id
< b
.id
? -1 : 0;
268 me
.ids
.forEach(function(id
) {
272 for (i
= 0; i
< list
.length
; i
++) {
273 var service
= me
.getComponent(list
[i
].id
);
275 // since services are already sorted, and
276 // we always have a sorted list
277 // we can add it at the service+1 position (because of the title)
278 service
= me
.insert(i
+1, {
279 xtype
: 'pveCephServiceWidget',
285 me
.ids
.push(list
[i
].id
);
287 delete ids
[list
[i
].id
];
289 service
.updateService(list
[i
].title
, list
[i
].text
, list
[i
].health
);
292 Object
.keys(ids
).forEach(function(id
) {
295 me
.suspendLayout
= false;
299 initComponent: function() {
302 me
.getComponent('title').update({
308 /*jslint confusion: true*/
309 Ext
.define('PVE.ceph.ServiceWidget', {
310 extend
: 'Ext.Component',
311 alias
: 'widget.pveCephServiceWidget',
313 userCls
: 'monitor inline-block',
316 health
: 'HEALTH_ERR',
318 iconCls
: PVE
.Utils
.get_health_icon()
323 '<i class="fa fa-fw {iconCls}"></i>'
326 updateService: function(title
, text
, health
) {
329 me
.update(Ext
.apply(me
.data
, {
333 iconCls
: PVE
.Utils
.get_health_icon(PVE
.Utils
.map_ceph_health
[health
])
337 me
.tooltip
.setHtml(text
);
342 destroy: function() {
345 me
.tooltip
.destroy();
351 fn: function(events
, element
) {
352 var me
= this.component
;
357 me
.tooltip
= Ext
.create('Ext.tip.ToolTip', {
361 renderTo
: Ext
.getBody(),
370 fn: function(events
, element
) {
371 var me
= this.component
;
373 me
.tooltip
.destroy();