ó 'KXc@s»ddlZddlmZddlmZddlmZddlmZddlmZddl m Z ej e ƒZ dZid d6dd6Zdejfd„ƒYZd„ZdS(iÿÿÿÿN(tdistros(thelpers(tlog(tutil(t HostnameConf(t PER_INSTANCEsapt-gets(--option=Dpkg::Options::=--force-confolds*--option=Dpkg::options::=--force-unsafe-ios --assume-yess--quiett eatmydatatcommandtautotenabledtDistrocBsæeZdZdZdZdZdZd„Zdd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zdd„Zd„Zd„Zddd„Zd„Zd„ZRS(s /etc/hostnames/etc/default/locales/etc/network/interfacess /etc/timezones/etc/localtimecCs8tjj||||ƒtj|ƒ|_d|_dS(Ntdebian(RR t__init__RtRunnerst_runnertosfamily(tselftnametcfgtpaths((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyR 4scCsz|s|j}ntjd|gdtƒtjd|gdtƒtjƒd|dg}tj|dj|ƒƒdS(Ns locale-gentcaptures update-locales LANG="%s"ts (tlocale_conf_fnRtsubptFalset make_headert write_filetjoin(Rtlocaletout_fntlines((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyt apply_locale<s   cCs!|jƒ|jdd|ƒdS(Ntinstalltpkgs(tupdate_package_sourcestpackage_command(Rtpkglist((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pytinstall_packagesIs cCstj|j|ƒdgS(Ntall(RRtnetwork_conf_fn(Rtsettings((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyt_write_networkMscCs‚t}x#|D]}|dkr t}q q W|r^|jƒ}|j|ƒtjj|dƒS|j|ƒtjj||ƒSdS(NR&s--all(RtTruet_get_all_interfacest_clear_addressesRR t_bring_up_interfacet_bring_up_interfaces(Rt device_namestuse_alltdt interfaces((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyR.Qs      cCsex^|D]V}tjd|dgƒ|j|ƒ}|dk rtjd|dd|gƒqqWdS(sÛ Removes any IPv4 addresses associated with each of the interface names in 'interfaces'. Also checks if the interface name has an associated IPv6 address, and if so, removes it as well. tifconfigs0.0.0.0tinet6tdelN(RRt_get_ipv6_addrtNone(RR2tifacet ipv6_addr((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyR,es   cCsFtjd|gdtƒ}|d}|jƒs>|dkrBdS|S(sž Returns None if the given interface name does not have an associated IPv6 address. Otherwise, returns the IPv6 address as a string. sIifconfig %s | grep "inet6 addr.*Scope:Global" | rev | cut -d" " -f2 | revtshelliRN(RRR*tisspaceR7(Rt interfacetoutputtstdout((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyR6ss    cCs9tjdgdtƒ}|d}|jdƒd }|S(sG Returns all eth* interface names, active or inactive. s!ifconfig -a | grep -o "eth[0-9]*"R:is iÿÿÿÿ(RRR*tsplit(RR=R>R2((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyR+s cCs\t}x#|D]}|dkr t}q q W|rEtjj|dƒStjj||ƒSdS(NR&s--all(RR*RR t_bring_down_interfacet_bring_down_interfaces(RR/R0R1((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyRAs   cCstjdgƒ}dS(NR3(RR(RR/((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyt_find_all_interfaces—scCs|s |S|S(N((Rthostnametfqdn((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyt_select_hostnamešscCsld}y|j|ƒ}Wntk r,nX|sBtdƒ}n|j|ƒtj|t|ƒdƒdS(NRi¤(R7t_read_hostname_conftIOErrorRt set_hostnameRRtstr(Rt your_hostnameRtconf((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyt_write_hostname¡s  cCs|j|jƒ}|j|fS(N(t_read_hostnamethostname_conf_fn(Rt sys_hostname((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyt_read_system_hostname®scCs#ttj|ƒƒ}|jƒ|S(N(RRt load_filetparse(RtfilenameRK((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyRF²s cCsDd}y|j|ƒ}|j}Wntk r5nX|s@|S|S(N(R7RFRCRG(RRStdefaultRCRK((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyRM·s  cCsdS(Ns 127.0.1.1((R((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyt_get_localhost_ipÂscCs]|j|ƒ}tjƒt|ƒdg}tj|jdj|ƒƒtj||jƒdS(NRs ( t _find_tz_fileRRRIRt tz_conf_fnRtcopyt tz_local_fn(Rttzttz_filettz_lines((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyt set_timezoneÆs    c Cs|dkrg}ntjjƒ}d|d<|jdtƒ}t|jdtdƒ|jdtdƒƒ}|jt |jdt ƒƒƒ|r³t |t ƒr³|j |ƒn%|rØt |t ƒrØ|j|ƒn|}|dkrÿ|jdd ƒ}n|j |ƒtjd |ƒ}|j|ƒtjd tjd d |dj|ƒfdtjd|fdi|d6td6ƒdS(NtnoninteractivetDEBIAN_FRONTENDtapt_get_wrapperRR tapt_get_commandtupgradetapt_get_upgrade_subcommands dist-upgrades%s=%stlogfunctmsgs apt-%s [%s]t tfunctargstkwargstenvR(R7tostenvironRXt get_optiontAPT_GET_WRAPPERt_get_wrapper_prefixtgettextendtlisttAPT_GET_COMMANDt isinstanceRItappendRtexpand_package_listtlog_timetLOGtdebugRRR( RRRhR!tetwcfgtcmdtsubcmdR$((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyR#Òs.        "cCs&|jjd|jdgdtƒdS(Nsupdate-sourcestupdatetfreq(RtrunR#R(R((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyR"öscCs+tjddgƒ\}}t|ƒjƒS(Ntdpkgs--print-architecture(RRRItstrip(Rtarcht_err((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pytget_primary_archúsN(t__name__t __module__RNRR'RWRYR R7RR%R)R.R,R6R+RARBRERLRPRFRMRUR]R#R"R…(((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyR -s2            $ cCsqt|tƒr!t|ƒg}ntj|ƒset|ƒjƒdkri|dritj|dƒri|SgSdS(NRi(RtRIRtis_truetlowertwhich(R|tmode((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyRoÿs"(sapt-gets(--option=Dpkg::Options::=--force-confolds*--option=Dpkg::options::=--force-unsafe-ios --assume-yess--quiet(Rkt cloudinitRRRtloggingRt"cloudinit.distros.parsers.hostnameRtcloudinit.settingsRt getLoggerR†RxRsRnR Ro(((sE/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/debian.pyts  Ò