Current Dir: /snap/core22/2437/usr/lib/python3/dist-packages/cloudinit/config/__pycache__/

[FILE] cc_ansible.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apk_configure.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apt_configure.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apt_pipelining.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_bootcmd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_byobu.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ca_certs.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_chef.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_disable_ec2_metadata.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_disk_setup.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_fan.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_final_message.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_growpart.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_grub_dpkg.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_install_hotplug.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_keyboard.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_keys_to_console.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_landscape.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_locale.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_lxd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_mcollective.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_mounts.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ntp.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_package_update_upgrade_install.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_phone_home.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_power_state_change.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_puppet.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_raspberry_pi.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_reset_rmc.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_resizefs.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_resolv_conf.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_rh_subscription.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_rsyslog.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_runcmd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_salt_minion.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_boot.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_instance.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_once.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_user.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_vendor.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_seed_random.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_set_hostname.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_set_passwords.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_snap.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_spacewalk.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh_authkey_fingerprints.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh_import_id.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_timezone.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_autoinstall.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_drivers.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_pro.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_update_etc_hosts.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_update_hostname.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_users_groups.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_wireguard.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_write_files.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_write_files_deferred.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_yum_add_repo.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_zypper_add_repo.cpython-310.pyc [ edit | delete | rename ]
[FILE] modules.cpython-310.pyc [ edit | delete | rename ]
[FILE] schema.cpython-310.pyc [ edit | delete | rename ]
[FILE] __init__.cpython-310.pyc [ edit | delete | rename ]

Viewing: /snap/core22/2437/usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_power_state_change.cpython-310.pyc

o

�t�h��
@sUdZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZeZd	Zd
egedgd�Zeed
<e�e�Zdd�Zdd�Zdede
dededdf
dd�Zdd�Z dd�Z!d!dd�Z"dd �Z#dS)"z&Power State Change: Change power state�N)�subp�util)�Cloud)�Config)�
MetaSchema)�ALL_DISTROS)�PER_INSTANCE��cc_power_state_change�power_state)�id�distros�	frequency�activate_by_schema_keys�metacCstz/t��r(t�ddt|�g�\}}|��d}t�d|�}|r%|�d�WSWdSt�d|�WSt	y9YdSw)N�procstatz-c�z\d+ (\w|\.|-)+\s+(/\w.+)�z/proc/%s/cmdline)
r�
is_FreeBSDr�str�
splitlines�re�search�group�load_text_file�IOError)�pid�output�_err�line�m�r!�H/usr/lib/python3/dist-packages/cloudinit/config/cc_power_state_change.py�givecmdline%s�r#c
Cs�t|t�r
t�d|�|Sd|}z6tj|t|t�d�}|��|j}|dkr1t�d|�WdS|dkr>t�d|�Wd	St�	d
||�Wd	St
ya}zt�	d||�WYd}~d	Sd}~ww)NzStatic Condition: %szcheck_condition command (%s): )�shellrz%sexited 0. condition met.Trz%sexited 1. condition not met.Fz*%sunexpected exit %s. do not apply change.z%sUnexpected error: %s)�
isinstance�bool�LOG�debug�
subprocess�Popen�list�communicate�
returncode�warning�	Exception)�cond�pre�proc�ret�er!r!r"�check_condition:s*
��r5�name�cfg�cloud�args�returnc
Cs�zt||j�\}}}|durt�d�WdSWnty2}zt�dt|��WYd}~dSd}~ww|dur>t�d�dSt��}t	|�}	|	sOt�d�dSt
tjd�}
t�d|d�|��t
�t||	||t||
g�dS)	Nz&no power_state provided. doing nothingz%%s Not performing power state change!Fz3Condition was false. Will not perform state change.z5power_state: failed to get cmdline of current process�wz#After pid %s ends, will execute: %s� )�load_power_state�distror'r(r/r.r�os�getpidr#�open�devnull�joinr�fork_cb�run_after_pid_gone�execmd)r6r7r8r9�arg_list�timeout�	conditionr4�mypid�cmdline�
devnull_fpr!r!r"�handleRs<
���

�rMc	
Cs�|�d�}|durdSt|t�std��gd�}|�d�}||jvr-tdd�|�|f��|j||�dd	�|�d
�d�}z
t|�dd
��}Wnty[}z	td|d�|�d}~ww|�dd�}t|t	t
tf�sntd��|||fS)Nr)NNNzpower_state is not a dict.)�halt�poweroff�reboot�modez<power_state[mode] required, must be one of: %s. found: '%s'.�,�delay�now�message)rQrSrUrHg>@z(failed to convert timeout '%s' to float.rITz2condition type %s invalid. must be list, bool, str)�getr%�dict�	TypeError�shutdown_options_maprC�shutdown_command�float�
ValueErrorrr+r&)	r7r>�pstate�modes_okrQr9rHr4rIr!r!r"r=vs@



��
�
����
r=cCst�|�dS�N)r?�_exit)�sysexitr!r!r"�doexit�srbcCsVd}ztj|tj|tjd�}|�|�|j}Wn
ty$tt�Ynwt|�dS)Nr)�stdin�stdout�stderr)	r)r*�PIPE�STDOUTr,r-r/rb�	EXIT_FAIL)�exe_argsr�data_inr3r2r!r!r"rF�s�

�rFc

CsHd}t��|}dd�}tjtjf}		t��|krd|}nSzt|�}
|
|kr/d||
f}WnBWn:tyS}z|j|	vrCd|j}n|d|�WYd}~n"d}~wtyj}z|d|�WYd}~nd}~wwt�d	�q|sw|d
�t	�
|�z	t|�s�WdSWnty�}z|d|�WYd}~nd}~ww||�dS)NcSst�|�tt�dSr_)r'r.rbrh)�msgr!r!r"�fatal�s
z!run_after_pid_gone.<locals>.fatalTztimeout reached before %s endedz cmdline changed for %s [now: %s]zpidfile gone [%d]zIOError during wait: %szUnexpected Exception: %sg�?z&Unexpected error in run_after_pid_gonez0Unexpected Exception when checking condition: %s)�time�	monotonic�errno�ENOENT�ESRCHr#rr/�sleepr'r(r5)
r�
pidcmdlinerHrI�funcr9rk�end_timerl�known_errnosrK�ioerrr4r!r!r"rE�sL�
���
�
���rE)NN)$�__doc__ro�loggingr?rr)rm�	cloudinitrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar�cloudinit.distrosr�cloudinit.settingsrrrhr�__annotations__�	getLogger�__name__r'r#r5rr+rMr=rbrFrEr!r!r!r"�<module>s8�
$&

Upload File: