]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: support setting iSCSI gateways from orchestrator 35068/head
authorKiefer Chang <kiefer.chang@suse.com>
Fri, 15 May 2020 09:22:15 +0000 (17:22 +0800)
committerKiefer Chang <kiefer.chang@suse.com>
Sun, 17 May 2020 01:21:19 +0000 (09:21 +0800)
- Dashboard doesn't actively query iSCSI gateways from orchestrator anymore.
  Instead, Orchestrator backend invokes iscsi-gateway-add CLI after any
  iSCSI daemons are deployed.
- Add an optional argument `name` to `iscsi-gateway-add` command. If
  `name` is provided, Dashboard won't issue API request to iSCSI gateway
  to get the hostname. This is required because when orchestrator sets
  the gateway via CLI, the gateway is just spawned and might be not
  ready yet.

Fixes: https://tracker.ceph.com/issues/45163
Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
src/pybind/mgr/dashboard/services/iscsi_cli.py
src/pybind/mgr/dashboard/services/iscsi_config.py

index fca1f61b3cc14db1a24a176f935bad97ba016bfb..e894a56caef73465f775dbbf6c69a40490440da2 100644 (file)
@@ -18,12 +18,14 @@ def list_iscsi_gateways(_):
 
 
 @CLIWriteCommand('dashboard iscsi-gateway-add',
-                 'name=service_url,type=CephString',
+                 'name=service_url,type=CephString '
+                 'name=name,type=CephString,req=false',
                  'Add iSCSI gateway configuration')
-def add_iscsi_gateway(_, service_url):
+def add_iscsi_gateway(_, service_url, name=None):
     try:
         IscsiGatewaysConfig.validate_service_url(service_url)
-        name = IscsiClient.instance(service_url=service_url).get_hostname()['data']
+        if name is None:
+            name = IscsiClient.instance(service_url=service_url).get_hostname()['data']
         IscsiGatewaysConfig.add_gateway(name, service_url)
         return 0, 'Success', ''
     except IscsiGatewayAlreadyExists as ex:
index 3c0698c574fa165c579ce06187df9fede59c287c..ab900485001b0a33796f7bcfcd565692b297ba83 100644 (file)
@@ -3,15 +3,11 @@ from __future__ import absolute_import
 
 import json
 
-from orchestrator import OrchestratorError
-
 try:
     from urlparse import urlparse
 except ImportError:
     from urllib.parse import urlparse
 
-from mgr_util import merge_dicts
-from .orchestrator import OrchClient
 from .. import mgr
 
 
@@ -76,19 +72,6 @@ class IscsiGatewaysConfig(object):
                     # or we will try to update automatically next time
                     continue
 
-    @staticmethod
-    def _load_config_from_orchestrator():
-        config = {'gateways': {}}  # type: dict
-        try:
-            instances = OrchClient.instance().services.list("iscsi")
-            for instance in instances:
-                config['gateways'][instance.hostname] = {
-                    'service_url': instance.service_url
-                }
-        except (RuntimeError, OrchestratorError, ImportError):
-            pass
-        return config
-
     @classmethod
     def _save_config(cls, config):
         mgr.set_store(_ISCSI_STORE_KEY, json.dumps(config))
@@ -110,9 +93,6 @@ class IscsiGatewaysConfig(object):
 
     @classmethod
     def remove_gateway(cls, name):
-        if name in cls._load_config_from_orchestrator()['gateways']:
-            raise ManagedByOrchestratorException()
-
         config = cls._load_config_from_store()
         if name not in config['gateways']:
             raise IscsiGatewayDoesNotExist(name)
@@ -122,10 +102,7 @@ class IscsiGatewaysConfig(object):
 
     @classmethod
     def get_gateways_config(cls):
-        orch_config = cls._load_config_from_orchestrator()
-        local_config = cls._load_config_from_store()
-
-        return {'gateways': merge_dicts(orch_config['gateways'], local_config['gateways'])}
+        return cls._load_config_from_store()
 
     @classmethod
     def get_gateway_config(cls, name):