404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.23.103.132: ~ $
3

\�me�2�	@s.ddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZddlmZmZmZddlmZmZddlmZdd	lmZmZmZeje�Zd
dd�d
ddd�ddddddgd�ZGdd�de	�Z Gdd�dej!�Z"Gdd�de"�Z#e#ej$ffe"ej$ej%ffgZ&eej!d�dd�Z'dS)�N)�	b64decode)�suppress)�Enum)�Any�List�Tuple�Union)�sources�
url_helper�util)�find_fallback_nic�get_interfaces_by_mac)�EphemeralIPNetwork)�get_dmi_config�get_local_instance_id�is_on_akamaizhttp://169.254.169.254zhttp://[fd00:a9fe:a9fe::1])�ipv4�ipv6z	/v1/tokenz/v1/instancez
/v1/user-data)�token�metadata�userdataTzf2:3)�	base_urls�paths�allow_local_stage�allow_init_stage�
allow_dhcp�
allow_ipv4�
allow_ipv6�preferred_mac_prefixesc@seZdZdZdZdZdZdS)�MetadataAvailabilityResultzj
    Used to indicate how this instance should behave based on the availability
    of metadata to it
    r��N)�__name__�
__module__�__qualname__�__doc__�
NOT_AVAILABLE�	AVAILABLE�DEFER�r)r)�&/usr/lib/python3.6/DataSourceAkamai.pyr-src@s�eZdZdZdZdd�Zdeeed�dd�Ze	d�d	d
�Z
e	d�dd�Ze	d�d
d�Ze
eeeefefd�dd�Zdeed�dd�Zed�dd�Zed�dd�ZdS)�DataSourceAkamai�AkamaiFcCsJtjd�tjj||||�t�|_tjt	�tj
|ddgi�tg�|_dS)NzSetting up Akamai DataSourceZ
datasourcer,)
�LOG�debugr	�
DataSource�__init__�dictrrZ
mergemanydictrZget_cfg_by_path�BUILTIN_DS_CONFIG�ds_cfg)�self�sys_cfg�distrorr)r)r*r0<s
zDataSourceAkamai.__init__)�	path_name�use_v6�returncCs\||jdkrtdj|���d}|s0|jdr4d}|jd|}|jd|}dj||�S)z�
        Looks up the path for a given name and returns a full url for it.  If
        use_v6 is passed in, the IPv6 base url is used; otherwise the IPv4 url
        is used unless IPv4 is not allowed in ds_cfg
        rzUnknown path name {}rrrrz{}{})r3�
