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 { Permissions } from '../../../../shared/models/permissions';
11 import { AuthStorageService } from '../../../../shared/services/auth-storage.service';
12 import { NotificationService } from '../../../../shared/services/notification.service';
15 selector: 'cd-osd-flags-modal',
16 templateUrl: './osd-flags-modal.component.html',
17 styleUrls: ['./osd-flags-modal.component.scss']
19 export class OsdFlagsModalComponent implements OnInit {
20 permissions: Permissions;
22 osdFlagsForm = new FormGroup({});
27 name: this.i18n('No In'),
29 description: this.i18n(
30 'OSDs that were previously marked out will not be marked back in when they start'
35 name: this.i18n('No Out'),
37 description: this.i18n(
38 'OSDs will not automatically be marked out after the configured interval'
43 name: this.i18n('No Up'),
45 description: this.i18n('OSDs are not allowed to start')
49 name: this.i18n('No Down'),
51 description: this.i18n(
52 'OSD failure reports are being ignored, such that the monitors will not mark OSDs down'
57 name: this.i18n('Pause'),
59 description: this.i18n('Pauses reads and writes')
63 name: this.i18n('No Scrub'),
65 description: this.i18n('Scrubbing is disabled')
69 name: this.i18n('No Deep Scrub'),
71 description: this.i18n('Deep Scrubbing is disabled')
75 name: this.i18n('No Backfill'),
77 description: this.i18n('Backfilling of PGs is suspended')
81 name: this.i18n('No Recover'),
83 description: this.i18n('Recovery of PGs is suspended')
87 name: this.i18n('Bitwise Sort'),
89 description: this.i18n('Use bitwise sort'),
93 code: 'purged_snapdirs',
94 name: this.i18n('Purged Snapdirs'),
96 description: this.i18n('OSDs have converted snapsets'),
100 code: 'recovery_deletes',
101 name: this.i18n('Recovery Deletes'),
103 description: this.i18n('Deletes performed during recovery instead of peering'),
107 code: 'pglog_hardlimit',
108 name: this.i18n('PG Log Hard Limit'),
110 description: this.i18n('Puts a hard limit on pg log length'),
115 unknownFlags: string[] = [];
118 public bsModalRef: BsModalRef,
119 private authStorageService: AuthStorageService,
120 private osdService: OsdService,
121 private notificationService: NotificationService,
124 this.permissions = this.authStorageService.getPermissions();
128 this.osdService.getFlags().subscribe((res: string[]) => {
129 res.forEach((value) => {
130 if (this.allFlags[value]) {
131 this.allFlags[value].value = true;
133 this.unknownFlags.push(value);
136 this.flags = _.toArray(this.allFlags);
141 const newFlags = this.flags
142 .filter((flag) => flag.value)
143 .map((flag) => flag.code)
144 .concat(this.unknownFlags);
146 this.osdService.updateFlags(newFlags).subscribe(
148 this.notificationService.show(NotificationType.success, this.i18n('Updated OSD Flags'));
149 this.bsModalRef.hide();
152 this.bsModalRef.hide();