܍~c 6UdZddlZddlmZddlmZddlZddlmZddlm Z ddl m Z ddl m Z dd lmZmZdd lmZd d gZd ZdddeeedgedgdZeed<eeZejeZdZdZdZdZdZdede de dede ddf d Z!dS)!z6zypper_add_repo: Add zypper repositories to the systemN)Logger)dedent)log)util)Cloud)Config) MetaSchema get_meta_doc) PER_ALWAYSopensuseslesaiZypper behavior can be configured using the ``config`` key, which will modify ``/etc/zypp/zypp.conf``. The configuration writer will only append the provided configuration options to the configuration file. Any duplicate options will be resolved by the way the zypp.conf INI file is parsed. .. note:: Setting ``configdir`` is not supported and will be skipped. The ``repos`` key may be used to add repositories to the system. Beyond the required ``id`` and ``baseurl`` attributions, no validation is performed on the ``repos`` entries. It is assumed the user is familiar with the zypper repository file format. cc_zypper_add_repozZypper Add Repoz5Configure zypper behavior and add zypper repositoriesa zypper: repos: - id: opensuse-oss name: os-oss baseurl: http://dl.opensuse.org/dist/leap/v/repo/oss/ enabled: 1 autorefresh: 1 - id: opensuse-oss-update name: os-oss-up baseurl: http://dl.opensuse.org/dist/leap/v/update # any setting per # https://en.opensuse.org/openSUSE:Standards_RepoInfo # enable and autorefresh are on by default config: reposdir: /etc/zypp/repos.dir servicesdir: /etc/zypp/services.d download.use_deltarpm: true # any setting in /etc/zypp/zypp.conf zypper)idnametitle descriptiondistrosexamples frequencyactivate_by_schema_keysmetac2|dd}|S)N _)replace)repo_ids E/usr/lib/python3/dist-packages/cloudinit/config/cc_zypper_add_repo.py_canonicalize_idrKsooc3''G Nct|tr|rdndSt|ttfrdd|DSt|t st |S|S)Nrz c,g|]}t|S)_format_repo_value).0vs r z&_format_repo_value..Us!AAA033AAAr ) isinstanceboollisttuplejoinstr)vals rr%r%Ps|#tqqQ#e}%%C}}AASAAABBB c3  3xx Jr ctj}i||<|D]\}}t||||<|}d|S)N ) configobj ConfigObjitemsr%writer-)r repo_configto_bekr'liness r_format_repository_configr:[sr   ! !EE'N##%%22A/q11gq KKMME 99U  r cf|sdSi}t|D]N\}}tddgt|}|r0td|d|i|d}t|}tj |d|z}tj |rt d||||vrt d||td | D} d D] } | | vrd | | < || f||<P| D]6\}} t|| d } tj| d | 7dS)zWrite the user-provided repo definition files @param repos: A list of repo dictionary objects provided by the user's cloud config. @param repo_base_path: The directory path to which repo definitions are written. Nrbaseurlz;Repo config at index %d is missing required config keys: %s,z%s.repoz)Skipping repo %s, file %s already exists!z*Skipping repo %s, file %s already pending!c3K|]K\}}|rD|dk |dd|fVLdS)r-rN)lowerstripr)r&r8r's r z_write_repos..si  1 $YYWWYY__   & &sC 0 0! 4YYY  r )enabled autorefresh1r) enumerateset differenceLOGwarningr-getrospathexistsinfodictr4r:r write_file) reposrepo_base_path valid_reposindexuser_repo_config missing_keysr canon_repo_id repo_fn_pthr6field repo_data repo_blobs r _write_reposr^gs K#,U#3#3(:(:D),--88=M9N9NOO   KKM&&    "&&t,,(11 gll>9 3NOO 7>>+ & &  HH;      # # HH<      (..00     0 ) )EK''%( E" +[9 G + 1 1 3 311)-gy}EE   ! i000011r c|sdSd}tj|}dg}|D]I\}}|dkr"d}|dz }t|-|r||d|Jt |dkr|d |z}n|}tj||dS) z@Write to the default zypp configuration file /etc/zypp/zypp.confNz/etc/zypp/zypp.confz# Added via cloud.cfg configdirz5Changing the location of the zypper configuration is z+not supported, skipping "configdir" setting=r"r1) r load_filer4rJrKappendlenr-rR) zypper_config zypp_configzypp_conf_content new_settingssettingvaluemsg new_configs r_write_zypp_configrms 'K{33+,L'--//<< k ! !IC @ @C KK      <   777EE : ; ; ; <1&<)@)@@ & OK,,,,,r rcfgcloudrargsreturncl|d}|std|dS|d}|std|dS|di}|dd}t|t ||dS)NrzBSkipping module named %s, no 'zypper' relevant configuration foundrSz8Skipping module named %s, no 'repos' configuration foundconfigreposdirz/etc/zypp/repos.d/)rLrJdebugrmr^) rrnrorrpzypper_sectionrSrerTs rhandlerwsWWX&&N   8       w ' 'E  F    "&&x44M"&&z3GHHN}%%%'''''r )"__doc__rMloggingrtextwraprr2 cloudinitrrcloudinit.cloudrcloudinit.configrcloudinit.config.schemar r cloudinit.settingsr rMODULE_DESCRIPTIONr__annotations__ getLogger__name__rJrr%r:r^rmr.r+rwr$r rrs =<< $$$$$$!!!!!!######<<<<<<<<)))))) v     D%   0 (z?  j   D ,t  g!!    717171t---,( ((#((/5(=A( ((((((r