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 :  /usr/lib/python3.6/site-packages/cloudinit/sources/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

��b
&�@sddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddl	mZddl	m
Z
mZmZmZddlmZmZddlmZmZeje�Zd	Zed
ededd
�ZdZdZdd�ZGdd�dejj �Z!dd�Z"dd�Z#Gdd�dej$�Z%e%ej&ffgZ'dd�Z(dS)�N)�HTTPConnection)�PoolManager)�dmi)�log)�net�sources�
url_helper�util)�
EventScope�	EventType)�EphemeralDHCPv4�NoDHCPLeaseErrorzhttp://169.254.42.42z/conf?format=jsonz/user_data/cloud-initz/vendor_data/cloud-init)�metadata_url�userdata_url�vendordata_url��
cCs>tjd�}|dkrdStjjd�r&dStj�}d|kr:dSdS)a
    There are three ways to detect if you are on Scaleway:

    * check DMI data: not yet implemented by Scaleway, but the check is made to
      be future-proof.
    * the initrd created the file /var/run/scaleway.
    * "scaleway" is in the kernel cmdline.
    zsystem-manufacturer�ScalewayTz/var/run/scalewayZscalewayF)rZ
read_dmi_data�os�path�existsr	Zget_cmdline)Zvendor_nameZcmdline�r�(/usr/lib/python3.6/DataSourceScaleway.py�on_scaleway0s	
rcs*eZdZdZ�fdd�Zddd�Z�ZS)�SourceAddressAdapterzF
    Adapter for requests to choose the local address to bind to.
    cs||_tt|�jf|�dS)N)�source_address�superr�__init__)�selfr�kwargs)�	__class__rrrLszSourceAddressAdapter.__init__FcCs0tjtjtjdfg}t||||j|d�|_dS)N�)Z	num_pools�maxsize�blockr�socket_options)rZdefault_socket_options�socketZ
