Skip to content

Commit

Permalink
handle target kernel module new attribute cpus_allowed_list
Browse files Browse the repository at this point in the history
target has been added cpus_allowed_list attribute in sysfs.
Therefore, the rtslib should handle the new attribute:
    1. add cpus_allowed_list item in target_names_excludes
    2. add cpus_allowed_list feature in ISCSIFabricModule

Signed-off-by: Zou Mingzhe mingzhe.zou@easystack.cn
  • Loading branch information
zoumingzhe committed Feb 14, 2022
1 parent 6198db8 commit 8d2543c
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions rtslib/fabric.py
Expand Up @@ -118,9 +118,15 @@
from .target import Target
from .utils import _get_auth_attr, _set_auth_attr

version_attributes = set(["lio_version", "version"])
discovery_auth_attributes = set(["discovery_auth"])
target_names_excludes = version_attributes | discovery_auth_attributes
excludes_list = [
# version_attributes
"lio_version", "version",
# discovery_auth_attributes
"discovery_auth",
# cpus_allowed_list_attributes
"cpus_allowed_list",
]
target_names_excludes = set(excludes_list)


class _BaseFabricModule(CFSNode):
Expand All @@ -144,7 +150,8 @@ def __init__(self, name):
self.name = name
self.spec_file = "N/A"
self._path = "%s/%s" % (self.configfs_dir, self.name)
self.features = ('discovery_auth', 'acls', 'auth', 'nps', 'tpgts')
self.features = ('discovery_auth', 'acls', 'auth', 'nps', 'tpgts',
'cpus_allowed_list')
self.wwn_types = ('free',)
self.kernel_module = "%s_target_mod" % self.name

Expand Down Expand Up @@ -220,6 +227,18 @@ def _assert_feature(self, feature):
raise RTSLibError("Fabric module %s does not implement "
+ "the %s feature" % (self.name, feature))

def _get_cpus_allowed_list(self):
self._check_self()
self._assert_feature('cpus_allowed_list')
path = "%s/cpus_allowed_list" % self.path
return fread(path)

def _set_cpus_allowed_list(self, allowed):
self._check_self()
self._assert_feature('cpus_allowed_list')
path = "%s/cpus_allowed_list" % self.path
fwrite(path, allowed)

def clear_discovery_auth_settings(self):
self._check_self()
self._assert_feature('discovery_auth')
Expand Down Expand Up @@ -267,6 +286,11 @@ def _set_disc_attr(self, *args, **kwargs):
self._assert_feature('discovery_auth')
_set_auth_attr(self, *args, **kwargs)

cpus_allowed_list = \
property(_get_cpus_allowed_list,
_set_cpus_allowed_list,
doc="Set or get the cpus_allowed_list attribute.")

discovery_enable_auth = \
property(_get_discovery_enable_auth,
_set_discovery_enable_auth,
Expand Down

0 comments on commit 8d2543c

Please sign in to comment.