
    Vh	                        d Z ddlmZ ddlZddlZddlZddlmZ ddl	m
Z
 ddlmZmZ ddlmZ ej                    G d	 d
             Zej                    G d de             Zej                    G d de             Zy)zBootstrapping for test hosts.    )annotationsN   )read_text_file)ANSIBLE_TEST_TARGET_ROOT)ShellScriptTemplateset_shebang)SshKeyc                  R    e Zd ZU dZded<   ded<   ded<   edd       Zdd	Zdd
Zy)	Bootstrapz%Base class for bootstrapping systems.bool
controllerzdict[str, str]python_interpretersr	   ssh_keyc                j    | j                   j                  j                  dd      j                         S )z7The bootstrap type to pass to the bootstrapping script.r    )	__class____name__replacelower)selfs    P/home/dcms/DCMS/lib/python3.12/site-packages/ansible_test/_internal/bootstrap.pybootstrap_typezBootstrap.bootstrap_type"   s*     ~~&&..{B?EEGG    c                8   t        | j                  | j                  rdnd| j                  j	                         D cg c]  \  }}| d|  c}}| j
                  j                  | j
                  j                  | j
                  j                        S c c}}w )6The variables to template in the bootstrapping script.yesr   :)r   r   r   ssh_key_typessh_private_keyssh_public_key)	dictr   r   r   itemsr   KEY_TYPEkey_contentspub_contents)r   keyvalues      r   get_variableszBootstrap.get_variables'   s|    .. $uRDHD\D\DbDbDd ejc5C5%!1 e.. LL55<<44
 	
 !fs   Bc                    t         j                  j                  t        dd      }t	        |      }t        |d      }t        |      }| j                         } |j                  di |}|S )z6Return a shell script to bootstrap the specified host.setupzbootstrap.shz/bin/sh )	ospathjoinr   r   r   r   r(   
substitute)r   r-   contenttemplate	variablesscripts         r   
get_scriptzBootstrap.get_script2   sa    ww||4g~N &gy1&w/&&(	$$$1y1r   N)returnstrr5   z"dict[str, t.Union[str, list[str]]])	r   
__module____qualname____doc____annotations__propertyr   r(   r4   r+   r   r   r   r      s4    /''OH H	
r   r   c                  $     e Zd ZdZd fdZ xZS )BootstrapDockerzBootstrap docker instances.c                J    t         |          }|j                  dd       |S )r   r   platformplatform_version)superr(   updater   r2   r   s     r   r(   zBootstrapDocker.get_variablesF   s1    G)+	 	 	

 r   r7   )r   r8   r9   r:   r(   __classcell__r   s   @r   r>   r>   B   s    %	 	r   r>   c                  :     e Zd ZU dZded<   ded<   d fdZ xZS )BootstrapRemotezBootstrap remote instances.r6   rA   rB   c                r    t         |          }|j                  | j                  | j                         |S )r   r@   )rC   r(   rD   rA   rB   rE   s     r   r(   zBootstrapRemote.get_variablesY   s;    G)+	]]!22 	 	

 r   r7   )r   r8   r9   r:   r;   r(   rF   rG   s   @r   rI   rI   R   s    %M	 	r   rI   )r:   
__future__r   dataclassesr,   typingtior   utilr   util_commonr   r   core_cir	   	dataclassr   r>   rI   r+   r   r   <module>rT      s    # "  	 

 $ $ $N i   i  r   