ValueError�format)r4r7r8Zversion_keyZbase_url�pathr)r)r*�
_build_urlNszDataSourceAkamai._build_url)r9cCsZ|jdr|jds0|jdr@|jdr@tjd�tjS|jrN|j�S|j�SdS)z�
        Returns whether metadata should be retrieved at this stage, at the next
        stage, or never, in the form of a MetadataAvailabilityResult.
        rrrrz*Configuration prohibits fetching metadata.N)r3r-�inforr&�local_stage�_should_fetch_data_local�_should_fetch_data_network)r4r)r)r*�_should_fetch_data`s
z#DataSourceAkamai._should_fetch_datacCsH|jdstjd�tjS|jdrB|jdrBtjd�tjStjS)z�
        Returns whether metadata should be retrieved during the local stage, or
        if it should wait for the init stage.
        rz)Configuration prohibits local stage setuprrz9Configuration does not allow for ephemeral network setup.)r3r-r>rr(r')r4r)r)r*r@ts

z)DataSourceAkamai._should_fetch_data_localcCs |jdstjd�tjStjS)zS
        Returns whether metadata should be fetched during the init stage.
        rz1Configuration does not allow for init stage setup)r3r-r>rr(r')r4r)r)r*rA�s

z+DataSourceAkamai._should_fetch_data_networkcs�g}|jr�t�}d}|jd}x0|j�D]$\�}t�fdd�|D��r(|}Pq(W|dkrhtjd�t�}g}|jdr�|jt	|j
|ddd	�df�|jd
r�|jdr�|jt	|j
|dd�df�n4|jdr�|jt�df�|jd
r�|jt�df�|S)
z�
        Returns a list of context managers which should be tried when setting
        up a network context.  If we're running in init mode, this return a
        noop since networking should already be configured.
        Nrcsg|]}�j|��qSr))�
startswith)�.0�prefix)�macr)r*�
<listcomp>�szBDataSourceAkamai._get_network_context_managers.<locals>.<listcomp>zGFailed to find default interface, attempting DHCP on fallback interfacerFT)rrrr)r)r?r
r3�items�anyr-�warningr�appendrr6�noop)r4�network_context_managersZ
interfacesZ	interfaceZpreferred_prefixes�infr))rFr*�_get_network_context_managers�sN





z.DataSourceAkamai._get_network_context_managers)r8r9cCs4y�tj|jd|d�ddddddid	�}|jd
krBtjd|j�dSt|�}tj|jd
|d�dddd|d�d�}tjt|��|_	tj|jd|d�dddd|id�}t|�|_
yt|j
�j�|_
Wn0t
jk
r�}ztjd|�WYdd}~XnXWn<tjk
�r.}ztjd|�rdnd|�dSd}~XnXdS)z�
        Runs through the sequence of requests necessary to retrieve our
        metadata and user data, creating a token for use in doing so, capturing
        the results.
        r)r8ZPUT�r!�zMetadata-Token-Expiry-SecondsZ300)Zrequest_method�timeout�sec_between�retries�headers��z-Fetching token returned %s; not fetching dataTrzapplication/json)ZAcceptzMetadata-Token)rRrSrTrUrzMetadata-Tokenz*Failed to base64 decode userdata due to %sNz1Failed to retrieve metadata using IPv%s due to %s�6�4F)r
Zreadurlr=�coder-r>�str�json�loadsrZuserdata_rawr�decode�binascii�ErrorrJZUrlError)r4r8Ztoken_responserrr�er)r)r*�_fetch_metadata�sP

"z DataSourceAkamai._fetch_metadatacCs�tjd�t�stjd�dSt�}d|i|_|j�}|tjkrf|tj	krXtjd�dStjd�dS|j
�}xP|D]>\}}|�,|j|d�}|r�|jjd	|�|jd<PWd
QRXqtWtj
d�dS)zW
        Overrides _get_data in the DataSource class to actually retrieve data
        z#Getting data from Akamai DataSourcez#Not running on Akamai, not running.Fzinstance-idz5Metadata is not available, returning local data only.TzFConfigured not to fetch data at this stage; waiting for a later stage.)r8�idNzHFailed to contact metadata service, falling back to local metadata only.)r-r.rr>rrrBrr'r&rOra�getrJ)r4Zlocal_instance_idZavailabilityrMZmanagerr8�doner)r)r*�	_get_data's6




zDataSourceAkamai._get_datacCstj|j�d�S)zj
        A local-only check to see if the instance id matches the id we see on
        the system
        zsystem-serial-number)r	Zinstance_id_matches_system_uuidZget_instance_id)r4r5r)r)r*�check_instance_id[sz"DataSourceAkamai.check_instance_idN)F)F)r"r#r$Zdsnamer?r0rZ�boolr=rrBr@rArrrrrrOrarerfr)r)r)r*r+8s
"MD4r+c@seZdZdZdZdS)�DataSourceAkamaiLocalz�
    A subclass of DataSourceAkamai that runs the same functions, but during the
    init-local stage.  This allows configuring networking via cloud-init, as
    networking hasn't been configured yet.
    TN)r"r#r$r%r?r)r)r)r*rhesrh)r9cCstj|t�S)N)r	Zlist_from_depends�datasources)Zdependsr)r)r*�get_datasource_listsrj)(r^r[Zlogging�base64r�
contextlibrrL�enumrZtypingrrrrZ	cloudinitr	r
rZ
cloudinit.netrr
Zcloudinit.net.ephemeralrZ cloudinit.sources.helpers.akamairrrZ	getLoggerr"r-r2rr/r+rhZDEP_FILESYSTEMZDEP_NETWORKrirjr)r)r)r*�<module>s@

/


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