grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a ·( f0Iã@spdZddlmZddlmZddlZddlZddlmZddl m Z m Z m Z m Z ddl mZmZmZdd lmZdd l mZmZgd ¢ZeeƒZGd d „d eƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZ Gdd„deƒZ!Gd d!„d!eƒZ"Gd"d#„d#eƒZ#eeed$œZ$Gd%d&„d&e%ƒZ&dS)'aI This file is part of RTSLib. Copyright (c) 2011-2013 by Datera, Inc Copyright (c) 2011-2014 by Red Hat, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Description ----------- Fabrics may differ in how fabric WWNs are represented, as well as what capabilities they support Available parameters -------------------- * features Lists the target fabric available features. Default value: ("discovery_auth", "acls", "auth", "nps") example: features = ("discovery_auth", "acls", "auth") example: features = () # no features supported Detail of features: * tpgts The target fabric module is using iSCSI-style target portal group tags. * discovery_auth The target fabric module supports a fabric-wide authentication for discovery. * acls The target's TPGTs support explicit initiator ACLs. * auth The target's TPGT's support per-TPG authentication, and the target's TPGT's ACLs support per-ACL initiator authentication. Fabrics that support auth must support acls. * nps The TPGTs support iSCSI-like IPv4/IPv6 network portals, using IP:PORT group names. * nexus The TPGTs have a 'nexus' attribute that contains the local initiator serial unit. This attribute must be set before being able to create any LUNs. * wwn_types Sets the type of WWN expected by the target fabric. Defaults to 'free'. Usually a fabric will only support one type but iSCSI supports more. First entry is the "native" wwn type - i.e. if a wwn can be generated, it will be of this type. Example: wwn_types = ("eui",) Current valid types are: * free Freeform WWN. * iqn The fabric module targets are using iSCSI-type IQNs. * naa NAA FC or SAS address type WWN. * eui EUI-64. See http://en.wikipedia.org/wiki/MAC_address for info on this format. * unit_serial Disk-type unit serial. * wwns This property returns an iterable (either generator or list) of valid target WWNs for the fabric, if WWNs should be chosen from existing fabric interfaces. The most common case for this is hardware-set WWNs. WWNs should conform to rtslib's normalized internal format: the wwn type (see above), a period, then the wwn with interstitial dividers like ':' removed. * to_fabric_wwn() Converts WWNs from normalized format (see above) to whatever the kernel code expects when getting a wwn. Only needed if different from normalized format. * kernel_module Sets the name of the kernel module implementing the fabric modules. If not specified, it will be assumed to be MODNAME_target_mod, where MODNAME is the name of the fabric module, from the fabrics list. Note that you must not specify any .ko or such extension here. Example: self.kernel_module = "my_module" * _path Sets the path of the configfs group used by the fabric module. Defaults to the name of the module from the fabrics list. Example: self._path = "%s/%s" % (self.configfs_dir, "my_cfs_dir") é)Úpartial)ÚiglobNé)ÚCFSNode)ÚfreadÚfwriteÚ normalize_wwnÚcolonize)Ú RTSLibErrorÚmodprobeÚignored)ÚTarget)Ú_get_auth_attrÚ_set_auth_attr)Z lio_versionÚversionÚdiscovery_authÚcpus_allowed_listcsŒeZdZdZ‡fdd„Z‡fdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zeeed(d)�Zeeed*d)�Zeed+d)�Zeeed,d-�eed,d-�d.d)�Zeeed/d-�eed/d-�d0d)�Zeeed1d-�eed1d-�d2d)�Zeeed3d-�eed3d-�d4d)�Zeed5d)�Z eed6d)�Z!eed7d)�Z"d8d9„Z#‡fd:d;„Z$‡Z%S)<Ú_BaseFabricModuleai Abstract Base clase for Fabric Modules. It can load modules, provide information about them and handle the configfs housekeeping. After instantiation, whether or not the fabric module is loaded depends on if a method requiring it (i.e. accessing configfs) is used. This helps limit loaded kernel modules to just the fabrics in use. csHtt|ƒ ¡||_d|_d|j|jf|_d|_d|_d|j|_ dS)z¦ Instantiate a FabricModule object, according to the provided name. @param name: the name of the FabricModule object. @type name: str zN/Aú%s/%s)rÚaclsÚauthZnpsÚtpgtsr)Úfreez %s_target_modN) ÚsuperrÚ__init__ÚnameZ spec_fileÚ configfs_dirÚ_pathÚfeaturesÚ wwn_typesÚ kernel_module)Úselfr©Ú __class__©ú1/usr/lib/python3.9/site-packages/rtslib/fabric.pyr�sz_BaseFabricModule.__init__csN|jsr$r$r%Ú"_get_discovery_authenticate_target s  z4_BaseFabricModule._get_discovery_authenticate_targetcCsdS)zc Returns either iterable or None. None means fabric allows arbitrary WWNs. Nr$r)r$r$r%Ú _get_wwnssz_BaseFabricModule._get_wwnscOs | d¡t|g|¢Ri|¤ŽS©Nr)r<r©r!ÚargsÚkwargsr$r$r%Ú_get_disc_attrs z _BaseFabricModule._get_disc_attrcOs$| d¡t|g|¢Ri|¤ŽdSrR)r<rrSr$r$r%Ú_set_disc_attrs z _BaseFabricModule._set_disc_attrz+Set or get the cpus_allowed_list attribute.)Údocz*Set or get the discovery enable_auth flag.z3Get the boolean discovery authenticate target flag.zdiscovery_auth/userid)Z attributez*Set or get the initiator discovery userid.zdiscovery_auth/passwordz,Set or get the initiator discovery password.zdiscovery_auth/userid_mutualz'Set or get the mutual discovery userid.zdiscovery_auth/password_mutualz)Set or get the mutual discovery password.zGet the list of target objects.z%Get the fabric module version string.z(iterable of WWNs present for this fabriccCsRt |¡D]B\}}|dkr zt|||ƒWq |d|d|fƒYq 0q dS)z@ Setup fabricmodule with settings from fm dict. rz&Could not set fabric %s attribute '%s'N)ÚsixZ iteritemsÚsetattr)r!ZfmZerr_funcrrLr$r$r%ÚsetupCs z_BaseFabricModule.setupcsZtt|ƒ ¡}|j|d<| d¡rVdD]$}t|d|dƒ}|r&||d|<q&|j|d<|S)Nrr)ZuseridÚpasswordZ mutual_useridZmutual_passwordZ discovery_rG)rrÚdumprr+ÚgetattrrG)r!Údr6Úvalr"r$r%r]Ns   z_BaseFabricModule.dump)&Ú__name__Ú __module__Ú __qualname__Ú__doc__rr(r+r4r7r8r9r2r;r<r?rArHrMrOrPrQrVrWÚpropertyrrGZdiscovery_authenticate_targetrrFrErDrCÚtargetsrr:r[r]Ú __classcell__r$r$r"r%r„sx      þÿþÿÿ  þ  þ  þ  þÿÿÿ rcseZdZ‡fdd„Z‡ZS)ÚISCSIFabricModulecstt|ƒ d¡d|_dS)NÚiscsi)ZiqnÚnaaÚeui)rrhrrr)r"r$r%r\szISCSIFabricModule.__init__©rarbrcrrgr$r$r"r%rhZsrhcseZdZ‡fdd„Z‡ZS)ÚLoopbackFabricModulecs&tt|ƒ d¡d|_d|_d|_dS)NÚloopback©Únexus©rjZtcm_loop)rrmrrrr r)r"r$r%rbszLoopbackFabricModule.__init__rlr$r$r"r%rmasrmcs8eZdZ‡fdd„Zdd„Zdd„Zedd„ƒZ‡ZS) ÚSBPFabricModulecs&tt|ƒ d¡d|_d|_d|_dS)NZsbpr$)rkZ sbp_target)rrrrrrr r)r"r$r%rjszSBPFabricModule.__init__cCs |dd…S©Nér$r3r$r$r%r9pszSBPFabricModule.to_fabric_wwncCsd|S)Núeui.r$r3r$r$r%r2sszSBPFabricModule.from_fabric_wwnccsLtdƒD]>}ttt|ƒƒƒrtj |¡d}dt|ƒdd…VqHqdS)Nz&/sys/bus/firewire/devices/fw*/is_localz/guidrué)ÚglobrJrKrr-r/Údirname)r!ÚfnameZ guid_pathr$r$r%r:ws  zSBPFabricModule.wwns© rarbrcrr9r2rer:rgr$r$r"r%rris  rrcs8eZdZ‡fdd„Zdd„Zdd„Zedd„ƒZ‡ZS) ÚQla2xxxFabricModulecs&tt|ƒ d¡d|_d|_d|_dS)NÚqla2xxx©rrqZ tcm_qla2xxx)rr{rrrr r)r"r$r%r�szQla2xxxFabricModule.__init__cCst|dd…ƒSrs©r r3r$r$r%r9‡sz!Qla2xxxFabricModule.to_fabric_wwncCsd| dd¡S©Núnaa.ú:rB©Úreplacer3r$r$r%r2‹sz#Qla2xxxFabricModule.from_fabric_wwnc cs”tdƒD]†}ttƒ�jtj tj |¡¡}| dd¡d}tj tj |d¡¡}|dkrpdt |ƒdd…VWdƒq1s„0YqdS) Nú"/sys/class/fc_host/host*/port_nameú/érú/driverr|r€rv© rwr ÚIOErrorr-r/ÚrealpathrxÚrsplitÚbasenamer©r!Úwwn_fileÚhostÚdeviceZdriverr$r$r%r:Žs  zQla2xxxFabricModule.wwnsrzr$r$r"r%r{€s  r{cs8eZdZ‡fdd„Zdd„Zdd„Zedd„ƒZ‡ZS) ÚEfctFabricModulecs&tt|ƒ d¡d|_d|_d|_dS)NÚefctr}rq)rr‘rrrr r)r"r$r%ršszEfctFabricModule.__init__cCst|dd…ƒSrsr~r3r$r$r%r9 szEfctFabricModule.to_fabric_wwncCsd| dd¡Srr‚r3r$r$r%r2¤sz EfctFabricModule.from_fabric_wwnc cs”tdƒD]†}ttƒ�jtj tj |¡¡}| dd¡d}tj tj |d¡¡}|dkrpdt |ƒdd…VWdƒq1s„0YqdS) Nr„r…r†rr‡r’r€rvrˆr�r$r$r%r:§s  zEfctFabricModule.wwnsrzr$r$r"r%r‘™s  r‘cs8eZdZ‡fdd„Zdd„Zdd„Zedd„ƒZ‡ZS) ÚSRPTFabricModulecs&tt|ƒ d¡d|_d|_d|_dS)NÚsrptr})ZibZib_srpt)rr“rrrr r)r"r$r%r³szSRPTFabricModule.__init__cCsd|dd…S)NÚ0xr†r$r3r$r$r%r9¹szSRPTFabricModule.to_fabric_wwncCsd|dd…S)Núib.rvr$r3r$r$r%r2½sz SRPTFabricModule.from_fabric_wwnccs(tdƒD]}dt|ƒ dd¡VqdS)Nz&/sys/class/infiniband/*/ports/*/gids/0r–r�rB)rwrrƒ)r!rŽr$r$r%r:Às zSRPTFabricModule.wwnsrzr$r$r"r%r“²s  r“cs8eZdZ‡fdd„Zdd„Zdd„Zedd„ƒZ‡ZS) ÚFCoEFabricModulecs6tt|ƒ d¡d|_d|_d|_d|jdf|_dS)NZtcm_fcr}rqrZfc)rr—rrr rrrr)r"r$r%rÇs zFCoEFabricModule.__init__cCst|dd…ƒSrsr~r3r$r$r%r9ÏszFCoEFabricModule.to_fabric_wwncCsd| dd¡Srr‚r3r$r$r%r2Ósz FCoEFabricModule.from_fabric_wwnc cs”tdƒD]†}ttƒ�jtj tj |¡¡}| dd¡d}tj tj |d¡¡}|dkrpdt |ƒdd…VWdƒq1s„0YqdS) Nr„r…r†rz /subsystemZfcoer€rvrˆ)r!rŽr�r�Z subsystemr$r$r%r:Ös  zFCoEFabricModule.wwnsrzr$r$r"r%r—Æs  r—cseZdZ‡fdd„Z‡ZS)ÚUSBGadgetFabricModulecs&tt|ƒ d¡d|_d|_d|_dS)NZ usb_gadgetrorqZtcm_usb_gadget)rr˜rrrr r)r"r$r%râszUSBGadgetFabricModule.__init__rlr$r$r"r%r˜ásr˜cseZdZ‡fdd„Z‡ZS)ÚVhostFabricModulecs&tt|ƒ d¡d|_d|_d|_dS)NZvhost)rprrrqZ tcm_vhost)rr™rrrr r)r"r$r%rêszVhostFabricModule.__init__rlr$r$r"r%r™ésr™cseZdZ‡fdd„Z‡ZS)ÚXenPvScsiFabricModulecs6tt|ƒ d¡d|jdf|_d|_d|_d|_dS)Nz xen-pvscsir)rprrqz xen-scsiback)rršrrrrrr r)r"r$r%rñs zXenPvScsiFabricModule.__init__rlr$r$r"r%ršðsršcs(eZdZ‡fdd„Zedd„ƒZ‡ZS)ÚIbmvscsisFabricModulecs tt|ƒ d¡d|_d|_dS)NZ ibmvscsisr$)rr›rrr r)r"r$r%rúszIbmvscsisFabricModule.__init__ccs2tdƒD]$}t|ƒ}|| d¡dd…VqdS)Nz5/sys/module/ibmvscsis/drivers/vio:ibmvscsis/*/devspecú@r)rwrÚfind)r!rŽrr$r$r%r:ÿs zIbmvscsisFabricModule.wwns)rarbrcrrer:rgr$r$r"r%r›ùs r›)r”rirnc@s,eZdZdd„Zedd„ƒZedd„ƒZdS)Ú FabricModulecCs t|ƒS©N)Úfabric_modules)Úclsrr$r$r%Ú__new__szFabricModule.__new__ccst t¡D] }|ƒVq dSrŸ)rYZ itervaluesr )r¡Úmodr$r$r%ÚallszFabricModule.allcCs(z t d¡WSty"gYS0dS)Nz#/sys/module/target_core_mod/holders)r-r.ÚOSError)r¡r$r$r%Úlist_registered_drivers"s  z$FabricModule.list_registered_driversN)rarbrcr¢Ú classmethodr¤r¦r$r$r$r%ržs  rž)'rdÚ functoolsrrwrr-rYZnoderZutilsrrrr r r r Útargetr rrZ excludes_listÚsetr1rrhrmrrr{r‘r“r—r˜r™ršr›r Úobjectržr$r$r$r%Ús:m    W ý