From: Ricardo Marques Date: Wed, 26 Jun 2019 10:04:25 +0000 (+0100) Subject: mgr/dashboard: Rename iSCSI gateways name to FQDN X-Git-Tag: v15.1.0~2274^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F28720%2Fhead;p=ceph.git mgr/dashboard: Rename iSCSI gateways name to FQDN iSCSI gateways name will be automatically renamed from host shot name to FQDN. Fixes: https://tracker.ceph.com/issues/40566 Signed-off-by: Ricardo Marques --- diff --git a/src/pybind/mgr/dashboard/services/iscsi_config.py b/src/pybind/mgr/dashboard/services/iscsi_config.py index 963d2f990d7c..c8cded19ab04 100644 --- a/src/pybind/mgr/dashboard/services/iscsi_config.py +++ b/src/pybind/mgr/dashboard/services/iscsi_config.py @@ -54,7 +54,33 @@ class IscsiGatewaysConfig(object): def _load_config_from_store(cls): json_db = mgr.get_store(_ISCSI_STORE_KEY, '{"gateways": {}}') - return json.loads(json_db) + config = json.loads(json_db) + cls.update_iscsi_config(config) + return config + + @classmethod + def update_iscsi_config(cls, config): + """ + Since `ceph-iscsi` config v10, gateway names were renamed from host short name to FQDN. + If Ceph Dashboard were configured before v10, we try to update our internal gateways + database automatically. + """ + for gateway_name, gateway_config in config['gateways'].items(): + if '.' not in gateway_name: + from .iscsi_client import IscsiClient + from ..rest_client import RequestException + try: + service_url = gateway_config['service_url'] + new_gateway_name = IscsiClient.instance( + service_url=service_url).get_hostname()['data'] + if gateway_name != new_gateway_name: + config['gateways'][new_gateway_name] = gateway_config + del config['gateways'][gateway_name] + cls._save_config(config) + except RequestException: + # If gateway is not acessible, it should be removed manually + # or we will try to update automatically next time + continue @staticmethod def _load_config_from_orchestrator():