Viewing File: /usr/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Ä
Back to Directory File Manager