+
    iO3                     h   R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIt^ RIH	t	H
t
Ht ]P                  ! ]4      t ! R R]	P                  4      t ! R R]4      tRR ltR	 tR
 tRR ltR tR tR tR tR t ! R R]4      t]]	P:                  33]]	P:                  ]	P<                  333tR t R t!R# )zZCloud-Init DataSource for OVF

This module provides a cloud-init datasource for OVF data.
N)minidom)sourcessubputilc                   X   a  ] tR t^t o RtR tR tR tR tR t	R t
]R 4       tR	tV tR
# )DataSourceOVFOVFc                    \         P                  P                  WW#4       R V n        \        P
                  P                  VP                  R4      V n        R V n        / V n	        RV n
        R V n        R # )Novf)/zfile://)r   
DataSource__init__seedospathjoinseed_direnvironmentcfgsupported_seed_starts_network_configselfsys_cfgdistropathss   &&&&A/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceOVF.pyr   DataSourceOVF.__init__    sX    ##D6A	U^^U;%5"#    c                h    \         P                  P                  V 4      pV: R V P                  : R2# )z [seed=])r   r   __str__r   )r   roots   & r   r!   DataSourceOVF.__str__)   s'    !!))$/!%tyy11r   c                X   . p/ pR pR pRR/p\        V P                  P                  4      w  rgV'       d[   \        P                  P                  V P                  P                  V4      p\        V4      w  r#p	Wpn        VP                  V4       MR\        3R\        3.p
RpV
 F  w  rV! 4       pV'       g   K   M	  V'       dK   \        VR4      w  r#p	Wpn        RV9   d   VR,          '       d   VR,          V n        VP                  V4       V'       g   R# R	V9   d   VR	,          '       d   VR	,          pRpV P                   F  pVP                  V4      '       g   K  Tp M	  V'       g   \        P                  R
W4       R# \         P"                  ! VRR7      w  pr4p\        P                  RV4       \         P$                  ! VV.4      pVP                  V4       \         P$                  ! W%.4      pRP                  V4      V n        W n        W0n        W@n        X	V n        R# ) instance-idz	iid-dsovfzcom.vmware.guestInfoisoNTnetwork-configFseedfromz Seed from %s not supported by %s)timeoutzUsing seeded cache data from %s,)get_ovf_envr   r   r   r   r   read_ovf_environmentr   appendtransport_vmware_guestinfotransport_iso9660r   r   
startswithLOGdebugr   read_seededmergemanydictr   metadatauserdata_rawvendordata_rawr   )r   foundmdudvddefaultsseedfilecontentsr   r   npname	transfuncr)   	seedfoundprotomd_seed_s   &                 r   	_get_dataDataSourceOVF._get_data-   s    ;
  +4::+>+>?77<<

 3 3X>D0:MRS'LL ()CD)*B D#%$;8 $&  4Xt D#+ #r)b1A.B.B+-.>+?D(T" :*~HI33&&u-- %I 4 		<hM#'#3#3Hd#K WbaII7B##RM2BLL" /HHUO	 r   c                (    R V P                   ,          # )zovf (%s))r   r   s   &r   _get_subplatformDataSourceOVF._get_subplatformo   s    DII%%r   c                    R V P                   9  d   . # V P                   R ,          p\        V\        4      '       d   V# V.# )public-keys)r6   
isinstancelist)r   pkss   & r   get_public_ssh_keys!DataSourceOVF.get_public_ssh_keysr   s:    -ImmM*cD""J5Lr   c                    V P                   # N)r   rJ   s   &r   get_config_objDataSourceOVF.get_config_obj~   s    xxr   c                    V P                   # rU   )r   rJ   s   &r   network_configDataSourceOVF.network_config   s    ###r   )	r   r   r   r6   r   r   r   r7   r8   N)__name__
__module____qualname____firstlineno__dsnamer   r!   rG   rK   rR   rV   propertyrY   __static_attributes____classdictcell____classdict__s   @r   r   r      s>     F$2@D& $ $r   r   c                   &   a  ] tR t^t o R tRtV tR# )DataSourceOVFNetc                    \         P                  WW#4       \        P                  P	                  VP
                  R 4      V n        RV n        R# )zovf-netN)zhttp://zhttps://)r   r   r   r   r   r   r   r   s   &&&&r   r   DataSourceOVFNet.__init__   s4    tf<U^^Y?%<"r   )r   r   N)r[   r\   r]   r^   r   ra   rb   rc   s   @r   rf   rf      s     = =r   rf   c                 D   \        V 4      p/ p/ pR pR.p. ROpR.pVP                  4        F  w  rV	R8X  d   Rp	W9   d   WV	&   K  W9   d   WV	&   K&  W9   dL   V'       dD    \        P                  ! V
