Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
idna / lib / python2.7 / site-packages / os_brick / initiator / linuxfc.pyc
Size: Mime:
ó
ˍEYc@s¦dZddlZddlZddlmZddlmZddl	m
Z
ejeƒZ
de
jfd„ƒYZdefd	„ƒYZd
efd„ƒYZdS(s&Generic linux Fibre Channel utilities.iÿÿÿÿN(tprocessutils(tlog(t	linuxscsitLinuxFibreChannelcBsGeZd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs$d}tjj|ƒrtStSdS(Ns/sys/class/fc_host(tostpathtisdirtTruetFalse(tselftFC_HOST_SYSFS_PATH((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pythas_fc_supportsc	Csð|d}|r/t|ƒdkr/|d}nd|}di|dd6|d6}yb|j|ƒ\}}g|jdƒD]5}|j|ƒr}|jd	ƒdjd
ƒd^q}SWn2tk
rë}tjdi|d6|d
6ƒdSXdS(sTry to get the HBA channel and SCSI target for an HBA.

        This method only works for Fibre Channel targets that implement a
        single WWNN for all ports, so caller should expect us to return either
        None or an empty list.

        :returns: List or None
        thost_deviceis!/sys/class/fc_transport/target%s:s!grep %(wwnn)s %(path)s*/node_namet	node_nametwwnnRs
t/t:isPCould not get HBA channel and SCSI target ID, path: %(path)s, reason: %(reason)streasonN(tlent_executetsplitt
startswitht	ExceptiontLOGtdebugtNone(	R	thbaRRtcmdtoutt_errtlinetexc((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pyt_get_hba_channel_scsi_target%s



J	
cCs¹x²|D]ª}|j|ƒ}|s.dg}nx€|D]x\}}tjdi|dd6|dd6|d6|d6|d	6ƒ|jd
|ddi|d6|d
6|d6ƒq5WqWdS(Nt-sRScanning host %(host)s (wwnn: %(wwnn)s, c: %(channel)s, t: %(target)s, l: %(lun)s)RthostR
Rtchannelttargettluns/sys/class/scsi_host/%s/scans%(c)s %(t)s %(l)stctttl(R!R!(R RRtecho_scsi_command(R	thbast
target_lunRtctsthba_channelt	target_id((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pytrescan_hosts@s
	
c	CsÍ|jƒstjdƒgSd}y1|jdddddtd|jƒ\}}Wnktjk
rŒ}|j	dkrˆtj
d	ƒngStk
rÁ}|jtj
kr½tj
d	ƒngSX|dkrÒgS|jd
ƒ}|d}g}i}d}xÉ|D]Á}|jƒ}|dkrY|dkrYt|ƒd
kr¿|j|ƒi}q¿nf|jdƒ}	t|	ƒdkr¿|	d
jƒjddƒ}
|	djƒ}|jddƒ||
<n|}qW|S(s&Get the Fibre Channel HBA information.s,No Fibre Channel support detected on system.tsystools-ctfc_hosts-vtrun_as_roottroot_helperi`ssystool is not installeds
itit=t it"N(RRRRRRt_root_helpertputilstProcessExecutionErrort	exit_codetwarningtOSErrorterrnotENOENTRtstripRtappendtreplace(R	RRRtlinesR*RtlastlineRtvaltkeytvalue((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pytget_fc_hbasSsH




cCs|jƒ}g}xw|D]o}|djddƒ}|djddƒ}|d}|d}|ji|d6|d6|d6|d6ƒqW|S(	s@Get Fibre Channel WWNs and device paths from the system, if any.t	port_namet0xR4R
tClassDevicepathtClassDeviceRtdevice_path(RHRBRA(R	R*t	hbas_infoRtwwpnRRMtdevice((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pytget_fc_hbas_infoŠs


cCs]|jƒ}g}xD|D]<}|ddkr|djddƒ}|j|ƒqqW|S(s0Get Fibre Channel WWPNs from the system, if any.t
port_statetOnlineRIRJR4(RHRBRA(R	R*twwpnsRRO((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pytget_fc_wwpnss
cCs]|jƒ}g}xD|D]<}|ddkr|djddƒ}|j|ƒqqW|S(s0Get Fibre Channel WWNNs from the system, if any.RRRSR
RJR4(RHRBRA(R	R*twwnnsRR((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pytget_fc_wwnns¬s
(	t__name__t
__module__RR R/RHRQRURW(((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pyRs				7		tLinuxFibreChannelS390XcBs#eZd„Zd„Zd„ZRS(cCs£|jƒ}g}xŠ|D]‚}|ddkr|djddƒ}|djddƒ}|d}|d}|ji|d6|d6|d	6|d
6ƒqqW|S(s@Get Fibre Channel WWNs and device paths from the system, if any.RRRSRIRJR4R
RKRLRRM(RHRBRA(R	R*RNRRORRMRP((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pyRQ½s


cCs*tjdi|d6|d6|d6ƒd||f}tjj|ƒsµd|}tjd|ƒy|j|dƒWqµtjk
r±}tjd	i|j	d
6|j
d6ƒqµXnd||f}tjd
|ƒy|j||ƒWn:tjk
r%}tjdi|j	d
6|j
d6ƒnXdS(sgWrite the LUN to the port's unit_add attribute.

        If auto-discovery of Fibre-Channel target ports is
        disabled on s390 platforms, ports need to be added to
        the configuration.
        If auto-discovery of LUNs is disabled on s390 platforms
        luns need to be added to the configuration through the
        unit_add interface
        shConfigure lun for s390: device_number=%(device_num)s target_wwn=%(target_wwn)s target_lun=%(target_lun)st
device_numt
target_wwnR+s/sys/bus/ccw/drivers/zfcp/%s/%ss(/sys/bus/ccw/drivers/zfcp/%s/port_rescansport_rescan call for s390: %st1sAport_rescan call for s390 failed exit %(code)s, stderr %(stderr)stcodetstderrs(/sys/bus/ccw/drivers/zfcp/%s/%s/unit_adds"unit_add call for s390 execute: %ss>unit_add call for s390 failed exit %(code)s, stderr %(stderr)sN(RRRRtexistsR)R9R:R<R;R_(R	t
device_numberR\R%tfilepathtzfcp_device_commandR((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pytconfigure_scsi_deviceÏs.
	

	"
	cCsštjdi|d6|d6|d6ƒd||f}tjd|ƒy|j||ƒWn:tjk
r•}tjdi|jd6|jd	6ƒnXd
S(sÝWrite the LUN to the port's unit_remove attribute.

        If auto-discovery of LUNs is disabled on s390 platforms
        luns need to be removed from the configuration through the
        unit_remove interface
        sjDeconfigure lun for s390: device_number=%(device_num)s target_wwn=%(target_wwn)s target_lun=%(target_lun)sR[R\R+s+/sys/bus/ccw/drivers/zfcp/%s/%s/unit_removes%unit_remove call for s390 execute: %ssAunit_remove call for s390 failed exit %(code)s, stderr %(stderr)sR^R_N(RRR)R9R:R<R;R_(R	RaR\R%RcR((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pytdeconfigure_scsi_deviceõs	

	(RXRYRQRdRe(((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pyRZ¼s		&tLinuxFibreChannelPPC64cBseZd„Zd„ZRS(c
Csä|d}|r/t|ƒdkr/|d}nd|}di|d6|d6}yh|j|dtƒ\}}g|jdƒD]5}|j|ƒr|jd	ƒdjd
ƒd^qSWn$tk
rß}	tjd|	ƒd
SXd
S(sTry to get the HBA channel and SCSI target for an HBA.

        This method works for Fibre Channel targets iterating over all the
        target wwpn port and finding the c, t, l. so caller should expect us to
        return either None or an empty list.
        Ris!/sys/class/fc_transport/target%s:s$grep -l %(wwpn)s %(path)s*/port_nameRORtshells
RRis8Could not get HBA channel and SCSI target ID, reason: %sN(	RRRRRRRterrorR(
R	RRORRRRRRR((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pyR s



J	c	CsÑxÊ|D]Â}x¹|dD]­}|j||ƒ}|sBdg}nx€|D]x\}}tjdi|dd6|dd6|d6|d6|d	6ƒ|jd
|ddi|d6|d
6|d6ƒqIWqWqWdS(NR\R!sRScanning host %(host)s (wwpn: %(wwpn)s, c: %(channel)s, t: %(target)s, l: %(lun)s)RR"ROR#R$R%s/sys/class/scsi_host/%s/scans%(c)s %(t)s %(l)sR&R'R((R!R!(R RRR)(R	R*R+RROR,R-R.((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pyR/&s"
	
(RXRYR R/(((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pyRf
s	(t__doc__R>Rtoslo_concurrencyRR9toslo_logRtloggingtos_brick.initiatorRt	getLoggerRXRt	LinuxSCSIRRZRf(((sO/home/tvault/.virtenv/lib/python2.7/site-packages/os_brick/initiator/linuxfc.pyt<module>s Q