From: Ricardo Marques Date: Mon, 13 May 2019 15:05:34 +0000 (+0100) Subject: mgr/dashboard: Optimize portal IPs calculation X-Git-Tag: v15.1.0~2494^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7107bf9196c9c0a7feafabcaaeb84b8a8cd1fd92;p=ceph.git mgr/dashboard: Optimize portal IPs calculation Now that portal IPs are part of the ceph-iscsi config we don't have to calculate this information, we just use the `portal_ip_addresses` field. Fixes: https://tracker.ceph.com/issues/39580 Signed-off-by: Ricardo Marques --- diff --git a/src/pybind/mgr/dashboard/controllers/iscsi.py b/src/pybind/mgr/dashboard/controllers/iscsi.py index da25f4c70a6d..7d304deb8e9b 100644 --- a/src/pybind/mgr/dashboard/controllers/iscsi.py +++ b/src/pybind/mgr/dashboard/controllers/iscsi.py @@ -570,10 +570,8 @@ class IscsiTarget(RESTController): def _config_to_target(target_iqn, config): target_config = config['targets'][target_iqn] portals = [] - for host in target_config['portals'].keys(): - ips = IscsiClient.instance(gateway_name=host).get_ip_addresses()['data'] - portal_ips = [ip for ip in ips if ip in target_config['ip_list']] - for portal_ip in portal_ips: + for host, portal_config in target_config['portals'].items(): + for portal_ip in portal_config['portal_ip_addresses']: portal = { 'host': host, 'ip': portal_ip diff --git a/src/pybind/mgr/dashboard/tests/test_iscsi.py b/src/pybind/mgr/dashboard/tests/test_iscsi.py index 949bf629b50b..4493e8f9f44a 100644 --- a/src/pybind/mgr/dashboard/tests/test_iscsi.py +++ b/src/pybind/mgr/dashboard/tests/test_iscsi.py @@ -475,7 +475,7 @@ class IscsiClientMock(object): "gateways": {}, "targets": {}, "updated": "", - "version": 5 + "version": 9 } @classmethod @@ -550,7 +550,7 @@ class IscsiClientMock(object): target_config['ip_list'] = [] target_config['ip_list'] += ip_address target_config['portals'][gateway_name] = { - "portal_ip_address": ip_address[0] + "portal_ip_addresses": ip_address } def create_disk(self, pool, image, backstore):