MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python2.7/site-packages/leapp/actors/config.pyo
�
9�Egc@sXdZeZddlZddlZddlZddlZddlm	Z	ddl
Z
ddlZddlm
Z
yddlmZWn!ek
r�ddlmZnXdaejd�Zdefd	��YZd
efd��YZe
jej�ddd
��Y�Zd�Zdd�Zd�Zd�Zd�Zd�Z d�Z!dS(sj
Config file format:
    yaml file like this:

---
# Note: have to add a fields.Map type before we can use yaml mappings.
section_name:
    field1_name: value
    field2_name:
        - listitem1
        - listitem2
section2_name:
    field3_name: value

Config files are any yaml files in /etc/leapp/actor_config.d/
(This is settable in /etc/leapp/leapp.conf)

i����N(tdefaultdict(tModelViolationError(tCSafeLoader(t
SafeLoadersleapp.actors.configtSchemaErrorcBseZdZRS(s�
    Raised when actors use conflicting schemas.

    For example, one schema wants `section.field` to be an integer and other schema wants
    `section.field` to be a string.
    (t__name__t
__module__t__doc__(((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pyR-stValidationErrorcBseZdZRS(s[
    Raised when a config file fails to validate against any of the available schemas.
    (RRR(((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pyR6stConfigcBs�eZdZejd��Zejd��Zejd��Zejd��Zejd��Z	e
d��Ze
d��ZRS(s
    An Actor config schema looks like this.

    ::
        class RHUIConfig(Config):
            section = "rhui"
            name = "file_map"
            type_ = fields.Map(fields.String())
            description = 'Description here'
            default = {"repo": "url"}
    cCsdS(N((tself((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pytsectionLscCsdS(N((R
((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pytnamePscCsdS(N((R
((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pyttype_TscCsdS(N((R
((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pytdescriptionXscCsdS(N((R
((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pytdefault\scCs*ii|jdj|j�6|j6}|S(s�
        Return a dictionary representation of the config item that would be suitable for putting
        into a config file.
        s{0}_description__(RtformatRR(tclstrepresentation((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pytto_dict`s cCsFi|jd6|jd6|jd6|jj�d6|jd6|jd6S(s@
        :return: Serialized information for the config
        t
class_nameRRttypeRR(RRRR
t	serializeRR(R((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pyRqs



(
RRRtabctabstractpropertyRRR
RRtclassmethodRR(((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pyR	?scCs_xX|j�D]J\}}||kr2|||<q
x"|D]\}}||||<q9Wq
WdS(s�
    Merge two dictionaries representing configuration.  fields in new_config overwrite
    any existing fields of the same name in the same section in configuration.
    N(titems(t
configurationt
new_configtsection_nameRt
field_nametfield((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pyt
_merge_config�s

s/etc/leapp/actor_conf.dcCs�tjtjj|d��}g|D]*}|jd�sI|jd�r%|^q%}|j�i}x�|D]|}t|��}|j�}WdQXytj	|t
�}Wn/tk
r�}tj
d|t|���nXt||�qlW|S(s_
    Read all configuration files from the config_dir and return a dict with their values.
    t*s.ymls.yamlNsCWarning: unparsable yaml file %s in the config directory. Error: %s(tglobtostpathtjointendswithtsorttopentreadtyamltloadRt	ExceptiontlogtwarningtstrR (t
config_dirtconfig_filestfRtconfig_filetraw_cfgt
parsed_configte((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pyt_get_config�s7

	cCs�t�}tt�}x�|D]�}x�|D]�}|j|jf}||kr�|||kr�djd|jd|j�}tj|�t|��n|j	|�|||j|j<q)WqW|S(s`
    Merge all schemas into a single dictionary and validate them for errors we can detect.
    skTwo actors added incompatible configuration items with the same name for Section: {section}, Field: {field}RR(
tsetRtdictRRRR-terrorRtadd(tschemastadded_fieldstnormalized_schematschemaRtunique_nametmessage((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pytnormalize_schemas�s	

		

cCsBy|j|d|�Wn$tk
r=}tjd|�tSXtS(s
    Return False if the field is not of the proper type.

    :param str field_path: Path in the config where the field is placed.
                           Example: A field 'target_clients' in a section 'rhui' would have a path 'rhui.target_clients'
    Rs/Configuration value failed to validate with: %s(t_validate_model_valueRR-tinfotFalsetTrue(t
field_typetfield_valuet
field_pathR6((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pyt_validate_field_type�scCs�x�|j�D]�\}}||krJdjd|�}tj|�q
nx[|D]S}|jd�rlqQn|||krQdjd|d|�}tj|�qQqQWq
Wi}x�|j�D]�\}}x�|j�D]�\}}y|||}Wn>tk
r6|j|i�}||<|j}|||<nXdj||�}	t|j	||	�st
djd|d|���n|j|i�}
||
|<|
||<q�Wq�W|S(Ns5A config file contained an unknown section: {section}Rt__sNA config file contained an unknown field: (Section: {section}, Field: {field})Rs{0}.{1}sPConfig value for (Section: {section}, Field: {field}) is not of the correct type(RRR-R.R&tKeyErrortgetRRJR
R(tactor_configR?RRRARtnormalized_actor_configRtvalueRItnormalized_section((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pyt_normalize_config�s<

	

	
cCs/tr
tSt|�}t||�}|atS(s�
    Return Actor Configuration.

    :returns: a dict representing the configuration.
    :raises ValueError: if the actor configuration does not match the schema.

    This function reads the config, validates it, and adds any default values.
    (t
_ACTOR_CONFIGR7RR(R0R<tconfig((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pyR+s
cCsItt�}x0|D](}t|j|j||j|j<qWt|�S(sOCalled by the actor to retrieve the actor configuration specific to this actor.(RR9RSRR(R?RR((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pytretrieve_config1s	
&(("RRt
__metaclass__RR"tloggingtos.pathR#tcollectionsRtsixR*tleapp.models.fieldsRRRtImportErrortNoneRSt	getLoggerR-R,RRt
add_metaclasstABCMetaR	R R7RBRJRRR+RU(((s7/usr/lib/python2.7/site-packages/leapp/actors/config.pyt<module>s2
		%B	
	 		C