Current File : //lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyo
�
oB�]c@s#dZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ej
e�adZ
dZd	Zd
ZdZidd
6dd6Zidd
6dd6ZddgZdddddgZddd�Zd�Zd�Zd�Zdd�Zdd�Zdd�Zd�Zd �Zdd!�Z d"�Z!d#�Z"d$�Z#d%�Z$dd&�Z%dd'�Z&d(�Z'dddd)�Z(d*�Z)d+�Z*d,�Z+d-�Z,d.�Z-d/�Z.d0�Z/d1�Z0d2�Z1d3�Z2dd4�Z3d5�Z4ied66Z5dS(7s�
Apt Configure
-------------
**Summary:** configure apt

This module handles both configuration of apt options and adding source lists.
There are configuration options such as ``apt_get_wrapper`` and
``apt_get_command`` that control how cloud-init invokes apt-get.
These configuration options are handled on a per-distro basis, so consult
documentation for cloud-init's distro support for instructions on using
these config options.

.. note::
    To ensure that apt configuration is valid yaml, any strings containing
    special characters, especially ``:`` should be quoted.

.. note::
    For more information about apt configuration, see the
    ``Additional apt configuration`` example.

**Preserve sources.list:**

By default, cloud-init will generate a new sources list in
``/etc/apt/sources.list.d`` based on any changes specified in cloud config.
To disable this behavior and preserve the sources list from the pristine image,
set ``preserve_sources_list`` to ``true``.

.. note::
    The ``preserve_sources_list`` option overrides all other config keys that
    would alter ``sources.list`` or ``sources.list.d``, **except** for
    additional sources to be added to ``sources.list.d``.

**Disable source suites:**

Entries in the sources list can be disabled using ``disable_suites``, which
takes a list of suites to be disabled. If the string ``$RELEASE`` is present in
a suite in the ``disable_suites`` list, it will be replaced with the release
name. If a suite specified in ``disable_suites`` is not present in
``sources.list`` it will be ignored. For convenience, several aliases are
provided for ``disable_suites``:

    - ``updates`` => ``$RELEASE-updates``
    - ``backports`` => ``$RELEASE-backports``
    - ``security`` => ``$RELEASE-security``
    - ``proposed`` => ``$RELEASE-proposed``
    - ``release`` => ``$RELEASE``

.. note::
    When a suite is disabled using ``disable_suites``, its entry in
    ``sources.list`` is not deleted; it is just commented out.

**Configure primary and security mirrors:**

The primary and security archive mirrors can be specified using the ``primary``
and ``security`` keys, respectively. Both the ``primary`` and ``security`` keys
take a list of configs, allowing mirrors to be specified on a per-architecture
basis. Each config is a dictionary which must have an entry for ``arches``,
specifying which architectures that config entry is for. The keyword
``default`` applies to any architecture not explicitly listed. The mirror url
can be specified with the ``uri`` key, or a list of mirrors to check can be
provided in order, with the first mirror that can be resolved being selected.
This allows the same configuration to be used in different environment, with
different hosts used for a local apt mirror. If no mirror is provided by
``uri`` or ``search``, ``search_dns`` may be used to search for dns names in
the format ``<distro>-mirror`` in each of the following:

    - fqdn of this host per cloud metadata
    - localdomain
    - domains listed in ``/etc/resolv.conf``

If there is a dns entry for ``<distro>-mirror``, then it is assumed that there
is a distro mirror at ``http://<distro>-mirror.<domain>/<distro>``. If the
``primary`` key is defined, but not the ``security`` key, then then
configuration for ``primary`` is also used for ``security``. If ``search_dns``
is used for the ``security`` key, the search pattern will be.
``<distro>-security-mirror``.

If no mirrors are specified, or all lookups fail, then default mirrors defined
in the datasource are used. If none are present in the datasource either the
following defaults are used:

    - primary: ``http://archive.ubuntu.com/ubuntu``
    - security: ``http://security.ubuntu.com/ubuntu``

**Specify sources.list template:**

A custom template for rendering ``sources.list`` can be specefied with
``sources_list``. If no ``sources_list`` template is given, cloud-init will
use sane default. Within this template, the following strings will be replaced
with the appropriate values:

    - ``$MIRROR``
    - ``$RELEASE``
    - ``$PRIMARY``
    - ``$SECURITY``

