4:65 : ˆl–ß=¿J µ2ÛR‚œP-\l ˜´oÇ ƒu·Æa–Ãa¾”*j"Tâ€ÆÅq—”Å£Å� a -@=j‚ã@sêdZddlZddlZddlZddlZddlZddlmZddlm Z m Z m Z ddl m Z mZe e¡ZdZdd„Zeed œd d „Zejed œd d„Zdd„Zdd„Zdd„Zdd„Zdd„ZGdd„de jƒZee j ffgZ!dd„Z"dS)zr This file contains code used to gather the user data passed to an instance on rootbox / hyperone cloud platforms éN)Ú IPv4Address)ÚsourcesÚsubpÚutil)Ú EventScopeÚ EventTypez /etc/hostscCs.tjtdd�}|r t d¡dSt d¡dS)NT)Úquietz5/etc/hosts exists - setting manage_etc_hosts to FalseFz=/etc/hosts does not exists - setting manage_etc_hosts to True)rÚload_text_fileÚ ETC_HOSTSÚLOGÚdebug)Úhosts©rúH/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceRbxCloud.pyÚget_manage_etc_hostss   r)ÚincÚreturncCstttt|ƒƒ|ƒƒS©N)ÚstrrÚint)ÚaddrrrrrÚ increment_ip#sr)rcCs|t|dƒt|dƒgS)z–Return a list of 3 IP addresses: [addr, addr + 2, addr + 3] @param addr: an object that is passed to IPvAddress @return: list of strings éé)r)rrrrÚ get_three_ips'sýrcCst dg|¡S)z© Uses the preferred cloud-init subprocess def of subp.subp and runs arping. Breaking this to a separate function for later use in mocking and unittests Zarping)r)ÚcmdrrrÚ_sub_arp4src Cs~d}|jdvrd}|D]b}ztdd||d|dgƒWqtjyv}z$t d|d|d|¡WYd}~qd}~00qdS) Nz-S)Z almalinuxZfedoraZcentosZ cloudlinuxZrhelz-sz-cÚ2ÚsourceÚ destinationz&Failed to arping from "%s" to "%s": %s)ÚnamerrZProcessExecutionErrorr Zwarning)ÚitemsÚdistroZ source_paramÚitemÚerrorrrrÚgratuitous_arp=s ÿür%c Csºtt d¡t d¡ƒ}|s dS|D]~}z&tj|tgd¢d�}|rL|WSWq$ty€}z|jtjkrl‚WYd}~q$d}~0tjy t  t d|¡Yq$0q$t   dd   |¡¡dS) zAReturns False (not found or error) or a dictionary with metadata.z LABEL=CLOUDMDz LABEL=cloudmdF)ZvfatZfatZmsdosfs)ÚdeviceÚcallbackZmtypeNz-Failed to mount %s when looking for user dataz0Did not find RbxCloud data, searched devices: %sú,) ÚsetrZfind_devs_withZmount_cbÚread_user_data_callbackÚOSErrorÚerrnoÚENOENTZMountFailedErrorÚlogexcr r Újoin)Zdevicesr&Úrbx_dataÚerrrrrÚget_mdRs6ÿÿý ÿ  ÿr2cCsddd„t|ƒDƒdœS)z‹Generate network configuration @param netadps: A list of network adapter settings @returns: A dict containing network config écsBg|]:\}‰dd t|ƒ¡ˆd ¡‡fdd„ˆdDƒdœ‘qS)Zphysicalzeth{}Z macaddressc s>g|]6}d|dˆdddˆddˆddddœ‘qS) ZstaticÚaddressÚnetworkÚnetmaskÚautoÚgatewayZdnsZ nameservers)Útyper4r6Zcontrolr8Zdns_nameserversr)Ú.0Úip©ÚnetadprrÚ s ÷   ÿúz6generate_network_config...r;)r9r Z mac_addressÚsubnets)ÚformatrÚlower)r:Úirr<rr>zsï   õüz+generate_network_config..)ÚversionZconfig)Ú enumerate)ZnetadpsrrrÚgenerate_network_configqs íþrEc Cstjtjtj |d¡d�d�}tjtj |d¡dd�}d|vsFd|vrVt td ¡d S|  d i¡  d ¡}|  d i¡  d g¡}d }|  d i¡  d¡r¢|d dd}t |dƒ}||dd|ddgdœdd„|dDƒddd||dg|d|dœi|t ƒdœdœ}t  d¡t  |¡|S