x[h'ddlZddlZddlmZmZmZmZddlmZddlm Z ddl m Z ddl mZmZej eZGddej&Zy) N)distroshelperssubputil) PackageList) rhel_util) HostnameConf) PER_ALWAYS PER_INSTANCEceZdZdZdZdgZdZdZdZdZ dZ d d d d d ddddiZ dZ d"dZ defdZd#dZdZdddZd"dZdZdZdZdZd Zed!Zy)$Distroz/etc/sysconfig/clockz /etc/HOSTNAMEservicez/etc/sysconfig/languagez/etc/sysconfig/network/configz /etc/hostnamez/etc/locale.confz/etc/localtime sysconfigzetc/sysconfig/network/configsusez%(base)s/network/ifcfg-%(name)sz3etc/udev/rules.d/85-persistent-net-cloud-init.rulesz!%(base)s/network/ifroute-%(name)s)ipv4ipv6)controlflavoriface_templates netrules_pathroute_templatesctjj||||tj||_d|_d|_d|_d|d<|jrdg|_ d|d<yy)NrFsshd ssh_svcname systemctlz sshd.service) rr __init__rRunners_runnerosfamily update_methodread_only_root uses_systemdinit_cmd)selfnamecfgpathss     K$  +7  r)c`|jr4|jdr#tj|j S|jr(t j dg\}}t |r|S|S |j|}|j}s|S|S#t$rYwxYw)N/previous-hostnamehostname) r"endswithrload_text_filestriprlen_read_hostname_confrgIOError)r$filenamedefaultout_errconfrgs r(_read_hostnamezDistro._read_hostnames    8#4#45I#J&&x0668 8    ))ZL1KS$3x  //9==O   s>B!! B-,B-cy)Nz 127.0.1.1)r$s r(_get_localhost_ipzDistro._get_localhost_ipsr)cbttj|}|j|SN)r rriparse)r$rnrrs r(rlzDistro._read_hostname_confs%D//9:  r)cz|jr |j}n |j}||j|fSrx)r"systemd_hostname_conf_fnhostname_conf_fnrs)r$host_fns r(_read_system_hostnamezDistro._read_system_hostnames:    33G++G,,W566r)c|jtjd}d}|r|\}}}tjdj d}|D]G}|j |s|j }|d|k7r.|dj d|_n|jd k(r'tjjd rd |_yd |_ytjd d |_yy)z7Decide if we want to use transactional-update or zypperN/z /proc/mounts robtrfsz/usr/sbin/transactional-updater=r>z7Could not determine filesystem type of '/' using zypper) r rget_mount_inforisplit startswithr!lowerospathexistsrIrQ)r$resultfs_typedevpth mount_pointmountsmount mount_infos r(rHzDistro._set_update_methods    %((-FG17.+,,^<BB4H#E''/%*[[] %a=K7$.8m.F.Ft.L+ ==?g-"''..43*9D&)1D&M&."1 &r)cZtj|jdd}|jr(|j drtj ||y|jrG|r"t j ddt|gyt j dddt|gyd} |j|}|s td}|j|tj |t|d y#t$r|rntjdYyYdwxYw) Ncreate_hostname_fileTrf hostnamectlz set-hostnamez --transientz7create_hostname_file is False; hostname file notcreatedri)rget_cfg_option_bool_cfgr"rh write_filerrMrlrmrIrQr set_hostname)r$rgrnrrrs r(_write_hostnamezDistro._write_hostnames#77 II-t     8#4#45I#J OOHh /    # =.#h-HI %&%H D //9#B'   h ' OOHc$i 7 'HH"  s4D!D*)D*c|jsqtjd}|d}t|dj dd}|dk\rd|vs|dk\rd|vr|dk7rgd|_|jSgd |_|jS) z5The preferred ntp client is dependent on the version.distrr.openSUSE*)chronysystemd-timesyncdntp)rrr)_preferred_ntp_clientsr system_infointr)r$ distro_infor% major_vers r(preferred_ntp_clientszDistro.preferred_ntp_clientss ****,V4Kq>DKN005a89IRJd$:RJ$$69?/+*** /+ ***r)rx)NN)__name__ __module__ __qualname__rZr|r#r.network_conf_fnr{r-rXrenderer_configsrr4rr;r:r_rdrsrvrlr~rHrpropertyrrur)r(r r s*M&{H.N5O./"K5@E<;     0 9  ;z1 /4 & 7.8$8L++r)r )loggingr cloudinitrrrrcloudinit.distrosrrr/"cloudinit.distros.parsers.hostnamer cloudinit.settingsr r getLoggerrrIr rur)r(rsC 22)1;7g!G+W^^G+r)