~ev TdZddlZddlmZddlmZdZd dZd dZdZd Z d Z d Z y)zG Network introspection utilities using ioctl and the /proc filesystem. N)read_binary_file)read_text_file) sys_vendorchassis_vendor bios_vendor product_namec@t|ryt|rytjj |d}t D]S}tjj ||}tjj |sCt|}|sQ|cSt|S)a Return a bytestring with the virtualization type if it's known, an empty bytestring otherwise. It loops through some possible configurations and return a bytestring with the name of the technology being used or None if there's no match sopenvzsxenzsys/class/dmi/id) _is_vm_openvz _is_vm_xenospathjoin DMI_FILESexists_get_vm_by_vendor_get_vm_legacy) root_path dmi_info_path dmi_info_filedmi_vendor_pathvendors 7/usr/lib/python3/dist-packages/landscape/lib/vm_info.py get_vm_infor sY)GGLL,>?M" '',,}mDww~~o. "?3 M  ) $$cdD]\}tjj||}tjj|sCt |j cSy)zu Return a string with the type of container the client is running in, if any, an empty string otherwise. )container_typezsystemd/container)r r rrrstrip)run_pathfilenamer s rget_container_infor!(sP <0ww||Hh/ 77>>$ !$'--/ /0 rctjj|d}tjj|xrtj|S)z*Check if the host is virtualized with Xen.zsys/bus/xen/devices)r r risdirlistdir)r sys_xen_paths rr r 4s877<< +@AL 77== & C2::l+CCrc|tjjtjj|dS)z-Check if the host is virtualized with OpenVZ.zproc/vz)r r rr)rs rr r ;s$ 77>>"'',,y)< ==rcbt|dj}d}|D] \}}||vs |cSy)zDReturn the VM type byte string (possibly empty) based on the vendor.i)limit) )s amazon ec2kvm)sbochsr))s digitaloceanr))sgooglesgce)sinnoteks virtualbox)s microsoftshyperv)snutanixr))s openstackr))sqemur))r)r))vmwarer*)srhevr))s parallelsr)r)rlower)sys_vendor_pathrcontent_vendors_mapnamevm_types rrr@sGoT : @ @ BF- g 6>N rc ttjj|d}d|vryy#t$rYywxYw)zBCheck if the host is virtualized looking at /proc/cpuinfo content.z proc/cpuinforqemur))rr r rOSError)rcpuinfos rrr\sD i!HI  s )1 ==)/)z/run) __doc__r landscape.lib.fsrrrrr!r r rrrrr8s< -+ L %6 D> 8 r