404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.119.213.129: ~ $
3

\�me�=�@s.ddlZddlZddlZddlZddlZddlmZddlZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZmZmZddlmZmZddlmZdd	lmZmZdd
lmZddlmZej 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�net�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|�jf|�dS)N)�source_address�superr�__init__)�selfr�kwargs)�	__class__��(/usr/lib/python3.6/DataSourceScaleway.pyr+szSourceAddressAdapter.__init__FcCs0tjtjtjdfg}t||||j|d�|_dS)N�)Z	num_pools�maxsize�blockr�socket_options)rZdefault_socket_options�socketZ
SOL_SOCKETZSO_REUSEPORTrrZpoolmanager)rZconnectionsrr r!rrr�init_poolmanager/sz%SourceAddressAdapter.init_poolmanager)F)�__name__�
__module__�__qualname__�__doc__rr#�
__classcell__rr)rrr&s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�
exceptionsr)�_�excrrr�<lambda>Ws
z%query_data_api_once.<locals>.<lambda>)�data�timeout�retriesZsessionZexception_cbi�)r	�readurlr
�
decode_binary�contents�UrlErrorr))�api_addressr2�requests_session�respr/rrr�query_data_api_once<s
r;c
Cs"�xtdt|d��D�]}y�tjd||�tj�}d}yRt|�j}|}|ddkr^|dd�}tj	|dtj
d�dd}	|	tjkr�d	}Wntk
r�YnX|j
d
t||fd��t|||d�}
tjd
|�|
Stjk
�r}z$tjd||�tjd�|}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.
    rrz*Trying to get %s data (bind on port %d)...z0.0.0.0r�[N)�protoz0::zhttp://)r)r2r9z%s-data downloadedz%Error while trying to get %s data: %s����)�range�max�LOG�debugr,ZSessionr�netlocr"�getaddrinfo�IPPROTO_TCP�AF_INET6�
ValueErrorZmountrr;r	r7�warning�timeZsleep)
Zapi_typer8r3r2Zportr9Z	localhostZurl_address�address�
addr_protor1r/�last_excrrr�query_data_apids>




rNcs�eZdZdZejejejej	hiZ
�fdd�Zdd�Zdd�Z
edd	��Zd
d�Zdd
�Zedd��Zedd��Zdd�Zdd�Zddd�Zedd��Zedd��Z�ZS)�DataSourceScaleway�Scalewaycs�tt|�j|||�tjtj|ddgi�g�|_t|jjdt	��|_
t|jjdt��|_t|jjdt
��|_d|_tj|_t|_d|_d|_d|_d|_d|jj�kr�|j|jd7_dS)NZ
datasourcerPr3r2�max_waitT�
metadata_urls)rrOrr
Z
mergemanydictZget_cfg_by_pathZds_cfg�int�get�DEF_MD_RETRIESr3�DEF_MD_TIMEOUTr2�DEF_MD_MAX_WAITrQ�_fallback_interfacer�UNSET�_network_config�DS_BASE_URLSrR�userdata_url�vendordata_url�ephemeral_fixed_address�has_ipv4�keys)rZsys_cfg�distro�paths)rrrr�szDataSourceScaleway.__init__cCs|tj�}tj||j|jdd�\}}|rZtjd|�|�d�|_|�d�|_|�d�|_	dStjd|t
tj�|��t�dS)	zO
        Define metadata_url based upon api-metadata URL availability.
        F)�urlsrQr2Zconnect_synchronouslyz%s is reachablez/conf?format=jsonz/user_data/cloud-initz/vendor_data/cloud-initNz3Unable to reach api-metadata at %s after %s seconds)rJr	Zwait_for_urlrQr2rBrC�metadata_urlr\r]rSr)rrcZ
start_timeZ	avail_urlr.rrr�_set_metadata_url�s"z$DataSourceScaleway._set_metadata_urlcCsZtj|j|j|jd�}tjtj|j	��|_
td|j|j|j�|_
td|j|j|j�|_dS)N)r2r3z	user-datazvendor-data)r	r4rdr2r3�json�loadsr
r5r6�metadatarNr\Zuserdata_rawr]Zvendordata_raw)rr:rrr�_crawl_metadata�sz"DataSourceScaleway._crawl_metadatacCs>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-manufacturerrPTz/var/run/scalewayZscalewayN)rZ
read_dmi_data�os�path�existsr
Zget_cmdline)Zvendor_nameZcmdlinerrr�	ds_detect�s

