o x[h@stddlZddlmZmZmZmZddlmZddlm Z ddl m Z ddl m Z mZeeZGdddejZdS) N)distroshelperssubputil) PackageList) HostnameConf)CLOUDINIT_NETPLAN_FILE) PER_ALWAYS PER_INSTANCEc@seZdZdZdgZdedddiZddZd!d d Zd e fd dZ ddZ ddZ ddZ d!ddZddZddZd"ddZdddd Zd S)#Distroz/etc/locale.gen systemctlnetplanz# generated by cloud-init T) netplan_pathnetplan_headerpostcmdscCs0tj||||t||_d|_d|d<dS)Narchsshd ssh_svcname)rr __init__rRunners_runnerosfamily)selfnamecfgpathsr8/usr/lib/python3/dist-packages/cloudinit/distros/arch.pyrs  zDistro.__init__NcCsj|dur|dkrtd|td|dg}t|jd|tjdgddtjd d |gdddS) Nz/etc/locale.confzFInvalid locale_configfile %s, only supported value is /etc/locale.confz%s UTF-8 z locale-genFcapture localectlz set-locale)LOGwarningr make_header write_file locale_gen_fnjoinr)rlocaleout_fnlinesrrr apply_locale&szDistro.apply_localepkglistcCs||jd|ddS)Nr)pkgs)update_package_sourcespackage_command)rr-rrrinstall_packages9szDistro.install_packagescCs|d}z||}Wnty%t|jdd}|rntdYdSYnw|s,td}||tj |t |ddddS)Ncreate_hostname_fileTz8create_hostname_file is False; hostname file not createdrwi)omodemode) _read_hostname_confIOErrorrget_cfg_option_bool_cfgr#infor set_hostnamer&str)rhostnamefilenameconfr2rrr_write_hostname=s&   zDistro._write_hostnamecCs||j}|j|fSN)_read_hostnamehostname_conf_fn)r sys_hostnamerrr_read_system_hostnameSs  zDistro._read_system_hostnamecCstt|}||SrA)rrload_text_fileparse)rr>r?rrrr6WszDistro._read_hostname_confcCs8d}z ||}|j}Wn tyYnw|s|S|SrA)r6r=r7)rr>defaultr=r?rrrrB\s   zDistro._read_hostnamecCsJtd|z tddd|gWdStjy$ttd|YdSw)Nz2Non-persistently setting the system hostname to %s hostnamectlz --transientz set-hostnamez;Failed to non-persistently adjust the system hostname to %s)r#debugrProcessExecutionErrorrlogexc)rr=rrr_apply_hostnameis zDistro._apply_hostnamecCstj|||ddS)N)tztz_file)rset_etc_timezone _find_tz_file)rrNrrr set_timezonevszDistro.set_timezonecCs|durg}gd}|rt|tr||n |r#t|tr#|||dkr)d}|r0||td|}||tj|dddS)N)pacmanz-Syz--quietz --noconfirmupgradez-uz%s-%sFr ) isinstancer<appendlistextendrexpand_package_listr)rcommandargsr.cmdr-rrrr0ys     zDistro.package_commandF)forcecCs$|jjd|jdg|r tntddS)Nzupdate-sourcesz-y)freq)rrunr0r r )rr]rrrr/s   zDistro.update_package_sourcesrA)NN)__name__ __module__ __qualname__r'init_cmdrrenderer_configsrr,rr1r@rEr6rBrMrRr0r/rrrrr s(    r )logging cloudinitrrrrcloudinit.distrosr"cloudinit.distros.parsers.hostnamercloudinit.net.netplanrcloudinit.settingsr r getLoggerr`r#r rrrrs