File: //proc/self/root/lib/python3/dist-packages/landscape/lib/__pycache__/cloud.cpython-38.pyc
U
���c� � @ s6 d dl mZ dZdef ZdZd
dd�Zddd �ZdS )� )�fetch_asyncz169.254.169.254zhttp://%s/latest�@ Nc sR g � t d� ��}|�� �fdd�� |�� �fdd�� � fdd�}|�|� |S )z�Fetch EC2 information about the cloud instance.
The fetch parameter provided above is for non-mocked testing purposes.
�instance-idc s t d� ��S )N�
instance-type��_fetch_ec2_item��ignore��
cloud_data�fetch� �5/usr/lib/python3/dist-packages/landscape/lib/cloud.py�<lambda> � z%fetch_ec2_meta_data.<locals>.<lambda>c s t d� ��S )N�ami-idr r r
r
r r r c s* dd� }� \}}}||�||�||�d�S )z1Record the instance data returned by the EC2 API.c S s, | d k r(t | t�r| �d�} | d t� S d S )Nzutf-8)�
isinstance�bytes�decode�
MAX_LENGTH)�valuer
r
r �_process_result s
zCfetch_ec2_meta_data.<locals>.return_result.<locals>._process_result)r r r r
)r r Zinstance_idZ
instance_typeZami_id)r r
r �
return_result s
�z*fetch_ec2_meta_data.<locals>.return_result)r �addCallback)r Zdeferredr r
r
r �fetch_ec2_meta_data s ��
r c C s, t d | }|dkrt}||dd��|j�S )z�
Get data at C{path} on the EC2 API endpoint, and add the result to the
C{accumulate} list. The C{fetch} parameter is provided for testing only.
z/meta-data/NF)Zfollow)�EC2_APIr r �append)�path�
accumulater Zurlr
r
r r ( s r )N)N)Zlandscape.lib.fetchr ZEC2_HOSTr r r r r
r
r
r �<module> s