+
    hѢ  c                   s   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^RIH	t	 ^RI	H
t
HtHtHt ^RIHt ^RIHt ^RIHt RtR tR	 tR
 tR tR tR tR tR tR tR tR tR tR t R t!R t"R t#R t$R t%R t&R t'R t(R t)R8R lt*R t+R  t,R! t-R" t.R# t/R$ t0R% t1R& t2R' t3 ! R( R)4      t4R* t5R+ t6 ! R, R-4      t7R. t8R/ t9R0 t:R1 t;R2 t<R3 t=R4 t>R5 t?R8R6 lt@R7 tAR# )9    N)cli)failfail_conflictingprint_stdoutprint_stderr)Network)Guest)logzD--location URL, --cdrom CD/ISO, --pxe, --import, --boot hd|cdrom|...c                s   V P                   P                   F  pVP                  VP                  8X  d   K   VP                  VP                  8w  d    R#  VP
                  P                  VP                  4      p\        VP
                  VP                  ^ 4      R7      pVP                  4       u # 	  R#   \         d    \        P                  ! RRR7         R# i ; i)zC
Return False if we are pretty sure the config doesn't support PXE
T)ZparsexmlzError checking if PXE supportedZexc_infoF)devices	interfacetypeZ	TYPE_USERZTYPE_VIRTUALconnZnetworkLookupByNameZsourcer   ZXMLDescZcan_pxe	Exceptionr   debug)guestZnicZnetobjZxmlobj   &   //usr/share/virt-manager/virtinst/virtinstall.pysupports_pxer      s     }}&&88s}}$88s'''	XX11#**=FSXXq0ABF>>## ' 	  	II7$G	s   AB77#CCc                 s    V P                   '       d   V P                  '       d   \        R R4       V P                   '       d9   RV P                   9   d   \        \	        R4      4       V P                   V n        R# R# )-c--cdromz://zk-c specified with what looks like a libvirt URI. Did you mean to use --connect? If not, use --cdrom insteadN)cdrom_shortcdromr   r   _options   &r   check_cdrom_option_errorr   3   sc    w}}}y)G'''  ++     c                 sT    V P                   '       d   V P                   V n        V = R # R # N)Zxmlstepxmlonlyr   r   r   convert_old_printxmlr    H   s     !//O r   c                 s    V P                   '       g   R # \        V P                   4       F+  w  rV P                   V,          e   K  RV P                   V&   K-  	  R # )Ndefault)Zsound	enumerate)r   idxZdummy   &  r   convert_old_soundr%   N   s@    ===.
==%!*GMM# /r   c                 s   V P                   '       g   R # V P                  '       g	   R.V n        V P                  R;;,          RV P                   ,          ,          uu&   \        P                  ! RV P                  R,          4       R # )N z,init=%sz!Converted old --init to --boot %s)Zinitbootr   r   r   r   r   convert_old_initr)   V   sU    <<<<<<tLL
W\\11II17<<3CDr   c           	      s   \         P                  P                  V P                  4      p\         P                  P                  V P                  4      pR  pV! V\        ^ \        V4      4      4      pV! V\        V4      4      p. p\        V4       F  w  rxRp	V'       d   V	RV,          ,          p	WW,          '       d(   V	'       d
   V	R,          p	V	RWW,          ,          ,          p	V P                  RJ d   V	'       d
   V	R,          p	V	R,          p	\        P                  ! RV	4       VP                  V	4       K  	  W`n        R# )	c                     \         P                  P                  V 4      p V P                  V\	        V 4      ,
          R .,          4       V # r   virtinstxmlutillistifyZextendlenZlstZpadsize   &&r   padlistZ&_do_convert_old_disks.<locals>.padlistc   9    &&s+

Gc#h&4&01
r   r&   zpath=%s,zsize=%sFz	sparse=noz!Converted to new style: --disk %sN)r,   r-   r.   
file_pathsdisksizemaxr/   r"   sparser   r   appenddisk)
r   ZpathsZsizesr2   ZdisklistZsizelistoptsr#   pathoptstr
   &         r   _do_convert_old_disksr?   _   s    $$W%7%78E$$W%5%56E
 uc!SZ01Huc(m,HDx(	i$&&F==#i(-//F>>U"#k!F		5v>F ) Lr   c                 s8   V P                   '       dK   V P                  '       g%   V P                  '       g   V P                  '       d   \	        \        R 4      4       V P                  '       g%   V P                  '       g   V P                  '       g'   V P                  '       d   \	        \        R4      4       V P                  '       g'   V P                   '       d
   R.V n        M\        V 4       V =V =V =V = \        P                  ! RV P                  4       R# )z(Cannot specify storage and use --nodiskszoCannot mix --file, --nonsparse, or --file-size with --disk options. Use --disk PATH[,size=SIZE][,sparse=yes|no]nonezDistilled --disk options: %sN)
Znodisksr5   r:   r6   r   r   r8   r?   r   r   r   r   r   convert_old_disksrA   ~   s    G...',,,'BRBRBRQ9:;g...gnnn',,,G	
 <<<???"8GL!'*II,gll;r   c                 sp    V P                   '       g   R # \        P                  ! \        R4      4       V = R # )Nz?--os-type is deprecated and does nothing. Please stop using it.)old_os_typer   warningr   r   r   r   convert_old_os_optionsrD      s)    KKSTUr   c                 s    V P                   '       d   R # V P                  '       g   R # \        V P                  4      V n         R # r   )memoryZ	oldmemorystrr   r   r   convert_old_memoryrG      s/    ~~~**+GNr   c                 s    V P                   '       g   R # V P                  ;'       g    . pVP                  RV P                   ,          4       Wn        \        P                  ! RV P                  R,          4       R # )Nz
,cpuset=%sz#Generated compat cpuset: --vcpus %sr'   )ZcpusetZvcpusr9   r   r   )r   Znewvcpus   & r   convert_old_cpusetrI      sQ    >>>}}""HOOL7>>12MII3W]]25FGr   c                 s   V P                   '       d	   R .V n        \        P                  P	                  V P
                  4      p\        P                  P	                  V P                  4      p\        P                  P	                  V P                  4      pV'       d   V'       d   \        RR4       V'       d   V Uu. uF  pRV,           NK  	  ppR pV! V\        \        V4      ^4      4      pV! V\        V4      4      p\        V4       F  w  rgW&,          f   RW&&   W,          '       d"   W&;;,          RW,          ,          ,          uu&   R FQ  pW&,          P                  VR,           4      '       g   K)  W&,          P                  VR,           VR	,           4      W&&   KS  	  K  	  V =V =V = W n        \        P                  ! R
V P                  4       R# u upi )r@   --bridgez	--networkzbridge:c                 r*   r   r+   r0   r1   r   r2   Z%convert_old_networks.<locals>.padlist   r3   r   Nr!   z,mac=%sZ:Z=zDistilled --network options: %s)networkbridge)Z
nonetworksrK   r,   r-   r.   ZmacrL   r   r7   r/   r"   Z
startswithZreplacer   r   )	r   ZmacsZnetworksZbridgesZbr2   r#   ZignoreZprefixs	   &        r   convert_old_networksrM      si   !(##GKK0D''8H&&w~~6G8[1+237aIMM73 xSY!23H4X'D *= %HM99MY22M ,F}''55 ( 5 5fslFSL Q , + 	OII/A7 4s   >Gc                 s   V P                   pV P                  pV P                  pV P                  pV P                  pV P
                  pV P                  pV'       d=   V'       g!   V'       g   V'       g   V'       g	   V'       d   \        \        R 4      4       \        R WWW3 4       4      pV^8  d   \        \        R4      4      hV P                  '       d   R# V^ 8X  d   R# T;'       d    R;'       g!    T;'       d    R;'       g    T;'       d    Rp	V'       d   V	RV,          ,          p	V'       d   V	RV,          ,          p	V'       d   V	R	V,          ,          p	\        P                  ! R
V	4       V	.V n        R# )z5Cannot mix --graphics and old style graphical optionsc              3   s8   "   T F  p\        V4      x  K  	  R # 5ir   )bool)Z.0ZgrH   r   Z	<genexpr>Z'convert_old_graphics.<locals>.<genexpr>   s     C"BQa"Bs   zCCan't specify more than one of VNC, SDL, --graphics or --nographicsNvncsdlr@   z
,listen=%sz,port=%sz
,keymap=%sz--graphics compat generated: %s)rO   vncport	vnclisten
nographicsrP   keymapgraphicsr   r   Zsum
ValueErrorr   r   )
r   rO   rQ   rR   rS   rP   rT   rU   Zoptnumr=   r>   r   convert_old_graphicsrW      s"   
++CooG!!I##J
++C^^FHSC6W	QFGHC3C"BCCFz`abb{ mmeLLLLJ4K4KFF,***w&&,''II/8xGr   c                 s    V P                   '       d   R # . pV P                  '       d   VP                  R4       V P                  '       d   VP                  R4       V'       d   RP	                  V4      .V n         R # R # )Nzacpi=offzapic=offr4   )ZfeaturesZnoacpir9   Znoapicjoin)r   r;   rH   r   convert_old_featuresrY      s[    D~~~J~~~JHHTN+ r   c                 st    V P                   ^ 8X  d'   \        P                  ! R4       RV n        RV n         R# R# )r    z$Treating --wait 0 as --noautoconsoler@   N)waitr   rC   autoconsoler   r   r   convert_wait_zeror\     s/    ||q:;$ r   c                 s   VP                   p\        P                  ! V 4      pVP                  '       d   VP                  VP                  n        VP
                  '       d   VP
                  VP                  n        VP                  4        \        P                  ! WR 7      p\        VP                  V4      RR7       R# ))locationTdo_forceN)
test_media_detectionr,   r   archosos_typeset_capabilities_defaults	Installerr   detect_distro)r   r   urlr   	installers   &&   r   do_test_media_detectionri     s}    

