* Use rtslib_fb instead of 'rtslib' as upstream changed. * New method access_group_list(): Return a list of access group in the format of
[ { 'name': str 'init_ids': list(str), 'init_type': str, }, ]
The 'name' is the name of acccess group. The 'init_ids' of result is the iSCSI IQN/NAA/EUI address of initiators which belong to current access group. Example: ['iqn.2000-04.com.example:someone-01'] The 'init_type' is reserved for future use, currently, it is 'iscsi'
Signed-off-by: Gris Ge fge@redhat.com --- API.md | 27 +++++++++++++++++++++++++++ targetd/block.py | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/API.md b/API.md index 9db742a..56044ad 100644 --- a/API.md +++ b/API.md @@ -122,6 +122,33 @@ Returns: Errors: N/A
+Access Group operations +----------------------- +Access Group is a group of initiators which sharing the same volume mapping +status. + +### access_group_list() +List all access groups. + +Parameters: + N/A +Returns: + [ + { + 'name': str + 'init_ids': list(str), + 'init_type': str, + }, + ] + The 'name' is the name of acccess group. + The 'init_ids' of result is the iSCSI IQN/NAA/EUI address of initiators + which belong to current access group. + Example: ['iqn.2000-04.com.example:someone-01'] + The 'init_type' is reserved for future use, currently, it is 'iscsi'. + +Errors: + N/A + File system operations ---------------------- Ability to create different file systems and perform operation on them. The diff --git a/targetd/block.py b/targetd/block.py index b17c58a..2e185ef 100644 --- a/targetd/block.py +++ b/targetd/block.py @@ -16,8 +16,9 @@ # Routines to export block devices over iscsi.
import contextlib -from rtslib import (Target, TPG, NodeACL, FabricModule, BlockStorageObject, RTSRoot, - NetworkPortal, LUN, MappedLUN, RTSLibError, RTSLibNotInCFS) +from rtslib_fb import ( + Target, TPG, NodeACL, FabricModule, BlockStorageObject, RTSRoot, + NetworkPortal, LUN, MappedLUN, RTSLibError, RTSLibNotInCFS) import lvm from main import TargetdError from utils import ignored @@ -106,6 +107,7 @@ def initialize(config_dict): export_destroy=export_destroy, initiator_set_auth=initiator_set_auth, initiator_list=initiator_list, + access_group_list=access_group_list, )
@@ -367,3 +369,31 @@ def initiator_list(req, standalone_only=False): {'init_id': node_acl.node_wwn, 'init_type': 'iscsi'} for node_acl in _get_iscsi_tpg().node_acls if _condition(node_acl, standalone_only)) + + +def access_group_list(req): + """Return a list of access group + + Iterate all iSCSI rtslib-fb.NodeACLGroup via rtslib-fb.TPG.node_acls(). + Args: + req (TargetHandler): Reserved for future use. + Returns: + [ + { + 'name': str, + 'init_ids': list(str), + 'init_type': 'iscsi', + }, + ] + Currently, targetd only support iscsi which means init_type is always + 'iscsi'. + Raises: + N/A + """ + return list( + { + 'name': node_acl_group.name, + 'init_ids': list(node_acl_group.wwns), + 'init_type': 'iscsi', + } + for node_acl_group in _get_iscsi_tpg().node_acl_groups)