HEX
Server: Apache
System: Linux a16-asgard6.hospedagemuolhost.com.br 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: maoristu4c3dbd03 (1436)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/up2date_client/__pycache__/hardware.cpython-39.pyc
a

c8h��@sJdZddlmZmZmZmZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl
mZzeWney�eZYn0zddlZdZWney�d	ZYn0zddlZddlZdZWney�d	ZYn0ddlZejd
dd�Zeed��seje_ejZddlZe�d
dg��ddl Z Wd�n1�sJ0Yddl	m!Z!zddl"m#Z#m$Z$dZ%WnZe�y�zddl&m#Z#m$Z$dZ%Wn,e�y�ddl'm(Z(m)Z)m*Z*dZ%Yn0Yn0zddl+Z+Wne�y�dZ+Yn0ej,�-d�zddl.m/Z0dZ1Wne�y2d	Z1Yn0da2da3dd�Z4e4�Z5e5�rne �6�e!�7�Z8e8�9de5�dd�Z:dd�Z;dd�Z<dd�Z=d d!�Z>d"d#�Z?d$d%�Z@d&d'�ZAd(d)�ZBd*d+�ZCd,d-�ZDd.d/�ZEd0d1�ZFd2d3�ZGd4d5�ZHd6d7�ZId8d9�ZJd:d;�ZKd<d=�Z/eLd>k�rFe/�D].ZMeM�N�D]ZOePd?eOeMeOf��q"eP�qdS)@z1Used to read hardware info from kudzu, /proc, etc�)�gethostname�getaddrinfo�AF_INET�AF_INET6N)�config)�	rhnserver)�up2dateUtils)�ustrTFzrhn-client-tools)�fallback�ugettextzFailed to save log entryzSMBIOS.*: entry point at)�
up2dateLog)�get_devices�get_computer_info�)�check_hal_dbus_status�get_hal_computer�read_halz/usr/share/rhsm)�HardwarecCsttd�sdSt��S)N�get_warnings)�hasattr�	dmidecoder�rr�;/usr/lib/python3.9/site-packages/up2date_client/hardware.py�dmi_warnings[s
rz.Warnings collected during dmidecode import: %scCs�tdur�trdSt��}|�tj�z6|�d�}t�}|rXt��t	�
�}|�d|�Wn$dat�}|rxt��YdS0|��atS)z= Initialize _dmi_data unless it already exist and returns it N�allzdmidecode warnings: %sr)
�	_dmi_data�_dmi_not_availablerZdmidecodeXMLZ
SetResultTypeZ
DMIXML_DOCZQuerySectionr�clear_warningsr�initLog�	log_debugZxpathNewContext)Zdmixml�data�dmi_warn�logrrr�_initialize_dmi_datags(
r#cCs6t�}|durdS|�|�}|gkr.|djSdSdS)z� Fetch DMI data from given section using given path.
        If data could not be retrieved, returns empty string.
        General method and should not be used outside of this module.
    N�r)r#Z	xpathEvalZcontent)�pathZdmi_datar rrr�get_dmi_data�s

r&cCstd�S)zt Return Vendor from dmidecode bios information.
        If this value could not be fetch, returns empty string.
    �/dmidecode/BIOSinfo/Vendor�r&rrrr�
dmi_vendor�sr)cCstd�}|sd}|S)zt Return UUID from dmidecode system information.
        If this value could not be fetch, returns empty string.
    z7/dmidecode/SystemInfo/SystemUUID[not(@unavailable='1')]r$r()Zuuidrrr�dmi_system_uuid�sr*cCs�t�dtj�siStdd���}i}d|d<|D]X}t|�s>q0|�d�}t|�dkrVq0|d��}||d<d�|dd����||d<q0|S)	Nz/etc/sysconfig/installinfo�rZINSTALLINFO�class�=rrr$)	�os�access�R_OK�open�	readlines�len�split�strip�join)ZinstallinfoZinstalldict�info�valsZstrippedstringrrr�read_installinfo�s
 r9csFzt�d�}Wnty$g}Yn0t�d��t�fdd�|D��S)z� returns number of CPU in system

    Beware that it can be different from number of active CPU (e.g. on s390x architecture
    z/sys/devices/system/cpu/z^cpu[0-9]+$csg|]}��|�r|�qSr)�match)�.0�i�Zre_cpurr�
<listcomp>��zcpu_count.<locals>.<listcomp>)r.�listdir�OSError�re�compiler3)Zcpu_dirrr=r�	cpu_count�s

rDcCs�ztrt���dWSWnYn0d}t�dtj�r�z\t�d���}d}|D].}|�d�r`qPt	|�
d�d�}||krP|}qP|dkr�d	|WSWnYn0t�d
tj��r"zbtd
d���}t
�}|D],}d|vr�t	|�
d
�d	���}|�|�q�t|�dk�rt|�WSWnYn0t�dtj��r�zDt�d���}d}|D]}d|v�rJ|d	7}�qJ|dk�rt|WSWnYn0dS)Nzcpu.cpu_socket(s)rz/usr/bin/lscpuz/usr/bin/lscpu -p����#�,�r�
/proc/cpuinfor+zphysical id�:z/usr/sbin/dmidecodez /usr/sbin/dmidecode -t processorzProcessor Information)�subscription_manager_available�SubManHardwareZ
getCpuInfor.r/�X_OK�popenr2�
startswith�intr4r0r1�setr5�addr3)�number_sockets�linesZmax_socket_index�lineZsocket_indexZ
socket_ids�countrrr�__get_number_sockets�sX



rWc
Csldd�}dd�}t�dtj�s"iStr4t�tjd�tdd���}t��d�	�}t
�}d	d
d�}|dd
kr~|dd�dks�|dk�rx||�}|dkr�d|d<nd|d<||d<||d�|d<||d�|d<||d�|d<||d�|d<||d�|d<||d�|d<||d�|d<||d �|d!<||d"�}|d#k�r:d$}zttt
|��d%�|d&<Wnt�yrd'|d&<Yn0�nr|d(v�rl||�}d)|d<||d*�|d<||d+�|d<||d,�|d<||d-�|d<d.||d/�||d0�f|d1<||d2�|d<d#|d<||d�|d<||d3�|d!<||d4�}|��}z ttt
|d���d5|d&<Wnt�yfd'|d&<Yn0�n~|d6v�r(||�}||d<||d<||d7�|d<||d8�|d<||d9�|d<||d:�|d<||d�|d<|d"}zttt
|��d%�|d&<Wnt�yd'|d&<Yn0||d;�|d!<�n�|d<v�r�||�}||d<||d<||d+�|d<||d:�|d<||d�|d<||d=�|d<||d>�dd?�}zttt
|��d%�|d&<Wnt�y�d'|d&<Yn0�n|d@v�r�i}|�dA�D]:}	|	�dB�}
t|
�dCk�r
�q�|
d%��||
d��<�q�||d<||d�|d<||d<||d<||dD�|d<d#|d<d#|d<d#|d<d#|d<||d;�|d!<d|d&<nX||d<||d<||d<||d<d#|d<d#|d<d#|d<d#|d<d#|d<d#|d!<d|d&<|d�s�d%|d<n@zt|d�|d<Wnd%|d<Yn0|ddk�r>d%|d<t��}|j�dE��rht�}|�rh||dF<|S)GNcSs|��}||vrdS||S)Nr$)�lower)�a�entry�errr�	get_entry�szread_cpuinfo.<locals>.get_entrycSs�d}i}|�d�D]z}t|�s q|d}|dkr4q�|�d�D]L}t|�sLq>|�d�}t|�dkrdq>|d��|d��}}|||��<q>q|S)Nrz

r�
rJrH)r4r3r5rX)�cpulistrV�tmpdict�cpuZcpu_attrr8�name�valuerrr�get_cpulist_as_dicts"
z)read_cpuinfo.<locals>.get_cpulist_as_dictrI�Cr+�ZCPUZ	Processor)r,Zdescrr<����86�x86_64�platformZi386rVZ	vendor_id�typez
model nameZmodelz
cpu familyZmodel_numberZ	model_verZsteppingZ	model_revz
cache size�cacheZbogomips�flags�otherzcpu mhzr$z-1rZspeedrE)�alphaZalphaev6rnz
cpus detectedr`z	cpu modelz
cpu variationz%s/%szsystem typezsystem variationZ
model_versionzcpu revisionzplatform stringzcycle frequency [Hz]i@B)Zia64�vendor�familyZarchrevZrevisionZfeatures)Zppc64�machineZclock���)Zs390Zs390xr]z: rHzbogomips per cpuZcpu_socketsZsocket_count)r.r/r0�locale�	setlocale�
LC_NUMERICr1�read�unamerXrDrP�round�float�
ValueErrorr4r3r5rZ	RhnServerZcapabilitiesZ
hasCapabilityrW)
r\rcr^rwrVZhwdictr_Z	mhz_speedZhz_speedr`r8�srSrrr�read_cpuinfo�s�	�&




�

 






r|cCs@t��}|d}|dd�dkr&t�S|dd�dkr<t�SdS)NrH�z2.6z2.4)r.rw�read_memory_2_6�read_memory_2_4)ZunZkernelrrr�read_memory�sr�cCs�t�dtj�siStdd���}|�d�}|d}|��}i}d|d<tt|d�d�}|dkrt|d	|d	}n|d
|d
}t|�|d<|d}|��}tt|d�d�}t|�|d
<|S)N�
/proc/meminfor+r]r�MEMORYr,i� re��ramrH�swap)	r.r/r0r1rvr4rP�long�str)�meminforTZcurlineZmemlist�memdict�megsrrrr�s$
rcCs�t�dtj�siStdd���}|�d�}i}|D]:}|�dd�}|d}t|�dkrXq2|d��}|||<q2i}d|d<|d	}|�d
�}	t|	d�}
t|
d�}|d}|�d
�}	t|	d�}
t|
d�}t	|�|d
<t	|�|d<|S)Nr�r+r]rJrrr�r,ZMemTotal� iZ	SwapTotalr�r�)
r.r/r0r1rvr4r3r5r�r�)r�rTZmeminfo_dictrUZblobs�keyrbr�Z	total_strZblipsZtotal_kr�Zswap_strZswap_kZ	swap_megsrrrr~�s2



r~c
Cs2t��}t��}ddd�}d}d}d}|D�]}|�d�d}|�d�d}||}	ttfD]�}
zt�|
�}Wntjy�Yq\Yn0|d	r�t��}|�d�\}}	t	|	�}	zP|�
d
�|�||	f�|��d}
|
tkr�|
}n|
}t�
|
�}||
kr�|}Wn"tj�y |��Yq\Yn0|��q\q*tj�d��r~t�dtj��r~tdd���}|D]}t|��sp�q^|��}�q^n�tj�d
��rt�d
tj��rtd
d���}|D]`}t|��s��q�|�d�}t|�dk�rܐq�|d��dk�r�d�|dd���d�}�q�q�|dk�s$|dk�r(d}|||fS)z� returns [hostname, intf, intf6]

        Where hostname is you FQDN of this machine.
        And intf is numeric IPv4 address. And intf6 is IPv6 address.
    i��P)�https�httpN�/rHrJrZenableProxy�z
