
    Vhc/                    \   d Z ddlmZ ddlZddlZddlZddlZddlZddl	m
Z
mZmZ ddlmZ ddlmZ ddlmZmZ dd	lmZmZmZmZmZmZmZ  ej8                  d
e      Z G d dej<                        Z ej@                  d       G d d             Z! ej@                  d       G d d             Z" G d de      Z# G d de#      Z$ G d de#      Z% G d de$      Z& G d de$      Z' ej8                  de'      Z( G d d e'      Z) G d! d"e'      Z* G d# d$e'      Z+ G d% d&e$      Z,y)'zConfiguration classes.    )annotationsN   )verify_sys_executableversion_to_str
type_guard)CommonConfig)Metadata)data_contextPayloadConfig)ControllerConfigControllerHostConfig
HostConfigHostSettingsOriginConfigPythonConfigVirtualPythonConfigTHostConfig)boundc                  |    e Zd ZdZ ej
                         Z ej
                         Z ej
                         Zd Z	y)TerminateModezWhen to terminate instances.c                6    | j                   j                         S N)namelowerselfs    M/home/dcms/DCMS/lib/python3.12/site-packages/ansible_test/_internal/config.py__str__zTerminateMode.__str__1   s    yy      N)
__name__
__module____qualname____doc__enumautoALWAYSNEVERSUCCESSr    r   r   r   r   *   s1    &TYY[FDIIKEdiikG!r   r   T)frozenc                  0    e Zd ZU dZded<   ded<   ded<   y)	ModulesConfigzConfiguration for modules.strpython_requirestuple[str, ...]python_versionsboolcontroller_onlyNr    r!   r"   r#   __annotations__r)   r   r   r,   r,   5   s    $$$r   r,   c                  &    e Zd ZU dZded<   ded<   y)ContentConfigzConfiguration for all content.r,   modulesr/   r0   Nr3   r)   r   r   r6   r6   >   s    ($$r   r6   c                  j     e Zd ZdZd fdZed	d       Zed
d       ZddZddZ	edd       Z
 xZS )EnvironmentConfigzEConfiguration common to all commands which execute in an environment.c                    t            ||       |j                   _        |j                   _        |j                   _        |j
                   _        |j                   _        d  _        d  _        	  j                  rd _	        nt         j                  t               xs t         j                  j                  t              xsq  j                  j                  j                  t!        t"        j$                  d d       k7  xs2 t'        t)         j                  j                  j*                               _	        |j,                   _        |j.                   _        |j0                   _        |j2                   _        |j4                   _        |j6                   _        |j8                   _        g  _        |j<                   _        |j>                   _        d fd}tA               jC                  |       y )NF   c                Z   }|j                   rt        j                  j                  |j                   d      }t        j                  j                  |j                   d      }t        j                  j                  |j                   d      }| j                  }|j                  t        j                  j                  |      |f       |j                  t        j                  j                  |      |f       |j                  t        j                  j                  |      |f       yy)z,Add the host files to the payload file list.zsettings.datz	state.datz
config.datN)	host_pathospathjoinfilesappendabspath)payload_configconfigsettings_path
state_pathconfig_pathrA   r   s         r   host_callbackz1EnvironmentConfig.__init__.<locals>.host_callbackx   s    F "V-=-=~ NWW\\&*:*:KH
 ggll6+;+;\J&,,bggoom<mLMbggooj9:FGbggook:KHI  r   rD   r   returnNone)"super__init__host_settingsr=   
