From c191c27059160786c31fcdaf2c119f2a776bee4f 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 (cherry picked from commit 7107bf9196c9c0a7feafabcaaeb84b8a8cd1fd92) --- 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 562a77f3d10..8270efcd90e 100644 --- a/src/pybind/mgr/dashboard/controllers/iscsi.py +++ b/src/pybind/mgr/dashboard/controllers/iscsi.py @@ -585,10 +585,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 c3c6c159c5c..c375f8a5488 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 delete_gateway(self, target_iqn, gateway_name): -- 2.47.3