SOL_SOCKETZSO_REUSEPORTrrZpoolmanager)rZconnectionsr"r#r$rrr�init_poolmanagerPsz%SourceAddressAdapter.init_poolmanager)F)�__name__�
__module__�__qualname__�__doc__rr&�
__classcell__rr)r rrGsrcCs`y&tj|d|d|dd�d�}tj|j�Stjk
rZ}z|jdkrHdS�WYdd}~XnXdS)aQ
    Retrieve user data or vendor data.

    Scaleway user/vendor data API returns HTTP/404 if user/vendor data is not
    set.

    This function calls `url_helper.readurl` but instead of considering
    HTTP/404 as an error that requires a retry, it considers it as empty
    user/vendor data.

    Also, be aware the user data/vendor API requires the source port to be
    below 1024 to ensure the client is root (since non-root users can't bind
    ports below 1024). If requests raises ConnectionError (EADDRINUSE), the
    caller should retry to call this function on an other port.
    NrcSs|jdkot|jtjj�S)Ni�)�code�
isinstance�cause�requests�
exceptions�ConnectionError)�_�excrrr�<lambda>xs
z%query_data_api_once.<locals>.<lambda>)�data�timeout�retriesZsessionZexception_cbi�)r�readurlr	�
decode_binary�contents�UrlErrorr,)�api_addressr6�requests_session�respr3rrr�query_data_api_once]s
r?c	Cs�x�tdt|d��D]�}yJtjd||�tj�}|jdtd|fd��t|||d�}tjd|�|St	j
k
r�}z$tjd	||�tj
d
�|}wWYdd}~XqXqW|�dS)a/Get user or vendor data.

    Handle the retrying logic in case the source port is used.

    Scaleway metadata service requires the source port of the client to
    be a privileged port (<1024).  This is done to ensure that only a
    privileged user on the system can access the metadata service.
    r!�z*Trying to get %s data (bind on port %d)...zhttp://z0.0.0.0)r)r6r=z%s-data downloadedz%Error while trying to get %s data: %srN)�range�max�LOG�debugr/ZSessionZmountrr?rr;�warning�timeZsleep)	Zapi_typer<r7r6Zportr=r5r3�last_excrrr�query_data_api�s$

rHcs�eZdZdZejejejej	hiZ
�fdd�Zdd�Zdd�Z
edd	��Zed
d��Zdd
�Zdd�Zddd�Zedd��Zedd��Z�ZS)�DataSourceScalewayrcs�tt|�j|||�tjtj|ddgi�tg�|_|jd|_|jd|_	|jd|_
t|jjdt
��|_t|jjdt��|_d|_tj|_dS)NZ
datasourcerrrrr7r6)rrIrr	Z
mergemanydictZget_cfg_by_path�BUILTIN_DS_CONFIGZds_cfg�metadata_address�userdata_address�vendordata_address�int�get�DEF_MD_RETRIESr7�DEF_MD_TIMEOUTr6�_fallback_interfacer�UNSET�_network_config)rZsys_cfgZdistro�paths)r rrr�s
zDataSourceScaleway.__init__cCsZtj|j|j|jd�}tjtj|j	��|_
td|j|j|j�|_
td|j|j|j�|_dS)N)r6r7z	user-datazvendor-data)rr8rKr6r7�json�loadsr	r9r:�metadatarHrLZuserdata_rawrMZvendordata_raw)rr>rrr�_crawl_metadata�sz"DataSourceScaleway._crawl_metadatacCs�t�s
dS|jdkrtj�|_y.t|j��tjtjd|j	d�WdQRXWn0t
k
r|}ztjtt|��dSd}~XnXdS)NFzCrawl of metadata service)Zlogfunc�msg�funcT)
rrRr�find_fallback_nicrr	Zlog_timerCrDrYr
Zlogexc�str)r�errr�	_get_data�s

zDataSourceScaleway._get_datacCs�|jdkr tjdtj�tj|_|jtjkr2|jS|jdkrFtj�|_dd|jd�}ddig}|jdr�|d	d|jdd
d|jddd|jddd
�g7}||d<d|gd�|_|jS)z`
        Configure networking according to data received from the
        metadata API.
        Nz5Found None as cached _network_config. Resetting to %sZphysicalz%s)�type�namer`Zdhcp4Zipv6Zstatic�address�gateway�netmask)r`rbrcrd�subnetsr!)�version�config)	rTrCrErrSrRrr\rX)rZnetcfgrerrr�network_config�s(




z!DataSourceScaleway.network_configcCsdS)Nr)rrrr�launch_index	szDataSourceScaleway.launch_indexcCs
|jdS)N�id)rX)rrrr�get_instance_id
sz"DataSourceScaleway.get_instance_idcCsbdd�|jdD�}d}t|�}x<|jjdg�D]*}|j|�s@q0|j|d|�jdd��q0W|S)NcSsg|]}|d�qS)�keyr)�.0rlrrr�
<listcomp>sz:DataSourceScaleway.get_public_ssh_keys.<locals>.<listcomp>Zssh_public_keyszAUTHORIZED_KEY=Ztagsr2� )rX�lenrO�
startswith�append�replace)rZssh_keysZakeypreZplen�tagrrr�get_public_ssh_keyss
z&DataSourceScaleway.get_public_ssh_keysFcCs
|jdS)NZhostname)rX)rZfqdnZ
resolve_ipZ
metadata_onlyrrr�get_hostnameszDataSourceScaleway.get_hostnamecCsdS)Nr)rrrr�availability_zonesz$DataSourceScaleway.availability_zonecCsdS)Nr)rrrr�region#szDataSourceScaleway.region)FFF)r'r(r)Zdsnamer
ZNETWORKrZBOOT_NEW_INSTANCEZBOOTZBOOT_LEGACYZdefault_update_eventsrrYr_�propertyrhrirkrurvrwrxr+rr)r rrI�s

"
rIcCstj|t�S)N)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_list-sr{))rVrr%rFr/Z$requests.packages.urllib3.connectionrZ%requests.packages.urllib3.poolmanagerrZ	cloudinitrrZloggingrrrr	Zcloudinit.eventr
rZcloudinit.net.dhcprr
Z	getLoggerr'rCZDS_BASE_URLrJrPrQrZadaptersZHTTPAdapterrr?rHZ
DataSourcerIZDEP_FILESYSTEMrzr{rrrr�<module>s2
(&~

Youez - 2016 - github.com/yon3zu
LinuXploit