3 \�me� � @ s� d dl Z d dlmZ d dlmZmZ d dlmZmZ d dl m Z d dl mZ e j e�ZdZG dd � d ej �Zd d� Zdd � ZG dd� de�ZeejffeejejffgZdd� ZdS )� N)�List)�dmi�sources)� EventScope� EventType)� DataSourceEc2)�DataSourceHostnamezAlibaba Cloud ECSc s^ e Zd ZU dZdgZdZg Zee e dd� �Z � fdd�Zdd d �Zdd� Z d d� Z� ZS )�DataSourceAliYunZAliYunzhttp://100.100.100.200z 2016-01-01c C s dS )NzX-aliyun-ecs-metadata-token� )�selfr r �&/usr/lib/python3.6/DataSourceAliYun.py�imdsv2_token_put_header s z(DataSourceAliYun.imdsv2_token_put_headerc s, t t| �j|||� | jtj jtj� d S )N) �superr �__init__Zdefault_update_eventsr ZNETWORK�addr ZBOOT)r Zsys_cfgZdistro�paths)� __class__r r r s zDataSourceAliYun.__init__Fc C s* | j jd�}d}|d kr d}d}t||�S )N�hostnameFzlocalhost.localdomainT)�metadata�getr )r ZfqdnZ resolve_ipZ metadata_onlyr Z is_defaultr r r �get_hostname"