]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Display WWN and LUN number in iSCSI target details
authorRicardo Marques <rimarques@suse.com>
Tue, 10 Sep 2019 10:44:26 +0000 (11:44 +0100)
committerRicardo Marques <rimarques@suse.com>
Fri, 27 Sep 2019 14:14:11 +0000 (15:14 +0100)
Fixes: https://tracker.ceph.com/issues/41742
Signed-off-by: Ricardo Marques <rimarques@suse.com>
src/pybind/mgr/dashboard/controllers/iscsi.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts
src/pybind/mgr/dashboard/tests/test_iscsi.py

index 7bca1f15ef6f85c4347614bc6be7fd738aa9d17c..fca993bbc8080a34871db87a5c80cf2677361248 100644 (file)
@@ -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 = []
index 5b17c8b9ff866e7214c05d0ce8483c53b98e6e1c..d1504afb916b4a24773c5a76cb6749f55a34a428 100644 (file)
@@ -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) => {
index 9f505c49f1e75ef586f197e9c2b298f16b73bcc5..aae823be7490772b04b5b567a10ea54dce7a3a99 100644 (file)
@@ -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):