P	                  4       4      p\        V4      P                  R4      W9&   Kw  V	R8X  g   K   \        P                  ! V
P	                  4       4      pK  	  W5V3#   \         d    \        P                  R4        K  i ; i  \         d    T
P	                  4       p K  i ; i)	Npasswordlocal-hostnamer(   hostnamenetworkz%Ignore network-config in wrong formatz	user-data)r)   rk   rN   r&   )
get_propertiesitemsbase64	b64decodeencodesafeload_yaml_or_dictget	Exceptionr2   r3   )r?   read_networkpropsr:   r   r;   	cfg_propsmd_propsnetwork_propspropvalrY   s   &&          r   r-   r-      s   8$E	B
C	BIKH%&M[[]	:#DtHI"|C!'!1!1#**,!?0@DDYO [ "%%cjjl3 #$ C=  C		ABC
  "ZZ\"s%   !A C-$D  C=<C= DDc                 8   RpV Fc  p\         P                  P                  W4      p\         P                  P                  V4      '       g   KI   \        P
                  ! V4      pW$3u # 	  R#   \         d!    \        P                  ! \        RT4        K  i ; i)ovf-env.xmlzFailed loading ovf file %s)r~   zovf_env.xmlzOVF_ENV.XMLzOVF-ENV.XML)NF)	r   r   r   isfiler   load_text_fileru   logexcr2   )dirname	env_namesfnamefull_fnr?   s   &    r   r,   r,      s    LI'',,w.77>>'""H..w7((    HC!=wGHs   A..'BBc                <   V '       g   R# \        V \        4      '       g   \        RV ,          4      h\        P                  P                  V 4      p V P                  R4      '       d   V P                  R4      R,          p V P                  R4      '       d   V P                  R4      R,          p MV P                  R4      ^ 8  d   R# V '       g   R# Rp\        P                  P                  RV4      p\        P                  ! V4      pVP                  V 4      RJ# )	zTest if devname matches known list of devices which may contain iso9660
   filesystems.

Be helpful in accepting either knames (with no leading /dev/) or full path
names, but do not allow paths outside of /dev/, like /dev/foo/bar/xxx.
Fz Unexpected input for devname: %sz/dev/r   z^(sr[0-9]+|hd[a-z]|xvd.*)CLOUD_INIT_CDROM_DEV_REGEXN)rO   str
ValueErrorr   r   normpathr1   	partitionsplitcountenvironrt   recompilematch)devnamedefault_regexdevname_regexcdmatchs   &   r   maybe_cdrom_devicer      s     %%;gEFF ggw'G '""##G,R0 #--$R(	s	a	  1MJJNN#?OMjj'G==!--r   c                 |   \         P                  ! 4       pVP                  4        FR  w  r#VR ,          pVR8w  d   V '       d   K  \        V4      '       g   K2  VR,          p\	        V4      w  rgVRJg   KP  Vu # 	  V '       d   RpMRp\         P
                  ! V'       d
   RV,          MR4       Uu. uF  p\        V4      '       g   K  VNK  	  p	pV	 F-  p \         P                  ! V\        VR7      w  rgTRJg   K+  Tu # 	  R# u upi   \         P                   d    \        P                  RT4        Kf  i ; i)fstypeiso9660
