
    d                         d Z ddlZddlZddlZddlmc mZ ddlmc m	Z	 ddl
mZ ddlmZ ddlmc mc mZ ddlmZmZmZmZ dZdZdZd	 Z G d
 de      Zy)zB
Copy and parse ovf-env.xml from provisioning ISO and local cache
    N)ProtocolError)ustr)	parse_docfindallfindfindtextz1.0z)http://schemas.dmtf.org/ovf/environment/1z)http://schemas.microsoft.com/windowsazurec                 <    | t        dj                  |            y )NzFailed to validate OVF: {0})r   format)valmsgs     H/usr/lib/python3/dist-packages/azurelinuxagent/common/protocol/ovfenv.py_validate_ovfr   $   s#    
{9@@EFF     c                       e Zd ZdZd Zd Zy)OvfEnvzO
    Read, and process provisioning info from provisioning file OvfEnv.xml
    c                     |t        d      t        j                  d       d | _        d | _        d | _        d | _        d| _        g | _        g | _	        d | _
        | j                  |       y )Nzovf-env is NonezLoad ovf-env.xmlT)
ValueErrorloggerverbosehostnameusernameuser_password
customdatadisable_ssh_password_authssh_pubkeysssh_keypairsprovision_guest_agentparse)selfxml_texts     r   __init__zOvfEnv.__init__-   sj    .//)*!)-&%)"

8r   c                    t         }t        }t        |      }t        |d|      }t	        |d       t        |d|      }t	        |d       t        |d|      }t	        |d       |t        kD  rt        j                  d       t        |d	|      }t	        |d
       t        |d|      | _	        t	        | j                  d       t        |d|      | _
        t	        | j                  d       t        |d|      | _        t        |d|      | _        t        |d|      }	|	|	j                         dk(  rd| _        nd| _        t        |d|      }
|
D ]J  }t        |d|      }t        |d|      }t        |d|      }| j                   j#                  |||f       L t        |d|      }|D ];  }t        |d|      }t        |d|      }| j$                  j#                  ||f       = t        |d|      }t	        |d       t        |d|      }t	        |d       t        |d|      | _        t	        | j&                  d        y)!z_
        Parse xml tree, retreiving user and ssh key information.
        Return self.
        Environment)	namespacezEnvironment not foundProvisioningSectionzProvisioningSection not foundVersionzVersion not foundzKNewer provisioning configuration detected. Please consider updating waagent!LinuxProvisioningConfigurationSetz+LinuxProvisioningConfigurationSet not foundHostNamezHostName not foundUserNamezUserName not foundUserPassword
CustomData DisableSshPasswordAuthenticationNtrueTF	PublicKeyPathFingerprintValueKeyPairPlatformSettingsSectionz!PlatformSettingsSection not foundPlatformSettingszPlatformSettings not foundProvisionGuestAgentzProvisionGuestAgent not found)WA_NAME_SPACEOVF_NAME_SPACEr   r   r   r   OVF_VERSIONr   warnr   r   r   r   lowerr   r   r   appendr   r   )r   r    wansovfnsxml_docenvironmentsectionversionconf_setauth_optionpublic_keys
public_keypathfingerprintvaluekeypairskeypairplatform_settings_sectionplatform_settingss                      r   r   zOvfEnv.parse;   sM   
 H%7MUCk#:;{$9TJg>?;	TBg23[ KK ; < !D"&(h MN :Fdmm%9: :Fdmm%9:%h$O"8\TJx)K)-/"{'8'8':f'D-1D*-2D*htD% 	@JJ$?D":}MKZDAE##T;$>?		@ 8Y$? 	:GGVt<D"7MTJK$$dK%89	:
 %)6O[_$`!/1TU !:<NZ^_')EF%-.?AVbf%g"d002QRr   N)__name__
__module____qualname____doc__r!   r    r   r   r   r   )   s    @Sr   r   )rP   osreshutilxml.dom.minidomdomminidomazurelinuxagent.common.loggercommonr    azurelinuxagent.common.exceptionr   azurelinuxagent.common.futurer   %azurelinuxagent.common.utils.fileutilutilsfileutil%azurelinuxagent.common.utils.textutilr   r   r   r   r8   r7   r6   r   objectr   rQ   r   r   <module>ra      sX   & 
 	  ! ! . . : . 8 8 T T<;G
RSV RSr   