]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/pg-category.model.ts
import ceph quincy 17.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / shared / pg-category.model.ts
1 export class PgCategory {
2 static readonly CATEGORY_CLEAN = 'clean';
3 static readonly CATEGORY_WORKING = 'working';
4 static readonly CATEGORY_WARNING = 'warning';
5 static readonly CATEGORY_UNKNOWN = 'unknown';
6 static readonly VALID_CATEGORIES = [
7 PgCategory.CATEGORY_CLEAN,
8 PgCategory.CATEGORY_WORKING,
9 PgCategory.CATEGORY_WARNING,
10 PgCategory.CATEGORY_UNKNOWN
11 ];
12
13 states: string[];
14
15 constructor(public type: string) {
16 if (!this.isValidType()) {
17 throw new Error('Wrong placement group category type');
18 }
19
20 this.setTypeStates();
21 }
22
23 private isValidType() {
24 return PgCategory.VALID_CATEGORIES.includes(this.type);
25 }
26
27 private setTypeStates() {
28 switch (this.type) {
29 case PgCategory.CATEGORY_CLEAN:
30 this.states = ['active', 'clean'];
31 break;
32 case PgCategory.CATEGORY_WORKING:
33 this.states = [
34 'activating',
35 'backfill_wait',
36 'backfilling',
37 'creating',
38 'deep',
39 'degraded',
40 'forced_backfill',
41 'forced_recovery',
42 'peering',
43 'peered',
44 'recovering',
45 'recovery_wait',
46 'repair',
47 'scrubbing',
48 'snaptrim',
49 'snaptrim_wait'
50 ];
51 break;
52 case PgCategory.CATEGORY_WARNING:
53 this.states = [
54 'backfill_toofull',
55 'backfill_unfound',
56 'down',
57 'incomplete',
58 'inconsistent',
59 'recovery_toofull',
60 'recovery_unfound',
61 'remapped',
62 'snaptrim_error',
63 'stale',
64 'undersized'
65 ];
66 break;
67 default:
68 this.states = [];
69 }
70 }
71 }