/usr/lib/python3/dist-packages/cloudinit/sources/__pycache__
NameSizeModeActions
DataSourceAkamai.cpython-310.pyc85290644editdlrm
DataSourceAliYun.cpython-310.pyc121310644editdlrm
DataSourceAltCloud.cpython-310.pyc72320644editdlrm
DataSourceAzure.cpython-310.pyc529630644editdlrm
DataSourceBigstep.cpython-310.pyc19580644editdlrm
DataSourceCloudCIX.cpython-310.pyc47660644editdlrm
DataSourceCloudSigma.cpython-310.pyc37920644editdlrm
DataSourceCloudStack.cpython-310.pyc103020644editdlrm
DataSourceConfigDrive.cpython-310.pyc85910644editdlrm
DataSourceDigitalOcean.cpython-310.pyc38830644editdlrm
DataSourceEc2.cpython-310.pyc286660644editdlrm
DataSourceExoscale.cpython-310.pyc61090644editdlrm
DataSourceGCE.cpython-310.pyc101260644editdlrm
DataSourceHetzner.cpython-310.pyc63390644editdlrm
DataSourceIBMCloud.cpython-310.pyc137660644editdlrm
DataSourceLXD.cpython-310.pyc137980644editdlrm
DataSourceMAAS.cpython-310.pyc119180644editdlrm
DataSourceNoCloud.cpython-310.pyc99850644editdlrm
DataSourceNone.cpython-310.pyc14170644editdlrm
DataSourceNWCS.cpython-310.pyc41470644editdlrm
DataSourceOpenNebula.cpython-310.pyc124340644editdlrm
DataSourceOpenStack.cpython-310.pyc81680644editdlrm
DataSourceOracle.cpython-310.pyc147910644editdlrm
DataSourceOVF.cpython-310.pyc94540644editdlrm
DataSourceRbxCloud.cpython-310.pyc75520644editdlrm
DataSourceScaleway.cpython-310.pyc111630644editdlrm
DataSourceSmartOS.cpython-310.pyc253120644editdlrm
DataSourceUpCloud.cpython-310.pyc45220644editdlrm
DataSourceVMware.cpython-310.pyc284110644editdlrm
DataSourceVultr.cpython-310.pyc36410644editdlrm
DataSourceWSL.cpython-310.pyc115500644editdlrm
__init__.cpython-310.pyc324600644editdlrm
Edit: /usr/lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceWSL.cpython-310.pyc (11550B)
o thC @sdZddlZddlZddlZddlmZddlmZmZmZddl Z ddl m Z m Z m Z ddlmZddlmZddlmZeeZd Zd Zd Zd Zd ZdZdZdefddZdeefddZ defddZ!defddZ"dedeefddZ#deefddZ$GdddZ%d edee&fd!d"Z'dedede&fd#d$Z(ded%edeee%ee%ffd&d'Z)d(ee%d)ee%deefd*d+Z*d,efd-d.Z+Gd/d0d0e j,Z-e-e j.ffgZ/d1d2Z0dS)3z?Datasource to support the Windows Subsystem for Linux platform.N)PurePath)ListOptionalTuple)sourcessubputil)Distro)type_from_starts_with)Pathsz/usr/bin/wslpathziid-datasource-wsl %s.user-dataz agent.yaml landscapeclientinstallation_request_idreturncCs"ttddg\}}t|jS)zL Returns the name of the current WSL instance as seen from outside. z-am/)r WSLPATH_CMDrrstripname) root_net_path_rA/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceWSL.py instance_name!s rcCsHd}d}g}tD]}|d|kr!||dvr!||dq |S)z Return a list of mount points of the Windows drives inside the current WSL instance, if drives are mounted, or an empty list otherwise 9pz aname=drvfsfstypeopts mountpoint)rmountsvaluesappend)FS_TYPEOPTIONS_CONTAINmountedmntrrrmounted_win_drives.sr%cCs`t}|s tdd}|D]}||}t|tjsq td|t|Stdd|)z? Returns the Linux path to the Windows host's cmd.exe. zWindows drives are not mounted.z%s/Windows/System32/cmd.exezFound cmd.exe at <%s>z,Couldn't find cmd.exe in any mount point: %sz, ) r%IOErrorosaccessX_OKLOGdebugrjoin)r candidater$cmdrrrcmd_executable>s   r/cCsVt}td|ddg\}}|}|stdttd|g\}}t|S)z Finds the user's home directory path as a WSL path. raises: IOError when no mountpoint with cmd.exe is found ProcessExecutionError when either cmd.exe is unable to retrieve the user's home directory z/initz/Czecho %USERPROFILE%z4No output from cmd.exe to show the user profile dir.z-au)r/ras_posixrProcessExecutionErrorrr)r.homeroutrrr find_homeVs r4 user_homecCs2tj|d}tj|std|dSt|S)z Returns the Windows user profile .cloud-init directory translated as a Linux path accessible inside the current WSL instance, or None if not found. z .cloud-initz*cloud-init user data dir %s doesn't exist.N)r'pathr,isdirr*r+r)r5seed_dirrrrcloud_init_data_dirts   r9cCs6t\}}}|r |n|}d|d||fd|dgS)z Return a list of candidate file names that may contain user-data in some supported format, ordered by precedence. r z%s-%s.user-dataz%s-all.user-datazdefault.user-data)rget_linux_distro)rdistribution_id version_idversion_codenameversionrrrcandidate_user_data_file_namess  r?c@s0eZdZdZdefddZdedefddZd S) ConfigDataz~Models a piece of configuration data as a dict if possible, while retaining its raw representation alongside its file pathrcCs |jduSN) config_dict)selfrrris_cloud_configs zConfigData.is_cloud_configr6 instance_idcCst||_||_d|_dt|jkrt|j|_|jrK|rM|tkrO|jt it durQ|jt t  t |}||krSdt |j|_dSdSdSdSdSdS)Nztext/cloud-configz#cloud-config %s)rload_text_filerawr6rBr load_yamlDEFAULT_INSTANCE_IDgetLANDSCAPE_CFG_KEYLANDSCAPE_CLIENT_CFG_KEY setdefaultLANDSCAPE_INSTALLATION_REQ_IDyamldumpstrip)rCr6rEreq_idrrr__init__s6  zConfigData.__init__N) __name__ __module__ __qualname____doc__boolrDrstrrSrrrrr@sr@ metadata_pathcCs@d}z tjt|id}W|Stytd|Y|Sw)zO Returns the relevant metadata loaded from the supplied metadata_path. N)defaultz!No instance metadata found at %s.)rrHrFFileNotFoundErrorr*r+)rZmetadatarrr_load_metadatas  r^c Csdti}t|d}t|}d}||fD]}|durq|d|}t|}|dur1|}|}nq|s9td|r?d|vrPd|d|} t| t| |S) z Returns the relevant metadata loaded from either the Ubuntu Pro dir or the user cloud-int dir based on the instance name instance-id .ubuntuproNz %s.meta-datazCUnable to find meta-data file candidates. Using default instance-idz Metadata at z5 does not contain instance-id key. Instead received: )rIr9r^r0r*r+error ValueError) r5rr]pro_diruser_dirfound_atdirr6dtmsgrrrload_instance_metadatas4     rjrEcCst|d}|dur dSttj|tt}d}tj|r.t d|t|t ||}ttj|t }d}tj|rDt ||}||fS)zg Read .ubuntupro user-data if present and return a tuple of agent and landscape user-data. r`N)NNzYLandscape configuration found: %s. Organization policy ignores any local user-data in %s.) r9rr'r6r,LANDSCAPE_DATA_FILErisfiler*r+r@AGENT_DATA_FILE)r5rErdlandscape_pathlandscape_data agent_path agent_datarrrload_ubuntu_pro_datas&     rrrq user_datacCs\|dus|js|dus|jsdS|jS|dus|js&|dus!|js#dS|jSt||gsAtdd|j|jfSi}d}g}t|jt r^|j}| di di dd}t|jt r|rktd|j}|D]}||vr{| |||||<qp|rtd ||r| di drtd |||ddd<d t |S) aMerge agent.yaml data provided by Ubuntu Pro for WSL and user data provided either by Landscape or the local user, according to the UP4W specific rules. When merging is not possible, provide #include directive to allow cloud-init to merge separate parts. NzaUnable to merge {agent_data.path} and {user_data.path}. Providing as separate user-data #include.z#include %s %s rar rtagsz.Merging both user_data and agent.yaml configs.z% agent.yaml overrides config keys: , zFLandscape client conf updated with user-data landscape.client.tags: %sz@#cloud-config # WSL datasouce Merged agent.yaml and user_data %s)rGallrDr*r+r6r0 isinstancerBdictrJr r,rOrPrQ)rqrsmerged user_tagsoverridden_keysagentkeyrrrmerge_agent_landscape_datas\       r}fieldc Csfzd|dd}tddg\}}||vWStjy2}ztd||jWYd}~dSd}~ww) zChecks if the landscape-config binary supports the intended configuration field, returning False if not or if attempting to run that binary fails. z--r-zlandscape-configz--helpz4Unable to verify if landscape-client supports %s: %sNF)replacerr1r*warningreason)r~flagr3rerrrrrlandscape_supports_fieldfs rcsZeZdZdZddedeffdd Zdedefd d Zde fd d Z de fd dZ Z S) DataSourceWSLWSLNdistropathscst||||d|_dS)Nra)superrSr)rCsys_cfgrrud_proc __class__rrrS~s zDataSourceWSL.__init__r8rcCsjddt|D}|std|ddt|jD}|D]}||vr.t||Sqtd|)z Finds the most precendent of the candidate files that may contain user-data, if any, or None otherwise. cSsi|] }|j|jqSr)rcasefoldr6).0efrrr sz5DataSourceWSL.find_user_data_file..z%s directory is emptycSsg|]}|qSr)r)rfrrr sz5DataSourceWSL.find_user_data_file..z6%s doesn't contain any of the expected user-data files)r'scandirr&r?rkeysr)rCr8existing_files folded_namesfilenamerrrfind_user_data_files   z!DataSourceWSL.find_user_data_filec Csn|}|sdSzt}t|t}||dkWSttfy6}ztdt |WYd}~dSd}~ww)NFr_z2Unable to check_instance_id from metadata file: %s) get_instance_idr4rjrrJr&rcr*rrY)rCrcurrentr2r]rrrrcheck_instance_ids zDataSourceWSL.check_instance_idc Cs|tts tdtdSt|_zt}Wnty/}z td|WYd}~dSd}~wwt|}d}d}z t ||j|_ Wnt tfy^}zt dt |WYd}~dSd}~ww|j d}|jjdkrwttspd}t||\}}z|dur|durt||d}Wn$t tfy}z|rtjntj }|d|t |WYd}~nd}~wwt||gsdSt|||_d S) Nz5No WSL command %s found. Cannot detect WSL datasourceFz#Unable to detect WSL datasource: %szUnable to load metadata: %sr_ubunturaz+Unable to load any user-data file in %s: %sT)rwhichrr*r+rr4r&r9rjr]rcrbrYrrrrNrrr@rinfoanyr} userdata_raw) rCr5er8rqrsriidlogrrr _get_datas`        zDataSourceWSL._get_datarA) rTrUrVdsnamer r rSrrrXrr __classcell__rrrrr{s rcCs t|tSrA)rlist_from_depends datasources)dependsrrrget_datasource_lists r)1rWloggingr'typingpathlibrrrrrO cloudinitrrrcloudinit.distrosr cloudinit.handlersr cloudinit.helpersr getLoggerrTr*rrIrkrmrKrLrNrYrr%r/r4r9r?r@rwr^rjrrr}r DataSourcerDEP_FILESYSTEMrrrrrrs^      $%   U u