1 import { Component, OnInit } from '@angular/core';
2 import { FormGroup } from '@angular/forms';
4 import { I18n } from '@ngx-translate/i18n-polyfill';
5 import * as _ from 'lodash';
6 import { BsModalRef } from 'ngx-bootstrap/modal';
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';
13 selector: 'cd-osd-flags-modal',
14 templateUrl: './osd-flags-modal.component.html',
15 styleUrls: ['./osd-flags-modal.component.scss']
17 export class OsdFlagsModalComponent implements OnInit {
18 osdFlagsForm = new FormGroup({});
23 name: this.i18n('No In'),
25 description: this.i18n(
26 'OSDs that were previously marked out will not be marked back in when they start'
31 name: this.i18n('No Out'),
33 description: this.i18n(
34 'OSDs will not automatically be marked out after the configured interval'
39 name: this.i18n('No Up'),
41 description: this.i18n('OSDs are not allowed to start')
45 name: this.i18n('No Down'),
47 description: this.i18n(
48 'OSD failure reports are being ignored, such that the monitors will not mark OSDs down'
53 name: this.i18n('Pause'),
55 description: this.i18n('Pauses reads and writes')
59 name: this.i18n('No Scrub'),
61 description: this.i18n('Scrubbing is disabled')
65 name: this.i18n('No Deep Scrub'),
67 description: this.i18n('Deep Scrubbing is disabled')
71 name: this.i18n('No Backfill'),
73 description: this.i18n('Backfilling of PGs is suspended')
77 name: this.i18n('No Recover'),
79 description: this.i18n('Recovery of PGs is suspended')
83 name: this.i18n('Bitwise Sort'),
85 description: this.i18n('Use bitwise sort'),
89 code: 'purged_snapdirs',
90 name: this.i18n('Purged Snapdirs'),
92 description: this.i18n('OSDs have converted snapsets'),
96 code: 'recovery_deletes',
97 name: this.i18n('Recovery Deletes'),
99 description: this.i18n('Deletes performed during recovery instead of peering'),
103 code: 'pglog_hardlimit',
104 name: this.i18n('PG Log Hard Limit'),
106 description: this.i18n('Puts a hard limit on pg log length'),
111 unknownFlags: string[] = [];
114 public bsModalRef: BsModalRef,
115 private osdService: OsdService,
116 private notificationService: NotificationService,
121 this.osdService.getFlags().subscribe((res: string[]) => {
122 res.forEach((value) => {
123 if (this.allFlags[value]) {
124 this.allFlags[value].value = true;
126 this.unknownFlags.push(value);
129 this.flags = _.toArray(this.allFlags);
134 const newFlags = this.flags
135 .filter((flag) => flag.value)
136 .map((flag) => flag.code)
137 .concat(this.unknownFlags);
139 this.osdService.updateFlags(newFlags).subscribe(
141 this.notificationService.show(NotificationType.success, this.i18n('Updated OSD Flags'));
142 this.bsModalRef.hide();
145 this.bsModalRef.hide();