← Back
Editing: clean.cpython-310.pyc
o ��i� � @ s d Z ddlZddlZddlZddlZddlZddlZddlmZm Z ddl mZ ddlm Z ddlmZ ddlmZ ddlmZ dd lmZmZmZ dd lmZmZmZmZmZ e�e�Z dZ!edd dddgZ"dgZ#de$de%fdd�Z&d dd�Z'd!dd�Z(dd� Z)dd� Z*edkr�e*� dS dS )"zFDefine 'clean' utility and handler as part of cloud-init command line.� N)�settings�sources)� cc_mounts)�uses_systemd)�log_util)�CLOUDINIT_NETPLAN_FILE)�Init)�ProcessExecutionError�runparts�subp)�del_dir�del_file�get_config_logfiles�is_link� write_filez/etc/machine-idz-/etc/NetworkManager/conf.d/99-cloud-init.confz?/etc/NetworkManager/conf.d/30-cloud-init-ip6-addr-gen-mode.confz@/etc/NetworkManager/system-connections/cloud-init-*.nmconnectionz,/etc/systemd/network/10-cloud-init-*.networkz+/etc/network/interfaces.d/50-cloud-init.cfgz)/etc/ssh/sshd_config.d/50-cloud-init.conf�log_file�returnc C sD zt �| �}t�|j�st�|j�rW dS W dS ty! Y dS w )z�Check if a log file should be removed. Avoid tracebacks from attempting to remove device files. @param log_file: Path to the log file to check. @returns: True if the file should be removed, False otherwise. FT)�os�stat�S_ISBLK�st_mode�S_ISCHR�OSError)r � file_stat� r �5/usr/lib/python3/dist-packages/cloudinit/cmd/clean.py�should_remove_log_file. s ���r c C s� | s t jddd�} | jdddddd d � | jddddd � | jdddddd � | jddddddd � | jddg d�g dddd� | S )a# Build or extend an arg parser for clean utility. @param parser: Optional existing ArgumentParser instance representing the clean subcommand which will be extended to support the args of this utility. @returns: ArgumentParser with proper argument configuration. �cleanzJRemove logs, configs and artifacts so cloud-init re-runs on a clean system)�prog�descriptionz-lz--logs� store_trueF�remove_logszRemove cloud-init logs.)�action�default�dest�helpz--machine-idz�Set /etc/machine-id to 'uninitialized\n' for golden image creation. On next boot, systemd generates a new machine-id. Remove /etc/machine-id on non-systemd environments.)r"