403Webshell
Server IP : 3.96.16.70  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3.9/site-packages/cloudinit/sources/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/cloudinit/sources/__pycache__/DataSourceConfigDrive.cpython-39.pyc
a

�½b,�@s�ddlZddlmZddlmZmZmZddlmZm	Z	ddl
mZddlm
Z
ddlmZe�e�ZdZd	Zd
eiZdZdZd
Zedd�eD��ZGdd�dejej�Zdd�Zdd�Zddd�Z dd�Z!d dd�Z"eZ#eej$ffgZ%dd�Z&dS)!�N)�log)�sources�subp�util)�
EventScope�	EventType)�eni)�get_ibm_platform)�	openstackziid-dsconfigdrive�pass�instance-id)ZvfatZiso9660)zconfig-2zCONFIG-2)�srZcdccs*|]"}tdd�D]}d||fVqqdS)r�z	/dev/%s%sN)�range)�.0�z�i�r�K/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceConfigDrive.py�	<genexpr>�rcsreZdZdZejejejej	ej
hiZ�fdd�Zdd�Z
dd�Zdd	�Zed
d��Zedd
��Zdd�Z�ZS)�DataSourceConfigDriveZConfigDrivecs\tt|��|||�d|_tj�|jd�|_d|_d|_	d|_
tj|_
d|_d|_i|_dS)NZconfig_drive)�superr�__init__�source�os�path�join�seed_dir�version�ec2_metadata�_network_configr�UNSET�network_json�network_eni�
known_macs�files)�self�sys_cfg�distro�paths��	__class__rrr/szDataSourceConfigDrive.__init__cCs0tj�|�}d||j|jf}|d|j7}|S)Nz%s [%s,ver=%s]z[source=%s])r�
DataSource�__str__�dsmoderr)r'�rootZmstrrrrr.;szDataSourceConfigDrive.__str__c

