MOON
Server: Apache
System: Linux server.cny.com.sg 4.18.0-477.21.1.el8_8.x86_64 #1 SMP Thu Aug 10 13:51:50 EDT 2023 x86_64
User: tissuegurucom (1020)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3.6/site-packages/cloudinit/config/__pycache__/cc_migrator.cpython-36.pyc
3

��bC�@sPdZddlZddlZddlmZmZddlmZeZdd�Z	dd�Z
d	d
�ZdS)a!
Migrator
--------
**Summary:** migrate old versions of cloud-init data to new

This module handles moving old versions of cloud-init data to newer ones.
Currently, it only handles renaming cloud-init's per-frequency semaphore files
to canonicalized name and renaming legacy semaphore names to newer ones. This
module is enabled by default, but can be disabled by specifying ``migrate:
false`` in config.

**Internal name:** ``cc_migrator``

**Module frequency:** always

**Supported distros:** all

**Config keys**::

    migrate: <true/false>
�N)�helpers�util)�
PER_ALWAYSc
Cs�|jjd�|jjd�f}d}x�|D]�}|s"tjj|�r<q"xttj|�D]f}tjj||�}tjj|�rHtjj	|�\}}t
j|�}||krHtjj|||�}	tj
||	�|d7}qHWq"W|S)N�semr�)�paths�	get_ipath�	get_cpath�os�path�exists�listdir�join�isfile�splitextr�canon_sem_name�shutilZmove)
�cloudrZam_adjusted�sem_path�p�	full_path�nameZextZ
canon_name�new_path�r�!/usr/lib/python3.6/cc_migrator.py�_migrate_canon_sems&s

rc
Cs&dddgi}|jjd�|jjd�f}x�|D]�}|s*tjj|�rDq*tj|�}x�|j�D]�\}}|tj	|�g}g}	x@tj
|�D]2}
tjj|
�\}}||kr~tjj|
�r~|	j
|
�q~Wxd|	D]\}
tjtjj||
��tjj|
�\}
}x2|D]*}|jd|
|�|j||��WdQRXq�Wq�WqXWq*WdS)Nzapt-update-upgradez
apt-configurezpackage-update-upgrade-installrz*Migrating %s => %s with the same frequency)rrr	r
rrrZFileSemaphores�itemsrr
rr�appendrZdel_filer�debug�lock)r�logZ
legacy_adjustrrZ
sem_helperZmod_nameZ
migrate_toZ	possiblesZ
old_existsrrZ_ext�_nameZfreq�mrrr�_migrate_legacy_sems8s.




r#cCsJtj|dd�}tj|�s(|jd|�dSt|�}|jd|�t||�dS)NZmigrateTz,Skipping module named %s, migration disabledz8Migrated %s semaphore files to there canonicalized names)rZget_cfg_option_strZtranslate_boolrrr#)rZcfgrr Z_argsZ
do_migrateZ
sems_movedrrr�handleVs
r$)�__doc__r
rZ	cloudinitrrZcloudinit.settingsrZ	frequencyrr#r$rrrr�<module>s