@@ -93,9 +93,9 @@ def get_service_info(cls, group=None):
9393 return None
9494
9595 if group :
96- return cls . _get_name_url_for_group (gateways , group )
96+ return _get_name_url_for_group (gateways , group )
9797
98- return cls . _get_default_service (gateways )
98+ return _get_default_service (gateways )
9999
100100 except (KeyError , IndexError ) as e :
101101 raise DashboardException (
@@ -129,52 +129,54 @@ def from_cert_store(cls, entity: str, service_name: str, key=False):
129129 orch = OrchClient .instance ()
130130 if orch .available ():
131131 if key :
132- return orch .cert_store .get_key (entity , service_name )
133- return orch .cert_store .get_cert (entity , service_name )
132+ return orch .cert_store .get_key (entity , service_name ,
133+ ignore_missing_exception = True )
134+ return orch .cert_store .get_cert (entity , service_name ,
135+ ignore_missing_exception = True )
134136 return None
135137 except OrchestratorError :
136138 # just return None if any orchestrator error is raised
137139 # otherwise nvmeof api will raise this error and doesn't proceed.
138140 return None
139141
140- @classmethod
141- def _get_name_url_for_group (cls , gateways , group ):
142- try :
143- orch = OrchClient .instance ()
144- for service_name , svc_config in gateways .items ():
145- # get the group name of the service and match it against the
146- # group name provided
147- group_name_from_svc = orch .services .get (service_name )[0 ].spec .group
148- if group == group_name_from_svc :
149- running_daemons = cls ._get_running_daemons (orch , service_name )
150- config = cls ._get_running_daemon_svc_config (svc_config , running_daemons )
151-
152- if config :
153- return service_name , config ['service_url' ]
154- return None
155142
156- except OrchestratorError :
157- return cls ._get_default_service (gateways )
143+ def _get_name_url_for_group (gateways , group ):
144+ try :
145+ orch = OrchClient .instance ()
146+ for service_name , svc_config in gateways .items ():
147+ # get the group name of the service and match it against the
148+ # group name provided
149+ group_name_from_svc = orch .services .get (service_name )[0 ].spec .group
150+ if group == group_name_from_svc :
151+ running_daemons = _get_running_daemons (orch , service_name )
152+ config = _get_running_daemon_svc_config (svc_config , running_daemons )
158153
159- @classmethod
160- def _get_running_daemons (cls , orch , service_name ):
161- # get the running nvmeof daemons
162- daemons = [d .to_dict ()
163- for d in orch .services .list_daemons (service_name = service_name )]
164- return [d ['daemon_name' ] for d in daemons
165- if d ['status_desc' ] == 'running' ]
154+ if config :
155+ return service_name , config ['service_url' ]
156+ return None
166157
167- @classmethod
168- def _get_running_daemon_svc_config (cls , svc_config , running_daemons ):
169- try :
170- return next (config for config in svc_config
171- if config ['daemon_name' ] in running_daemons )
172- except StopIteration :
173- return None
158+ except OrchestratorError :
159+ return _get_default_service (gateways )
174160
175- @classmethod
176- def _get_default_service (cls , gateways ):
177- if gateways :
178- service_name = list (gateways .keys ())[0 ]
179- return service_name , gateways [service_name ][0 ]['service_url' ]
161+
162+ def _get_running_daemons (orch , service_name ):
163+ # get the running nvmeof daemons
164+ daemons = [d .to_dict ()
165+ for d in orch .services .list_daemons (service_name = service_name )]
166+ return [d ['daemon_name' ] for d in daemons
167+ if d ['status_desc' ] == 'running' ]
168+
169+
170+ def _get_running_daemon_svc_config (svc_config , running_daemons ):
171+ try :
172+ return next (config for config in svc_config
173+ if config ['daemon_name' ] in running_daemons )
174+ except StopIteration :
180175 return None
176+
177+
178+ def _get_default_service (gateways ):
179+ if gateways :
180+ service_name = list (gateways .keys ())[0 ]
181+ return service_name , gateways [service_name ][0 ]['service_url' ]
182+ return None
0 commit comments