/etc/hostnamer+z/etc/sysconfig/networkr-rZHOSTNAMEr$z"' 	
zlocalhost.localdomain�unknown)r�initUp2dateConfigZgetServerURLr4rr�socket�errorZgetProxySettingrPZ
settimeoutZconnectZgetsockname�getfqdn�closer.r%�isfiler/r0r1r2r3r5r6)�cfg�sl�st�hostnameZintfZintf6Z	serverUrlZserverZ
servertype�portrpr{Zserver_portZintf_tmpZhostname_tmpZhostnameinfor7Znetworkinfor8rrr�findHostByRoute�sj









r�cCs�d}ztd|d�}Wn|YS0d}|��D]L}|rZ|�d�dkrZ|��d}q�|�d�dkr4|��d	}||kr4d
}q4|��|S)Nr$z/proc/net/bonding/%sr+FzPermanent HW addr: rEr}zSlave Interface: rHT)r1r2�findr4r�)�masterZslave�hwaddrZbondingZslave_foundrUZifnamerrr�get_slave_hwaddrFs 
r�cCs.i}d|d<t�\|d<|d<|d<|ddkrRt�|d<d|dvrRt��|d<|ddur�z4t|dd�}tdd	�|�}|d
dd
|d<Wnd|d<Yn0|ddur�z4t|dd�}td
d	�|�}|d
dd
|d<Wnd|d<Yn0|ddu�rd|d<|ddu�r*d|d<|S)NZNETINFOr,r��ipaddrZip6addrr��.cSs|dtjkS�Nr)r�r��xrrr�<lambda>ir?zread_network.<locals>.<lambda>rrez	127.0.0.1cSs|dtjkSr�)r�rr�rrrr�rr?z::1r$)r�rr�r�r�filter)ZnetdictZ
list_of_addrsZ
ipv4_addrsZ
ipv6_addrsrrr�read_network[s4
r�c
Csti}d|d<ts$ts$tj�d�|StrBttt��t�	���}nt
��}|D�]}z,trft�|�}nt
�
|�t
jdd}Wnd}Yn0zt�d|�}Wnd}Yn0|r�tj�|�}t||�}z@tr�t�|�}n,td|d	�}|���d
�d��}|��Wn |dk�r(d
}nd}Yn0z.t�rFt�|�}nt
�
|�t
jdd}Wnd}Yn0z.t�r�t�|�}	nt
�
|�t
jdd}	Wnd}	Yn0z.t�r�t�|�}
nt
�
|�t
jdd}
Wnd}
Yn0g}t�rPt�|�}|D]@}
|
��D]0}|j }|dk�r.d}|�!||j"|j#d���q�q
�nz�t
�
|�t
j$D]�}|d�d�d}t%�&|�}|j'�r�d}n(|j(�r�d}n|j)�r�d}n|j*�r�d}|d}d}|�d�D]Z}|�s��q*nF|�+�dk�r�|d7}n.|dt,t-|�d�dd��dd��.d�7}�q�|�!|||d���qbWnt/�yVYn0|||	|
||d�||<qN|S)NZ
NETINTERFACESr,zWWarning: information about network interfaces could not be retrieved on this platform.
r�addrr$z/sys/class/net/%s/masterz/sys/class/net/%s/device/ueventr+r-r�loZloopbackZUnknown�netmask�	broadcast�globalZuniverse)�scoper�r��%�link�hostZsiterJZffffr�r�rH�1)r�r�r�r��moduleZipv6)0�ethtool_present�netifaces_present�sys�stderr�write�listrQ�ethtoolr
Zget_active_devices�	netifaces�
interfacesZ
get_hwaddrZifaddressesZAF_LINKr.�readlinkr%�basenamer�Z
get_moduler1�readliner4r5r�Z
get_ipaddrrZget_netmaskZ
get_broadcastZget_interfaces_infoZget_ipv6_addressesr��append�addressr�r�	ipaddress�IPv6Address�	is_global�
is_link_local�is_loopback�
is_site_localrX�binrP�rindex�KeyError)ZintDictr�Z	interfacer�r�Zmaster_interfacer�Zdriver_filer�r�r�Zip6_listZdev_infor7Zip6r�Zip6_addrZ
scope_infoZip6_netmaskZnetmask_bitsZ
two_octetsrrr�read_network_interfaces~s�










�

2��r�c	Cs:i}d|d<t��d��}|ddkr8|dd�dksD|dksD|St�}|rV||d	<td
�}|rj||d<td�}|r�|d
|}||d<td�|d<td�}|r�||d<td�}|r�||d<td�}|r�||d<td�}td�}td�}	td�}
dd|d|d|	d|
f|d<t|���D]}||du�r||=�q|S)NZDMIr,rerr<rfrgrhro�!/dmidecode/SystemInfo/ProductName�product�/dmidecode/SystemInfo/Versionr��systemz%/dmidecode/BaseBoardInfo/ManufacturerZboardr'Zbios_vendorz/dmidecode/BIOSinfo/VersionZbios_versionz/dmidecode/BIOSinfo/ReleaseDateZbios_releasez#/dmidecode/ChassisInfo/SerialNumberz/dmidecode/ChassisInfo/AssetTagz%/dmidecode/BaseBoardInfo/SerialNumber�"/dmidecode/SystemInfo/SerialNumberz#(%s: %s) (%s: %s) (%s: %s) (%s: %s)ZchassisZasset)r.rwrXr)r&r��keys)Zdmidictrwror��versionr��releaseZchassis_serialZchassis_tagZboard_serialZ
system_serial�krrr�read_dmisL$�

r�cCs�ztrt�}nt�}|��}Wn8tyVt��}dt��d}|�	|�iYS0i}|D]"}|�
d�r`t||�|t|�<q`|�t
��|S)Nz0Error reading system and smbios information: %s
rr�)�using_gudevrrZGetAllProperties�	Exceptionrrr��exc_inforrOr	�update�
get_smbios)ZpropsZcomputerr"�msgZsystem_and_smbiosr�rrr�get_hal_system_and_smbios;s 


