+
     ]i  c                   sz    ^ RI t ^ RIt^ RIt^ RIt^ RIt^RIHt ^RIHt ^RIH	t	  ! R R4      t
 ! R R4      tR# )	i    N)log)progress)
urlfetcherc                   s<   a  ] tR t^t o RtR tR tR tR tRt	V t
R# )_CloudInitConfiga  
Helper class to create cloud-init configuration file.

@destfile: Name of the cloud-init configuration file to be included
    in cloud-init ISO file.
@content: Function to create the content of @destfile. It should return str
    to create the configuration file or None to not create the file.
@config: Path to configuration file user provided to virt-install, if provided
    @content is ignored.
@scratchdir: Directory where to place temporary files.
c                s6    Wn         W n        W0n        W@n        R # N)	_destfile_content_config_scratchdir)selfZdestfilecontentZconfig
scratchdirs   &&&&&5/usr/share/virt-manager/virtinst/install/cloudinit.py__init__Z_CloudInitConfig.__init__   s    !%    c                sT   V P                  4       pVf   R # \        P                  ! RRV P                   2V P                  RR7      p\        VP                  R4      ;_uu_ 4       pVP                  V4       R R R 4       VP                  #   + '       g   i     TP                  # ; i)Nz	virtinst-Z-F)ZprefixZsuffixZdirZdeletezw+)r   tempfileZNamedTemporaryFiler   r   openZnameZwrite)r	   r
   ZfileobjZfs   &   r   _create_fileZ_CloudInitConfig._create_file$   s    --/?--4>>*:';AQAQZ_
 ',,%%GGG &|| &%||s   &BB'	c                s   \         P                  ! R V P                  V P                  4       \        P
                  ! RR7      p\        P                  ! RV P                  V4      pVP                  V P                  4      # )z!Using '%s' content from path='%s'T)ZquietN)
r    debugr   r   r   Z
make_meterr   ZDirectFetcherr   ZacquireFile)r	   ZmeterZfetchers   &  r   _fetch_fileZ_CloudInitConfig._fetch_file1   sZ    		5t~~t||T##$/**41A1A5I""4<<00r   c                s    V P                   '       d   V P                  4       pMV P                  4       pV'       g   R # VP                  W P                  34       R # r   )r   r   r   Zappendr   )r	   	filepairsZfile   && r   add_filepairZ_CloudInitConfig.add_filepair7   sB    <<<##%D$$&D$/0r   )r   r   r   r   N)__name__
__module____qualname____firstlineno__Z__doc__r   r   r   r   __static_attributes____classdictcell__Z__classdict__   @r   r   r      s#     
&1	1 	1r   r   c                   sb   a  ] tR t^Ct o R tR tR tR tR tR t	R t
R tR	 tR
 tR tRtV tR# )CloudInitDatac                s    R V n         R V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n        R # r   )	disableroot_password_generateroot_password_filegenerated_root_passwordroot_ssh_keyclouduser_ssh_key	user_data	meta_datanetwork_configr	      &r   r   ZCloudInitData.__init__D   sG    &*#"&'+$ !%"r   c                s   V P                   '       gj   R V n         \        ^4       FS  pV ;P                   \        P                  ! \        P
                  \        P                  ,           4      ,          un         KU  	  V P                   #  )r#   ZrangerandomZchoicestringZascii_lettersZdigits)r	   Zdummys   & r   _generate_passwordZ CloudInitData._generate_passwordO   s\    ++++-D(r,,f>R>RU[UbUb>b0cc, #+++r   c                s    \        VR 4      ;_uu_ 4       pVP                  4       P                  R4      uuRRR4       #   + '       g   i     R# ; i)Zrz
N)r   ZreadlineZrstrip)r	   ZpwdfileZfobjr   r   _get_passwordZCloudInitData._get_passwordV   s4    '34==?))&1  s	   ?A	c                sJ    V P                   '       d   V P                  4       # R # r   )r!   r/   r)   r*   r   get_password_if_generatedZ'CloudInitData.get_password_if_generatedZ   s"    &&&**,, 'r   c                s|    V P                   '       d   V P                  V P                   4      # V P                  4       # r   )r"   r0   r1   r)   r*   r   get_root_passwordZCloudInitData.get_root_password^   s4    """%%d&=&=>>--//r   c                `    V P                   '       d   V P                  V P                   4      # R # r   )r$   r0   r)   r*   r   get_root_ssh_keyZCloudInitData.get_root_ssh_keyc   s*    %%d&7&788 r   c                r3   r   )r%   r0   r)   r*   r   get_clouduser_ssh_keyZ#CloudInitData.get_clouduser_ssh_keyg   s*    !!!%%d&<&<== "r   c                    R # r+    r)   r*   r   _create_metadata_contentZ&CloudInitData._create_metadata_contentk   s    r   c                s,   R pV P                   '       g   V P                  '       d3   V P                  4       pVR,          pVR,          pVRV,          ,          pV P                   '       d   VR,          pMV P                  '       d
   VR,          pV P                  '       dE   V P	                  4       pVR,          pVR,          pVR,          pVR	,          pVR
V,          ,          pV P
                  '       d*   V P                  4       pVR,          pVRV,          ,          pV P                  '       d   VR,          pVR,          p\        P                  ! RRV4      pR\        P                  9   d   \        V4       \        P                  ! RV4       V# )z#cloud-config
z
chpasswd:
z
  list: |
z    root:%s
z  expire: True
z  expire: False
zusers:
z  - default
z  - name: root
z    ssh_authorized_keys:
z      - %s
zssh_authorized_keys:
z  - %s
zruncmd:
zC- echo "Disabled by virt-install" > /etc/cloud/cloud-init.disabled
z	root:(.*)zroot:[SCRUBBLED]Z#VIRTINST_TEST_SUITE_PRINT_CLOUDINITz"Generated cloud-init userdata: 
%s)r!   r"   r2   r$   r4   r%   r5   r    reZsubosZenvironZprintr    r   )r	   r
   ZrootpassZrootkeyZuserkeyZclean_contents   &     r   _create_userdata_contentZ&CloudInitData._create_userdata_contentn   s]   #&&&$*A*A*A--/H}$G}$G11G&&&))G$$$**G++-Gz!G&G))G33G~//G!!!002G//GzG++G<<<{"G]]G|-?I0BJJ>- 		7Gr   c                r6   r   r7   r)   r*   r   _create_network_config_contentZ,CloudInitData._create_network_config_content   s    r   c                s   \        R V P                  V P                  V4      p\        RV P                  V P                  V4      p\        RV P
                  V P                  V4      p. p VP                  V4       VP                  V4       VP                  V4       V#   \         d)    T F   p\        P                  ! T^ ,          4       K"  	  h i ; i)z	meta-dataz	user-dataznetwork-config)r   r8   r'   r;   r&   r<   r(   r   Z	Exceptionr:   Zunlink)r	   r   r'   r&   r(   r   Zfilepairs   &&     r   create_filesZCloudInitData.create_files   s    $66

	 %66

	 *dAA4CVCVXb
 		""9-""9-''	2   	%		(1+& &	s   *3B 3C)	r%   r    r#   r'   r(   r"   r!   r$   r&   N)r   r   r   r   r   r/   r0   r1   r2   r4   r5   r8   r;   r<   r=   r   r   r   r   r   r   r   C   sB     	#,2-0
9>$L r   r   )r:   r-   r9   r.   r   Zloggerr    r,   r   r   r   r   r7   r   r   <module>r>      s6    
  	     /1 /1di ir   