Cs�d}i}i}|jdfD]L}tj�|�s(qzt|�}|}WqdWqtjy`t�t	d|�Yq0q|�s
|j
�d�}t|d�D]�}d}t�
�r�|�d�r�d}ztj|t|d�}|}WnFtjy�Yn4tjy�Yn"tjy�t�t	d|�Yn0|r��q
q�|�sd	S|�d
i�}t�|tg�}|�|�d�|j�d�|dd
k�rXtjndg�|_|jtjk�rtd	St|j�}|d}	||	k�r�t||j|jtjkd�|jtjk�r�t	�d||j�d	S||_||_ |�d�|_!|�d�|_"|d|_#|j$�%|�di��|�d�}
|
|_&zt�'|
�|_(Wn8t)�yd}zt	�*d|�d|_(WYd}~n
d}~00|�d�}||_+zt�'|�|_,Wn8t)�y�}zt	�*d|�d|_,WYd}~n
d}~00|�d�|_-|�d�|_.dS)Nz
/config-drivez#Failed reading config drive from %sZdatasource_list)�dslistz/dev/cdZcd9660)�mtypezBroken config drive: %sF�metadatar/r�r)r)�networkz&%s: not claiming datasource, dsmode=%szec2-metadataZuserdatar&Z
vendordataz"Invalid content in vendor-data: %sZvendordata2z#Invalid content in vendor-data2: %s�network_configZnetworkdataT)/rrr�isdir�read_config_driver
�NonReadabler�logexc�LOGr(�get�find_candidate_devsZis_BSD�
startswithZmount_cbZMountFailedErrorZBrokenMetadataZ
mergemanydict�DEFAULT_METADATAZ_determine_dsmodeZds_cfgrZDSMODE_PASSr/ZDSMODE_DISABLED�get_previous_iidr*�
on_first_bootr)�debugrr3r Zuserdata_rawrr&�updateZvendordata_pureZconvert_vendordataZvendordata_raw�
ValueError�warningZvendordata2_pureZvendordata2_rawr$r#)
r'�foundZmd�resultsZsdirr1�devr2Zprev_iidZcur_iidZvd�eZvd2rrr�	_get_dataAs�

�
��


��


zDataSourceConfigDrive._get_datacCst�|���S�N)rZinstance_id_matches_system_uuidZget_instance_id)r'r(rrr�check_instance_id�sz'DataSourceConfigDrive.check_instance_idcCsn|jdurh|jdtjfvr:t�d�tj|j|jd�|_n.|j	dur^t
�|j	�|_t�d�n
t�d�|jS)Nz(network config provided via network_json)r%z.network config provided via converted eni dataz"no network configuration available)r!r#rr"r;rBr
Zconvert_net_jsonr%r$r�convert_eni_data�r'rrrr6�s

�


z$DataSourceConfigDrive.network_configcCsdS)Nr
rrNrrr�platform�szDataSourceConfigDrive.platformcCs$|j�d�rd}nd}d||jfS)z/Return the subplatform metadata source details.z/devzconfig-diskzseed-dirz%s (%s))rr>)r'Zsubplatform_typerrr�_get_subplatform�sz&DataSourceConfigDrive._get_subplatform)�__name__�
__module__�__qualname__ZdsnamerZNETWORKrZBOOT_NEW_INSTANCEZBOOTZBOOT_LEGACYZHOTPLUGZsupported_update_eventsrr.rJrL�propertyr6rOrP�
__classcell__rrr+rr"s"��	f

rcCs�t�|�}|jgif|jgifg}g}|D]P\}}}z||i|��WStjyx}z|�|�WYd}~q*d}~00q*|d�dS)N���)r
ZConfigDriveReaderZread_v2Zread_v1r9�append)Z
source_dir�readerZfindersZexcpsZfunctor�args�kwargsrIrrrr8�s


�"r8cCs@tj�|�d�d�}zt�|��d�WSty:YdS0dS)N�datar�
)rrrZ	get_cpathrZ	load_file�rstrip�IOError)r*Zfnamerrrr@�s
r@TcCs^t|t�stdt|���|rL|�dd�}|rL|rLt�d�|�t�	|��t
|�d��dS)zDPerforms any first-boot actions using data read from a config-drive.z/Config-drive data expected to be a dict; not %sr6�z-Updating network interfaces from config driver&N)�
isinstance�dict�	TypeError�typer<r;rEZapply_network_configrrM�write_injected_files)r[r)r5Znet_confrrrrA�s

�
rAc	Csv|rrt�dt|��|��D]T\}}|�tj�s:tj|}ztj||dd�Wqt	ynt�
td|�Yq0qdS)NzWriting %s injected filesi�)�modezFailed writing file: %s)r;rB�len�itemsr>r�seprZ
write_filer^r:)r&�filenameZcontentrrrrd�s
rdc
	s|durg}|r@tD]*}ztj|d�Wqtjy<Yq0qg}tD]}|�t�d|��qHg�tD]}��t�d|��qj|jdd��jdd���fdd�|D�}�fd	d�|D�}t	�
d
||�|�rd|v�rt�\}}	|	|v�r|�|	�t	�
d|	|�|S)
aReturn a list of devices that may contain the config drive.

    The returned list is sorted by search order where the first item has
    should be searched first (highest priority)

    config drive v1:
       Per documentation, this is "associated as the last available disk on the
       instance", and should be VFAT.
       Currently, we do not restrict search list to "last available disk"

    config drive v2:
       Disk should be:
        * either vfat or iso9660 formatted
        * labeled with 'config-2' or 'CONFIG-2'
    N)rzTYPE=%szLABEL=%sT)�reversecsg|]}|�vr|�qSrr�r�d�Zby_labelrr�
<listcomp>%rz'find_candidate_devs.<locals>.<listcomp>cs"g|]}|�vst�|�s|�qSr)rZis_partitionrkrmrrrn)szdevices=%s dslist=%sZIBMCloudz5IBMCloud device '%s' (%s) removed from candidate list)
�OPTICAL_DEVICESrZfind_devs_withrZProcessExecutionError�FS_TYPES�extend�LABEL_TYPES�sortr;rBr	�remove)
Z
probe_opticalr1ZdeviceZ	by_fstypeZfs_typeZlabelZ
candidatesZdevicesZibm_platformZibm_pathrrmrr=�s>
�


�r=cCst�|t�SrK)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_listFsrv)NT)TN)'rZ	cloudinitrZloggingrrrZcloudinit.eventrrZ
cloudinit.netrZ$cloudinit.sources.DataSourceIBMCloudr	Zcloudinit.sources.helpersr
Z	getLoggerrQr;ZDEFAULT_IIDZDEFAULT_MODEr?rprrZPOSSIBLE_MOUNTS�tupleroZSourceMixinr-rr8r@rArdr=ZDataSourceConfigDriveNetZDEP_FILESYSTEMrurvrrrr�<module>	s8
��&

B
�

Youez - 2016 - github.com/yon3zu
LinuXploit