]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-flags-modal/osd-flags-modal.component.ts
import ceph nautilus 14.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / osd / osd-flags-modal / osd-flags-modal.component.ts
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 { Permissions } from '../../../../shared/models/permissions';
11 import { AuthStorageService } from '../../../../shared/services/auth-storage.service';
12 import { NotificationService } from '../../../../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: this.i18n('No In'),
28 value: false,
29 description: this.i18n(
30 'OSDs that were previously marked out will not be marked back in when they start'
31 )
32 },
33 noout: {
34 code: 'noout',
35 name: this.i18n('No Out'),
36 value: false,
37 description: this.i18n(
38 'OSDs will not automatically be marked out after the configured interval'
39 )
40 },
41 noup: {
42 code: 'noup',
43 name: this.i18n('No Up'),
44 value: false,
45 description: this.i18n('OSDs are not allowed to start')
46 },
47 nodown: {
48 code: 'nodown',
49 name: this.i18n('No Down'),
50 value: false,
51 description: this.i18n(
52 'OSD failure reports are being ignored, such that the monitors will not mark OSDs down'
53 )
54 },
55 pause: {
56 code: 'pause',
57 name: this.i18n('Pause'),
58 value: false,
59 description: this.i18n('Pauses reads and writes')
60 },
61 noscrub: {
62 code: 'noscrub',
63 name: this.i18n('No Scrub'),
64 value: false,
65 description: this.i18n('Scrubbing is disabled')
66 },
67 'nodeep-scrub': {
68 code: 'nodeep-scrub',
69 name: this.i18n('No Deep Scrub'),
70 value: false,
71 description: this.i18n('Deep Scrubbing is disabled')
72 },
73 nobackfill: {
74 code: 'nobackfill',
75 name: this.i18n('No Backfill'),
76 value: false,
77 description: this.i18n('Backfilling of PGs is suspended')
78 },
79 norecover: {
80 code: 'norecover',
81 name: this.i18n('No Recover'),
82 value: false,
83 description: this.i18n('Recovery of PGs is suspended')
84 },
85 sortbitwise: {
86 code: 'sortbitwise',
87 name: this.i18n('Bitwise Sort'),
88 value: false,
89 description: this.i18n('Use bitwise sort'),
90 disabled: true
91 },
92 purged_snapdirs: {
93 code: 'purged_snapdirs',
94 name: this.i18n('Purged Snapdirs'),
95 value: false,
96 description: this.i18n('OSDs have converted snapsets'),
97 disabled: true
98 },
99 recovery_deletes: {
100 code: 'recovery_deletes',
101 name: this.i18n('Recovery Deletes'),
102 value: false,
103 description: this.i18n('Deletes performed during recovery instead of peering'),
104 disabled: true
105 },
106 pglog_hardlimit: {
107 code: 'pglog_hardlimit',
108 name: this.i18n('PG Log Hard Limit'),
109 value: false,
110 description: this.i18n('Puts a hard limit on pg log length'),
111 disabled: true
112 }
113 };
114 flags: any[];
115 unknownFlags: string[] = [];
116
117 constructor(
118 public bsModalRef: BsModalRef,
119 private authStorageService: AuthStorageService,
120 private osdService: OsdService,
121 private notificationService: NotificationService,
122 private i18n: I18n
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, this.i18n('Updated OSD Flags'));
149 this.bsModalRef.hide();
150 },
151 () => {
152 this.bsModalRef.hide();
153 }
154 );
155 }
156 }