File: //snap/core22/current/usr/lib/python3/dist-packages/cloudinit/net/__pycache__/dhcp.cpython-310.pyc
o
x[hЏ � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl m
Z
d dlmZ d dl
mZ d dlmZmZmZmZmZmZ d dlZd dlmZmZmZ d dlmZmZ e�e�Z dZ!d Z"d
Z#dZ$G dd
� d
e%�Z&G dd� de&�Z'G dd� de&�Z(G dd� de&�Z) d%dee*ef fdd�Z+dd� Z,d&dd�Z-d&dd�Z.G dd� de j/�Z0G dd � d e0�Z1G d!d"� d"e0�Z2G d#d$� d$e0�Z3e2e1e3gZ4dS )'� N)�suppress)�StringIO)�TimeoutExpired)�Any�Callable�Dict�List�Optional�Tuple)�subp�
temp_utils�util)�get_interface_mac�is_ib_interfacez/run/systemd/netif/leasesz/var/lib/dhclientz.+\.leases?$aN #!/bin/sh
log() {
echo "udhcpc[$PPID]" "$interface: $2"
}
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
case $1 in
bound|renew)
cat <<JSON > "$LEASE_FILE"
{
"interface": "$interface",
"fixed-address": "$ip",
"subnet-mask": "$subnet",
"routers": "${router%% *}",
"static_routes" : "${staticroutes}"
}
JSON
;;
deconfig)
log err "Not supported"
exit 1
;;
leasefail | nak)
log err "configuration failed: $1: $message"
exit 1
;;
*)
echo "$0: Unknown udhcpc command: $1" >&2
exit 1
;;
esac
c @ � e Zd ZdZdS )�NoDHCPLeaseErrorz'Raised when unable to get a DHCP lease.N��__name__�
__module__�__qualname__�__doc__� r r �4/usr/lib/python3/dist-packages/cloudinit/net/dhcp.pyr A � r c @ r )�InvalidDHCPLeaseFileErrorz�Raised when parsing an empty or invalid dhclient.lease file.
Current uses are DataSourceAzure and DataSourceEc2 during ephemeral
boot to scrape metadata.
Nr r r r r r E r r c @ r )�NoDHCPLeaseInterfaceErrorz7Raised when unable to find a viable interface for DHCP.Nr r r r r r M r r c @ r )�NoDHCPLeaseMissingDhclientErrorz$Raised when unable to find dhclient.Nr r r r r r Q r r �returnc C s2 |p| j }|du rt�d� t� �| j�||| �S )a Perform dhcp discovery if nic valid and dhclient command exists.
If the nic is invalid or undiscoverable or dhclient command is not found,
skip dhcp_discovery and return an empty dict.
@param nic: Name of the network interface we want to run dhclient on.
@param dhcp_log_func: A callable accepting the dhclient output and error
streams.
@return: A list of dicts representing dhcp options for each lease obtained
from the dhclient discovery if run, otherwise an empty list is
returned.
Nz1Skip dhcp_discovery: Unable to find fallback nic.)�fallback_interface�LOG�debugr �dhcp_client�dhcp_discovery)�distro�nic�
dhcp_log_func� interfacer r r �maybe_perform_dhcp_discoveryU s
r'