Current File : //lib/python2.7/site-packages/cloudinit/config/cc_yum_add_repo.pyo
�
oB�]c@s�dZddlZyddlmZWn!ek
rIddlmZnXddlZddlmZddgZd�Z	d�Z
d	�Zd
�ZdS(s�
Yum Add Repo
------------
**Summary:** add yum repository configuration to the system

Add yum repository configuration to ``/etc/yum.repos.d``. Configuration files
are named based on the dictionary key under the ``yum_repos`` they are
specified with. If a config file already exists with the same name as a config
entry, the config entry will be skipped.

**Internal name:** ``cc_yum_add_repo``

**Module frequency:** per always

**Supported distros:** fedora, rhel

**Config keys**::

    yum_repos:
        <repo-name>:
            baseurl: <repo url>
            name: <repo name>
            enabled: <true/false>
            # any repository configuration options (see man yum.conf)
i����N(tConfigParser(tutiltfedoratrhelcCs.|j�jdd�}|jdd�}|S(Nt-t_t (tlowertreplace(trepo_id((sD/usr/lib/python2.7/site-packages/cloudinit/config/cc_yum_add_repo.pyt_canonicalize_id.scCszt|t�rtt|��St|ttf�rZdjg|D]}t|�^qA�St|tj	�svt|�S|S(Ns
(
t
isinstancetbooltstrtinttlistttupletjoint_format_repo_valuetsixtstring_types(tvaltv((sD/usr/lib/python2.7/site-packages/cloudinit/config/cc_yum_add_repo.pyR4s&
cCs�t�}|j|�x3|j�D]%\}}|j||t|��q#Wtj�}|j|�|jd�|j	�}|j
ddtj��dj
|�S(Nis# Created by cloud-init on %s
t(Rtadd_sectiontitemstsetRRtStringIOtwritetseekt	readlinestinsertRttime_rfc2822R(R	trepo_configtto_betkRtto_be_streamtlines((sD/usr/lib/python2.7/site-packages/cloudinit/config/cc_yum_add_repo.pyt_format_repository_configCs	


cCs|jd�}|s)|jd|�dStj|dd�}i}i}xn|j�D]`\}	}
t|	�}tjj|d|�}tjj	|�r�|j
d|	|�qWn%||kr�|j
d|	|�qWn|
s�i}
ni}
xK|
j�D]=\}}|j�j�j
dd	�}|r�||
|<q�q�W|
}
d
}x=dgD]2}||
krQ|jd|	|�|d
7}qQqQW|s�|
||<|||<qW|jd|	|�qWWxB|j�D]4\}}t||j|��}tj||�q�WdS(Nt	yum_reposs<Skipping module named %s, no 'yum_repos' configuration foundtyum_repo_dirs/etc/yum.repos.d/s%s.repos)Skipping repo %s, file %s already exists!s*Skipping repo %s, file %s already pending!RRitbaseurlsBRepository %s does not contain a %s configuration 'required' entryis6Repository %s is missing %s required fields, skipping!(tgettdebugRtget_cfg_option_strRR
tostpathRtexiststinfoRtstripRtwarningR&t
write_file(tnametcfgt_cloudtlogt_argstrepostrepo_base_pathtrepo_locationstrepo_configsR	R!t
canon_repo_idtrepo_fn_ptht
n_repo_configR#Rtmissing_requiredt	req_fieldt	c_repo_idR.t	repo_blob((sD/usr/lib/python2.7/site-packages/cloudinit/config/cc_yum_add_repo.pythandleSsV			
	
		


	(
t__doc__R-tconfigparserRtImportErrorRt	cloudinitRtdistrosR
RR&RD(((sD/usr/lib/python2.7/site-packages/cloudinit/config/cc_yum_add_repo.pyt<module>s