&
&CNN4 E|||"??	##%""46I((/$?r   c                 s    VP                   P                  4       '       d   R # V P                  ;'       g    V P                  # T)rb   is_containerr:   Z
filesystemr   r   r1   r   storage_specifiedrm   *  s0    xx<<--7---r   c                 s~    V P                   ;'       g+    V P                  ;'       g    V P                  P                  # r   )rE   currentMemoryZcpuZcellsr   r   r   memory_specifiedrp   0  s*    <<AA5..AA%))//Ar   c                 s   R pV P                   '       gU   \        V4      '       g   VR\        R4      ,           ,          p\        W4      '       g   VR\        R4      ,           ,          pVP                  P                  4       '       g=   VP                  4       '       g'   VR\        R4      R\        /,          ,           ,          pV'       d   \        V4       R# R# )r&   
z"--memory amount in MiB is requiredz<--disk storage must be specified (override with --disk none)z1An install method must be specified
(%(methods)s)ZmethodsN)		reinstallrp   r   rm   rb   rk   Zoptions_specifiedINSTALL_METHODSr   )r   r   rh   msgs   &&& r   validate_required_optionsru   4  s     C&&4!@AAAC 0041[\]]C88  ""9+F+F+H+HtBCyRaFbb
 	
 S	 r   c                 s    V P                   '       g   R # VP                  4       '       g   R # \        P                  ! \	        R4      R,           \	        R4      ,           4       R # )NzCDROM media does not print to the text console by default, so you likely will not see text install output. You might want to use --location.Z zBSee the man page for examples of using --location with CDROM media)r   Zis_textr   rC   r   )rh   r[   r1   r   show_console_warningsrv   I  sT    ???  KK	0	

 	 P
