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