</div>
</div>
- <div *ngIf="form.getValue('poolType')">
+ <div *ngIf="isReplicated || isErasure">
<!-- PG Autoscale Mode -->
<div class="form-group row">
<label i18n
<!-- Replica Size -->
<div class="form-group row"
- *ngIf="form.getValue('poolType') === 'replicated'">
+ *ngIf="isReplicated">
<label class="cd-col-form-label required"
for="size"
i18n>Replicated size</label>
<!-- Flags -->
<div class="form-group row"
- *ngIf="info.is_all_bluestore && form.getValue('poolType') === 'erasure'">
+ *ngIf="info.is_all_bluestore && isErasure">
<label i18n
class="cd-col-form-label">Flags</label>
<div class="cd-col-form-input">
</div>
<!-- CRUSH -->
- <div *ngIf="form.getValue('poolType')">
+ <div *ngIf="isErasure || isReplicated">
<legend i18n>CRUSH</legend>
<!-- Erasure Profile select -->
<div class="form-group row"
- *ngIf="form.getValue('poolType') === 'erasure'">
+ *ngIf="isErasure">
<label i18n
class="cd-col-form-label"
for="erasureProfile">Erasure code profile</label>
</div>
<!-- Pool configuration -->
- <div [hidden]="form.get('poolType').value !== 'replicated' || data.applications.selected.indexOf('rbd') === -1">
+ <div [hidden]="isErasure || data.applications.selected.indexOf('rbd') === -1">
<cd-rbd-configuration-form [form]="form"
[initializeData]="initializeConfigData"
(changes)="currentConfigurationValues = $event()">
info: PoolFormInfo;
routeParamsSubscribe: any;
editing = false;
+ isReplicated = false;
+ isErasure = false;
data = new PoolFormData(this.i18n);
externalPgChange = false;
private modalSubscription: Subscription;
initialData: pool.configuration,
sourceType: RbdConfigurationSourceField.pool
});
-
+ this.rulesChange(pool.type);
const dataMap = {
name: pool.pool_name,
poolType: pool.type,
this.data.pgs = this.form.getValue('pgNum');
this.setAvailableApps(this.data.applications.default.concat(pool.application_metadata));
this.data.applications.selected = pool.application_metadata;
- this.rulesChange();
}
private setAvailableApps(apps: string[] = this.data.applications.default) {
private listenToChangesDuringAdd() {
this.form.get('poolType').valueChanges.subscribe((poolType) => {
- this.form.get('size').updateValueAndValidity();
- this.rulesChange();
- if (poolType === 'replicated') {
- this.replicatedRuleChange();
- }
- this.pgCalc();
+ this.rulesChange(poolType);
});
this.form.get('crushRule').valueChanges.subscribe(() => {
- if (this.form.getValue('poolType') === 'replicated') {
+ if (this.isReplicated) {
this.replicatedRuleChange();
}
this.pgCalc();
});
}
- private rulesChange() {
- const poolType = this.form.getValue('poolType');
+ private rulesChange(poolType: string) {
+ if (poolType === 'replicated') {
+ this.setTypeBooleans(true, false);
+ } else if (poolType === 'erasure') {
+ this.setTypeBooleans(false, true);
+ } else {
+ this.setTypeBooleans(false, false);
+ }
if (!poolType || !this.info) {
this.current.rules = [];
return;
}
const rules = this.info['crush_rules_' + poolType] || [];
+ this.current.rules = rules;
+ if (this.editing) {
+ return;
+ }
const control = this.form.get('crushRule');
if (rules.length === 1) {
control.setValue(rules[0]);
this.current.rules = rules;
}
+ private setTypeBooleans(replicated: boolean, erasure: boolean) {
+ this.isReplicated = replicated;
+ this.isErasure = erasure;
+ }
+
private replicatedRuleChange() {
- if (this.form.getValue('poolType') !== 'replicated') {
+ if (!this.isReplicated) {
return;
}
const control = this.form.get('size');
return;
}
const pgMax = this.info.osd_count * 100;
- const pgs =
- poolType === 'replicated' ? this.replicatedPgCalc(pgMax) : this.erasurePgCalc(pgMax);
+ const pgs = this.isReplicated ? this.replicatedPgCalc(pgMax) : this.erasurePgCalc(pgMax);
if (!pgs) {
return;
}
)
]);
} else {
- CdValidators.validateIf(
- this.form.get('size'),
- () => this.form.get('poolType').value === 'replicated',
- [
- CdValidators.custom(
- 'min',
- (value: number) => this.form.getValue('size') && value < this.getMinSize()
- ),
- CdValidators.custom(
- 'max',
- (value: number) => this.form.getValue('size') && this.getMaxSize() < value
- )
- ]
- );
+ CdValidators.validateIf(this.form.get('size'), () => this.isReplicated, [
+ CdValidators.custom(
+ 'min',
+ (value: number) => this.form.getValue('size') && value < this.getMinSize()
+ ),
+ CdValidators.custom(
+ 'max',
+ (value: number) => this.form.getValue('size') && this.getMaxSize() < value
+ )
+ ]);
this.form
.get('name')
.setValidators([
replaceFn: (value: number) => (this.form.getValue('pgAutoscaleMode') === 'on' ? 1 : value),
editable: true
},
- this.form.getValue('poolType') === 'replicated'
+ this.isReplicated
? { externalFieldName: 'size', formControlName: 'size' }
: {
externalFieldName: 'erasure_code_profile',
this.assignFormField(pool, {
externalFieldName: 'flags',
formControlName: 'ecOverwrites',
- replaceFn: () => ['ec_overwrites']
+ replaceFn: () => (this.isErasure ? ['ec_overwrites'] : undefined)
});
if (this.form.getValue('mode') !== 'none') {
// Only collect configuration data for replicated pools, as QoS cannot be configured on EC
// pools. EC data pools inherit their settings from the corresponding replicated metadata pool.
- if (
- this.form.get('poolType').value === 'replicated' &&
- !_.isEmpty(this.currentConfigurationValues)
- ) {
+ if (this.isReplicated && !_.isEmpty(this.currentConfigurationValues)) {
pool['configuration'] = this.currentConfigurationValues;
}