File: //lib/python3.6/site-packages/cloudinit/sources/helpers/__pycache__/digitalocean.cpython-36.pyc
3
\�meE � @ s� d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZmZm Z ddd�Z
eje�Z
ddd �Zd
d� Zddd
�Zdd� Zddd�Zdd� ZdS )� N)�dmi)�net)�subp�
url_helper�utilZeth0Zeth1)�publicZprivatec C s� |st | �}tjd|� |s$td��djtjdd�tjdd��}dd d
|d|g}ddd
d|dg}tjd�srtd��y2tj|� tjd||� tj|� tjd|� W n& t k
r� t
jtd||� � Y nX |S )z�Bring up NIC using an address using link-local (ip4LL) IPs.
On DigitalOcean, the link-local domain is per-droplet routed, so there
is no risk of collisions. However, to be more safe, the ip4LL
address is random.
z,selected interface '%s' for reading metadatazPunable to find interfaces to access themeta-data server. This droplet is broken.z169.254.{0}.{1}/16� � r � �ip�addr�add�dev�link�setZupz4No 'ip' command available to configure ip4LL addressz#assigned ip4LL address '%s' to '%s'zbrought device '%s' upzRip4LL address assignment of '%s' to '%s' failed. Droplet networking will be broken)�get_link_local_nic�LOG�debug�RuntimeError�format�randomZrandintr Zwhich� Exceptionr �logexc)�distro�nicr �ip_addr_cmdZip_link_cmd� r �"/usr/lib/python3.6/digitalocean.py�assign_ipv4_link_local s4
r c s. � fdd�t j� D �}|sd S t|dd� d�S )Nc s g | ]}� j j|�r|�qS r )Z
networkingZis_physical)�.0�f)r r r �
<listcomp>C s z&get_link_local_nic.<locals>.<listcomp>c S s t j| d�S )NZifindex)�cloudnetZread_sys_net_int)�dr r r �<lambda>I s z$get_link_local_nic.<locals>.<lambda>)�key)r"