@@ -174,13 +174,24 @@ def _on_ctrl_removed(self, udev_obj):
174174 self ._retry_connect_tmr .start (self .FAST_CONNECT_RETRY_PERIOD_SEC )
175175
176176 def _get_cfg (self ):
177- '''Get configuration parameters. These may either come from the [Global]
178- section or from a "controller" entry in the configuration file. A
179- definition found in a "controller" entry overrides the same definition
180- found in the [Global] section.
177+ '''Get all parameters needed to create and connect an nvme.ctrl object.
178+ Transport ID parameters are included directly. Fabrics config parameters
179+ may come from the [Global] section or from a "controller" entry in the
180+ configuration file; a "controller" entry overrides the [Global] section.
181181 '''
182- cfg = {}
183182 service_conf = conf .SvcConf ()
183+ cfg = {
184+ 'subsysnqn' : self .tid .subsysnqn ,
185+ 'transport' : self .tid .transport ,
186+ 'traddr' : self .tid .traddr ,
187+ }
188+ if self .tid .trsvcid :
189+ cfg ['trsvcid' ] = self .tid .trsvcid
190+ if self .tid .host_traddr :
191+ cfg ['host_traddr' ] = self .tid .host_traddr
192+ if self .tid .host_iface and not service_conf .ignore_iface and self ._nvme_options .host_iface_supp :
193+ cfg ['host_iface' ] = self .tid .host_iface
194+
184195 for option , keyword in (
185196 ('kato' , 'keep_alive_tmo' ),
186197 ('queue-size' , 'queue_size' ),
@@ -206,21 +217,8 @@ def _get_cfg(self):
206217 return cfg
207218
208219 def _do_connect (self ):
209- service_conf = conf .SvcConf ()
210- host_iface = (
211- self .tid .host_iface
212- if (self .tid .host_iface and not service_conf .ignore_iface and self ._nvme_options .host_iface_supp )
213- else None
214- )
215- self ._ctrl = nvme .ctrl (
216- self ._root ,
217- subsysnqn = self .tid .subsysnqn ,
218- transport = self .tid .transport ,
219- traddr = self .tid .traddr ,
220- trsvcid = self .tid .trsvcid if self .tid .trsvcid else None ,
221- host_traddr = self .tid .host_traddr if self .tid .host_traddr else None ,
222- host_iface = host_iface ,
223- )
220+ cfg = self ._get_cfg ()
221+ self ._ctrl = nvme .ctrl (self ._root , cfg )
224222
225223 self ._ctrl .discovery_ctrl = self ._discovery_ctrl
226224
@@ -238,7 +236,7 @@ def _do_connect(self):
238236 # This is used for bidirectional authentication
239237 dhchap_ctrl_key = self .tid .cfg .get ('dhchap-ctrl-secret' )
240238 if dhchap_ctrl_key and self ._nvme_options .dhchap_ctrlkey_supp :
241- self ._ctrl .dhchap_key = dhchap_ctrl_key
239+ self ._ctrl .dhchap_ctrl_key = dhchap_ctrl_key
242240
243241 # Audit existing nvme devices. If we find a match, then
244242 # we'll just borrow that device instead of creating a new one.
@@ -253,12 +251,11 @@ def _do_connect(self):
253251 self ._on_connect_success , self ._on_connect_fail , self ._ctrl .init , self ._host , int (udev_obj .sys_number )
254252 )
255253 else :
256- cfg = self ._get_cfg ()
257254 logging .debug (
258255 'Controller._do_connect() - %s Connecting to nvme control with cfg=%s' , self .id , cfg
259256 )
260257 self ._connect_op = gutil .AsyncTask (
261- self ._on_connect_success , self ._on_connect_fail , self ._ctrl .connect , self ._host , cfg
258+ self ._on_connect_success , self ._on_connect_fail , self ._ctrl .connect , self ._host
262259 )
263260
264261 self ._connect_op .run_async ()
0 commit comments