+
    ˜qgjg  ã                   ó  € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
Ht ^ RIHtHt ]P                  ! ]4      tRtR tR R ltR	 R
 ltR tR tR tR tR t ! R R]	P6                  4      t]]	P:                  33.tR tR# )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/hostsc                  ó¦   € \         P                  ! \        R R7      p V '       d   \        P	                  R4       R# \        P	                  R4       R # )T)Ú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)Úhostss    ÚF/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceRbxCloud.pyÚget_manage_etc_hostsr      s7   € Ü×Ò¤	°Ô6€EßÜ�	‰	ÐIÔJÙÜ‡I�IÐMÔNÙó    c                ó0   € V ^8„  d   QhR\         R\        /# )é   ÚincÚreturn)ÚintÚstr)Úformats   "r   Ú__annotate__r   #   s   € ÷ :ñ :œCð :¤Cñ :r   c           	      ó\   € \        \        \        \        V 4      4      V,           4      4      # ©N)r   r   r   )Úaddrr   s   &&r   Úincrement_ipr   #   s!   € ÜŒ{œ3œ{¨4Ó0Ó1°CÕ7Ó8Ó9Ð9r   c                óN   € V ^8„  d   QhR\         P                  \        ,          /# )r   r   )ÚtypingÚListr   )r   s   "r   r   r   '   s   € ÷ 
ñ 
œ6Ÿ;™;¤sÕ+ñ 
r   c                ó4   € V \        V ^4      \        V ^4      .# )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   )r   s   &r   Úget_three_ipsr"   '   s%   € ð 	Ü�T˜1ÓÜ�T˜1Óðð r   c                ó>   € \         P                   ! R.V ,           4      # )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
Úarping)r   )Úcmds   &r   Ú_sub_arpr&   4   s   € ô �9Š9�h�Z #Õ%Ó&Ð&r   c           	      ó  € R pVP                   R9   d   RpV  F!  p \        RRW#R,          VR,          .4       K#  	  R#   \        P                   d2   p\        P                  RTR,          TR,          T4        Rp?Kh  Rp?ii ; i)	z-Sz-sz-cÚ2ÚsourceÚdestinationz&Failed to arping from "%s" to "%s": %sN)ÚfedoraÚcentosÚrhel)Únamer&   r   ÚProcessExecutionErrorr   Úwarning)ÚitemsÚdistroÚsource_paramÚitemÚerrors   &&   r   Úgratuitous_arpr6   =   s…   € Ø€LØ‡{�{Ð2Ô2ØˆÛˆð	ÜØ�s˜L¨x­.¸$¸}Õ:MÐNöó øô
 ×)Ñ)ô 		ô �K‰KØ8Ø�X•Ø�]Õ#Ø÷	ò ûð			ús   œ?¿BÁ&B Â Bc                 ó  € \        \        P                  ! R4      \        P                  ! R4      ,           4      p V '       g   R# V  F/  p \        P                  ! V\        . R	OR7      pV'       d   Vu # K1  	  \        P                  RRP                  V 4      4       R#   \
         d,   pTP                  \        P                  8w  d   h  Rp?K‹  Rp?i\        P                   d!    \        P                  ! \        RT4        KÂ  i ; i)
zAReturns False (not found or error) or a dictionary with metadata.zLABEL=CLOUDMDzLABEL=cloudmdF)ÚdeviceÚcallbackÚmtypeNz-Failed to mount %s when looking for user dataz0Did not find RbxCloud data, searched devices: %sÚ,)ÚvfatÚfatÚmsdosfs)Úsetr   Úfind_devs_withÚmount_cbÚread_user_data_callbackÚOSErrorÚerrnoÚENOENTÚMountFailedErrorÚlogexcr   r   Újoin)Údevicesr8   Úrbx_dataÚerrs       r   Úget_mdrL   R   s×   € äÜ×Ò˜OÓ,Ü
×
Ò
˜oÓ
.õ	/ó€G÷ ÙÛˆð	Ü—}’}ØÜ0Ú0ôˆH÷
 Ø’ñ ñ ô" ‡I�IØ:¸C¿H¹HÀWÓ<Môñ øô ô 	Ø�y‰yœEŸL™LÔ(Øõ )ûä×$Ñ$ô 	Ü�KŠKÜÐDÀf÷ð	ús$   Á(B!Â!D