containers
pypi_proxypypi_endpointcontent_configcontroller_pythondelegate
isinstance
controllerr   pythonr   versionr   sysversion_infor1   r   r?   docker_networkdocker_terminateremote_endpointremote_stageremote_terminateprime_containersrequirementsdelegate_argsdev_systemd_debugdev_probe_cgroupsr
   register_payload_callback)r   argscommandrI   	__class__s   `   r   rN   zEnvironmentConfig.__init__I   s   w'+/+=+=*...+/?? $.2.@.@ :> <@	
 >>!DM t== Ldoo446IJL??))11^CDTDTUWVWDX5YYL -doo.D.D.I.IJK	 M 04/B/B;?;P;P040D0D-1->->;?;P;P&*&;&;"&"3"3(*'+'='=262H2H	J 	00?r   c                .    | j                   j                  S )z&Host configuration for the controller.)rO   rW   r   s    r   rW   zEnvironmentConfig.controller   s     !!,,,r   c                .    | j                   j                  S )z#Host configuration for the targets.)rO   targetsr   s    r   rl   zEnvironmentConfig.targets   s     !!)))r   c                    t        | j                        }t        |      dk7  rt        d      |j	                         }t        ||      st        dt        |       d| d      |S )z
        Return the host configuration for the target.
        Requires that there is exactly one target of the specified type.
        r   z!There must be exactly one target.z
Target is z instead of .)listrl   len	ExceptionpoprV   type)r   target_typerl   targets       r   only_targetzEnvironmentConfig.only_target   se    
 t||$w<1?@@&+.jk):(;<}TUVWWr   c                    | j                   st        d      t        | j                   |      sJ t        j                  t
        t           | j                         S )z
        Return a list of target host configurations.
        Requires that there are one or more targets, all the specified type.
        z"There must be one or more targets.)rl   rq   r   tcastro   r   )r   rt   s     r   only_targetszEnvironmentConfig.only_targets   sE    
 ||@AA$,,444vvd;'66r   c                    t        d | j                  D              }t        |      dk7  rt        d      |j	                         }t        |t              rt        | j                        }|S )z
        The true type of the target(s).
        If the target is the controller, the controller type is returned.
        Requires at least one target, and all targets must be of the same type.
        c              3  2   K   | ]  }t        |        y wr   )rs   ).0ru   s     r   	<genexpr>z0EnvironmentConfig.target_type.<locals>.<genexpr>   s     CF4<Cs   r   z8There must be one or more targets, all of the same type.)	setrl   rp   rq   rr   
issubclassr   rs   rW   )r   target_typesrt   s      r   rt   zEnvironmentConfig.target_type   s^     CdllCC|!VWW"&&(k#34t/Kr   rg   t.Anyrh   r-   rK   rL   )rK   r   )rK   zlist[HostConfig])rt   t.Type[THostConfig]rK   r   )rt   r   rK   zlist[THostConfig])rK   zt.Type[HostConfig])r    r!   r"   r#   rN   propertyrW   rl   rv   rz   rt   __classcell__ri   s   @r   r9   r9   F   sS    O>@@ - - * *"
7  r   r9   c                  $     e Zd ZdZd fdZ xZS )
TestConfigz*Configuration common to all test commands.c                n    t            ||       |j                   _        |j                   _        |j                  xs g  _        |j
                  xs g  _        |j                  xs g  _        |j                   _        |j                   _        |j                   _	        |j                   _
        |j                   _        |j                   _        |j                   _        |j                   _        |j                   _        t!        |dd       _        t!        |dd       _        t!        |dd       _        |j(                  rt+        j,                  |j(                        n	t+                _        d  _         j                  rd _        d fd}t1               j3                  |       y )NlintFjunit
failure_okTc                    }| j                   }|j                  rE|j                  t        j                  j                  |j                        |j                  f       yy)z/Add the metadata file to the payload file list.N)rA   metadata_pathrB   r>   r?   rC   )rD   rE   rA   r   s      r   metadata_callbackz.TestConfig.__init__.<locals>.metadata_callback   sK    F"((E##bggoof.B.BCVEYEYZ[ $r   rJ   )rM   rN   coveragecoverage_checkincludeexcluderequirechangedtracked	untracked	committedstagedunstagedchanged_fromchanged_pathbase_branchgetattrr   r   r   metadatar	   	from_filer   r
   rf   )r   rg   rh   r   ri   s   `   r   rN   zTestConfig.__init__   sJ   w'"mm$($7$7"&,,"4""&,,"4""&,,"4"!\\!\\#~~#~~ KK"mm!%!2!2'+'8'8 $ 0 0!$6	"4%8
 'lE B=A]]**4==9PXPZ.2 DM	\ 	001BCr   r   r    r!   r"   r#   rN   r   r   s   @r   r   r      s    4%D %Dr   r   c                  $     e Zd ZdZd fdZ xZS )ShellConfigz$Configuration for the shell command.c                    t         |   |d       |j                  | _        |j                  | _        | j                  | _        t        j                  j                         xr |j                   | _	        |j                  | _
        d| _        y )NshellT)rM   rN   cmdrawrU   check_layoutrZ   stdinisattyinteractiveexportdisplay_stderrr   rg   ri   s     r   rN   zShellConfig.__init__   sg    w'"hh MM99++->dhh,'+{{"r   rg   r   rK   rL   r   r   s   @r   r   r      s    .# #r   r   c                  $     e Zd ZdZd fdZ xZS )SanityConfigz%Configuration for the sanity command.c                0   t         |   |d       |j                  | _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        |j                  | _        | j                  xs | j                  | _	        y )Nsanity)
rM   rN   test	skip_test
list_testsallow_disabledenable_optional_errorsprime_venvsr   r   r   s     r   rN   zSanityConfig.__init__   sr    x(#yy	$(NN $$($7$7,0,G,G#!%!1!1"ii:4??r   r   r   r   s   @r   r   r      s    /
; 
;r   r   c                  0     e Zd ZdZd fdZd fdZ xZS )IntegrationConfigz*Configuration for the integration command.c                   t         |   ||       |j                  | _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        |j                  | _        |j                  | _        |j                  | _	        |j                  | _
        |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j                   | _        |j"                  | _        |j$                  | _        |j&                  | _        |j(                  | _        | j                  rd| _        d| _        y y )NT)rM   rN   start_atstart_at_taskallow_destructive
allow_rootr   allow_unstableallow_unstable_changedallow_unsupportedretry_on_errorcontinue_on_errordebug_strategychanged_all_targetchanged_all_modelist_targetstags	skip_tagsdiffno_temp_workdirno_temp_unicodeexplainr   )r   rg   rh   ri   s      r   rN   zIntegrationConfig.__init__  s*   w'!]]"&"4"4'+'='= $$($7$7$($7$7,0,G,G#'+'='=$($7$7'+'='=$($7$7'+'>'>%)%:%:"&"3"3II	II	%)%9%9%)%9%9DL"&D r   c                l   t         j                  j                  t               j                  j
                  d| j                  z        }t         j                  j                  t               j                  j                  |      }t         j                  j                  |      st        | )         }|S )z;Return the path to the Ansible config for the given config.z%s.cfg)r>   r?   r@   r
   contentintegration_pathrh   rootexistsrM   get_ansible_config)r   ansible_config_relative_pathansible_config_pathri   s      r   r   z$IntegrationConfig.get_ansible_config+  s|    ')ww||LN4J4J4[4[]ehlhtht]t'u$ ggll<>+A+A+F+FHdeww~~12"''"<">""r   r   )rK   r-   )r    r!   r"   r#   rN   r   r   r   s   @r   r   r     s    4'6	# 	#r   r   TIntegrationConfigc                  $     e Zd ZdZd fdZ xZS )PosixIntegrationConfigz0Configuration for the posix integration command.c                &    t         |   |d       y )NintegrationrM   rN   r   s     r   rN   zPosixIntegrationConfig.__init__=  s    }-r   r   r   r   s   @r   r   r   :  s    :. .r   r   c                  $     e Zd ZdZd fdZ xZS )WindowsIntegrationConfigz2Configuration for the windows integration command.c                &    t         |   |d       y )Nzwindows-integrationr   r   s     r   rN   z!WindowsIntegrationConfig.__init__D  s    45r   r   r   r   s   @r   r   r   A  s    <6 6r   r   c                  $     e Zd ZdZd fdZ xZS )NetworkIntegrationConfigz2Configuration for the network integration command.c                H    t         |   |d       |j                  | _        y )Nznetwork-integration)rM   rN   testcaser   s     r   rN   z!NetworkIntegrationConfig.__init__K  s    45!]]r   r   r   r   s   @r   r   r   H  s    <+ +r   r   c                  $     e Zd ZdZd fdZ xZS )UnitsConfigz$Configuration for the units command.c                    t         |   |d       |j                  | _        |j                  | _        t	        |dd      | _        | j
                  dk(  rd| _        y | j
                  dk(  rd| _        y y )Nunitsrequirements_mode onlyTskipF)rM   rN   collect_onlynum_workersr   r   rb   r   s     r   rN   zUnitsConfig.__init__T  sq    w'"&"3"3 $ 0 0&-d4G&L!!V+ $D##v- %D .r   r   r   r   s   @r   r   r   Q  s    .& &r   r   )-r#   
__future__r   dataclassesr$   r>   rZ   typingrx   utilr   r   r   util_commonr   r   r	   datar
   r   host_configsr   r   r   r   r   r   r   TypeVarr   Enumr   	dataclassr,   r6   r9   r   r   r   r   r   r   r   r   r   r)   r   r   <module>r      sA    "   	 
  
   aiiZ8!DII ! d#  $ d#% % $%{ {|(D" (DV## #;: ; '#
 '#T QYY3;LM .. .60 6+0 +&* &r   