403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.7
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.6/site-packages/cloudinit/sources/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.6/site-packages/cloudinit/sources/__pycache__/DataSourceConfigDrive.cpython-36.pyc
3

��b�*�@s�ddlZddlmZddlmZmZmZddlmZm	Z	ddl
mZddlm
Z
ddlmZeje�ZdZd	Zd
eiZd"Zd#Zd$Zedd�eD��ZGdd�dejej�Zdd�Zdd�Zd%dd�Z dd�Z!d&dd�Z"eZ#eej$ffgZ%d d!�Z&dS)'�N)�log)�sources�subp�util)�
EventScope�	EventType)�eni)�get_ibm_platform)�	openstackziid-dsconfigdrive�passzinstance-id�vfat�iso9660�config-2�CONFIG-2�sr�cdccs*|]"}tdd�D]}d||fVqqdS)r�z	/dev/%s%sN)�range)�.0�z�i�r�+/usr/lib/python3.6/DataSourceConfigDrive.py�	<genexpr>srcsreZdZdZejejejej	ej
hiZ�fdd�Zdd�Z
dd�Zdd	�Zed
d��Zedd
��Zdd�Z�ZS)�DataSourceConfigDriveZConfigDrivecs\tt|�j|||�d|_tjj|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__cCs0tjj|�}d||j|jf}|d|j7}|S)Nz%s [%s,ver=%s]z[source=%s])r�
DataSource�__str__�dsmoder"r)r*�rootZmstrrrrr0;szDataSourceConfigDrive.__str__cCs�d}i}i}xX|jdfD]J}tjj|�s*qyt|�}|}PWqtjk
r`tjt	d|�YqXqW|�s|j
jd�}x�t|d�D]�}d}tj
�r�|jd�r�d}ytj|t|d�}|}WnNtjk
r�Yn:tjk
r�Yn&tjk
�rtjt	d|�YnX|r�Pq�W|�sd	S|jd
i�}tj|tg�}|j|jd�|jjd�|dd
k�rbtjndg�|_|jtjk�r~d	St|j�}|d}	||	k�r�t||j|jtjkd�|jtjk�r�t	jd||j�d	S||_||_ |jd�|_!|jd�|_"|d|_#|j$j%|jdi��|jd�}
|
|_&ytj'|
�|_(Wn6t)k
�rl}zt	j*d|�d|_(WYdd}~XnX|jd�|_+|jd�|_,dS)Nz
/config-drivez#Failed reading config drive from %sZdatasource_list)�dslistz/dev/cdZcd9660)�mtypezBroken config drive: %sF�metadatar1r"�zinstance-id)r,�networkz&%s: not claiming datasource, dsmode=%szec2-metadataZuserdatar)Z
vendordataz"Invalid content in vendor-data: %s�network_configZnetworkdataT)-r!rr�isdir�read_config_driver
�NonReadabler�logexc�LOGr+�get�find_candidate_devsZis_BSD�
startswithZmount_cbZMountFailedErrorZBrokenMetadataZ
mergemanydict�DEFAULT_METADATAZ_determine_dsmodeZds_cfgrZDSMODE_PASSr1ZDSMODE_DISABLED�get_previous_iidr-�
on_first_bootr,�debugrr5r#Zuserdata_rawr"r)�updateZvendordata_pureZconvert_vendordataZvendordata_raw�
ValueError�warningr'r&)r*�foundZmd�resultsZsdirr3Zdevr4Zprev_iidZcur_iidZvd�errr�	_get_dataAs�





zDataSourceConfigDrive._get_datacCstj|j��S)N)rZinstance_id_matches_system_uuidZget_instance_id)r*r+rrr�check_instance_id�sz'DataSourceConfigDrive.check_instance_idcCsn|jdkrh|jdtjfkr:tjd�tj|j|jd�|_n.|j	dk	r^t
j|j	�|_tjd�n
tjd�|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=rDr
Zconvert_net_jsonr(r'r�convert_eni_data)r*rrrr8�s



z$DataSourceConfigDrive.network_configcCsdS)Nr
r)r*rrr�platform�szDataSourceConfigDrive.platformcCs$|jjd�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_eventsrr0rKrL�propertyr8rNrO�
__classcell__rr)r.rr"s
^rcCs�tj|�}|jgif|jgifg}g}xL|D]D\}}}y
|||�Stjk
rn}z|j|�WYdd}~Xq,Xq,W|d�dS)Nr6���)r
ZConfigDriveReaderZread_v2Zread_v1r;�append)Z
source_dir�readerZfindersZexcpsZfunctor�args�kwargsrJrrrr:�s


 r:cCs>tjj|jd�d�}ytj|�jd�Stk
r8dSXdS)N�datazinstance-id�
)rrr Z	get_cpathrZ	load_file�rstrip�IOError)r-ZfnamerrrrB�s
rBTcCs^t|t�stdt|���|rL|jdd�}|rL|rLtjd�|jtj	|��t
|jd��dS)zDPerforms any first-boot actions using data read from a config-drive.z/Config-drive data expected to be a dict; not %sr8�z-Updating network interfaces from config driver)N)�
isinstance�dict�	TypeError�typer>r=rGZapply_network_configrrM�write_injected_files)rZr,r7Znet_confrrrrC�s

rCcCs||rxtjdt|��xb|j�D]V\}}|jtj�s<tj|}ytj||dd�Wqt	k
rrtj
td|�YqXqWdS)NzWriting %s injected filesi�)�modezFailed writing file: %s)r=rD�len�itemsr@r�seprZ
write_filer]r<)r)�filenameZcontentrrrrc�s
rcc
s|dkrg}|rFx4tD],}ytj|d�Wqtjk
r@YqXqWg}x tD]}|jtjd|��qPWg�x tD]}�jtjd|��qvW|jdd��jdd���fdd�|D�}�fd	d�|D�}t	j
d
||�|o�d|k�rt�\}}	|	|k�r|j|	�t	j
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|]}|�kr|�qSrr)r�d)�by_labelrr�
<listcomp>sz'find_candidate_devs.<locals>.<listcomp>cs$g|]}|�kstj|�r|�qSr)rZis_partition)rrj)rkrrrl"szdevices=%s dslist=%sZIBMCloudz5IBMCloud device '%s' (%s) removed from candidate list)
�OPTICAL_DEVICESrZfind_devs_withrZProcessExecutionError�FS_TYPES�extend�LABEL_TYPES�sortr=rDr	�remove)
Z
probe_opticalr3ZdeviceZ	by_fstypeZfs_typeZlabelZ
candidatesZdevicesZibm_platformZibm_pathr)rkrr?�s8






r?cCstj|t�S)N)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_list>srt)rr
)rr)rr)NT)TN)'rZ	cloudinitrZloggingrrrZcloudinit.eventrrZ
cloudinit.netrZ$cloudinit.sources.DataSourceIBMCloudr	Zcloudinit.sources.helpersr
Z	getLoggerrPr=ZDEFAULT_IIDZDEFAULT_MODErArnrpZPOSSIBLE_MOUNTS�tuplermZSourceMixinr/rr:rBrCrcr?ZDataSourceConfigDriveNetZDEP_FILESYSTEMrsrtrrrr�<module>	s2


B

Youez - 2016 - github.com/yon3zu
LinuXploit