a 'Dgi*@sddlZddlZddlmZddlmZmZmZddlm Z ddl m Z ddl m Z ddlmZeeZdZd ZGd d d ejZdd dZedfddZdddZdddZdS)N)List)distrossubputil)Apt)PackageManager) HostnameConf)CLOUDINIT_NETPLAN_FILEa8# This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} z/etc/default/localecseZdZdZdedZededededddZd Zd Z fd d Z d dZ d(ddZ fddZ ddZddZddZd)ddZddZdd Zd*d!d"Zd#d$Zeeeed%d&d'ZZS)+Distroz /etc/hostnamez'/etc/network/interfaces.d/50-cloud-init)eninetplanr )Zeni_pathZ eni_headerr T)Z netplan_pathZnetplan_headerZpostcmdsz /var/lib/dhcpzdhclient\.\w+\.leasescs@t|||d|_d|_d|_t|j||_|jg|_ dS)NZdebianzC.UTF-8) super__init__Zosfamilydefault_locale system_localerZ from_configZ_runneraptZpackage_managers)selfnameZcfgpaths __class__r3r<rBrDrFrGr7rR __classcell__rrrrr !s6   ;   r "/etc/network/interfaces.d/eth0.cfgcCstj|sdSd}zPt|}ddg}dd|D}||krVt|d|}n |d|}Wnty|d |}Yn0t |dS) aOUbuntu cloud images previously included a 'eth0.cfg' that had hard coded content. That file would interfere with the rendered configuration if it was present. if the file does not exist do nothing. If the file exists: - with known content, remove it and warn - with unknown content, leave it and warn Nz(Dynamic networking config may not apply.z auto eth0ziface eth0 inet dhcpcSsg|]}|ds|qS)#) startswithstrip).0frrr sz-_maybe_remove_legacy_eth0..zremoved %s with known contentsz* '%s' exists with user configured content.z" %s exists, but could not be read.) r!r"r#rr? splitlinesZdel_file Exceptionr$Zwarning)r"ZbmsgrQZknown_contentslinesmsgrrrr,s     r,rcCsDd}|std|tj|r@t|}t|}||d}|S)z.Read system default locale setting, if presentr1zInvalid path: %s)r r!r"r#rr?Zload_shell_contentget)sys_pathrZsys_valZlocale_contentZ sys_defaultsrrrr s     rcCsHtd|||tds$|dgtjdd|d||fgdddS) zUpdate system locale configz%Updating %s with locale setting %s=%sz update-localelocalesz--locale-file=z%s=%sFZcaptureN)r$r%rwhichr)rdrrrrrr(s   r(cCsT|dvrtd||dStds2|dgtd|tjd|gdddS) z Run locale-gen for the provided locale and set the default system variable `keyname` appropriately in the provided `sys_path`. )czc.utf-8posixz$%s=%s does not require rengenerationNz locale-genrezGenerating locales for %sFrf)r&r$r%rrgrhrrrr'+s    r')rX)rN)rN)Zloggingr!typingrZ cloudinitrrrZ(cloudinit.distros.package_management.aptrZ4cloudinit.distros.package_management.package_managerrZ"cloudinit.distros.parsers.hostnamerZcloudinit.net.netplanr Z getLoggerrSr$rVrr r,rr(r'rrrr s"      J