MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: sonne (1011)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyc
�
d�bc@s�dZddlZddlZddlZddljjZddljjZddl	jj
jZddljj
j
Z
ddlmZmZmZdddgZd�Zdefd	��YZdddgZd
efd��YZdS(s>
Handle packages and modules to enable RDMA for IB networking
i����N(t	parse_doctfindt	getattribs
/etc/dat.confs/etc/rdma/dat.confs/usr/local/etc/dat.confcCs*tjd�t|j�}|dkr9tjd�dSt|d�}|s_tjd�dSt|d�}|s�tjd�dSt|d�}|s�tjd�dSd	jgt	d
t
|�d�D]}|||d!^q��}tjdj||��t
|||�j�tjd
�dS(Ns2Parsing SharedConfig XML contents for RDMA detailss)Could not parse SharedConfig XML documenttInstances2Could not find <Instance> in SharedConfig documenttrdmaIPv4AddresssYCould not find rdmaIPv4Address attribute on Instance element of SharedConfig.xml documenttrdmaMacAddresssXCould not find rdmaMacAddress attribute on Instance element of SharedConfig.xml documentt:iis$Found RDMA details. IPv4={0} MAC={1}sRDMA: device is set up(tloggertverboseRtxml_texttNoneterrorRRtjointrangetlentinfotformattRDMADeviceHandlertstart(t
nd_versiontshared_conftxml_doct
instance_elemtrdma_ipv4_addrt
rdma_mac_addrti((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pytsetup_rdma_device's4


	6

tRDMAHandlercBsYeZdZdZd�Zed��Zd�Zd�Z	d�Z
d�Zd�ZRS(	thv_network_directcCsC|jr|jSd}d}d}d}|d7}tjj|�sid}||7}tj||�dSt|d���}x�tr!|j|�}|j|�}|r|r|j	d	�d
}	|	r�|	j
�}	n|j	d	�d
}
|
r�|
j
�}
n|	dkr|
|_|jSq~Pq~WWdQXd}tj||�dS(
sRetrieve the firmware version information from the system.
           This depends on information provided by the Linux kernel.iis/var/lib/hyperv/.kvp_pool_0s&Kernel does not provide the necessary s-information or the kvp daemon is not running.s'RDMA: Source file "%s" does not exist. NtrbtitNdDriverVersions'RDMA: NdDriverVersion not found in "%s"(RtostpathtisfileRRtopentTruetreadt	partitiontdecode(tselftkvp_key_sizetkvp_value_sizetdriver_info_sourcetbase_kernel_err_msgt	error_msgt	pool_filetkeytvaluetkey_0tvalue_0((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pytget_rdma_versionOs<	

		
cCs�ddg}tjd�\}}|dkr@td|��nx@|D]8}||krntjd|�tStjd|�qGWtS(sILook for kvp daemon names in ps -ef output and return True/False
        t
hypervkvpdt
hv_kvp_daemonsps -efisRDMA: ps -ef failed: %ss RDMA: kvp daemon (%s) is runnings$RDMA: kvp daemon (%s) is not running(t	shellutiltrun_get_outputt	ExceptionRRR$RtFalse(tkvp_daemon_namestexitcodetps_outtn((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pytis_kvp_daemon_runningvs
cCsxtjd|j�tjd|j�}|dkrgd}|d7}tj||j|jf�tStjd�tS(suLoad the kernel driver, this depends on the proper driver
           to be installed with the install_driver() methodsRDMA: probing module '%s'smodprobe --first-time %sis#Could not load "%s" kernel module. s7Run "modprobe --first-time %s" as root for more detailss,RDMA: Loaded the kernel driver successfully.(RRtdriver_module_nameR6trunRR9R$(R(tresultR-((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pytload_driver_module�s

cCsC|jr2tj�r"|j�q?tjd�n
tjd�dS(Ns;RDMA: check RDMA driver is disabled, skip installing drivers8RDMA: skip installing driver when ndversion not present
(Rtconftenable_check_rdma_drivertinstall_driverRR(R(((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pytinstall_driver_if_needed�s
	
cCstjd�dS(sqInstall the driver. This is distribution specific and must
           be overwritten in the child implementation.s*RDMAHandler.install_driver not implementedN(RR(R(((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRE�scCsWd|j}tj|�\}}tjd�|rFtjd�tStjd�tS(s5Check if the network module is loaded in kernel spaceslsmod | grep ^%ss$RDMA: Checking if the module loaded.sRDMA: module loaded.sRDMA: module not loaded.(R?R6R7RRR$R9(R(tcmdtstatustloaded_modules((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pytis_driver_loaded�s



cCs<tjd�tjd�}|dkr8tjd�ndS(suReboot the system. This is required as the kernel module for
           the rdma driver cannot be unloaded with rmmodsRDMA: Rebooting system.sshutdown -r nowis!RDMA: Failed to reboot the systemN(RRR6R@R(R(tret((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyt
reboot_system�s
N(
t__name__t
__module__R?R
RR3tstaticmethodR>RBRFRERJRL(((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRKs	'					RcBseZdZdZdZdZdZdZdZdZ
dZdZd�Z
d�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��ZRS(s^
    Responsible for writing RDMA IP and MAC address to the /dev/hvnd_rdma
    interface.
    s/dev/hvnd_rdmas/sys/class/infinibandixii<cCs||_||_||_dS(N(t	ipv4_addrtmac_addrR(R(RPRQR((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyt__init__�s		cCs(tjd�|j�tjd�dS(Ns!RDMA: starting device processing.s"RDMA: completed device processing.(RRtprocess(R(((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyR�s

cCsny>|js&tjd�|j�ntjd�|j�Wn)tk
ri}tjdj|��nXdS(Ns%RDMA: provisioning SRIOV RDMA device.s.RDMA: provisioning Network Direct RDMA device.s#RDMA: device processing failed: {0}(RRRtprovision_sriov_rdmatprovision_network_direct_rdmaR8RR(R(te((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRS�s	


cCs�tjt|j�tj�sFtjd�tj|j	|j�dSt
}d}tjd|dt
�\}}|dkr�|j
�}n
tjd�tjd|�\}}|dkr�tjd|�dStjd	|�\}}|dkr�tjd
|tj�}|r�t|jd�d�}t|jd�d�}|dksl|dkr�|dkr�tjd
�t}q�q�tjd�n
tjd�|s�tj|j|j|j�tj|j|j|j	�ntj|j	|j�dS(Ns'RDMA: skip checking RDMA driver versionRsmodprobe -R %stchk_erris6RDMA: failed to resolve module name. Use original namesmodprobe %ssRDMA: failed to load module %ss
modinfo %ss version:\s+(\d+)\.(\d+)\.(\d+)\Diis+Skip setting /dev/hvnd_rdma on 4.1 or latersLRDMA: hv_network_direct driver version not present, assuming 4.0.x or older.s5RDMA: failed to get module info on hv_network_direct.(Rtupdate_dat_conftdapl_config_pathsRPRCRDRRtupdate_network_interfaceRQR9R6R7tstripRtretsearcht
IGNORECASEtinttgroupsR$twarntwait_rdma_devicetrdma_devtdevice_check_timeout_sectdevice_check_interval_sectwrite_rdma_config_to_device(R(tskip_rdma_devicetmodule_nametretcodetouttversiontv1tv2((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRU�s@

$

cCs�|j�\}}|r5tjd�|j|�n^|jr�tjd�tj|j|j|j	�tj
|j|j|j�n
tjd�dS(Ns0RDMA: provisioning multiple IP over IB addressess,RDMA: provisioning single IP over IB addresssRDMA: missing IP address(
tread_ipoib_dataRRtprovision_sriov_multiple_ibRPRtwait_any_rdma_devicet	sriov_dirRdRetupdate_iboip_interfacetipoib_check_timeout_sectipoib_check_interval_sec(R(R/R0((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRT
s
	
c	Csd}d}d}tjj|�s5tjd�d	Sd}d}t|d���}x�tr�|j|�}|j|�}|r�|r�|j	d�d}|r�|j
�}n|dkr�|j	d�d}|r�|j
�}nPq�qVPqVWWdQX|dkr
||fSd
S(Niis/var/lib/hyperv/.kvp_pool_0sRDMA: can't read KVP pool 0RRit
IPoIB_Data(NN(NN(R R!R"RRR
R#R$R%R&R'(	R(R)R*R+R1R2R.R/R0((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRns2
	
cCs�g}|jd�}t|�d}tjd|d�}|r�t|jd�d�}||kr�tjdj||��dSntjdj|d��dSx�t	d|d�D]|}tjd||�}|r|jd�d}|jd�d}	|j
||	f�q�tjdj||��dSq�Wd	}
xL|
dkr�|j|�}|t|�krrdStj
d�|
d8}
qAWtjd
�dS(Nt|isNUMPAIRS:(\d+)is<RDMA: multiple IPs reported num={0} actual number of IPs={1}s2RDMA: failed to find number of IP addresses in {0}s([^:]+):(\d+\.\d+\.\d+\.\d+)s*RDMA: failed to find MAC/IP address in {0}i<s,RDMA: failed to set all IP over IB addresses(tsplitRR\tmatchR_R`RRRR
tappendtupdate_iboip_interfacesttimetsleep(R(R0tmac_ip_arraytvaluestnum_ipsRxtnumRRQRPtretrytcount((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRo@s6
c
	Csd}tj|�}d}x�|D]�}tjd|�s@q"nd}ttjj||d���}|j�}WdQX|s�t	j
dj|��q"n|j�}tjd|�}|s�t	j
dj||��q"nd}|j|j
d��}x
|D]}	|	d|krd}
yXd	d
d|dg}tj|�d	d
ddj|	d�d|g}tj|�Wntjk
r�}|j}
nX|
dkr�t	jdj|	d|��n|
r�|
dkr�t	j
dj|	d|��n
|d7}PqqWq"W|S(Ns/sys/class/netisib\w+taddresss'RDMA: can't read address for device {0}s7.+(\w\w):(\w\w):(\w\w):\w\w:\w\w:(\w\w):(\w\w):(\w\w)\ns8RDMA: failed to parse address for device {0} address {1}ttiptlinktsettuptaddrtadds{0}/16itdevs#RDMA: set address {0} to device {1}is0RDMA: failed to set IP address {0} on device {1}(R tlistdirR\RxR
R#R!RR%RRRtupperR`R6trun_commandtCommandErrort
returncodeR(
R(R}tnet_dirtnicsR�tnicRQtaddress_fileRxtmac_ipRKt
ip_commandR((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRzlsH
!

%
  
c
Cs'tjd�||}d}d}x�|r�||kr�tjd�\}}|dkritd��ntjd|tj�}|r�Pnt	j
|�|d7}q&W|s�td��nd}tjd	�d
j||�}	tjdj|	��dkrtdj|	���ntjd
�dS(NsWait for ib0 become availableisifconfig -as!Failed to list network interfacestib0isib0 is not availableis:RDMA: configuring IPv4 addr and netmask on ipoib interfaces{0}/{1}sifconfig ib0 {0}sCould set addr to {0} on ib0s7RDMA: ipoib address and netmask configured on interface(
RRR
R6R7R8R\R]R^R{R|RR@(
RPttimeout_sectcheck_interval_sect
total_retriesR=t	found_ib0RKtoutputtnetmaskR�((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRr�s*



cCs�tjd�x�|D]�}tjdj|��tjj|�s^tjdj|��qntjdj|��tj|�}tj	||�}tj
||�tjd�dSWtd��dS(ss
        Looks at paths for dat.conf file and updates the ip address for the
        infiniband interface.
        s Updating DAPL configuration filesRDMA: trying {0}s"RDMA: DAPL config not found at {0}sRDMA: DAPL config is at: {0}s#RDMA: DAPL configuration is updatedNs;RDMA: DAPL configuration file not found at predefined paths(RRRR R!R"tfileutilt	read_fileRtreplace_dat_conf_contentst
write_fileR8(tpathsRPtftcfgtnew_cfg((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRX�s


cCs(d}dj|�}tj|||�S(NsFofa-v2-ib0 u2.0 nonthreadsafe default libdaplofa.so.2 dapl.2.0 "\S+ 0"sFofa-v2-ib0 u2.0 nonthreadsafe default libdaplofa.so.2 dapl.2.0 "{0} 0"(RR\tsub(R�RPtoldtnew((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyR��s	cCsktj||�}tjdj|��t|d��!}tjd�|j|�WdQXtjd�dS(Ns-RDMA: Updating device with configuration: {0}twsRDMA: Device opened for writings4RDMA: Updated device with IPv4/MAC addr successfully(Rtgenerate_rdma_configRRRR#twrite(R!RPRQtdataR�((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRf�s
cCsdj||�S(Ns*rdmaMacAddress="{0}" rdmaIPv4Address="{1}"(R(RPRQ((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyR��scCs�tjdj||��||}d}x`||kr�tjj|�r[tjd�dStjdj|��tj|�|d7}q,Wtj	d�t
dj||���dS(Ns)RDMA: waiting for device={0} timeout={1}sisRDMA: device readys"RDMA: device not ready, sleep {0}sisRDMA device wait timed outs7The device did not show up in {0} seconds ({1} retries)(RRRR R!texistsRR{R|RR8(R!R�R�R�R=((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRb�s



	cCs�tjdj||��||}d}xl||kr�tj|�}|rgtjdj|��dStjdj|��tj|�|d7}q,Wtjd�t	dj||���dS(NsERDMA: waiting for any Infiniband device at directory={0} timeout={1}sisRDMA: device found in {0}s"RDMA: device not ready, sleep {0}sisRDMA device wait timed outs7The device did not show up in {0} seconds ({1} retries)(
RRRR R�RR{R|RR8(t	directoryR�R�R�R=tr((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRp�s"



	cCs�d}tjd�tj|�}tjd|�tjd�tjdj|��dkrutdj|���ntjd�d	j||�}tjd
j||��dkr�tdj||���ntjd�dS(
Nis5RDMA: will update the network interface with IPv4/MACs"RDMA: network interface found: {0}s#RDMA: bringing network interface upsifconfig {0} upis&Could not bring up RMDA interface: {0}s4RDMA: configuring IPv4 addr and netmask on interfaces{0}/{1}sifconfig {0} {1}sCould set addr to {1} on {0}s9RDMA: network address and netmask configured on interface(RRRtget_interface_by_macR6R@RR8(RQRPR�tif_nameR�((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyRZs


!cCs�tjd�\}}|dkr0td��n|jdd�}tjdj|�|tj�}|dkr�tdj|���n|j	d�}tj
d|�}|dks�t|�dkr�td	j|���n|d
S(Nsifconfig -ais!Failed to list network interfacess
R�s(eth\d).*(HWaddr|ether) {0}s"Failed to get ifname with mac: {0}seth\dsifname with mac: {0} not foundi����(R6R7R8treplaceR\R]RR^R
tgrouptfindallR(tmacRKR�Rxteths((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyR�!sN(RMRNt__doc__RcRqRdReRsRtR
RPRQRRRRRSRURTRnRoRzRORrRXR�RfR�RbRpRZR�(((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyR�s6				)		"	,	8
(R�R R\R{tazurelinuxagent.common.conftcommonRCtazurelinuxagent.common.loggerRt%azurelinuxagent.common.utils.fileutiltutilsR�t&azurelinuxagent.common.utils.shellutilR6t%azurelinuxagent.common.utils.textutilRRRRYRtobjectRR(((s?/usr/lib/python2.7/site-packages/azurelinuxagent/common/rdma.pyt<module>s		$p