]> git.apps.os.sepia.ceph.com Git - ceph.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>
Thu, 7 Nov 2019 11:56:32 +0000 (11:56 +0000)
Fixes: https://tracker.ceph.com/issues/41742
Signed-off-by: Ricardo Marques <rimarques@suse.com>
(cherry picked from commit 6b7017d91af9557feb09d86e4edb1234247316c9)

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 c02ca4aadd94ba09f4f785348cf50459c4a770be..fd8633db43f85f94e6e9be6629e6bc2342f5f30b 100644 (file)
@@ -716,8 +716,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 47dcebff15a12ab454d5a30c65e9a5bc3f47997d..7a03b0ff3b4f0a5f02cba80ac704cb64a017fdee 100644 (file)
@@ -53,7 +53,7 @@ export class IscsiTargetDetailsComponent implements OnChanges, OnInit {
       {
         prop: 'displayName',
         name: this.i18n('Name'),
-        flexGrow: 2,
+        flexGrow: 1,
         cellTemplate: this.highlightTpl
       },
       {
@@ -118,7 +118,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
@@ -299,6 +303,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 c4e0d6b439bc8317052020f902bb45586574f2bf..d0d86e32115f2514857cd22e7c12815dd3266dc8 100644 (file)
@@ -221,7 +221,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)
@@ -427,8 +430,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': [
@@ -561,7 +566,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] = {
@@ -577,7 +582,7 @@ class IscsiClientMock(object):
             },
             "controls": target_controls,
             "created": "2019/01/17 09:22:34",
-            "disks": [],
+            "disks": {},
             "groups": {},
             "portals": {}
         }
@@ -604,12 +609,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):
@@ -669,7 +677,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):