File: //lib/python3.6/site-packages/cloudinit/net/__pycache__/ephemeral.cpython-36.pyc
3
\�meS9 � @ s� d Z ddlZddlZddlmZ ddlmZmZmZm Z m
Z
ddljZddl
mZmZmZ ddlmZ eje�ZG dd� d�ZG d d
� d
�ZG dd� d�ZG d
d� d�ZdS )z.Module for ephemeral network context managers
� N)�partial)�Any�Callable�Dict�List�Optional)�IscDhclient�NoDHCPLeaseError�maybe_perform_dhcp_discovery)�ProcessExecutionErrorc @ sT e Zd ZdZdeeeef d�dd�Zdd� Z dd � Z
d
d� Zdd
� Zdd� Z
dS )�EphemeralIPv4Networka� Context manager which sets up temporary static network configuration.
No operations are performed if the provided interface already has the
specified configuration.
This can be verified with the connectivity_url_data.
If unconnected, bring up the interface with valid ip, prefix and broadcast.
If router is provided setup a default route for that interface. Upon
context exit, clean up the interface leaving no configuration behind.
N)�connectivity_url_datac
C s� t ||||g�s$tdj||||���ytj|�| _W n2 tk
rf } ztdj| ��| �W Y dd} ~ X nX || _|| _|| _|| _ || _
|| _g | _|| _
dS )aX Setup context manager and validate call signature.
@param interface: Name of the network interface to bring up.
@param ip: IP address to assign to the interface.
@param prefix_or_mask: Either netmask of the format X.X.X.X or an int
prefix.
@param broadcast: Broadcast address for the IPv4 network.
@param router: Optionally the default gateway IP.
@param connectivity_url_data: Optionally, a URL to verify if a usable
connection already exists.
@param static_routes: Optionally a list of static routes from DHCP
z5Cannot init network on {0} with {1}/{2} and bcast {3}z4Cannot setup network, invalid prefix or netmask: {0}N)�all�
ValueError�format�netZipv4_mask_to_net_prefix�prefixr
� interface�ip� broadcast�router�
static_routes�cleanup_cmds�distro)
�selfr r r �prefix_or_maskr r r
r �e� r �/usr/lib/python3.6/ephemeral.py�__init__ s&