Current File : //lib/python2.7/site-packages/cloudinit/config/cc_migrator.pyo
�
oB�]c@ssdZddlZddlZddlmZddlmZddlmZeZd�Z	d�Z
d�ZdS(	s%
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:** per always

**Supported distros:** all

**Config keys**::

    migrate: <true/false>
i����N(thelpers(tutil(t
PER_ALWAYSc
Cs|jjd�|jjd�f}d}x�|D]�}|s1tjj|�rWq1nx�tj|�D]�}tjj||�}tjj|�rgtjj	|�\}}t
j|�}||krtjj|||�}	tj
||	�|d7}qqgqgWq1W|S(Ntsemii(tpathst	get_ipatht	get_cpathtostpathtexiststlistdirtjointisfiletsplitextRtcanon_sem_nametshutiltmove(
tcloudRtam_adjustedtsem_pathtpt	full_pathtnametextt
canon_nametnew_path((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_migrator.pyt_migrate_canon_sems(s$
c
Cs�iddgd6}|jjd�|jjd�f}xW|D]O}|s>tjj|�rdq>ntj|�}x|j�D]	\}}|tj	|�g}g}	x]tj
|�D]L}
tjj|
�\}}||kr�tjj|
�r�|	j
|
�q�q�Wx|	D]w}
tjtjj||
��tjj|
�\}
}x:|D]2}|jd|
|�|j||��WdQXqOWqWq�Wq>WdS(Ns
apt-configurespackage-update-upgrade-installsapt-update-upgradeRs*Migrating %s => %s with the same frequency(RRRRRR	RtFileSemaphorestitemsRR
R
RtappendRtdel_fileRtdebugtlock(Rtlogt
legacy_adjustRRt
sem_helpertmod_namet
migrate_tot	possiblest
old_existsRRt_extt_nametfreqtm((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_migrator.pyt_migrate_legacy_sems:s.
$


	
cCsetj|dt�}tj|�s8|jd|�dSt|�}|jd|�t||�dS(Ntmigrates,Skipping module named %s, migration disableds8Migrated %s semaphore files to there canonicalized names(Rtget_cfg_option_strtTruettranslate_boolRRR,(RtcfgRR!t_argst
do_migratet
sems_moved((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_migrator.pythandleWs	(t__doc__RRt	cloudinitRRtcloudinit.settingsRt	frequencyRR,R5(((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_migrator.pyt<module>s