**Pass configuration to apt:**

Apt configuration can be specified using ``conf``. Configuration is specified
as a string. For multiline apt configuration, make sure to follow yaml syntax.

**Configure apt proxy:**

Proxy configuration for apt can be specified using ``conf``, but proxy config
keys also exist for convenience. The proxy config keys, ``http_proxy``,
``ftp_proxy``, and ``https_proxy`` may be used to specify a proxy for http, ftp
and https protocols respectively. The ``proxy`` key also exists as an alias for
``http_proxy``. Proxy url is specified in the format
``<protocol>://[[user][:pass]@]host[:port]/``.

**Add apt repos by regex:**

All source entries in ``apt-sources`` that match regex in
``add_apt_repo_match`` will be added to the system using
``add-apt-repository``. If ``add_apt_repo_match`` is not specified, it defaults
to ``^[\w-]+:\w``

**Add source list entries:**

Source list entries can be specified as a dictionary under the ``sources``
config key, with key in the dict representing a different source file. The key
of each source entry will be used as an id that can be referenced in
other config entries, as well as the filename for the source's configuration
under ``/etc/apt/sources.list.d``. If the name does not end with ``.list``,
it will be appended. If there is no configuration for a key in ``sources``, no
file will be written, but the key may still be referred to as an id in other
``sources`` entries.

Each entry under ``sources`` is a dictionary which may contain any of the
following optional keys:

    - ``source``: a sources.list entry (some variable replacements apply)
    - ``keyid``: a key to import via shortid or fingerprint
    - ``key``: a raw PGP key
    - ``keyserver``: alternate keyserver to pull ``keyid`` key from

The ``source`` key supports variable replacements for the following strings:

    - ``$MIRROR``
    - ``$PRIMARY``
    - ``$SECURITY``
    - ``$RELEASE``

**Internal name:** ``cc_apt_configure``

**Module frequency:** per instance

**Supported distros:** ubuntu, debian

**Config keys**::

    apt:
        preserve_sources_list: <true/false>
        disable_suites:
            - $RELEASE-updates
            - backports
            - $RELEASE
            - mysuite
        primary:
            - arches:
                - amd64
                - i386
                - default
              uri: "http://us.archive.ubuntu.com/ubuntu"
              search:
                - "http://cool.but-sometimes-unreachable.com/ubuntu"
                - "http://us.archive.ubuntu.com/ubuntu"
              search_dns: <true/false>
            - arches:
                - s390x
                - arm64
              uri: "http://archive-to-use-for-arm64.example.com/ubuntu"
        security:
            - arches:
                - default
              search_dns: true
        sources_list: |
            deb $MIRROR $RELEASE main restricted
            deb-src $MIRROR $RELEASE main restricted
            deb $PRIMARY $RELEASE universe restricted
            deb $SECURITY $RELEASE-security multiverse
        debconf_selections:
            set1: the-package the-package/some-flag boolean true
        conf: |
            APT {
                Get {
                    Assume-Yes "true";
                    Fix-Broken "true";
                }
            }
        proxy: "http://[[user][:pass]@]host[:port]/"
        http_proxy: "http://[[user][:pass]@]host[:port]/"
        ftp_proxy: "ftp://[[user][:pass]@]host[:port]/"
        https_proxy: "https://[[user][:pass]@]host[:port]/"
        sources:
            source1:
                keyid: "keyid"
                keyserver: "keyserverurl"
                source: "deb http://<url>/ xenial main"
            source2:
                source: "ppa:<ppa-name>"
            source3:
                source: "deb $MIRROR $RELEASE multiverse"
                key: |
                    ------BEGIN PGP PUBLIC KEY BLOCK-------
                    <key data>
                    ------END PGP PUBLIC KEY BLOCK-------
