/usr/lib/python3/dist-packages/landscape/lib/__pycache__
NameSizeModeActions
amp.cpython-310.pyc217830644editdlrm
backoff.cpython-310.pyc21370644editdlrm
base64.cpython-310.pyc3330644editdlrm
bootstrap.cpython-310.pyc22770644editdlrm
bpickle.cpython-310.pyc66580644editdlrm
cli.cpython-310.pyc5810644editdlrm
cloud.cpython-310.pyc18610644editdlrm
compat.cpython-310.pyc6060644editdlrm
config.cpython-310.pyc102180644editdlrm
disk.cpython-310.pyc40800644editdlrm
encoding.cpython-310.pyc7590644editdlrm
fd.cpython-310.pyc9510644editdlrm
fetch.cpython-310.pyc72350644editdlrm
format.cpython-310.pyc8920644editdlrm
fs.cpython-310.pyc35930644editdlrm
gpg.cpython-310.pyc21700644editdlrm
hashlib.cpython-310.pyc4080644editdlrm
jiffies.cpython-310.pyc13520644editdlrm
juju.cpython-310.pyc8070644editdlrm
lock.cpython-310.pyc10650644editdlrm
log.cpython-310.pyc6710644editdlrm
logging.cpython-310.pyc23660644editdlrm
message.cpython-310.pyc21270644editdlrm
monitor.cpython-310.pyc72000644editdlrm
network.cpython-310.pyc90150644editdlrm
os_release.cpython-310.pyc12490644editdlrm
persist.cpython-310.pyc177870644editdlrm
plugin.cpython-310.pyc25650644editdlrm
process.cpython-310.pyc43830644editdlrm
reactor.cpython-310.pyc101080644editdlrm
schema.cpython-310.pyc71550644editdlrm
scriptcontent.cpython-310.pyc6740644editdlrm
sequenceranges.cpython-310.pyc49200644editdlrm
store.cpython-310.pyc12200644editdlrm
sysstats.cpython-310.pyc77650644editdlrm
tag.cpython-310.pyc8790644editdlrm
testing.cpython-310.pyc261940644editdlrm
timestamp.cpython-310.pyc4360644editdlrm
twisted_util.cpython-310.pyc47360644editdlrm
user.cpython-310.pyc9080644editdlrm
versioning.cpython-310.pyc16480644editdlrm
vm_info.cpython-310.pyc28240644editdlrm
warning.cpython-310.pyc6150644editdlrm
__init__.cpython-310.pyc3520644editdlrm
Edit: /usr/lib/python3/dist-packages/landscape/lib/__pycache__/network.cpython-310.pyc (9015B)
o NLh]&@sddlmZ ddlZddlZddlZddlZddlZddlZddlZddl m Z m Z ddgZ dZ dZdZd d Zd d Zd dZddZddZddZddZddZddZddZd*dd Z ! " d+d#dZd,d%dZd&d'Zd(d)ZdS)-)absolute_importN)long_PY3get_active_device_infoget_network_trafficiiFcCstddkS)z>Returns C{True} if the platform is 64-bit, otherwise C{False}.l)structcalcsizer r 7/usr/lib/python3/dist-packages/landscape/lib/network.pyis_64srcCs|d@S)zReturns C{True} if the interface is up, otherwise C{False}. @param flags: the integer value of an interface's flags. @see /usr/include/linux/if.h for the meaning of the flags. rr )flagsr r r is_upsrcCs@|tjigdd}|tjigdd}t|p|S)zChecks if interface address data has an IP address @param ifaddresses: a dict as returned by L{netifaces.ifaddresses} raddr)get netifacesAF_INETAF_INET6bool) ifaddresses inet_addr inet6_addrr r r is_active&s rcCsNi}tj|vr|tj|tj<tj|vr%dd|tjD}|r%||tj<|S)zReturn all IP addresses of an interfaces. Returns the same structure as L{ifaddresses}, but filtered to keep IP addresses only. @param ifaddresses: a dict as returned by L{netifaces.ifaddresses} cSsg|] }|dds|qS)rzfe80: startswith).0rr r r =s  z$get_ip_addresses..)rrr)rresults global_addrsr r r get_ip_addresses0s   r!cC|tjdddS)zReturn the broadcast address associated to an interface. @param ifaddresses: a dict as returned by L{netifaces.ifaddresses} r broadcast0.0.0.0rrrrr r r get_broadcast_addressEr'cCr")zReturn the network mask associated to an interface. @param ifaddresses: a dict as returned by L{netifaces.ifaddresses} rnetmaskr%r&r r r get_netmaskMr(r+cCs|tjddS)zReturn the first IPv4 address associated to the interface. @param ifaddresses: a dict as returned by L{netifaces.ifaddresses} rr)rrr&r r r get_ip_addressUsr,cCs$tj|vr|tjdddSdS)a Return the hardware MAC address for an interface in human friendly form, ie. six colon separated groups of two hexadecimal digits, if available; otherwise an empty string. @param ifaddresses: a dict as returned by L{netifaces.ifaddresses} rrr*)rAF_LINKrr&r r r get_mac_address]s r.c Cs:t|ttd|dd}td|dddS)zReturn the integer value of the interface flags for the given interface. @param sock: a socket instance. @param interface: The name of the interface. @see /usr/include/linux/if.h for the meaning of the flags. 256sNHr)fcntlioctlfileno SIOCGIFFLAGSr packunpack)sock interfacedatar r r get_flagsjsr=cCs"td}dd|D}|S)z: Returns a list of interfaces with default routes defaultcSsg|]}|dqS)rr )rgatewayr r r r{z*get_default_interfaces..)rgatewaysvalues) default_table interfacesr r r get_default_interfacesvs rEr Fc s:g}zttjtjtj}tD]tfdd|Drqt}t|s.tj |vr.q }t ||}t |}di}||d<t ||\|d<|d<|rT||d<tj|vrrt||d<t||d <t||d <t||d <ntj |vr|sd |d<t||d <d |d <d |d <||qW||S|w) z Returns a dictionary containing info on each active network interface that passes all `filters`. A filter is a callable that returns True if the interface should be skipped. c3s|]}|VqdSNr )rfr;r r sz'get_filtered_if_info..r;rspeedduplex ip_addresses ip_address mac_addressbroadcast_addressr)r$)socketr SOCK_DGRAM IPPROTO_IPrrDanyrrr-encoder=r!get_network_interface_speedr,r.r'r+appendclose) filtersextendedrr:r ifencodedrrLifinfor rHr get_filtered_if_infosP          % r\loTc sNfdd}dd}dd}tfdd}d d } t| ||||f|d S) Ncs|vSrFr rH)skipped_interfacesr r filter_localz,get_active_device_info..filter_localcSd|vS)N.r rHr r r filter_vlanraz+get_active_device_info..filter_vlancSrb)N:r rHr r r filter_aliasraz,get_active_device_info..filter_aliascs o|vSrFr rH) default_ifs default_onlyr r filter_defaults z.get_active_device_info..filter_defaultcSs |dS)NtaprrHr r r filter_taps z*get_active_device_info..filter_tap)rXrY)rEr\) r_ skip_vlan skip_aliasrYrhr`rdrfrirkr )rgrhr_r rs  /proc/net/devc Cst|d }|}Wdn1swY|dd\}}}dd|D}|dd|Di}|ddD] }d |vrGq@|d \} } | } tt|tt| || <q@|S) ze Retrieves an array of information regarding the network activity per network interface. rNr|cSg|]}d|qS)zrecv_%sr rcolumnr r r rr@z'get_network_traffic..cSrq)zsend_%sr rrr r r rr@re) open readlinessplitextendstripdictzipmapr) source_filenetdevlines_receive_columnstransmit_columnscolumnsdeviceslinedevicer<r r r rs  cCsLt}d|vr$ttdtjtjtjtjdd}d|vr$t}|S)a Return the current fqdn of the machine, trying hard to return a meaningful name. In particular, it means working against a NetworkManager bug which seems to make C{getfqdn} return localhost6.localdomain6 for machine without a domain since Maverick. localhostNr)rPgetfqdn getaddrinfo gethostnamerrQrR AI_CANONNAME)fqdnr r r get_fqdns rc Cstdtd}td|}td||d}d}zt|t|tr)| }n| }t d|\}}Wn2t t fyh}z$|jtjkrLtdn|jtjkrZ|jtjkrZ|d}d }WYd }~nd }~ww|d krod}|d krud }t|}||fS) a Return the ethernet device's advertised link speed. The return value can be one of: * 10, 100, 1000, 2500, 10000: The interface speed in Mbps * -1: The interface does not support querying for max speed, such as virtio devices for instance. * 0: The cable is not connected to the interface. We cannot measure interface speed, but could if it was plugged in. I39ss'B16sPr12xHB28xzECould not determine network interface speed, operation not permitted.FNi)r r8 ETHTOOL_GSETarray buffer_infor4r5 SIOCETHTOOLrtobytestostringr9IOErrorOSErrorerrnoEPERMloggingwarning EOPNOTSUPPEINVALr) r:interface_name cmd_struct status_cmdpackedrJresrKer r r rUs2     rU)r F)r]TTFF)rn) __future__rrr4rPr rrrlandscape.lib.compatrr__all__r7rrrrrr!r'r+r,r.r=rEr\rrrrUr r r r s@     8 !