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 Rebalance'),
83 description: this.i18n('OSD will choose not to backfill unless PG is also degraded')
87 name: this.i18n('No Recover'),
89 description: this.i18n('Recovery of PGs is suspended')
93 name: this.i18n('Bitwise Sort'),
95 description: this.i18n('Use bitwise sort'),
99 code: 'purged_snapdirs',
100 name: this.i18n('Purged Snapdirs'),
102 description: this.i18n('OSDs have converted snapsets'),
106 code: 'recovery_deletes',
107 name: this.i18n('Recovery Deletes'),
109 description: this.i18n('Deletes performed during recovery instead of peering'),
113 code: 'pglog_hardlimit',
114 name: this.i18n('PG Log Hard Limit'),
116 description: this.i18n('Puts a hard limit on pg log length'),
121 unknownFlags: string[] = [];
124 public bsModalRef: BsModalRef,
125 private authStorageService: AuthStorageService,
126 private osdService: OsdService,
127 private notificationService: NotificationService,
130 this.permissions = this.authStorageService.getPermissions();
134 this.osdService.getFlags().subscribe((res: string[]) => {
135 res.forEach((value) => {
136 if (this.allFlags[value]) {
137 this.allFlags[value].value = true;
139 this.unknownFlags.push(value);
142 this.flags = _.toArray(this.allFlags);
147 const newFlags = this.flags
148 .filter((flag) => flag.value)
149 .map((flag) => flag.code)
150 .concat(this.unknownFlags);
152 this.osdService.updateFlags(newFlags).subscribe(
154 this.notificationService.show(NotificationType.success, this.i18n('Updated OSD Flags'));
155 this.bsModalRef.hide();
158 this.bsModalRef.hide();