zDataSourceScaleway.ds_detectcCs�|dkrtjd|�gSg}x�|D]~}t|�j}|ddkrH|dd	�}tj|dtjd�dd}|tjkr�|dkr�||g7}q"q"|tjkr"|dkr"||g7}q"q"W|S)
N�ipv4�ipv6zInvalid IP version : %srr<r)r=)rnror?)	rBrCrrDr"rErFZAF_INETrG)rr=rcZ
filtered_urlsZurlrKrLrrr�_set_urls_on_ip_version�s$




z*DataSourceScaleway._set_urls_on_ip_versionc!Cs4|jdkrtj�|_|jr�y`t|j|j��H}tjtj	d|j
|jfd�tjtj	d|jd�|d|_
d|jd<WdQRXWn>tttfk
r�}ztjtt|��d|_WYdd}~XnX|j�s0yVt|j|j��>tjtj	d	|j
|jfd�tjtj	d|jd�d
|jd<WdQRXWntk
�r.dSXdS)Nz3Set api-metadata URL depending on IPv4 availability)�logfunc�msg�func�argszCrawl of metadata service)rqrrrsz
fixed-addressrnZ
net_in_useFz3Set api-metadata URL depending on IPv6 availabilityroT)rXr�find_fallback_nicr_rrar
Zlog_timerBrCrerRrir^rhr
rrZlogexc�strr)rrn�errr�	_get_datasV





zDataSourceScaleway._get_datac	Cs�|jdkr tjdtj�tj|_|jtjkr2|jS|jdkrFtj�|_|jddk�rFi}i}x�|jdD]�}|d|j	kr�d|d<dd	d
�g|d<qjd|j
�kr�|d|d�d
|d��f7<n|d�d
|d��f|d<|ddkrj|ddd�}d|j
�k�r |d|g7<qj|g|d<qjW|||j<d|d�|_n�dd|jd�}ddig}|jd�r�|dd|jddd|jddddd|jddd�gd�g7}||d <d!|gd"�|_tjd#|j�|jS)$z`
        Configure networking according to data received from the
        metadata API.
        Nz5Found None as cached _network_config. Resetting to %sZ