Q	Rr   c           	      s   V P                   '       g   R # V P                  P                  4       pV P                   R,          pVP                  V P                  P
                  4      ;'       g    ^ pV'       d^   VR,          V P                   8  dD   \        P                  ! \        R4      RVRVR,          RV P                  P                  /4       R # R # V^8  d#   \        P                  ! \        R4      V4       R # R # )N   zYRequested memory %(mem1)s MiB is less than the recommended %(mem2)s MiB for OS %(osname)sZmem1Zmem2osnamezJRequested memory %s MiB is abnormally low. Were you trying to specify GiB?   )
rn   osinfoget_recommended_resourcesZget_minimum_ramrb   ra   r   rC   r   name)r   resZrammbZminramr   r   _show_memory_warningsr~   Y  s    
,,
0
0
2C4'E  /441FdNe111KKA ;(?5<<K\K\] 2 
Z[	
 
r   c                 s6    V P                   P                  4       # r   )rb   Zis_hvmro   r   r   _needs_accurate_osinfor   p  s     88??r   c                 s   V P                   '       d1   \        V4      '       g    \        P                  ! \	        R 4      4       VP
                  P                  4       '       dU   \        V4      '       dD   \        P                  ! \	        R4      P                  VP
                  P                  R7      4       \        V4       R# )z5The guest's network configuration may not support PXEz_Using --osinfo {osname}, VM performance may suffer. Specify an accurate OS for optimal results.)rx   N)pxer   r   rC   r   rz   Z
is_genericr   formatr|   r~   rl   r1   r   show_guest_warningsr   z  s    {{{<..AMNO||  %;E%B%B> fELL--f.		
 % r   c                 s    \         P                  P                  VR R7      pVP                  V P                  P
                  V4      p\        \        R4      P                  WR7      4       V# )T)Zraise_errorzUsing {osname} --location {url})rx   rg   )	r,   OSDBZ	lookup_osZget_locationrb   ra   r   r   r   )r   rx   profilerz   r]   s   &&&  r   get_location_for_osr     sV    ]]$$V$>F""588==':H45<<F<YZOr   c                 s   R pR pR pR p\        V P                  4      pR pV P                  p	VP                  p
VP                  pVP
                  pVP                  pVP                  pVP                  pVP                  '       d-   VP                  '       d   VP                  pMVP                  .p	V P                  '       d*   V P                  '       d   \        P                  ! RR4       V P                  '       d!   \        P                  ! V P                  4      pV'       d$   V'       d   VP                  MR p\!        WV4      pMV P"                  '       d%   \        P$                  ! V P"                  4      w  rEpMV P&                  '       d"   V P&                  pV P(                  '       d   RpMfV P*                  '       d   Rp
MQVP,                  '       d   M>V P.                  '       d   RpM)V P0                  '       d   RpMV P2                  '       d   Rp\4        P6                  ! VP8                  VVVVV
VVVVVR7      pV'       d   VP;                  V4       V	'       d   VP=                  V	4       V P>                  '       d   VPA                  V P>                  4       V PB                  '       d   RVn!        V P                  '       d2   \        PD                  ! V P                  4      pVPG                  V4       V# )N--unattended--cloud-initTrK   )
r   r]   location_kernellocation_initrdinstall_bootdevinstall_kernelinstall_initrdinstall_kernel_args
no_installis_reinstall)$rN   rr   
extra_argsZbootdevZkernelZinitrdZkernel_argsrb   r   Zkernel_args_overwrite
unattendedZ
cloud_initr   r   Zparse_unattendedr   r   r]   Zparse_locationr   Zlivecdr   Zis_setr   import_installboot_was_setr,   re   r   Zset_unattended_dataZset_extra_argsZinitrd_injectZset_initrd_injectionsZ	autostartZparse_cloud_initZset_cloudinit_data)r   r   installdatar   r]   r   r   r   Zunattended_datar   r   r   r   r   Z
install_osr   r   rh   Zcloudinit_datas   &&&                r   build_installerr     sh   EHOO))*LO##J!))O ''N ''N%11J''J,,,"-"9"9%112Jg000^^<..w/A/AB-</))$&u'B				7:7I7I'JZJZ7[4O	>>>J	#					
				
				
""