Â, CÃD
Ã)D
Ä	D
c                ó„  € R^R\        V 4       UUUu. uF—  w  rRRRRP                  \        V4      4      RVR,          P                  4       R	VR
,           Uu. uFI  pRRRVR,          RVR,          R,          RRRVR,          R,          RVR,          R,          R,          /NKK  	  up/NK™  	  uppp/# u upi u upppi )zGenerate network configuration

@param netadps: A list of network adapter settings

@returns: A dict containing network config
ÚversionÚconfigÚtypeÚphysicalr.   zeth{}Úmac_addressÚ
macaddressÚsubnetsÚipÚstaticÚaddressÚnetmaskÚnetworkÚcontrolÚautoÚgatewayÚdns_nameserversÚdnsÚnameservers)Ú	enumerater   r   Úlower)ÚnetadpsÚiÚnetadprU   s   &   r   Úgenerate_network_configre   q   sæ   € ð 	�1Øô& ' wÔ/õ'
ñ& 0‘	�ð# ˜
Ø˜Ÿ™¤s¨1£vÓ.Ø˜v lÕ3×9Ñ9Ó;Øð % Tžlóñ +˜ð  Ø! 2 i¥=Ø! 6¨)Õ#4°YÕ#?Ø! 6Ø! 6¨)Õ#4°YÕ#?Ø)¨6°)Õ+<¸UÕ+CØ)õ,ó	ñ +ñó	ñ$ 0ó'
ðð ùòùô
s   “AB;ÁAB6"Â(B;Â6B;c                ó.  € \         P                  ! \         P                  ! \        P                  P                  V R4      R7      R7      p\         P                  ! \        P                  P                  V R4      RR7      pRV9  g   RV9  d   \         P                  ! \        R	4       R
# VP                  R/ 4      P                  R4      pVP                  R/ 4      P                  R. 4      pR
pVP                  R/ 4      P                  R4      '       d   VR,          R,          R,          p\        VR,          4      pRTRRVR,          R,          RVR,          R,          R. /RVR,           UUU	u. uF@  pVR,           F0  p\        VR,          R,          4       F  p	RVR,          RV	/NK  	  K2  	  KB  	  up	ppRRRR RR!R"RVR#VR$R%.R&VR'R(R)V//R*VR+\        4       //p
\        P                  R,4       \        P                  V
4       V
# u up	ppi )-zìThis callback will be applied by util.mount_cb() on the mounted
drive.

@param mount_dir: String representing path of directory where mounted drive
is available

@returns: A dict containing userdata, metadata and cfg based on metadata.
z
cloud.json)Úfname)Útextz	user.dataT)rg   r	   Úvmrd   z(Failed to load metadata. Invalid format.NÚadditionalMetadataÚusernameÚsshKeysÚpasswordÚsha512ÚuserdataÚmetadatazinstance-idÚ_idzlocal-hostnamer.   úpublic-keysr6   rU   rY   r\   r)   rW   r*   ÚcfgÚ
ssh_pwauthÚdisable_rootÚsystem_infoÚdefault_userÚgecosÚsudozALL=(ALL) NOPASSWD:ALLÚpasswdÚlock_passwdFÚssh_authorized_keysÚnetwork_configÚmanage_etc_hostszreturning DATA object:)r   Ú	load_jsonÚload_binary_fileÚosÚpathrH   r
   rG   r   Úgetre   r"   r   r   )Ú	mount_dirÚ	meta_dataÚ	user_datark   Ússh_keysÚhashrY   rd   rU   ÚtargetÚdatas   &          r   rB   rB   ’   s  € ô —’Ü×"Ò"¬¯©¯©°iÀÓ)NÔOô€Iô ×#Ò#Ü�g‰g�l‰l˜9 kÓ2¸$ô€Ið �9Ô °	Ô 9Ü�Š”CÐCÔDÙØ�}‰}Ð1°2Ó6×:Ñ:¸:ÓF€HØ�}‰}Ð1°2Ó6×:Ñ:¸9ÀbÓI€Hà€DØ‡}�}Ð)¨2Ó.×2Ñ2°:×>Ò>ØÐ-Õ.¨zÕ:¸8ÕDˆä% i°Õ&9Ó:€Gð 	�IØØ˜9 T�?¨5Õ1Ø˜i¨�o¨fÕ5Ø˜2ð
ð
 	à# HÖ-õ
