self._set_pool_values(pool, application_metadata, flags, False, kwargs)
def _set_pool_values(self, pool, application_metadata, flags, update_existing, kwargs):
+ update_name = False
if update_existing:
current_pool = self._get(pool)
self._handle_update_compression_args(current_pool.get('options'), kwargs)
CephService.send_command('mon', 'osd pool set', pool=pool, var=key, val=str(value))
for key, value in kwargs.items():
- set_key(key, value)
- if key == 'pg_num':
- set_key('pgp_num', value)
+ if key == 'pool':
+ update_name = True
+ destpool = value
+ else:
+ set_key(key, value)
+ if key == 'pg_num':
+ set_key('pgp_num', value)
+ if update_name:
+ CephService.send_command('mon', 'osd pool rename', srcpool=pool, destpool=destpool)
def _handle_update_compression_args(self, options, kwargs):
if kwargs.get('compression_mode') == 'unset' and options is not None:
});
it('validates name', () => {
+ expect(component.editing).toBeFalsy();
formHelper.expectError('name', 'required');
formHelper.expectValidChange('name', 'some-name');
component.info.pool_names.push('someExistingPoolName');
});
it('disabled inputs', () => {
- const disabled = [
- 'name',
- 'poolType',
- 'crushRule',
- 'size',
- 'erasureProfile',
- 'ecOverwrites'
- ];
+ const disabled = ['poolType', 'crushRule', 'size', 'erasureProfile', 'ecOverwrites'];
disabled.forEach((controlName) => {
return expect(form.get(controlName).disabled).toBeTruthy();
});
- const enabled = ['pgNum', 'mode', 'algorithm', 'minBlobSize', 'maxBlobSize', 'ratio'];
+ const enabled = [
+ 'name',
+ 'pgNum',
+ 'mode',
+ 'algorithm',
+ 'minBlobSize',
+ 'maxBlobSize',
+ 'ratio'
+ ];
enabled.forEach((controlName) => {
return expect(form.get(controlName).enabled).toBeTruthy();
});
this.form = new CdFormGroup(
{
name: new FormControl('', {
- validators: [
- Validators.pattern('[A-Za-z0-9_-]+'),
- Validators.required,
- CdValidators.custom(
- 'uniqueName',
- (value) => this.info && this.info.pool_names.indexOf(value) !== -1
- )
- ]
+ validators: [Validators.pattern('[A-Za-z0-9_-]+'), Validators.required]
}),
poolType: new FormControl('', {
validators: [Validators.required]
}
private disableForEdit() {
- ['name', 'poolType', 'crushRule', 'size', 'erasureProfile', 'ecOverwrites'].forEach(
- (controlName) => this.form.get(controlName).disable()
+ ['poolType', 'crushRule', 'size', 'erasureProfile', 'ecOverwrites'].forEach((controlName) =>
+ this.form.get(controlName).disable()
);
}
.setValidators(
CdValidators.custom('noDecrease', (pgs) => this.data.pool && pgs < this.data.pool.pg_num)
);
+ this.form
+ .get('name')
+ .setValidators([
+ this.form.get('name').validator,
+ CdValidators.custom(
+ 'uniqueName',
+ (name) =>
+ this.data.pool &&
+ this.info &&
+ this.info.pool_names.indexOf(name) !== -1 &&
+ this.info.pool_names.indexOf(name) !==
+ this.info.pool_names.indexOf(this.data.pool.pool_name)
+ )
+ ]);
} else {
CdValidators.validateIf(
this.form.get('size'),
)
]
);
+ this.form
+ .get('name')
+ .setValidators([
+ this.form.get('name').validator,
+ CdValidators.custom(
+ 'uniqueName',
+ (name) => this.info && this.info.pool_names.indexOf(name) !== -1
+ )
+ ]);
}
this.setCompressionValidators();
}
formControlName: 'mode',
editable: true,
replaceFn: () => 'unset'
+ },
+ {
+ externalFieldName: 'srcpool',
+ formControlName: 'name',
+ editable: true,
+ replaceFn: () => this.data.pool.pool_name
}
]);
}
this.taskWrapper
.wrapTaskAroundCall({
task: new FinishedTask('pool/' + (this.editing ? 'edit' : 'create'), {
- pool_name: pool.pool
+ pool_name: pool.hasOwnProperty('srcpool') ? pool.srcpool : pool.pool
}),
call: this.poolService[this.editing ? 'update' : 'create'](pool)
})
}
update(pool) {
- const name = pool.pool;
- delete pool.pool;
+ let name: string;
+ if (pool.hasOwnProperty('srcpool')) {
+ name = pool.srcpool;
+ delete pool.srcpool;
+ } else {
+ name = pool.pool;
+ delete pool.pool;
+ }
return this.http.put(`${this.apiPath}/${name}`, pool, { observe: 'response' });
}