From: Ricardo Marques Date: Tue, 10 Sep 2019 10:44:26 +0000 (+0100) Subject: mgr/dashboard: Display WWN and LUN number in iSCSI target details X-Git-Tag: v15.1.0~1232^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6b7017d91af9557feb09d86e4edb1234247316c9;p=ceph-ci.git mgr/dashboard: Display WWN and LUN number in iSCSI target details Fixes: https://tracker.ceph.com/issues/41742 Signed-off-by: Ricardo Marques --- diff --git a/src/pybind/mgr/dashboard/controllers/iscsi.py b/src/pybind/mgr/dashboard/controllers/iscsi.py index 7bca1f15ef6..fca993bbc80 100644 --- a/src/pybind/mgr/dashboard/controllers/iscsi.py +++ b/src/pybind/mgr/dashboard/controllers/iscsi.py @@ -721,8 +721,12 @@ class IscsiTarget(RESTController): 'pool': disk_config['pool'], 'image': disk_config['image'], 'controls': disk_config['controls'], - 'backstore': disk_config['backstore'] + 'backstore': disk_config['backstore'], + 'wwn': disk_config['wwn'] } + # lun_id was introduced in ceph-iscsi config v11 + if config['version'] > 10: + disk['lun'] = target_config['disks'][target_disk]['lun_id'] disks.append(disk) disks = IscsiTarget._sorted_disks(disks) clients = [] diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts index 5b17c8b9ff8..d1504afb916 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts @@ -54,7 +54,7 @@ export class IscsiTargetDetailsComponent implements OnChanges, OnInit { { prop: 'displayName', name: this.i18n('Name'), - flexGrow: 2, + flexGrow: 1, cellTemplate: this.highlightTpl }, { @@ -122,7 +122,11 @@ export class IscsiTargetDetailsComponent implements OnChanges, OnInit { controls: disk.controls, backstore: disk.backstore }; - + ['wwn', 'lun'].forEach((k) => { + if (k in disk) { + this.metadata[id][k] = disk[k]; + } + }); disks.push({ value: `${disk.pool}/${disk.image}`, id: id @@ -303,6 +307,15 @@ export class IscsiTargetDetailsComponent implements OnChanges, OnInit { default: this.iscsiBackstorePipe.transform(this.settings.default_backstore), current: this.iscsiBackstorePipe.transform(tempData.backstore) }); + ['wwn', 'lun'].forEach((k) => { + if (k in tempData) { + this.data.push({ + displayName: k, + default: undefined, + current: tempData[k] + }); + } + }); } else { this.columns[2].isHidden = true; this.data = _.map(tempData, (value, key) => { diff --git a/src/pybind/mgr/dashboard/tests/test_iscsi.py b/src/pybind/mgr/dashboard/tests/test_iscsi.py index 9f505c49f1e..aae823be749 100644 --- a/src/pybind/mgr/dashboard/tests/test_iscsi.py +++ b/src/pybind/mgr/dashboard/tests/test_iscsi.py @@ -225,7 +225,10 @@ class IscsiTest(ControllerTestCase, CLICommandTestMixin): "image": "lun3", "pool": "rbd", "controls": {}, - "backstore": "user:rbd" + "backstore": "user:rbd", + "wwn": "64af6678-9694-4367-bacc-f8eb0baa2", + "lun": 2 + }) response['clients'][0]['luns'].append({"image": "lun3", "pool": "rbd"}) self._update_iscsi_target(create_request, update_request, response) @@ -431,8 +434,10 @@ iscsi_target_response = { ], 'disks': [ {'pool': 'rbd', 'image': 'lun1', 'backstore': 'user:rbd', + 'wwn': '64af6678-9694-4367-bacc-f8eb0baa0', 'lun': 0, 'controls': {'max_data_area_mb': 128}}, {'pool': 'rbd', 'image': 'lun2', 'backstore': 'user:rbd', + 'wwn': '64af6678-9694-4367-bacc-f8eb0baa1', 'lun': 1, 'controls': {'max_data_area_mb': 128}} ], 'clients': [ @@ -565,7 +570,7 @@ class IscsiClientMock(object): } def get_config(self): - return self.config + return copy.deepcopy(self.config) def create_target(self, target_iqn, target_controls): self.config['targets'][target_iqn] = { @@ -581,7 +586,7 @@ class IscsiClientMock(object): }, "controls": target_controls, "created": "2019/01/17 09:22:34", - "disks": [], + "disks": {}, "groups": {}, "portals": {} } @@ -608,12 +613,15 @@ class IscsiClientMock(object): "pool": pool, "image": image, "backstore": backstore, - "controls": {} + "controls": {}, + "wwn": '64af6678-9694-4367-bacc-f8eb0baa' + str(len(self.config['disks'])) } def create_target_lun(self, target_iqn, image_id): target_config = self.config['targets'][target_iqn] - target_config['disks'].append(image_id) + target_config['disks'][image_id] = { + "lun_id": len(target_config['disks']) + } self.config['disks'][image_id]['owner'] = list(target_config['portals'].keys())[0] def reconfigure_disk(self, pool, image, controls): @@ -673,7 +681,7 @@ class IscsiClientMock(object): def delete_target_lun(self, target_iqn, image_id): target_config = self.config['targets'][target_iqn] - target_config['disks'].remove(image_id) + target_config['disks'].pop(image_id) del self.config['disks'][image_id]['owner'] def delete_disk(self, pool, image):