á-�Ø˜T—l�l�Ü'¨¨yÕ(9¸)Õ(DÖE�ð �r˜)•} m°VÓ<ñ Fñ =á"ñ =Ù-ó
ð 	Ø˜$Ø˜DØØØ˜HØ˜XØÐ5Ð6Ø˜dØ! 5Ø)¨8ð!ð	ð ˜gØÔ 4Ó 6ð
ð€Dô> ‡I�IÐ&Ô'Ü‡I�Iˆd„Oà€Kùô7
s   Å5AHc                   ó¼   a € ] tR t^Òt o Rt]P                  ]P                  ]P                  ]P                  0/tR tR tR t]R 4       tR tR tR tR	 tR
tV tR# )ÚDataSourceRbxCloudÚRbxCloudc                óp   € \         P                  P                  WW#4       R V n        R V n        R V n        R # r   )r   Ú
DataSourceÚ__init__Úseedr6   rs   )ÚselfÚsys_cfgr2   Úpathss   &&&&r   r�   ÚDataSourceRbxCloud.__init__Ü   s.   € Ü×Ñ×#Ñ# D°6ÔAØˆŒ	Ø"ˆÔØˆŽr   c                óh   € \         P                  P                  V 4      pV: R V P                  : R2# )z [seed=Ú])r   r�   Ú__str__r‘   )r’   Úroots   & r   r˜   ÚDataSourceRbxCloud.__str__â   s'   € Ü×!Ñ!×)Ñ)¨$Ó/ˆÛ!% t§y¤yÐ1Ð1r   c                óš   € \        4       pVRJ d   R# VR,          V n        VR,          V n        VR,          V n        VR,          V n        R# )z_
Metadata is passed to the launching instance which
is used to perform instance configuration.
Fro   rp   r6   rs   T)rL   Úuserdata_rawrp   r6   rs   )r’   rJ   s   & r   Ú	_get_dataÚDataSourceRbxCloud._get_dataæ   sK   € ô
 “8ˆØ�uÓÙØ$ ZÕ0ˆÔØ  Õ,ˆŒØ&Ð'7Õ8ˆÔØ˜E•?ˆŒÙr   c                ó(   € V P                   R ,          # )r}   ©rs   ©r’   s   &r   r}   Ú!DataSourceRbxCloud.network_configô   s   € à�x‰xÐ(Õ)Ð)r   c                ó(   € V P                   R ,          # )rr   )rp   r¡   s   &r   Úget_public_ssh_keysÚ&DataSourceRbxCloud.get_public_ssh_keysø   s   € Ø�}‰}˜]Õ+Ð+r   c                ó   € V P                   # r   )rœ   r¡   s   &r   Úget_userdata_rawÚ#DataSourceRbxCloud.get_userdata_rawû   s   € Ø× Ñ Ð r   c                ó   € V P                   # r   r    r¡   s   &r   Úget_config_objÚ!DataSourceRbxCloud.get_config_objþ   s   € Ø�x‰xˆr   c                óF   € \        V P                   V P                  4       R # r   )r6   r2   )r’   rs   Úis_new_instances   &&&r   ÚactivateÚDataSourceRbxCloud.activate  s   € Ü�t×*Ñ*¨D¯K©KÖ8r   )rs   r6   rp   r‘   rœ   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Údsnamer   ÚNETWORKr   ÚBOOT_NEW_INSTANCEÚBOOTÚBOOT_LEGACYÚdefault_update_eventsr�   r˜   r�   Úpropertyr}   r¤   r§   rª   r®   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   rŒ   rŒ   Ò   su   ø‡ € Ø€Fà×ÑØ×'Ñ'Ø�N‰NØ×!Ñ!ð
ðÐòò2òð ñ*ó ð*ò,ò!ò÷9ð 9r   rŒ   c                 ó8   € \         P                  ! V \        4      # r   )r   Úlist_from_dependsÚdatasources)Údependss   &r   Úget_datasource_listrÂ     s   € Ü×$Ò$ W¬kÓ:Ð:r   ) Ú__doc__rD   Úloggingr�   Úos.pathr   Ú	ipaddressr   Ú	cloudinitr   r   r   Úcloudinit.eventr   r   Ú	getLoggerr°   r   r   r   r   r"   r&   r6   rL   re   rB   r�   rŒ   ÚDEP_FILESYSTEMrÀ   rÂ   © r   r   Ú<module>rÌ      s˜   ðñó Û Û 	Û Û Ý !ç )Ñ )ß 1à×Ò˜Ó!€Ø€	òõ:õ
ò'òò*ò>òB=ô@09˜×+Ñ+ô 09ðj ˜'×0Ñ0Ð2Ð3ð€ô;r   