Current File : //lib/python2.7/site-packages/cloudinit/distros/gentoo.pyo
�
oB�]c@s�ddlmZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZeje
�Zdejfd	��YZd
�ZdS(i����(tdistros(thelpers(tlog(tutil(tnet_util(tHostnameConf(tPER_INSTANCEtDistrocBs�eZdZdZdZdZdgZd�Zdd�Z	d�Z
d�Zed	��Z
d
�Zd�Zd�Zd
�Zed��Zdd�Zd�Zddd�Zd�ZRS(s/etc/locale.gens/etc/conf.d/nets/etc/resolv.confs/etc/conf.d/hostnames
rc-servicecCsBtjj||||�tj|�|_d|_d|d<dS(Ntgentoos/etc/init.d/sshdtssh_svcname(RRt__init__RtRunnerst_runnertosfamily(tselftnametcfgtpaths((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyR
s	cCsd|s|j}ntjdd|gdt�tj�d|dg}tj|dj|��dS(Ns
locale-gens-Gtcaptures	LANG="%s"ts
(tlocale_conf_fnRtsubptFalsetmake_headert
write_filetjoin(Rtlocaletout_fntlines((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pytapply_locale's		cCs!|j�|jdd|�dS(NRtpkgs(tupdate_package_sourcestpackage_command(Rtpkglist((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pytinstall_packages3s
c
Cs{tj|�}tjd||�|j�}g}x|j�D]\}}d|krm|j|d�n|dkrqAn|jd|}|jd�}t	|t
tf�r�tt|��j
dd�}nd}	|jd�dkr	|	d	jd
|�7}	nh|	djd
|d|jd
�d|jd�d|jd��7}	|	djd
|d|jd��7}	|jd�r�|	djd
|d|�7}	ntj||	�|j|�|jd�rAdddjd
|�dg}
y;tj|
�\}}t|�r#tjd|
|�nWqQtjk
rMtjtd|
�qQXqAqAW|rwtj|jt|��n|S(Ns3Translated ubuntu style network settings %s into %ssdns-nameserverstlot.t,Rt	bootprototdhcpsconfig_{name}="dhcp"RsEconfig_{name}="{ip_address} netmask {netmask}"
mac_{name}="{hwaddr}"
t
ip_addresstaddresstnetmaskthwaddrt	hwaddresss&routes_{name}="default via {gateway}"
tgateways"dns_servers_{name}="{dnsservers}"
t
dnsserverstautos	rc-updatetadds
net.{name}tdefaults(Running %s resulted in stderr output: %ss#Running interface command %s failed(Rttranslate_networktLOGtdebugtkeystitemstextendtnetwork_conf_fntgett
isinstancetlistttupletstrtreplacetformatRRt_create_network_symlinkRtlentwarningtProcessExecutionErrortlogexctresolve_conf_fntconvert_resolv_conf(
Rtsettingstentriest	dev_namestnameserverstdevtinfotnet_fntdns_nameserverstresultstcmdt_outterr((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyt_write_network7s\	
!	

		cCs8djd|�}tj|�s4tjd|�ndS(Ns/etc/init.d/net.{name}Rs/etc/init.d/net.lo(R?Rtis_linktsym_link(tinterface_namet	file_path((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyR@oscCs�d|dg}tjd||�y?tj|�\}}t|�r]tjd||�ntSWn(tjk
r�tjtd|�t	SXdS(Ns/etc/init.d/net.%strestarts8Attempting to run bring up interface %s using command %ss(Running %s resulted in stderr output: %ss#Running interface command %s failed(
R3R4RRRARBtTrueRCRDR(Rtdevice_nameRPRQRR((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyt_bring_up_interfaceus	
	
c	Cs�t}x#|D]}|dkr
t}q
q
W|r�ddg}y;tj|�\}}t|�rxtjd||�nWn(tjk
r�tjtd|�tSXg|j	d�D]}|j	d�d^q�}t
jj||�St
jj||�SdS(	Ntalltlss/etc/init.d/net.*s(Running %s resulted in stderr output: %ss#Running interface command %s faileds  R$i(
RRYRRRAR3RBRCRDtsplitRRt_bring_up_interfaces(	Rtdevice_namestuse_alltdRPRQRRtxtdevices((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyR_�s"

	/cCs�d}y|j|�}Wntk
r,nX|sBtd�}n|j|�d|}|jdd�}tj||d�dS(NRs
hostname="%s"s
i�(tNonet_read_hostname_conftIOErrorRtset_hostnameR>RR(Rt
your_hostnameRtconftgentoo_hostname_config((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyt_write_hostname�s


cCs|j|j�}|j|fS(N(t_read_hostnamethostname_conf_fn(Rtsys_hostname((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyt_read_system_hostname�scCs#ttj|��}|j�|S(N(RRt	load_filetparse(tfilenameRj((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyRf�s
cCsDd}y|j|�}|j}Wntk
r5nX|s@|S|S(N(ReRfthostnameRg(RRsR1RtRj((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyRm�s

cCs#tjd|d|j|��dS(Nttzttz_file(Rtset_etc_timezonet
_find_tz_file(RRu((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pytset_timezone�scCs�|dkrg}ntd�}|jd�|rSt|t�rS|j|�n%|rxt|t�rx|j|�n|r�|j|�ntjd|�}|j|�tj|dt	�dS(Ntemerges--quiets%s-%sR(
ReR;tappendR:R=R7Rtexpand_package_listRR(RtcommandtargsRRPR!((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyR �s	

cCs)|jjd|jddgdt�dS(Nsupdate-sourcess-utworldtfreq(RtrunR R(R((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyR�sN(t__name__t
__module__RR8RERntinit_cmdR
ReRR"RStstaticmethodR@R[R_RlRpRfRmRyR R(((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyRs&		
		8					cCs;d}t|t�r7x|D]}|d|7}qWn|S(s4Returns a settings string formatted for resolv.conf.Rsnameserver %s
(R:R;(RGtresulttns((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyRF�s

N(t	cloudinitRRRtloggingRtcloudinit.distrosRt"cloudinit.distros.parsers.hostnameRtcloudinit.settingsRt	getLoggerR�R3RRF(((s</usr/lib/python2.7/site-packages/cloudinit/distros/gentoo.pyt<module>	s