r�c	CsDt�triSt�t�td�td�td�td�td�td�d�SdS)	a
 Returns dictionary with values we are interested for.
        For historical reason it is in format, which use HAL.
        Currently in dictionary are keys:
        smbios.system.uuid, smbios.bios.vendor, smbios.system.serial,
        smbios.system.manufacturer.
    r�z"/dmidecode/SystemInfo/Manufacturerr�z/dmidecode/SystemInfo/SKUnumberz/dmidecode/SystemInfo/Familyr�)zsmbios.system.uuidzsmbios.bios.vendorzsmbios.system.serialzsmbios.system.manufacturerzsmbios.system.productzsmbios.system.skunumberzsmbios.system.familyzsmbios.system.versionN)r#rr*r)r&rrrrr�Ps�r�cCs"trt�}nzt�\}}d}|s"|r<t��}d}|�|�d}g}|r�zt�}|rT|}Wn.t��}dt��d}|�|�Yn0zt	�}|r�|�
|�Wn"ttd�t��d�Yn0zt
�}|r�|�
|�Wn"ttd�t��d�Yn0t��}|d�sNzt�}|�r(|�
|�Wn"ttd�t��d�Yn0zt�}|�rf|�
|�Wn.t��}d	t��d}|�|�Yn0zt�}|�r�|�
|�Wn"ttd
�t��d�Yn0|d�szt�}|�r�|�
|�Wn"ttd�t��d�Yn0|S)NrzaWarning: haldaemon or messagebus service not running. Cannot probe hardware and DMI information.
rz'Error reading hardware information: %s
zError reading cpu information:z(Error reading system memory information:ZskipNetworkz%Error reading networking information:z"Error reading DMI information: %s
z)Error reading install method information:z,Error reading network interface information:)r�r
rrrZlog_merr�r�r|r��print�_r�rr�r�r�r9r�)ZallhwZ
hal_statusZdbus_statusZhwdaemonr"r��retr�rrrrgsv



r�__main__z'%s' : '%s')Q�__doc__r�rrrrrBr.r�Zup2date_clientrrrZrhn.i18nr	r��	NameErrorrPr�r��ImportErrorr�r�r��gettext�translation�trrr�ZdbusZsuppress_errorsrrZup2date_client.hardware_udevr
rr�Zup2date_client.hardware_gudevZup2date_client.hardware_halrrrrsr%r�Zsubscription_manager.hwproberrLrKrrrr!rrr"rr#r&r)r*r9rDrWr|r�rr~r�r�r�r�r�r�r��__name__Zhwr�r�r�rrrr�<module>s�


�(

7B!K#:]