o c@s6ddlmZdZdefZdZd ddZd dd ZdS) ) fetch_asyncz169.254.169.254zhttp://%s/latest@NcsRgtd}|fdd|fddfdd}|||S)zFetch EC2 information about the cloud instance. The fetch parameter provided above is for non-mocked testing purposes. instance-idc tdS)N instance-type_fetch_ec2_itemignore cloud_datafetch5/usr/lib/python3/dist-packages/landscape/lib/cloud.py z%fetch_ec2_meta_data..cr)Nami-idrr r rrrrcs*dd}\}}}||||||dS)z1Record the instance data returned by the EC2 API.cSs,|durt|tr|d}|dtSdS)Nzutf-8) isinstancebytesdecode MAX_LENGTH)valuerrr_process_results    zCfetch_ec2_meta_data..return_result.._process_result)rrrr)r r instance_id instance_typeami_id)r rr return_results  z*fetch_ec2_meta_data..return_result)r addCallback)r deferredrrr rfetch_ec2_meta_datas     rcCs,td|}|dur t}||dd|jS)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)follow)EC2_APIrrappend)path accumulater urlrrrr(s r)N)landscape.lib.fetchrEC2_HOSTr!rrrrrrrs