From 7107bf9196c9c0a7feafabcaaeb84b8a8cd1fd92 Mon Sep 17 00:00:00 2001 From: Ricardo Marques Date: Mon, 13 May 2019 16:05:34 +0100 Subject: [PATCH] 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 --- src/pybind/mgr/dashboard/controllers/iscsi.py | 6 ++---- src/pybind/mgr/dashboard/tests/test_iscsi.py | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/iscsi.py b/src/pybind/mgr/dashboard/controllers/iscsi.py index da25f4c70a6d9..7d304deb8e9b6 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 949bf629b50bf..4493e8f9f44aa 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): -- 2.39.5