Current File : //lib/python2.7/site-packages/cloudinit/config/cc_yum_add_repo.pyo |
�
oB�]c @ s� d Z d d l Z y d d l m Z Wn! e k
rI d d l m Z n Xd d l Z d d l m Z d d g Z d � Z d � Z
d � Z d
� Z d S( 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( t utilt fedorat rhelc C s. | j � j d d � } | j d d � } | S( Nt -t _t ( t lowert replace( t repo_id( ( sD /usr/lib/python2.7/site-packages/cloudinit/config/cc_yum_add_repo.pyt _canonicalize_id. s c C sz t | t � r t t | � � St | t t f � rZ d j g | D] } t | � ^ qA � St | t j � sv t | � S| S( Ns
(
t
isinstancet boolt strt intt listt tuplet joint _format_repo_valuet sixt string_types( t valt v( ( sD /usr/lib/python2.7/site-packages/cloudinit/config/cc_yum_add_repo.pyR 4 s &
c C s� t � } | j | � x3 | j � D]% \ } } | j | | t | � � q# Wt j � } | j | � | j d � | j � } | j
d d t j � � d j
| � S( Ni s # Created by cloud-init on %s
t ( R t add_sectiont itemst setR R t StringIOt writet seekt readlinest insertR t time_rfc2822R ( R t repo_configt to_bet kR t to_be_streamt lines( ( sD /usr/lib/python2.7/site-packages/cloudinit/config/cc_yum_add_repo.pyt _format_repository_configC s
c C s | j d � } | s) | j d | � d St j | d d � } i } i } xn| j � D]`\ } }
t | � } t j j | d | � } t j j | � r� | j
d | | � qW n% | | k r� | j
d | | � qW n |
s� i }
n i }
xK |
j � D]= \ } } | j � j � j
d d � } | r� | |
| <q� q� W|
}
d
} x= d g D]2 } | |
k rQ| j d | | � | d
7} qQqQW| s�|
| | <| | | <qW | j d | | � qW WxB | j � D]4 \ } } t | | j | � � } t j | | � q�Wd S( Nt yum_reposs<