]> git.apps.os.sepia.ceph.com Git - ceph.git/blob
92985516a001ca48a5882f84ddbe487a81a4f593
[ceph.git] /
1 import { Component, OnInit } from '@angular/core';
2 import { FormGroup } from '@angular/forms';
3
4 import { I18n } from '@ngx-translate/i18n-polyfill';
5 import * as _ from 'lodash';
6 import { BsModalRef } from 'ngx-bootstrap/modal';
7
8 import { OsdService } from '../../../../shared/api/osd.service';
9 import { NotificationType } from '../../../../shared/enum/notification-type.enum';
10 import { NotificationService } from '../../../../shared/services/notification.service';
11
12 @Component({
13   selector: 'cd-osd-flags-modal',
14   templateUrl: './osd-flags-modal.component.html',
15   styleUrls: ['./osd-flags-modal.component.scss']
16 })
17 export class OsdFlagsModalComponent implements OnInit {
18   osdFlagsForm = new FormGroup({});
19
20   allFlags = {
21     noin: {
22       code: 'noin',
23       name: this.i18n('No In'),
24       value: false,
25       description: this.i18n(
26         'OSDs that were previously marked out will not be marked back in when they start'
27       )
28     },
29     noout: {
30       code: 'noout',
31       name: this.i18n('No Out'),
32       value: false,
33       description: this.i18n(
34         'OSDs will not automatically be marked out after the configured interval'
35       )
36     },
37     noup: {
38       code: 'noup',
39       name: this.i18n('No Up'),
40       value: false,
41       description: this.i18n('OSDs are not allowed to start')
42     },
43     nodown: {
44       code: 'nodown',
45       name: this.i18n('No Down'),
46       value: false,
47       description: this.i18n(
48         'OSD failure reports are being ignored, such that the monitors will not mark OSDs down'
49       )
50     },
51     pause: {
52       code: 'pause',
53       name: this.i18n('Pause'),
54       value: false,
55       description: this.i18n('Pauses reads and writes')
56     },
57     noscrub: {
58       code: 'noscrub',
59       name: this.i18n('No Scrub'),
60       value: false,
61       description: this.i18n('Scrubbing is disabled')
62     },
63     'nodeep-scrub': {
64       code: 'nodeep-scrub',
65       name: this.i18n('No Deep Scrub'),
66       value: false,
67       description: this.i18n('Deep Scrubbing is disabled')
68     },
69     nobackfill: {
70       code: 'nobackfill',
71       name: this.i18n('No Backfill'),
72       value: false,
73       description: this.i18n('Backfilling of PGs is suspended')
74     },
75     norecover: {
76       code: 'norecover',
77       name: this.i18n('No Recover'),
78       value: false,
79       description: this.i18n('Recovery of PGs is suspended')
80     },
81     sortbitwise: {
82       code: 'sortbitwise',
83       name: this.i18n('Bitwise Sort'),
84       value: false,
85       description: this.i18n('Use bitwise sort'),
86       disabled: true
87     },
88     purged_snapdirs: {
89       code: 'purged_snapdirs',
90       name: this.i18n('Purged Snapdirs'),
91       value: false,
92       description: this.i18n('OSDs have converted snapsets'),
93       disabled: true
94     },
95     recovery_deletes: {
96       code: 'recovery_deletes',
97       name: this.i18n('Recovery Deletes'),
98       value: false,
99       description: this.i18n('Deletes performed during recovery instead of peering'),
100       disabled: true
101     },
102     pglog_hardlimit: {
103       code: 'pglog_hardlimit',
104       name: this.i18n('PG Log Hard Limit'),
105       value: false,
106       description: this.i18n('Puts a hard limit on pg log length'),
107       disabled: true
108     }
109   };
110   flags: any[];
111   unknownFlags: string[] = [];
112
113   constructor(
114     public bsModalRef: BsModalRef,
115     private osdService: OsdService,
116     private notificationService: NotificationService,
117     private i18n: I18n
118   ) {}
119
120   ngOnInit() {
121     this.osdService.getFlags().subscribe((res: string[]) => {
122       res.forEach((value) => {
123         if (this.allFlags[value]) {
124           this.allFlags[value].value = true;
125         } else {
126           this.unknownFlags.push(value);
127         }
128       });
129       this.flags = _.toArray(this.allFlags);
130     });
131   }
132
133   submitAction() {
134     const newFlags = this.flags
135       .filter((flag) => flag.value)
136       .map((flag) => flag.code)
137       .concat(this.unknownFlags);
138
139     this.osdService.updateFlags(newFlags).subscribe(
140       () => {
141         this.notificationService.show(NotificationType.success, this.i18n('Updated OSD Flags'));
142         this.bsModalRef.hide();
143       },
144       () => {
145         this.bsModalRef.hide();
146       }
147     );
148   }
149 }