oB]c@sddlmZddlmZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z dd lZejeZd ejfd YZd d dd dZdZdZd S(i(tdistros(thelpers(tlog(tutil(tnet_util(t HostnameConf(tRendererNotFoundError(t PER_INSTANCENtDistrocBseZdZdZdZdgZiidd6dd6ed6d 6Zd Zdd Z d Z d Z dZ dZdZdZdZdZdZddZdZdddZdZRS(s/etc/locale.gens /etc/netctls/etc/resolv.conft systemctls/etc/netplan/50-cloud-init.yamlt netplan_paths# generated by cloud-init tnetplan_headertpostcmdstnetplancCsBtjj||||tj||_d|_d|dtTrueR?R@R(RRARBRCRD((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyt_bring_up_interfaceVs     cCs(x!|D]}|j|stSqWtS(N(RGRRF(Rt device_namestd((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyt_bring_up_interfacesds cCsud}y|j|}Wntk r,nX|sBtd}n|j|tj|t|dddddS(NRtomodetwtmodei(tNonet_read_hostname_conftIOErrorRt set_hostnameRRtstr(Rt your_hostnameR"tconf((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyt_write_hostnamejs  cCs|j|j}|j|fS(N(t_read_hostnamethostname_conf_fn(Rt sys_hostname((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyt_read_system_hostnamewscCs#ttj|}|j|S(N(RRt load_filetparse(RtfilenameRT((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyRO{s cCsDd}y|j|}|j}Wntk r5nX|s@|S|S(N(RNROthostnameRP(RR\tdefaultR]RT((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyRVs  cCs#tjd|d|j|dS(Nttzttz_file(Rtset_etc_timezonet _find_tz_file(RR_((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyt set_timezonescCs|dkrg}nddddg}|rLt|trL|j|n%|rqt|trq|j|n|r|j|ntjd|}|j|tj|dt dS(Ntpacmans-Sys--quiets --noconfirms%s-%sR( RNt isinstanceRRtappendtlisttextendRtexpand_package_listRR(RtcommandtargsR%RBR(((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyR's   cCs&|jjd|jdgdtdS(Nsupdate-sourcess-ytfreq(RtrunR'R(R((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyR&sN(t__name__t __module__RR6R5tinit_cmdRFtrenderer_configsRRNR$R)R-R:R7RGRJRURYRORVRcR'R&(((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyRs.         t/s etc/netctlsetc/resolv.confc Csfg}g}tj||}tj||}x|jD]\}}|dkr[q=n|j|tjj||} idd6|d6|jdd6d|jd|jd fd 6|jd d 6|jd gd6} tj| t | |r|jdr||nd |kr=|j |d q=q=W|rbtj|t |n|S(snRender the translate_network format into netctl files in target. Paths will be rendered under target. tlotethernett Connectiont Interfacet bootprototIPs%s/%staddresstnetmasktAddresstgatewaytGatewaysdns-nameserverstDNStauto( Rt target_pathtitemsRftostpathR tgetRtconvert_netctlRhtconvert_resolv_conf( R9ttargetR/R.R0tdevst nameserverstdevtinfotnet_fntnet_cfg((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyR4s4     cCsg}xt|D]u}||}|dkr8d}n9t|ttfrqddjd|Dd}n|jd||fqWdj|S(sGiven a dictionary, returns a string in netctl profile format. netctl profile is described at: https://git.archlinux.org/netctl.git/tree/docs/netctl.profile.5.txt Note that the 'Special Quoting Rules' are not handled here.Rt(t css|]}d|VqdS(s'%s'N((t.0tv((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pys st)s%s=%s N(tsortedRNRettupleRgR Rf(R8tresulttkeytval((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyRs   $cCs;d}t|tr7x|D]}|d|}qWn|S(s4Returns a settings string formatted for resolv.conf.Rsnameserver %s (ReRg(R8Rtns((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyRs  (t cloudinitRRRtloggingRtcloudinit.distrosRt"cloudinit.distros.parsers.hostnameRtcloudinit.net.renderersRtcloudinit.settingsRRt getLoggerRnR2RRNR4RR(((s:/usr/lib/python2.7/site-packages/cloudinit/distros/arch.pyts %