'block_name_prefix': JLeaf(str),
'name': JLeaf(str),
'id': JLeaf(str),
+ 'unique_id': JLeaf(str),
+ 'image_format': JLeaf(int),
'pool_name': JLeaf(str),
'namespace': JLeaf(str, none=True),
'features': JLeaf(int),
class="bold">Order</td>
<td>{{ selection.order }}</td>
</tr>
+ <tr>
+ <td i18n
+ class="bold">Format Version</td>
+ <td>{{ selection.image_format }}</td>
+ </tr>
</tbody>
</table>
</ng-template>
import { FormatterService } from '../../../shared/services/formatter.service';
import { TaskWrapperService } from '../../../shared/services/task-wrapper.service';
import { Pool } from '../../pool/pool';
+import { RBDImageFormat, RbdModel } from '../rbd-list/rbd-model';
import { RbdImageFeature } from './rbd-feature.interface';
import { RbdFormCloneRequestModel } from './rbd-form-clone-request.model';
import { RbdFormCopyRequestModel } from './rbd-form-copy-request.model';
this.rbdForm.get('obj_size').disable();
this.rbdForm.get('stripingUnit').disable();
this.rbdForm.get('stripingCount').disable();
+
+ /* RBD Image Format v1 */
+ this.rbdImage.subscribe((image: RbdModel) => {
+ if (image.image_format === RBDImageFormat.V1) {
+ this.rbdForm.get('deep-flatten').disable();
+ this.rbdForm.get('layering').disable();
+ this.rbdForm.get('exclusive-lock').disable();
+ }
+ });
}
disableForClone() {
[data]="images"
columnMode="flex"
[columns]="columns"
- identifier="id"
+ identifier="unique_id"
[searchableObjects]="true"
forceIdentifier="true"
selectionType="single"
import { URLBuilderService } from '../../../shared/services/url-builder.service';
import { RbdParentModel } from '../rbd-form/rbd-parent.model';
import { RbdTrashMoveModalComponent } from '../rbd-trash-move-modal/rbd-trash-move-modal.component';
-import { RbdModel } from './rbd-model';
+import { RBDImageFormat, RbdModel } from './rbd-model';
const BASE_URL = 'block/rbd';
private createRbdFromTask(pool: string, namespace: string, name: string): RbdModel {
const model = new RbdModel();
model.id = '-1';
+ model.unique_id = '-1';
model.name = name;
model.namespace = namespace;
model.pool_name = pool;
+ model.image_format = RBDImageFormat.V2;
return model;
}
permission: 'delete',
icon: Icons.trash,
click: () => this.trashRbdModal(),
- name: this.actionLabels.TRASH
+ name: this.actionLabels.TRASH,
+ disable: (selection: CdTableSelection) =>
+ !selection.first() ||
+ !selection.hasSingleSelection ||
+ selection.first().image_format === RBDImageFormat.V1
};
this.tableActions = [
addAction,
export class RbdModel {
id: string;
+ unique_id: string;
name: string;
pool_name: string;
namespace: string;
+ image_format: RBDImageFormat;
cdExecuting: string;
}
+
+export enum RBDImageFormat {
+ V1 = 1,
+ V2 = 2
+}
@classmethod
def get_pool_name_from_id(cls, pool_id):
# type: (int) -> Union[str, None]
- pool = cls.get_pool_by_attribute('pool', pool_id)
- return pool['pool_name'] if pool is not None else None
+ return mgr.rados.pool_reverse_lookup(pool_id)
@classmethod
def get_pool_by_attribute(cls, attribute, value):
stat = img.stat()
stat['name'] = image_name
- stat['id'] = img.id()
+ if img.old_format():
+ stat['unique_id'] = get_image_spec(pool_name, namespace, stat['block_name_prefix'])
+ stat['id'] = stat['unique_id']
+ stat['image_format'] = 1
+ else:
+ stat['unique_id'] = get_image_spec(pool_name, namespace, img.id())
+ stat['id'] = img.id()
+ stat['image_format'] = 2
+
stat['pool_name'] = pool_name
stat['namespace'] = namespace
features = img.features()
def test_get_pool_by_attribute_matching_a_not_always_set_attribute(self):
self.assertEqual(self.service.get_pool_by_attribute('flaky', 'option_x'), self.pools[1])
- def test_get_pool_name_from_id_with_match(self):
+ @mock.patch('dashboard.mgr.rados.pool_reverse_lookup', return_value='good_pool')
+ def test_get_pool_name_from_id_with_match(self, _mock):
self.assertEqual(self.service.get_pool_name_from_id(1), 'good_pool')
- def test_get_pool_name_from_id_without_match(self):
+ @mock.patch('dashboard.mgr.rados.pool_reverse_lookup', return_value=None)
+ def test_get_pool_name_from_id_without_match(self, _mock):
self.assertEqual(self.service.get_pool_name_from_id(3), None)
def test_get_pool_pg_status(self):