private_ipZ
public_ipsrKTZdhcp4z169.254.42.42/32z
62.210.0.1)�to�via�routesZ	addresses�/�netmaskZfamilyZinet6�gatewayz::/0)rzryr)�versionZ	ethernetsZphysicalz%s)�type�namer�roZstaticz::�0)Znetwork�prefixr~)r�rKr}r{�subnetsr)r�configznetwork_config : %s)rZrBrIrrYrXrrurhr^r`rC)rZnetcfgZip_cfgZipZrouter�rrr�network_configMsV




z!DataSourceScaleway.network_configcCsdS)Nr)rrrr�launch_index�szDataSourceScaleway.launch_indexcCs
|jdS)N�id)rh)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)�.0r�rrr�
<listcomp>�sz:DataSourceScaleway.get_public_ssh_keys.<locals>.<listcomp>Zssh_public_keyszAUTHORIZED_KEY=Ztagsr.� )rh�lenrT�
startswith�append�replace)rZssh_keysZakeypreZplen�tagrrr�get_public_ssh_keys�s
z&DataSourceScaleway.get_public_ssh_keysFcCst|jdd�S)NZhostnameF)rrh)rZfqdnZ
resolve_ipZ
metadata_onlyrrr�get_hostname�szDataSourceScaleway.get_hostnamecCsdS)Nr)rrrr�availability_zone�sz$DataSourceScaleway.availability_zonecCsdS)Nr)rrrr�region�szDataSourceScaleway.region)FFF)r$r%r&ZdsnamerZNETWORKrZBOOT_NEW_INSTANCEZBOOTZBOOT_LEGACYZdefault_update_eventsrreri�staticmethodrmrprx�propertyr�r�r�r�r�r�r�r(rr)rrrO�s$

AM
rOcCstj|t�S)N)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_list�sr�)1rfZloggingrjr"rJZurllib.parserr,Zrequests.exceptionsrZurllib3.connectionrZurllib3.poolmanagerrZ	cloudinitrrrr	r
Zcloudinit.eventrrZcloudinit.net.dhcpr
Zcloudinit.net.ephemeralrrZcloudinit.sourcesrZcloudinit.subprZ	getLoggerr$rBr[rUrWrVZadaptersZHTTPAdapterrr;rNZ
DataSourcerOZDEP_FILESYSTEMr�r�rrrr�<module>s8
(4$

Filemanager

Name Type Size Permission Actions
DataSourceAkamai.cpython-36.opt-1.pyc File 8.18 KB 0644
DataSourceAkamai.cpython-36.pyc File 8.18 KB 0644
DataSourceAliYun.cpython-36.opt-1.pyc File 3.22 KB 0644
DataSourceAliYun.cpython-36.pyc File 3.22 KB 0644
DataSourceAltCloud.cpython-36.opt-1.pyc File 6.74 KB 0644
DataSourceAltCloud.cpython-36.pyc File 6.74 KB 0644
DataSourceAzure.cpython-36.opt-1.pyc File 47.95 KB 0644
DataSourceAzure.cpython-36.pyc File 47.95 KB 0644
DataSourceBigstep.cpython-36.opt-1.pyc File 1.84 KB 0644
DataSourceBigstep.cpython-36.pyc File 1.84 KB 0644
DataSourceCloudSigma.cpython-36.opt-1.pyc File 3.62 KB 0644
DataSourceCloudSigma.cpython-36.pyc File 3.62 KB 0644
DataSourceCloudStack.cpython-36.opt-1.pyc File 5.97 KB 0644
DataSourceCloudStack.cpython-36.pyc File 5.97 KB 0644
DataSourceConfigDrive.cpython-36.opt-1.pyc File 8.18 KB 0644
DataSourceConfigDrive.cpython-36.pyc File 8.18 KB 0644
DataSourceDigitalOcean.cpython-36.opt-1.pyc File 3.65 KB 0644
DataSourceDigitalOcean.cpython-36.pyc File 3.65 KB 0644
DataSourceEc2.cpython-36.opt-1.pyc File 23.49 KB 0644
DataSourceEc2.cpython-36.pyc File 23.49 KB 0644
DataSourceExoscale.cpython-36.opt-1.pyc File 5.92 KB 0644
DataSourceExoscale.cpython-36.pyc File 5.92 KB 0644
DataSourceGCE.cpython-36.opt-1.pyc File 9.83 KB 0644
DataSourceGCE.cpython-36.pyc File 9.93 KB 0644
DataSourceHetzner.cpython-36.opt-1.pyc File 3.78 KB 0644
DataSourceHetzner.cpython-36.pyc File 3.78 KB 0644
DataSourceIBMCloud.cpython-36.opt-1.pyc File 12.44 KB 0644
DataSourceIBMCloud.cpython-36.pyc File 12.44 KB 0644
DataSourceLXD.cpython-36.opt-1.pyc File 13.31 KB 0644
DataSourceLXD.cpython-36.pyc File 13.31 KB 0644
DataSourceMAAS.cpython-36.opt-1.pyc File 11.86 KB 0644
DataSourceMAAS.cpython-36.pyc File 11.86 KB 0644
DataSourceNWCS.cpython-36.opt-1.pyc File 3.77 KB 0644
DataSourceNWCS.cpython-36.pyc File 3.77 KB 0644
DataSourceNoCloud.cpython-36.opt-1.pyc File 7.97 KB 0644
DataSourceNoCloud.cpython-36.pyc File 7.97 KB 0644
DataSourceNone.cpython-36.opt-1.pyc File 1.47 KB 0644
DataSourceNone.cpython-36.pyc File 1.47 KB 0644
DataSourceOVF.cpython-36.opt-1.pyc File 9.15 KB 0644
DataSourceOVF.cpython-36.pyc File 9.15 KB 0644
DataSourceOpenNebula.cpython-36.opt-1.pyc File 11.75 KB 0644
DataSourceOpenNebula.cpython-36.pyc File 11.75 KB 0644
DataSourceOpenStack.cpython-36.opt-1.pyc File 7.91 KB 0644
DataSourceOpenStack.cpython-36.pyc File 7.91 KB 0644
DataSourceOracle.cpython-36.opt-1.pyc File 10.99 KB 0644
DataSourceOracle.cpython-36.pyc File 10.99 KB 0644
DataSourceRbxCloud.cpython-36.opt-1.pyc File 7.19 KB 0644
DataSourceRbxCloud.cpython-36.pyc File 7.19 KB 0644
DataSourceScaleway.cpython-36.opt-1.pyc File 10.84 KB 0644
DataSourceScaleway.cpython-36.pyc File 10.84 KB 0644
DataSourceSmartOS.cpython-36.opt-1.pyc File 24.51 KB 0644
DataSourceSmartOS.cpython-36.pyc File 24.51 KB 0644
DataSourceUpCloud.cpython-36.opt-1.pyc File 4.36 KB 0644
DataSourceUpCloud.cpython-36.pyc File 4.36 KB 0644
DataSourceVMware.cpython-36.opt-1.pyc File 23.66 KB 0644
DataSourceVMware.cpython-36.pyc File 23.66 KB 0644
DataSourceVultr.cpython-36.opt-1.pyc File 3.44 KB 0644
DataSourceVultr.cpython-36.pyc File 3.44 KB 0644
__init__.cpython-36.opt-1.pyc File 30.52 KB 0644
__init__.cpython-36.pyc File 30.52 KB 0644