i����N(tgpg(tlog(t	templater(tutils
^[\w-]+:\ws/var/lib/apt/listss'/etc/apt/apt.conf.d/94cloud-init-configs)/etc/apt/apt.conf.d/90cloud-init-aptproxyskeyserver.ubuntu.coms!http://archive.ubuntu.com/ubuntu/tPRIMARYs"http://security.ubuntu.com/ubuntu/tSECURITYs$http://ports.ubuntu.com/ubuntu-portstamd64ti386ts390xtarm64tarmhftpowerpctppc64elcCs^|dkrtj|�}n|tkr4tj�S|tkrJtj�Std|��dS(s�returns the default mirrors for the target. These depend on the
       architecture, for more see:
       https://wiki.ubuntu.com/UbuntuDevelopment/PackageArchive#Portss#No default mirror known for arch %sN(	tNoneRtget_architecturetPRIMARY_ARCHEStPRIMARY_ARCH_MIRRORStcopytPORTS_ARCHESt
PORTS_MIRRORSt
ValueError(tarchttarget((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytget_default_mirrors�s

cCs�d}|dk	r|ant|�}|jdi�}t|t�sitdjdt|����nt	||�t
|||�dS(s�process the config for apt_config. This can be called from
       curthooks if a global apt config was provided or via the "apt"
       standalone command.tapts9Expected dictionary for 'apt' config, found {config_type}tconfig_typeN(R
tLOGtconvert_to_v3_apt_formattgett
isinstancetdictRtformatttypetapply_debconf_selectionst	apply_apt(tnametocfgtcloudRt_Rtcfg((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pythandles		
cCsHtj�rtdfStjd�p1tjd�s>tdfStdfS(Nssystem is snappy.sapt-getRsno apt commands.sApt is available.(Rtsystem_is_snappytFalsetwhichtTrue(((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyt_should_configure_on_empty_apts


c	Cs�|s2t�\}}|s2tjd|�dSntjd|�tjd|�d}tj|�}t||d|�}tjd|�tj|jdt	��r�t
||||�t||�nyt|t
t�Wn$ttfk
rtjd�nXd	|kr�|}||d
<|d|d<d}	|jdt�}
|
rbtj|
�j}	nt|d	|d|d
|d|	�ndS(Ns#Nothing to do: No apt config and %sshandling apt config: %sRtcodenameRsApt Mirror info: %stpreserve_sources_lists)Failed to apply proxy or apt config info:tsourcestRELEASEtMIRRORtadd_apt_repo_matchttemplate_paramst
aa_repo_match(R-RtdebugRtlsb_releaseRtfind_apt_mirror_infotis_falseRR*tgenerate_sources_listtrename_apt_liststapply_apt_configtAPT_PROXY_FNt
APT_CONFIG_FNtIOErrortOSErrort	exceptionR
tADD_APT_REPO_MATCHtretcompiletsearchtadd_apt_sources(R'R%Rt
should_configtmsgtreleaseRtmirrorstparamstmatchertmatchcfg((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyR"'s6
cCsB|jd�s|d7}ntjdgd|d|dt�dS(Ns
sdebconf-set-selectionstdataRtcapture(tendswithRtsubpR,(t
selectionsR((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytdebconf_set_selectionsNs
cCs�g}g}xU|D]M}|tkrStjd|�t||�|j|�q|j|�qWt|�r�tjd|�nt|�r�tjddgt|�ddd|dt
�ndS(Nsunconfiguring %ssSThe following packages were installed and preseeded, but cannot be unconfigured: %ssdpkg-reconfigures--frontend=noninteractiveRNRRO(tCONFIG_CLEANERSRR6tappendtlentwarningRRQtlistR
R,(tpackagesRt	unhandledt	to_configtpkg((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytdpkg_reconfigureUs
	
cCsG|jd�}|s&tjd�dSdjgt|j��D]}||^q?�}t|j�d|�t�}xh|j	�D]Z\}}xK|j
�D]=}|jd�r�q�ntj
dd|�}	|j|	�q�Wq�Wtj|�}
tjd	|�|j|
�}t|�d
kr3tjd�dSt|d|�dS(s2apply_debconf_selections - push content to debconftdebconf_selectionss(debconf_selections was not set in configNs
Rt#s[:\s].*ts
pkgs_cfgd: %sisno need for reconfig(RRR6tjointsortedtkeysRStencodetsettitemst
splitlinest
startswithRCtsubtaddRtget_installed_packagestintersectionRVR](R'RtselsetstkeyRRt	pkgs_cfgdt_keytcontenttlineR\tpkgs_installedt
need_reconfig((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyR!ns*
,	
cCsMtjtj|d��}tjd|�x|D]}tj|�q2WdS(s%clean out any local cloud-init configs/etc/cloud/cloud.cfg.d/*dpkg*s#cleaning cloud-init config from: %sN(tglobRttarget_pathRR6tostunlink(Rtflisttdpkg_cfg((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytclean_cloud_init�s

cCsg|}|jd�r%|dd!}n|jd�}|dkrQ||d}n|jdd�}|S(s�mirrorurl_to_apt_fileprefix
       Convert a mirror url to the file prefix used by apt on disk to
       store cache information for that mirror.
       To do so do:
       - take off ???://
       - drop tailing /
       - convert in string / to _t/ii����s://iR&(RPtfindtreplace(tmirrortstringtpos((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytmirrorurl_to_apt_fileprefix�scCs5ttj|��}tj|t�}x|j�D]�\}}|j|�}|s[q4n|tjj	t
|�}|tjj	t
|�}||kr�q4nt|�}	x}tjd|�D]h}
d||
|	f}t
jd|
|�ytj|
|�Wq�tk
r(t
jddt�q�Xq�Wq4WdS(s>rename_apt_lists - rename apt lists to preserve old cache datas%s_*s%s%ssRenaming apt list %s to %ssFailed to rename apt list:texc_infoN(RRRRvt	APT_LISTSRfRRwtpathtsepR�RVRuRR6trenameR@RWR,(tnew_mirrorsRtdefault_mirrorstpreR#tomirrortnmirrortoprefixtnprefixtolentfilenametnewname((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyR;�s$
cCs2||kr"tjd||�n|j||�S(s�mirror_to_placeholder
       replace the specified mirror in a template with a placeholder string
       Checks for existance of the expected mirror and warns if not founds%Expected mirror '%s' not found in: %s(RRWR~(ttmplRtplaceholder((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytmirror_to_placeholder�scCsUidd6dd6dd6dd6d	d
6}y||}Wntk
rP|}nX|S(s�there are a few default names which will be auto-extended.
       This comes at the inability to use those names literally as suites,
       but on the other hand increases readability of the cfg quite a lots$RELEASE-updatestupdatess$RELEASE-backportst	backportss$RELEASE-securitytsecuritys$RELEASE-proposedtproposeds$RELEASERI(tKeyError(tsuitetmappingtretsuite((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytmap_known_suites�s



cCs8|s
|S|}x!|D]}t|�}tj|i|d6�}tjd||�d}x�|jt�D]�}|jd�r�||7}qkn|j�}t	|�dkrd}	|djd�r�x2|dD]#}
|	d7}	|
j
d�r�Pq�q�Wn||	|krd	|}qn||7}qkW|}qW|S(
sUreads the config for suites to be disabled and removes those
       from the templateR1sDisabling suite %s as %sR`R_iit[t]s"# suite disabled by cloud-init: %s(R�Rt
render_stringRR6RgR,RhtsplitRVRP(tdisabledtsrcRItretsrcR�treleasesuitetnewsrcRrtcolstpcoltcol((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytdisable_suites�s2



cCsd}i|d6|d6}x0|D](}||||<||||j�<q!W|jdd	�}|d	kr�tjd�|jd|jj�}|s�|jd�}n|s�tjd�d	St	j
|�}ntj||�}	t
|jd
�|	|�}
t	j||
dd�d	S(
s�generate_sources_list
       create a source.list file based on a custom or default template
       by replacing mirrors and release in the templates/etc/apt/sources.listR1R.tsources_lists1No custom template provided, fall back to builtinssources.list.%sssources.lists6No template found, not rendering /etc/apt/sources.listNR�tmodei�(tlowerRR
Rtinfotget_template_filenametdistroR#RWRt	load_fileRR�R�t
write_file(R'RIRJR%taptsrcRKtkR�ttemplate_fntrenderedR�((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyR:s&

	
cCsgtjd|�y,tjdddgd|j�d|�Wn$tjk
rbtjd��nXdS(	sM
    actual adding of a key as defined in key argument
    to the system
    sAdding key:
'%s'sapt-keyRjt-RNRs(failed to add apt GPG Key to apt keyringN(RR6RRQRdtProcessExecutionErrorRA(RnR((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytadd_apt_key_raw"s,
cCsxd|krTd|krTt}d|kr7|d}ntj|d|�|d<nd|krtt|d|�ndS(s�
    Add key to the system as defined in ent (if any).
    Supports raw keys or keyid's
    The latter will as a first step fetched to get the raw key
    tkeyidRnt	keyserverN(tDEFAULT_KEYSERVERRt
getkeybyidR�(tentRR�((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytadd_apt_key/s
cCs|jj�dS(N(R�tupdate_package_sources(R%((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytupdate_packages@scCs�|dkri}n|dkr0td��nt|t�sRtd|��nx�|D]�}||}tjd|�d|kr�||d<nt||�d|kr�qYn|d}tj	||�}|dj
d�stjj
d|d�|d<n|djd�s&|dcd7<n||�r|ytjd	|gd
|�WqYtjk
rutjd��qYXqYntj||d�}y$d|}	tj||	d
d�WqYtk
r�}
tjd||
��qYXqYWt|�dS(s�
    add entries in /etc/apt/sources.list.d for each abbreviated
    sources.list entry in 'srcdict'.  When rendering template, also
    include the values in dictionary searchList
    s did not get a valid repo matchersunknown apt format: %ssadding source/key '%s'R�tsourceR|s/etc/apt/sources.list.d/s.listsadd-apt-repositoryRsadd-apt-repository failed.s%s
tomodetasfailed write to file %s: %sN(R
RRRt	TypeErrorRR6R�RR�RhRwR�RaRPRRQR�RARvR�R?R�(tsrcdictR%RR4R5R�R�R�tsourcefntcontentstdetail((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyRFDsJ	







cCs�i}t|t�rutjd�xt|D]E}d|krZd|d<tj|d�}n
|d}|||<q)Wn$t|t�r�|}ntd��|S(s1convert v1 apt format to v2 (dict in apt_sources)s9apt config: convert V1 to V2 format (source list to dict)R�scloud_config_sources.listsunknown apt_sources format(RRXRR6Rt
rand_dict_keyRR(tsrclistR�tsrcentRn((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytconvert_v1_to_v2_apt_format|s



	cCs:|j|d�dk	r6|j|�||<||=tStS(slconvert an old key to the new one if the old one exists
       returns true if a key was found and convertedN(RR
R,R*(toldcfgtaptcfgtoldkeytnewkey((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytconvert_key�s
cCstddd
g}t}idgd6}x2|D]*\}}t||||�r,t}q,q,W|rp|g|d	<nd
S(sBconvert old apt_mirror keys into the new more advanced mirror spect
apt_mirrorturitapt_mirror_searchREtapt_mirror_search_dnst
search_dnstdefaulttarchestprimaryN(R�R�(R�ssearch(R�R�(R*R�R,(R�R�tkeymapt	convertedtnewmcfgR�R�((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytconvert_mirror�s	
cCsidd6dd6dd6dd6dd6dd	6d
d6dd
6dd6dd6dd6}g}xD|D]<}||kr`||dkr�||=q�|j|�q`q`W|s�|Stjddj|��|jdd�}|dk	rxtjd�x�|D]{}||}||}||=|dks�|j|d�dkr@q�n|||kr�td||||f��q�q�W|Si}x8|D]0}||dk	r�t|||||�q�q�Wt||�x9|D]1}|j|d�dk	r�td|��q�q�W||d<|S(s:convert old to new keys and adapt restructured mirror specR0tapt_sourcesR�R�R�tproxyt	apt_proxyt
http_proxytapt_http_proxythttps_proxyt
apt_ftp_proxyt	ftp_proxytapt_https_proxyR/tapt_preserve_sources_listR�tapt_custom_sources_listR3R`s1apt config: convert V2 to V3 format for keys '%s's, Rs7apt config: V1/2 and V3 format specified, preferring V3s@Old and New apt format defined with unequal values %s vs %s @ %ss&old apt key '%s' left after conversionN(NR`(	R
RURR6RaRRR�R�(R�t
mapoldkeyst
needtoconvertR�t	newaptcfgR�tverifyR�((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytconvert_v2_to_v3_apt_format�s\



	



$



cCsA|jdd�}|dk	r1t|�|d<nt|�}|S(s�convert the old list based format to the new dict based one. After that
       convert the old dict keys/format to v3 a.k.a 'new apt config'R�N(RR
R�R�(R'R�((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyR�s
cCsp|dkrdStjd|�xI|D]A}y'tj|�rStjd|�|SWq'tk
rgq'Xq'WdS(sc
    Search through a list of mirror urls for one that works
    This needs to return quickly.
    s%search for mirror in candidates: '%s'sfound working mirror: '%s'N(R
RR6Rtis_resolvable_urlt	Exception(t
candidatestcand((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytsearch_for_mirror�s

cCsd
}|rd}g}|dkr-d}n!|dkrBd}ntd��tj||�\}}	dj|	jd�d�}|r�|jd	|�n|jd�g}
|jj	}d||d|f}x|D]}
|
j||
�q�Wt
|
�}n|S(sG
    Try to resolve a list of predefines DNS names to pick mirrors
    R`R�RR�ssecurity-mirrorsunknown mirror typet.is.%ss.localdomainshttp://%s-%s%s/%ss%sN(s.localdomainR`(R
RRtget_hostname_fqdnRaR�RUtextendR�R#R�(t
configuredt
mirrortypeR'R%Rtmydomtdomst	mirrordnsR&tfqdntmirror_listR�t	mirrorfmttpost((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytsearch_for_mirror_dnss*		

cCs~|dk	r3|dkr!|}ni|d6|d6S|jj�}|rt|j�}|d|d<|d|d<|St|�S(sasets security mirror to primary if not defined.
       returns defaults if no mirrors are definedRRR�R�N(R
t
datasourcetget_package_mirror_infoRR(tpmirrortsmirrorRR%tmirror_infotm((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytupdate_mirror_info5s	
cCsq|j|d�}|dkr"dSd}xB|D]:}|jd�}||krT|Sd|kr/|}q/q/W|S(sxout of a list of potential mirror configurations select
       and return the one matching the architecture (or default)R�R�N(RR
(R'R�Rtmirror_cfg_listR�tmirror_cfg_elemR�((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pytget_arch_mirrorconfigNs

cCs�t|||�}|dkr"dS|jdd�}|dkr[t|jdd��}n|dkr�t|jdd�|||�}n|S(s�pass the three potential stages of mirror specification
       returns None is neither of them found anything otherwise the first
       hit is returnedR�RER�N(R
R
RR�R(R'R�RR%tmcfgR((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyt
get_mirrorascCs�|dkr+tj�}tjd|�nt|d||�}tjd|�t|d||�}tjd|�t||||�}|d|d<|S(	s"find_apt_mirror_info
       find an apt_mirror given the cfg provided.
       It can check for separate config of primary and security mirrors
       If only primary is given security is assumed to be equal to primary
       If the generic apt_mirror is given that is defining for both
    s!got arch for mirror selection: %sR�sgot primary mirror: %sR�sgot security mirror: %sRR2N(R
RRRR6RR(R'R%RRRR((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyR8zscCs/ddddf}g|D].\}}|j|�r||j|�^q}t|�r�tjd|�tj|d	j|�d	�n2tjj	|�r�tj
|�tjd
|�n|jdd�r�tjd|�tj||jd��n2tjj	|�r+tj
|�tjd
|�ndS(sKapply_apt_config
       Applies any apt*proxy config from if specified
    R�sAcquire::http::Proxy "%s";R�R�sAcquire::ftp::Proxy "%s";R�sAcquire::https::Proxy "%s";swrite apt proxy info to %ss
s#no apt proxy configured, removed %stconfswrite apt config info to %ss$no apt config configured, removed %sN(sproxysAcquire::http::Proxy "%s";(s
http_proxysAcquire::http::Proxy "%s";(s	ftp_proxysAcquire::ftp::Proxy "%s";(shttps_proxysAcquire::https::Proxy "%s";(RRVRR6RR�RaRwR�tisfiletdel_fileR
(R'tproxy_fnametconfig_fnametcfgsR#tfmttproxies((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyR<�s"	; 

s
cloud-init(6t__doc__RuRwRCt	cloudinitRRtloggingRRt	getLoggert__name__RRBR�R>R=R�RRRRR
RR(R-R"RSR]R!R{R�R;R�R�R�R:R�R�R�RFR�R�R�R�RR�RRR
RR8R<RT(((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_apt_configure.pyt<module>�sh




				'$	
					&	
	7		
		B			$