HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceUpCloud.cpython-310.pyc
o

�Ad6�@s�ddlmZddlmZddlmZmZddlmZddl	m
Z
ddlmZ
e�e�ZddiZd	Zd
Zd
ZGdd�dej�ZGd
d�de�ZeejffeejejffgZdd�ZdS)�)�log)�net)�sources�util)�NoDHCPLeaseError)�EphemeralDHCPv4)�upcloud�metadata_urlz'http://169.254.169.254/metadata/v1.json��c@sHeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	e
d
d��ZdS)�DataSourceUpCloud�UpCloudFcCs�tj�||||�||_t�|_t�t�|ddgi�t	g�|_
|j
d|_|j
�dt
�|_|j
�dt�|_|j
�dt�|_d|_dS)N�
datasourcer
r	�retries�timeout�
wait_retry)r�
DataSource�__init__�distro�dict�metadatar�
mergemanydict�get_cfg_by_path�BUILTIN_DS_CONFIG�ds_cfg�metadata_address�get�
MD_RETRIESr�
MD_TIMEOUTr�
MD_WAIT_RETRYr�_network_config)�self�sys_cfgr�paths�r$�E/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceUpCloud.pyr!s��
zDataSourceUpCloud.__init__cCst��S�N)�	uc_helper�read_sysinfo�r!r$r$r%�_get_sysinfo1szDataSourceUpCloud._get_sysinfocCstj|j|j|j|jd�S)N)r�sec_betweenr)r'�
read_metadatarrrrr)r$r$r%�_read_metadata4s�z DataSourceUpCloud._read_metadatac
Cs�|��\}}|s
dSt�d|�|jrfz4t�d�t��}t�d|�t||j�	�d��t
jtjd|jd�}Wd�n1sAwYWnRt
tjfye}zt
�tt|��WYd}~dSd}~wwzt�d�t
jtjd|jd�}Wn"tjy�}zt
�tt|��t�d	|�WYd}~dSd}~ww||_|�d
|�|jd<|�d�|jd
<|�d�|jd<|�d�|jd<|�dd�|jd<|�dd�|_|�dd�|_dS)NFz"Running on UpCloud. server_uuid=%szFinding a fallback NICz*Discovering metadata via DHCP interface %s)�tmp_dirzReading from metadata service)�logfunc�msg�funcz7Discovering metadata without DHCP-configured networkingzENo DHCP-enabled interfaces available, unable to fetch metadata for %s�instance_idzinstance-id�hostnamezlocal-hostname�network�public_keyszpublic-keys�region�default�availability_zone�vendor_data�	user_dataT)r*�LOG�info�perform_dhcp_setup�debug�cloudnet�find_fallback_nicrr�get_tmp_exec_pathr�log_timer-rr�InvalidMetaDataException�logexc�str�
metadata_fullrr�vendordata_raw�userdata_raw)r!�
is_upcloud�server_uuid�nic�md�er$r$r%�	_get_data<sf

�������
����	zDataSourceUpCloud._get_datacCst�|���Sr&)r�instance_id_matches_system_uuid�get_instance_id)r!r"r$r$r%�check_instance_idssz#DataSourceUpCloud.check_instance_idcCs6|jr|jS|j�d�}|std��t�|�|_|jS)z�
        Configure the networking. This needs to be done each boot,
        since the IP and interface information might have changed
        due to reconfiguration.
        r4z/Unable to get network meta-data from server....)r rr�	Exceptionr'�convert_network_config)r!�raw_network_configr$r$r%�network_configvs�z DataSourceUpCloud.network_configN)�__name__�
__module__�__qualname__�dsnamer=rr*r-rNrQ�propertyrUr$r$r$r%rs7rc@seZdZdZdZdS)�DataSourceUpCloudLocalaz
    Run in init-local using a DHCP discovery prior to metadata crawl.

    In init-local, no network is available. This subclass sets up minimal
    networking with dhclient on a viable nic so that it can talk to the
    metadata service. If the metadata service provides network configuration
    then render the network configuration for that instance based on metadata.
    TN)rVrWrX�__doc__r=r$r$r$r%r[�s	r[cCst�|t�Sr&)r�list_from_depends�datasources)�dependsr$r$r%�get_datasource_list�sr`N)�	cloudinitr�loggingrr?rr�cloudinit.net.dhcpr�cloudinit.net.ephemeralr�cloudinit.sources.helpersrr'�	getLoggerrVr;rrrrrrr[�DEP_FILESYSTEM�DEP_NETWORKr^r`r$r$r$r%�<module>s"
r
