Your IP : 216.73.217.13


Current Path : /usr/lib/python3/dist-packages/cloudinit/distros/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/cloudinit/distros/__pycache__/alpine.cpython-38.pyc

U

�Ad��@sJddlmZmZmZmZddlmZddlmZdZ	Gdd�dej
�Z
dS)�)�distros�helpers�subp�util)�HostnameConf)�PER_INSTANCEa7# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}

c@s�eZdZdZdZdZdeed�iZdd�Zdd	�Z	d*dd�Z
d
d�Zdd�Zdd�Z
dd�Zd+dd�Zdd�Zdd�Zd,dd�Zdd�Zedd ��Zd-d#d$�Zd%d&�Zeed'�d(d)�Zd
S).�Distrozpy3-pipz/etc/profile.d/locale.shz/etc/network/interfacesZeni)Zeni_pathZ
eni_headercCs6tj�||||�t�|�|_d|_d|_d|d<dS)NzC.UTF-8ZalpineZsshdZssh_svcname)rr�__init__rZRunners�_runner�default_localeZosfamily)�self�nameZcfg�paths�r�:/usr/lib/python3/dist-packages/cloudinit/distros/alpine.pyr	s
zDistro.__init__cCs|jS)zgThe default locale for Alpine Linux is different than
        cloud-init's DataSource default.
        )r�rrrr�
get_locale)szDistro.get_localeNcCsB|s
|j}|s|j}ddddd|ddg}t�|d�|�d�dS)	N�#z?# This file is created by cloud-init once per new instance bootzexport CHARSET=UTF-8zexport LANG=%szexport LC_COLLATE=C��
�)r�locale_conf_fnr�
write_file�join)rZlocaleZout_fn�linesrrr�apply_locale/s�	zDistro.apply_localecCs|��|jd|d�dS)N�add)�pkgs)�update_package_sources�package_command)r�pkglistrrr�install_packagesBszDistro.install_packagescCsTd}z|�|�}Wntk
r&YnX|s4td�}|�|�t�|t|�d�dS)Nrr)�_read_hostname_conf�IOErrorrZset_hostnamerr�str)r�hostname�filename�confrrr�_write_hostnameFs
zDistro._write_hostnamecCs|�|j�}|j|fS�N)�_read_hostnameZhostname_conf_fn)rZsys_hostnamerrr�_read_system_hostnameSszDistro._read_system_hostnamecCstt�|��}|��|Sr))rrZ	load_file�parse)rr&r'rrrr"WszDistro._read_hostname_confcCs:d}z|�|�}|j}Wntk
r,YnX|s6|S|Sr))r"r%r#)rr&�defaultr%r'rrrr*\s

zDistro._read_hostnamecCsdS)Nz	127.0.1.1rrrrr�_get_localhost_ipgszDistro._get_localhost_ipcCstj||�|�d�dS)N)�tzZtz_file)rZset_etc_timezoneZ
_find_tz_file)rr/rrr�set_timezonejszDistro.set_timezonecCs�|dkrg}dg}|�d�|r6t|t�r6|�|�n|rNt|t�rN|�|�|r\|�|�|dkrr|�ddg�t�d|�}|�|�tj|dd�dS)	NZapkz--quietZupgradez--update-cachez--availablez%s-%sF�Zcapture)�append�
isinstancer$�list�extendrZexpand_package_listr)r�command�argsr�cmdr rrrrms



zDistro.package_commandcCs|jjd|jdgtd�dS)Nzupdate-sources�update)Zfreq)r
�runrrrrrrr�s�zDistro.update_package_sourcescCs|jsddg|_|jS)z7Allow distro to determine the preferred ntp client listZchronyZntp)Z_preferred_ntp_clientsrrrr�preferred_ntp_clients�s
zDistro.preferred_ntp_clients�poweroff�nowc
Csn|dg}|dkr|dg7}nNz|�tt|�d��Wn2tk
rh}ztd|f�|�W5d}~XYnX|S)Nz-dr=�0�<z?power_state[delay] must be 'now' or '+m' (minutes). found '%s'.)r2r$�int�
ValueError�	TypeError)r�modeZdelay�messager6�errr�shutdown_command�s���zDistro.shutdown_commandcCsdS)z1
        Alpine uses OpenRC, not systemd
        Frrrrr�uses_systemd�szDistro.uses_systemd)�action�servicec
Cs�ddg}ddg}t|�|dgt|�|dgt|�d|gt|�d|gt|�|dgt|�|dgt|�|dgt|�|d	gd
�}t||�}tj|dd�S)
a<
        Perform the requested action on a service. This handles OpenRC
        specific implementation details.

        OpenRC has two distinct commands relating to services,
        'rc-service' and 'rc-update' and the order of their argument
        lists differ.
        May raise ProcessExecutionError
        z
rc-servicez	--nocolorz	rc-update�stop�start�delr�restart�status)rJrK�disable�enablerM�reloadz
try-reloadrNTr1)r4r)rrHrIZinit_cmdZ
update_cmdZcmdsr8rrr�manage_service�s
�
zDistro.manage_service)N)N)NN)r<r=N)�__name__�
__module__�__qualname__Zpip_package_namerZnetwork_conf_fn�NETWORK_FILE_HEADERZrenderer_configsr	rrr!r(r+r"r*r.r0rr�propertyr;rFrGr$rRrrrrrs.�






rN)Z	cloudinitrrrrZ"cloudinit.distros.parsers.hostnamerZcloudinit.settingsrrVrrrrr�<module>	s