Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions staslib/ctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class Controller(stas.ControllerABC):
def __init__(self, tid: trid.TID, service, discovery_ctrl: bool = False):
sysconf = conf.SysConf()
self._nvme_options = conf.NvmeOptions()
self._root = nvme.global_ctx()
self._host = nvme.host(
self._root = nvme.GlobalCtx()
self._host = nvme.Host(
self._root, hostnqn=sysconf.hostnqn, hostid=sysconf.hostid, hostsymname=sysconf.hostsymname
)
self._host.dhchap_key = sysconf.hostkey if self._nvme_options.dhchap_hostkey_supp else None
self._host.dhchap_host_key = sysconf.hostkey if self._nvme_options.dhchap_hostkey_supp else None
self._udev = udev.UDEV
self._device = None # Refers to the nvme device (e.g. /dev/nvme[n])
self._ctrl = None # libnvme's nvme.ctrl object
Expand Down Expand Up @@ -93,7 +93,7 @@ def all_ops_completed(self) -> bool:

def connected(self):
'''@brief Return whether a connection is established'''
return self._ctrl and self._ctrl.connected()
return self._ctrl and self._ctrl.connected

def controller_id_dict(self) -> dict:
'''@brief return the controller ID as a dict.'''
Expand Down Expand Up @@ -218,7 +218,7 @@ def _get_cfg(self):

def _do_connect(self):
cfg = self._get_cfg()
self._ctrl = nvme.ctrl(self._root, cfg)
self._ctrl = nvme.Ctrl(self._root, cfg)

self._ctrl.discovery_ctrl = self._discovery_ctrl

Expand Down Expand Up @@ -330,7 +330,7 @@ def cback(controller: Controller, success: bool)
logging.debug(
'Controller.disconnect() - %s | %s: keep_connection=%s', self.id, self.device, keep_connection
)
if self._ctrl and self._ctrl.connected() and not keep_connection:
if self._ctrl and self._ctrl.connected and not keep_connection:
logging.info('%s | %s - Disconnect initiated', self.id, self.device)
op = gutil.AsyncTask(self._on_disconn_success, self._on_disconn_fail, self._ctrl.disconnect)
op.run_async(disconnected_cb)
Expand Down Expand Up @@ -552,7 +552,7 @@ def _find_existing_connection(self):
def _post_registration_actions(self):
if conf.SvcConf().pleo_enabled and self._is_ddc():
self._get_supported_op = gutil.AsyncTask(
self._on_get_supported_success, self._on_get_supported_fail, self._ctrl.supported_log_pages
self._on_get_supported_success, self._on_get_supported_fail, self._ctrl.get_supported_log_pages
)
self._get_supported_op.run_async()
else:
Expand Down Expand Up @@ -656,10 +656,7 @@ def _on_get_supported_success(self, op_obj: gutil.AsyncTask, data):
)
return

try:
dlp_supp_opts = data[nvme.NVME_LOG_LID_DISCOVERY] >> 16
except (TypeError, IndexError):
dlp_supp_opts = 0
dlp_supp_opts = data[nvme.NVME_LOG_LID_DISCOVERY] >> 16

logging.debug(
'Dc._on_get_supported_success() - %s | %s: supported options = 0x%04X = %s',
Expand Down
2 changes: 1 addition & 1 deletion staslib/nbft.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
def get_nbft_files(root_dir=defs.NBFT_SYSFS_PATH):
"""Return a dictionary containing the NBFT data for all the NBFT binary files located in @root_dir"""
pathname = os.path.join(root_dir, defs.NBFT_SYSFS_FILENAME)
root = nvme.global_ctx()
root = nvme.GlobalCtx()
return {fname: nvme.nbft_get(root, fname) or {} for fname in glob.iglob(pathname=pathname)}
1 change: 1 addition & 0 deletions test/test-controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Ctrl:
def __init__(this):
this.name = 'nvme666'

@property
def connected(this):
return self._connected

Expand Down
Loading