%PDF- %PDF-
Direktori : /snap/core20/current/lib/python3/dist-packages/cloudinit/net/__pycache__/ |
Current File : //snap/core20/current/lib/python3/dist-packages/cloudinit/net/__pycache__/ephemeral.cpython-38.pyc |
U Ӈg V � @ s� d Z ddlZddlZddlmZ ddlmZmZmZm Z m Z mZmZ ddl mZ ddlmZ ddlmZmZ ddlmZ ddlmZmZ e�e�ZG dd � d �ZG d d� d�ZG dd � d �ZG dd� d�Ze ee ef ee d�dd�Z!dS )z.Module for ephemeral network context managers � N)�partial)�Any�Callable�Dict�List�Literal�Optional�Tuple)�NoDHCPLeaseError�maybe_perform_dhcp_discovery)�ProcessExecutionError)�UrlError�wait_for_urlc @ sH e Zd ZdZded�dd�Zdd� Zdd � Zd d� Zdd � Z dd� 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_urls_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)�interface_addrs_before_dhcpc C s� t ||||g�s$td�||||���zt�|�| _W n2 tk rf } ztd�| ��| �W 5 d} ~ X Y nX || _|| _|| _|| _ || _ g | _|| _| j� d| j� �| _ |�| ji �| _dS )a� 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 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�prefix� interface�ip� broadcast�router� static_routes�cleanup_cmds�distro�cidr�getr ) �selfr r r �prefix_or_maskr r r r �e� r# �9/usr/lib/python3/dist-packages/cloudinit/net/ephemeral.py�__init__ s>