mountpointFNzTYPE=%s)mtypez%s not mountable as iso9660)
r   mountsro   r   r,   find_devs_withmount_cbMountFailedErrorr2   r3   )
require_isor   devinfor   mp_fnamer?   r   devss
   &         r   r0   r0      s   [[]F\\^	hY;!#&&,(_5 O $ 
 &&Ey5'8tLLCc" 	L 	 
 	!%sKu!MV
 5 O   $$ 	II3S9	s   2D
DD+D;:D;c                 @    W.p\         P                   ! V4      w  r4W#V3# rU   r   rpctoolargcmdstdoutstderrs   &&   r   exec_vmware_rpctoolr   
  s$    .Cyy~V  r   c                 D    V R V.p\         P                   ! V4      w  r4W#V3# )z--cmdr   r   s   &&   r   exec_vmtoolsdr     s)    GS
!Cyy~V  r   c                  T   R R r\         P                  ! R4      p\         P                  ! R4      pV'       d   T\        r\        P	                  RV4       V'       d&   V'       g   T\
        r\        P	                  RV4       V '       g   \        P	                  R4       R # R p V! W4      #   \         P                   d   pT'       d:   Y8X  d4   TP                  ^8w  d   \        P                  ! \        RT4        R p?R # T'       g   \        P                  R4        R p?R #  \        P                  R	4       T! T\
        4      u R p?#   \         P                   d=   pTP                  ^8w  d   \        P                  ! \        RT4        R p? R p?R # R p?ii ; iR p?ii ; i)
Nvmtoolsdzvmware-rpctoolzdiscovered vmware-rpctool: %szdiscovered vmtoolsd: %szno rpctool discoveredc                 ,   \         P                  R V 4        V! V R4      w  r#pV'       d   V# \         P                  RV4       R#   \        P                   d9   pTP
                  ^8w  d!   \         P                  RYP
                  4       ThRp?ii ; i)zquery guestinfo.ovfEnv with %szinfo-get guestinfo.ovfEnvz!cmd %s exited 0 with empty stdoutNz%s exited with code %d)r2   r   r3   r   ProcessExecutionError	exit_codewarning)r   
rpctool_fnr   r   rF   errors   &&    r   query_guestinfo3transport_vmware_guestinfo.<locals>.query_guestinfo-  s{    17;		'1LMNCII93?)) 	!#4gOK	s   A A B3BBz+vmtoolsd failed to get guestinfo.ovfEnv: %sz$vmtoolsd fallback option not presentzfallback to vmtoolsd)r   whichr   r2   r3   r   r   r   r   r   r   )r   r   r   vmware_rpctoolr   r   s         r   r/   r/     s>   Zzz*%HZZ 01N ,.A		1>B "*MZ		+X6 		)* w33%%  +!#F HH;<	HH+,"8];;)) 	!#F 	+sN   %B- -F';F"F"F"'!EF'F#-FF"FF""F'c                     . pV P                  4       '       g   V# V P                   F$  pV! V4      '       g   K  VP                  V4       K&  	  V# rU   )hasChildNodes
childNodesr.   )nodefilter_funcretchilds   &&  r   
find_childr   ]  sG    
C
uJJu ! Jr   c                 
   \         P                  ! V 4      pVP                  P                  R 8w  d   \	        R4      hVP                  P                  4       '       g   \	        R4      hRp\        VP                  R 4      pV'       g   \	        R4      h/ p\        V^ ,          R 4      pV FS  pVP                  P                  VR4      P                  pVP                  P                  VR4      P                  pWV&   KU  	  V# )	EnvironmentzNo Environment NodezNo Child Nodesz)http://schemas.dmtf.org/ovf/environment/1c                      V P                   R 8H  # )PropertySection	localNamens   &r   <lambda> get_properties.<locals>.<lambda>t  s    q{{6G'Gr   zNo 'PropertySection'sc                      V P                   R 8H  # )Propertyr   r   s   &r   r   r   |  s    AKK:$=r   keyvalue)
r   parseStringdocumentElementr   XmlErrorr   r   
attributesgetNamedItemNSr   )	r?   domenvNsURIpropSectionsrw   	propElemselemr   r|   s	   &        r   rn   rn   g  s    


h
'C
$$5,--,,..'((:H GL .//EQ=I oo,,Xu=CCoo,,Xw?EEc
 
 Lr   c                       ] tR tRtRtR# )r   i   N)r[   r\   r]   r^   ra   r   r   r   r   r     s    r   r   c                 8    \         P                  ! V \        4      # rU   )r   list_from_dependsdatasources)dependss   &r   get_datasource_listr     s    $$Wk::r   c                B    V '       g   / # \         P                  ! V 4      # )z
The meta data could be JSON or YAML. Since YAML is a strict superset of
JSON, we will unmarshal the data as YAML. If data is None then a new
dictionary is returned.
)yaml	safe_load)datas   &r   rs   rs     s     	>>$r   )F)T)"__doc__rp   loggingr   r   xml.domr   r   	cloudinitr   r   r   	getLoggerr[   r2   r   r   rf   r-   r,   r   r0   r   r   r/   r   rn   ru   r   DEP_FILESYSTEMDEP_NETWORKr   r   rs   r   r   r   <module>r      s   
   	 	   ) )!f$G&& f$R=} =>
$.R#L!!DN@	y 	 W++-...0C0CDE; r   