'''%%/!I %%o6  ,''(=(=>"	--g.@.@A$$^4r   c                 s    V P                   '       gW   \        P                  P                  V 4      p\        P
                  ! \        R 4      P                  VR7      4       Wn         R# R# )zUsing default --name {vm_name})Zvm_nameN)r|   r,   r   Zgenerate_namer   r   r   r   )r   Zdefault_namerH   r   set_cli_default_namer     sK    :::~~33E:;<CCLCYZ!
 r   c                 s   VP                   P                  4       '       dS   \        V4      '       g@   R p\        P                  ! \        R4      P                  VR7      4       VR ,          Vn        R# V P                  '       d   VP                  P                  4       '       dt   VP                  P                  VP                   P                  4      '       d?   VP                  VP                  P                  VP                   P                  4      4       VP                  P                  4       pVP!                  VP                   P                  4      pVP#                  VP                   P                  4      pVP%                  VP                   P                  4      pV'       d   \        V4      '       g   \'        VR,          4      P)                  R4      P)                  R4      p\        P                  ! \        R4      P                  VP                  P*                  VR7      4       VR ,          Vn        V'       d   VP-                  V4       V'       d   \/        W4      '       g   RVR,          ,          p\        P                  ! \        R	4      P                  VP                  P*                  VR
7      4       V.V n        \        P2                  ! WqR7      P5                  R4       R# R# R# )rw   z,Using container default --memory {megabytes})	megabytesNZ0Z.z,Using {os_name} default --memory {megabytes})os_namer   zsize=%dz-Using {os_name} default --disk {disk_options})r   Zdisk_optionsro   ry   i   @)rb   rk   rp   r   r   r   r   rn   r   rz   Z
is_windowsZsupports_unattended_driversra   Zadd_extra_driversZget_pre_installable_devicesr{   Zget_recommended_storageZget_recommended_ramZget_recommended_ncpusrF   Zrstripr|   Zsync_vcpus_topologyrm   r:   Z
ParserDiskZparse)r   r   Zmbramr}   ZstorageZramZncpusZdiskstrs   &&      r   set_cli_defaultsr     s!   xx&&E @AHHSXHY #($,E 	LL##%%LL44UXX]]CC H H WX
,,
0
0
2C))%((--8G

!
!%((--
0C%%ehhmm4E
#E**C;'(//4;;C@<=DD))U E 	

 "Tk!!%((88w734=>EE)) F 	

  yw,2248 9wr   c                 s   V P                   '       d   V P                   Vn         R V n         V P                  '       d   V P                  Vn        R V n        V P                  '       d   V P                  Vn        R V n        V P                  '       d#   V P                  VP                  n        R V n        V P
                  '       d   V P
                  Vn        R V n        V P                  '       d#   V P                  VP                  n        R V n        V P                  '       d%   V P                  VP                  n        R V n        R # R # r   )	r|   ZuuidZdescriptionrc   rb   Z	virt_typer   ra   Zmachinerl   r1   r   set_explicit_guest_optionsr     s    |||\\
|||\\
#//""??&&
 |||"?? r   c                 s   R p RpVP                  4       '       d$   VP                  4       pRpV P                  V4       VP                  V 4      pVP                  4       '       dV   V'       d   RpV P                  V4       M9V'       d2   \	        R4      P                  VR7      p\        P                  ! V4       \	        R4      pV'       d   R# VP                  4       '       d   \        V4       \        V 4      '       g   R# VR,           pV\	        R4      ,          p\	        R	4      p	\        VP                  ;'       g    VP                  4      p
V
'       d   VR
V	,           ,          pVR
\	        R4      ,           ,          p\         P"                  P%                  4        Uu. uF&  qP'                  4       '       g   K  VP(                  NK(  	  pp\	        R4      P                  RP+                  V4      R7      pV'       d   VR
V,           ,          pRpVR
\	        R4      P                  VR7      ,           ,          pR
V,           pV\,        P.                  9   dJ   \        P                  ! V4       \	        R4      P                  VR7      p\        P                  ! V4       R# \        V4       R#   \         d0   p\        \	        R4      \        T4      ,          4        Rp?EL-Rp?ii ; iu upi )FNTzFailed to detect osinfo OS name from install media, using fallback name '{name}'.
Please file a bug against virt-install if you expected the detection to succeed.)r|   z%Error validating install location: %szL--osinfo/--os-variant OS name is required, but no value was
set or detected.z

zzThis is now a fatal error. Specifying an OS name is required
for modern, performant, and secure virtual machine defaults.
zIf you expected virt-install to detect an OS name from the
install media, you can set a fallback OS name with:

  --osinfo detect=on,name=OSNAME
rq   zXYou can see a full list of possible OS name values with:

   virt-install --osinfo list
zPIf your Linux distro is not listed, try one of generic values
such as: {oslist}
z, )ZoslistZ"VIRTINSTALL_OSINFO_DISABLE_REQUIREzuIf you just need to get the old behavior back, you can use:

  --osinfo detect=on,require=off

Or export {env_var}=1
)Zenv_varz${env_var} set. Skipping fatal error.)Zget_nameZset_os_namerf   Z	is_detectr   r   r   rC   rV   r   rF   Zis_require_onr   rN   r]   r   r,   r   Zlist_osZis_linux_genericr|   rX   rb   environ)r   rh   osdataZos_setZfallback_nameZ
autodistrort   eZfail_msgZ
detect_msgZpossibly_detectableZoZgeneric_linux_namesZgeneric_linux_msgZenvkeyZms   &&&             r   installer_detect_distror   0  s   FB ??"OO-MFm, ,,U3
!!*-=
 &m&,  C  [
\CS	!%((V|H	I H
 	-J y11DDY__ED:%%q	*  H ,4==+@+@+B[+BaFXFXFZ6166+B[\fDII12f3  D,,,1Fq	" fVf H hHH45<<V<LAXq  BQ67#a&@AABD \sA   J3 A	J3 &J3 .J3 J3 
1J3 $K0 K03K->$K((K-c                 s    \        V 4      pR Vn        \        W4       \        P                  ! V\        P
                  VP                  4       \        P                  ! V\        P                  VP                  4       VP                  4        V# rj   )
r   Zskip_default_osinfor   r   Z
run_parserZ
ParserBootr(   ZParserMetadataZmetadatard   )r   r   r   s   && r   _build_options_guestr     sf    $KE $E w.
 NN5#..',,7NN5#,,g.>.>? 
##%Lr   c                 s   \         P                  ! VP                  4      p\         P                  ! VP                  ;'       g    VP
                  4      p\        VP                  4      Vn        VP                  '       d%   \         P                  ! WP                  4      w  rEpM\        W4      p\        WV4      pVP                  4        \        WWV4       VP                  '       g-   \        V4       \         P                   ! W4       \#        W4       VP%                  V4       VP'                  V4       F$  p\         P(                  ! VP*                  V4       K&  	  VP                  '       g|   VP,                  P.                   F  p	\         P0                  ! V	4       K  	  VP,                  P2                   F.  p
\         P4                  ! V
P*                  V
P6                  4       K0  	  \9        WV4       \;        W4       WW3# r   )r   Zparse_installZinstallZparse_osinforz   rb   rN   r(   r   rr   Zget_domain_and_guestr   r   Zset_default_os_namer   r   Zrun_all_parsersr   Zset_install_defaultsZget_search_pathsZcheck_path_searchr   r
   r:   Zvalidate_diskr   Zvalidate_macZmacaddrru   r   )r   r   r   r   Zdummy1r   Zdummy2rh   r<   r:   Znets   &&         r   build_guest_instancer     sx   ##GOO4Kgnn>>?F-G # 8 8?P?P Qv$T3<I 
Ef5 	U#G+(""5)**51ejj$/ 2 MM&&Dd# '==**CSXXs{{3 + gi8'r   c                 s~    \         P                  P                  4       '       g   \        P                  ! V 4       R # R # r   )r,   r-   in_testsuitetimeZsleep)Zsecsr   r   _sleepr     s(    ((**

4 +r   c                 s    VP                   f-   V P                  4       '       g   V P                  4       '       g   R # \        P                  ! \        R4      4       RVn         R # )Nz;No console to launch for the guest, defaulting to --wait -1r'   )rZ   Zhas_console_cbZ
is_defaultr   rC   r   )r[   r   r1   r   _set_default_waitr     sF    ||;#=#=#?#?{G]G]G_G_ KKOPQGLr   c                   sl   a  ] tR tRt o RtR t]R 4       t]R 4       t]R 4       t	R t
R tR	 tR
tV tR# )WaitHandleri  zH
Helper class for handling the --wait option sleeping and time tracking
c                sV    R V n         ^ V n        ^ V n        Ve   RV n         Wn        R# R# )FNT)wait_is_requested
_wait_mins_start_time)selfrZ   r1   r   __init__ZWaitHandler.__init__  s1    !&%)D""O r   c                s$    V P                   '       * # r   )r   r   r   r   wait_for_console_to_exitZ$WaitHandler.wait_for_console_to_exit  s    
 ))))r   c                s     V P                   ^ 8  # )r    r   r   r   r   _wait_foreverZWaitHandler._wait_forever  s    ""r   c                s(    V P                   ^<,          # )i<   r   r   r   r   
_wait_secsZWaitHandler._wait_secs  s    ##r   c                s:    \         P                   ! 4       V n        R # r   )r   r   r   r   r   startZWaitHandler.start  s    99;r   c                s    V P                   '       d   \        R 4      # \        RRV P                  4      RV P                  /,          # )z)Waiting for the installation to complete.z<Waiting %(minutes)d minute for the installation to complete.z=Waiting %(minutes)d minutes for the installation to complete.Zminutes)r   r   Zngettextr   r   r   r   get_time_stringZWaitHandler.get_time_string  sG    @AAJKOO
 (	) 	)r   c                s@   \        ^4       V P                  '       d)   \        P                  P	                  4       '       d   R# R# \
        P
                  ! 4       V P                  ,
          pWP                  8  ;'       g    \        P                  P	                  4       # )z;
sleep 1 second, then return True if wait time has expired
TF)r   r   r,   r-   r   r   r   r   )r   Ztime_elapsedrH   r   rZ   ZWaitHandler.wait   sl     	q	,,..yy{T%5%55/SSH4D4D4Q4Q4SSr   )r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   Zpropertyr   r   r   r   r   rZ   __static_attributes____classdictcell__Z__classdict__   @r   r   r     sa     # * * # # $ $')T Tr   r   c                 s6   V P                  4       pV'       g   R # \        \        R4      V,          RRR7       \        P                  .p^
p\        P                  P
                  '       g%   \        P                  P                  4       '       g+   \        P                  P                  4       '       g   R # . pRp\        P                  P                  \        R4      4       \        P                  P                  4        \        P                  ! V. . V4       R # )Nz$Password for first root login is: %sTF)r_   Zdo_logg-C6?zAInstallation will continue in 10 seconds (press Enter to skip)...)Zget_generated_passwordr   r   sysZstdinZclosedZisattyr,   r-   r   ZstdoutZwriteZflushselect)rh   ZpasswdZstdinsZtimeoutr   r   _print_cloudinit_passwdr     s    --/F9:VCd[`aii[FG
yysyy//11,,..JJQZ[\JJ
MM&"b'*r   c                sh   VP                  4       pV'       g   R# V! V 4      pV'       g   R#  \        P                  ! V^ 4      ^,          pX'       d    \        P                  ! \        R4      4       VP                  4        R#   \         d"   p\        P
                  ! RT4        Rp?L`Rp?ii ; i)zp
Launched the passed console callback for the already defined
domain. If domain isn't running, return an error.
Nzwaitpid error: %sz!Console command returned failure.)	get_console_cbrb   ZwaitpidZOSErrorr   r   rC   r   handle_destroy_on_exit)r   
instdomainr[   rZ   Z
console_cbZchildZerrcoder   s   &&&&    r   _connect_consoler   #  s    
 ++-JuE***UA&q) A9:;%%'  *		%q))*s   B B1B,,B1c                   s<   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	_InstalledDomaini<  zB
Wrapper for the domain object after the initial install creation
c                st    Wn         W n        W0n        V'       d   \        P                  ! \        V4       R # R # r   )_domain
_transient_destroy_on_exitatexitZregister)r   domain	transientdestroy_on_exits   &&&&r   r   Z_InstalledDomain.__init__A  s)    # /OO,f5 r   c                s    V P                   '       dU   V P                  P                  4       '       d3   \        P                  ! R 4       V P                  P                  4        R# R# R# )z5console exited and destroy_on_exit passed, destroyingN)r   r   isActiver   r   destroyr   r   r   r   Z'_InstalledDomain.handle_destroy_on_exitI  sE       T\\%:%:%<%<IIMNLL  " &= r   c                s    V P                   P                  4       w  rV\        P                  8H  ;'       d$    V\        P                  \        P
                  39   #   \         d    \        P                  ! R RR7        R# i ; i)z!Error checking VM shutdown reasonTr	   N)	r   statelibvirtZVIR_DOMAIN_SHUTOFFZVIR_DOMAIN_SHUTOFF_DESTROYEDZVIR_DOMAIN_SHUTOFF_SAVEDr   r   r   )r   r   Zreasonr$   r   domain_was_destroyedZ%_InstalledDomain.domain_was_destroyedN  s}    	J LL..0MEG666  64400F <   	JII9DII	Js   5A #A #BBc                s    V P                   P                  4       pV^ ,          pV\        P                  8X  d   \	        \        R4      4       V P                   P                  4       '       * #   \        P                   dy   pTP                  4       \        P                  8w  d   h T P                  '       d   \        P                  ! R4        Rp?R# \	        \        R4      T,          4        Rp?R# Rp?ii ; i)r    zDomain has crashed.z&transient VM shutdown and disappeared.NTzVM disappeared unexpectedly: %s)r   Zinfor   ZVIR_DOMAIN_CRASHEDr   r   r   libvirtErrorget_error_codeVIR_ERR_NO_DOMAINr   r   r   )r   Zdominfor   r   r   r   check_inactiveZ_InstalledDomain.check_inactiveX  s    	;ll'')GAJE222Q,-.||,,...## 	;!W%>%>>		BC459::	;s$   A*A- -C:5C58C5C55C:)r   r   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <  s$     6#
J; ;r   r   c                s   VP                  4       '       d   R# \        VP                  4       4      '       d$   \        ^4       VP                  4       '       d   R# RpV\	        R4      ,          pVP
                  '       gU   V P                  4       '       g   R# VR,          pV\	        R4      ,          p\        V4       \        P                  ! ^ 4       \        V4       \        VP                  4       4        VP                  4       '       d   \        \	        R4      4       R# VP                  4       pV'       g   KG  \        \	        R4      4       \        P                  ! ^4       Ks  )z^
Make sure domain ends up in expected state, and wait if for install
to complete if requested
Nrq   z9Domain is still running. Installation may be in progress.zFYou can reconnect to the console to complete the installation process.z Domain has shutdown. Continuing.zDInstallation has exceeded specified time limit. Exiting application.)r   rN   r   r   r   r   requires_postboot_xml_changesr   r   exitr   rZ   )rh   r   r[   waithandlerrt   Zdones   &&&&  r   _wait_for_domainr   k  s   
   ""K&&())
 	q	$$&& C1HIIC((( 6688tqYZZS,,./ $$&&=>?!4abcHHQKr   c                 st    \         P                  P                  R 4      '       d   V P                  4        R# R# )ZVIRTINST_TESTSUITE_HACK_DESTROYN)rb   r   Zgetr   )r   r   r   _testsuite_hack_destroyr     s%    	zz~~788 9r   c                sL   \        WV4      p\        WWCP                  4       \        V 4       \	        W(WC4       \        \        R4      4       V'       d   R# V P                  4       '       d   R# V'       g   VP                  4       '       g2   \        \        R4      \        P                  ! V4      ,          4       R# VP                  4       '       d   V'       g   \        \        R4      4       R# \        \        R4      4       V P                  4        \        WVR4       R# )zG
Handle the pieces of the install process after the initial VM startup
zDomain creation completed.Nz,You can restart your domain by running:
  %sz#User stopped the VM. Not rebooting.zRestarting guest.T)r   r   r   r   r   r   r   r   r   r   Zvirsh_start_cmdr   Zcreate)	r   r   rh   r   r[   r   r   norebootr   s	   &&&&&&&& r   _process_domainr     s     "&_EJU5Y5YZF#YKE/01y>>@@=>ATATUZA[[	
 	&&((Q<=>&'(
MMOUT:r   c           
     s   \         P                  ! W V4      p\        W4       \        W24       \	        VP
                  4      p\         P                  ! 4       p\        \        R4      4       \        V4       VP                  4          VP                  WVP                  '       * VP                  R7      p\#        TT TTTTP                  TP$                  TP                  4       \        P&                  P)                  4       '       d"   TP$                  '       d   \+        T4       R	# R	# R	#    \        P                  P!                  Y4       h ; i  \,         d/    \.        P0                  ! RRR7       \3        \        R4      4       h \4         d/   p\7        TRR7       \         P8                  ! T 4        R	p?R	# R	p?ii ; i)
zW
Process all the install workflow specific options, and kick off
the Installer process
z
Starting install...)meterZdobootr   r&   Tr	   zDomain install interrupted.F)Zdo_exitN)r   Zparse_autoconsolerv   r   r   rZ   Z	get_meterr   r   r   r   start_installr   r   r,   re   Zcleanup_created_disksr   r   r-   r   r   KeyboardInterruptr   r   r   r   r   Zinstall_fail)r   rh   r   r[   r   r   r   r   s   &&&     r   r   r     sp   
 ''	BK)1k+gll+KMMOE *+,I& 	,,w/?/?+?7K\K\ - F 	##		
 ((**w/F/F/FV$ 0G*	44UB   		"t$Q456  Q s8   	-D- 6A%E E -"EE A GG#F==Gc                 sX   VP                  WR R7      w  rEV'       g   TpRpV'       d   V'       g   \        \        R4      4       R# VR9  d   \        \        R4      V,          4       VR8X  d   V# VR8X  d   V'       g   \        \        R4      4       V# TpV'       d	   We,          pV# )	T)dryZ
return_xmlNzDry run completed successfully12z3Unknown XML step request '%s', must be 1, 2, or allz/Requested installation does not have XML step 2)Fr   r   Zall)r   r   r   r   )r   rh   r   r   Z	start_xmlZ	final_xmlxmls   &&&&   r   xml_to_printr     s    $225d2SI		
7Q789..QDEOP#~#~DEF CJr   c            
      s   \         P                  ! R \        R4      RR7      p \         P                  ! V 4       V P	                  \        R4      4      pVP                  RR\        R4      R7       \         P                  ! VRR	7       \         P                  ! V4       \         P                  ! V4       \         P                  ! V4       VP                  R
R\        P                  R7       VP                  R\        P                  R7       V P	                  \        R4      4      pVP                  RR\        P                  R7       VP                  R\        R4      R7       VP                  RR\        R4      R7       VP                  RR\        R4      R7       VP                  RRR\        R4      R7       VP                  RR\        P                  R7       VP                  RR R!\        R"4      R7       VP                  R#R!\        R$4      R7       VP                  R%R&^\        R'4      R(7       VP                  R)\        R*4      R7       VP                  R+R,\        R-4      R.7       VP                  R/R&^\        R04      R(7       VP                  R1\        P                  R7       VP                  R2R\        P                  R7       \         P                  ! V4       VP                  R3\        P                  R7       \         P                  ! V RR47      pVP                  R5R6\        P                  R7       V P	                  \        R74      4      p\         P                  ! V4       \         P                  ! V4       \         P                   ! V4       \         P"                  ! VRR87       VP                  R9R:R;R!\        P                  R<7       VP                  R=R>\$        R!R?\        P                  R@7       VP                  RARBRRC\        P                  RD7       VP                  RER\        P                  R7       VP                  RFR\        P                  R7       VP                  RGRHR!\        P                  R7       VP                  RIRJR!\        P                  R7       VP                  RKR\        P                  R7       VP                  RL\&        \        P                  RM7       VP                  RN\        P                  R7       VP                  RORP\        P                  R7       VP                  RQR\        P                  R7       VP                  RRR\        P                  R7       V P	                  \        RS4      4      p\         P(                  ! V4       V P	                  \        RT4      4      pVP+                  4       pVP                  RURVRWRXRY\        RZ4      R[7       VP                  R\R]RWR^RY\        R_4      R[7       VP                  R`RWRaRY\        Rb4      R[7       VP                  Rc\        Rd4      R7       VP                  Re\        Rf4      R7       VP                  Rg\        Rh4      R7       VP                  RiR\        P                  R7       VP                  RjRRk\        P                  Rl7       VP                  RmRRk\        P                  Rl7       V P	                  \        Rn4      4      pVP                  RoRRk\        Rp4      Rl7       VP                  RqRRk\        Rr4      Rl7       VP                  RsRRk\        Rt4      Rl7       VP                  Ru\&        RyR&\        Rv4      Rw7       \         P,                  ! VRRRRRRRx7       \         P.                  ! V 4       V P1                  4       # )zz%(prog)s OPTIONSz:Create a new virtual machine from specified install media.T)Zintrospection_epilogzGeneral Optionsz-nz--namezName of the guest instance)help)Z
backcompatz-uz--uuidz--descriptionzInstallation Method Optionsr   r   )destr   r   zCD-ROM installation mediaz-lz
--locationzUDistro install URL, eg. https://host/path. See man page for specific distro examples.z--pxeZ
store_truez,Boot from the network using the PXE protocol)actionr   z--importr   z)Build guest around an existing disk image)r   r   r   z--livecdz-xz--extra-argsr9   zIAdditional arguments to pass to the install kernel booted from --locationz--initrd-injectz0Add given file to root of initrd from --locationr   Z?z"Perform an unattended installation)nargsconstr   z	--installz$Specify fine grained install optionsz--reinstallZDOMAINzhReinstall existing VM. Only install options are applied, all other VM configuration options are ignored.)Zmetavarr   r   z:Perform a cloud image installation, configuring cloud-initz--test-media-detectionz--test-stub-commandz--init)Zvirtinstallz	--os-typerB   zDevice Options)Zsound_back_compatz-fz--filer5   )r   r   r   z-sz--file-sizer6   )r   r   r   r   z--nonsparseZstore_falser8   )r   r!   r   r   z	--nodisksz--nonetworksz-brJ   z-mz--macz--vncz	--vncport)r   r   z--vnclistenz-kz--keymapz--sdlz--nographicszGuest Configuration OptionszVirtualization Platform Optionsz-vz--hvmZstore_constZhvmrc   z.This guest should be a fully virtualized guest)r   r   r   r   z-pz
--paravirtZxenz,This guest should be a paravirtualized guestz--containerZexez&This guest should be a container guestz--virt-typez,Hypervisor name to use (kvm, qemu, xen, ...)z--archz The CPU architecture to simulatez	--machinezThe machine type to emulatez--acceleratez--noapicF)r   r!   r   z--noacpizMiscellaneous Optionsz--autostartz&Have domain autostart on host boot up.z--transientzCreate a transient domain.z--destroy-on-exitz=Force power off the domain when the console viewer is closed.z--waitz(Minutes to wait for install to complete.)r   r   r   r   )promptZprintxmlZ	printstepr   ZdryrunZnoautoconsoler'   )r   ZsetupParserr   Zadd_connect_optionZadd_argument_groupZadd_argumentZadd_memory_optionZvcpu_cli_optionsZadd_metadata_optionZadd_xml_optionargparseZSUPPRESSZadd_boot_optionsZadd_osinfo_optionZadd_disk_optionZadd_net_optionZadd_gfx_optionZadd_device_optionsZfloatZintZadd_guest_xml_optionsZadd_mutually_exclusive_groupZadd_misc_optionsZautocomplete
parse_args)	ZparserZgengZinsgZosgZdevgZgxmlgZvirgZostypegZmiscs	            r   r   r     s1   __	
FG!F
 6"$$Q'8%9:DdH1-I+JK$40D!tdH8+<+<=oH,=,=>$$Q'D%EFDdX5F5FGia(C&DE1
   	1-[+\   	:;	   	jH<M<MNZ[	   	AB  
 	c3W1X   	k*P(QR>
   	KL	   	.X5F5FG+LxGXGXYhX%6%67


D
9C[}8;L;LM$$Q'7%89Dtt448 	dH<xO`O`am%zPXPaPa   	mTxO`O`   	k,X=N=NOn\@Q@QRdJxh>O>OPdGH8;L;LMgl9J9JKk(2C2CDm(*;*;<dJX->->?gl9J9JKn\@Q@QR%%a(E&FGEe$$$Q'H%IJD//1G?@   =>   78   	m!,Z*[\hQ'I%JKk*G(HIn\@Q@QRju8K\K\]ju8K\K\]$$Q'>%?@D78	   	lEB^@_   	NO	   	s"Ca8b6c    Vr   c                 sJ    \        T ;'       d    V P                  4       4      pV'       d   V P                  4        R# R#   \        P                   dM   pTP                  4       \        P                  8w  d   \        P                  ! R RR7        Rp?R#  Rp?R# Rp?ii ; i)z%Error invoking atexit destroy_on_exitTr	   N)	rN   r   r   r   r   r   r   r   r   )r   Zisactiver   r$   r   r   r     sy    N446??#45NN  N!:!::II=MM ;Ns!   A A A B";BB"c                 sl   V P                   '       g   R # RV n        V P                  '       g   RV n        V P                  '       g   RV n        V P                  '       g   RV n        V P
                  '       g   RV n        V P                  '       g   RV n        V P                  '       g
   RV n        R # R # )NTztest:///defaultztest-stub-commandZ256r@   Zfedora27)Ztest_stub_commandr   connectr|   rE   r:   rU   rz   r   r   r   set_test_stub_optionsr     s     $$$!G???+<<<*>>><<<!>>># r   c                 s   \         P                  ! 4        \        4       p\        V4       VP                  ;'       g!    VP
                  ;'       g    VP                  Vn        \         P                  ! R VP                  VP                  4       \         P                  ! V4      '       d   ^ # \         P                  ! V4      '       d   ^ # \        V4       \         P                  ! V4       \         P                  ! VP                  4       \         P                  ! VP                   4       \#        V4       \%        V4       \'        V4       \)        V4       \+        V4       \-        V4       \/        V4       \1        V4       \3        V4       \5        V4       \7        V4       \         P8                  ! VP:                  V R7      p VP
                  '       d   \=        W4       ^ # \?        W4      w  r#VP                  '       g   VP@                  '       d9   \C        W#VP                  VP@                  4      pV'       d   \E        VRR7       ^ # \G        W#V4       ^ # )zvirt-install)r   Tr^   )$r   ZearlyLoggingr   r    r   r`   ZquietZsetupLoggingr   Zcheck_option_introspectionZcheck_osinfo_listr   Zconvert_old_forceZparse_checkZcheckZ
set_promptr   rG   r%   rM   rW   rA   rY   rI   r)   r\   r   rD   ZgetConnectionr   ri   r   r   r   r   r   )r   r   r   rh   r   s   &    r   mainr     s   lG !OOTTw'C'CTTw}}GM^W]]GMMB
%%g..
W%%W%'"OOGMM"NN7>>"wg!!g!wWg'"7#W__48D###.+D:E'+++5W__gkkJt,  	e0r   c                  sf    \         P                  ! \        4       4       R #   \         d,   p \         P                  ! T P                  4        R p ? R # R p ? i\
         d1    \        P                  ! RRR7       \        \        R4      4        R # \         d   p\        T4        R p?R # R p?ii ; i)Nr&   Tr	   z$Installation aborted at user request)r   r   r   Z
SystemExitZcoder   r   r   r   r   r   r   )Zsys_eZmain_es     r   runclir     so      @		"t$Q=>? Vs2   " B0 AB0 -B0B0B0B++B0r   )Br   r   rb   r   r   r   r   r,   r&   r   r   r   r   r   r   r   r   Zloggerr   rs   r   r   r    r%   r)   r?   rA   rD   rG   rI   rM   rW   rY   r\   ri   rm   rp   ru   rv   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ) r   r   <module>r      sB     	 
      C C    Y*,*+E><2,H(BV  F
,
@$.B* 
.!(IX"-9`0Rj,%Z
4T 4Tn+*(2,; ,;^-`;D- j@khN$*,^	r   