11# -*- coding: utf-8 -*-
22
33import json
4+ import logging
45
56from orchestrator import OrchestratorError
67
78from .. import mgr
89from ..exceptions import DashboardException
910from ..services .orchestrator import OrchClient
1011
12+ logger = logging .getLogger ('nvmeof_conf' )
1113
1214class NvmeofGatewayAlreadyExists (Exception ):
1315 def __init__ (self , gateway_name ):
@@ -87,12 +89,9 @@ def get_client_key(cls, service_name: str):
8789
8890 @classmethod
8991 def get_root_ca_cert (cls , service_name : str ):
90- try :
91- root_ca_cert = cls .from_cert_store ('nvmeof_root_ca_cert' , service_name )
92- return root_ca_cert .encode ()
93- except DashboardException :
94- # If root_ca_cert is not set, use server_cert as root_ca_cert
95- return cls .get_server_cert (service_name )
92+ root_ca_cert = cls .from_cert_store ('nvmeof_root_ca_cert' , service_name )
93+ # If root_ca_cert is not set, use server_cert as root_ca_cert
94+ return root_ca_cert .encode () if root_ca_cert else cls .get_server_cert (service_name )
9695
9796 @classmethod
9897 def get_server_cert (cls , service_name : str ):
@@ -108,7 +107,7 @@ def from_cert_store(cls, entity: str, service_name: str, key=False):
108107 return orch .cert_store .get_key (entity , service_name )
109108 return orch .cert_store .get_cert (entity , service_name )
110109 return None
111- except OrchestratorError as e :
112- raise DashboardException (
113- msg = f'Failed to get { entity } for { service_name } : { e } ' ,
114- )
110+ except OrchestratorError :
111+ # just return None if any orchestrator error is raised
112+ # otherwise nvmeof api will raise this error and doesn't proceed.
113+ return None
0 commit comments