HEX
Server: nginx/1.24.0
System: Linux localhost 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64
User: www (1000)
PHP: 8.3.27
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: //usr/share/netplan/netplan/cli/commands/__pycache__/ip.cpython-310.pyc
o

�u�b��@s�dZddlZddlZddlZddlZddlmZddlmmZddd�ddd�d	�Z	Gd
d�dej
�ZGdd
�d
ej
�ZdS)znetplan ip command line�N)�CalledProcessErrorz#run/systemd/netif/leases/{lease_id}�ifindex)�pattern�methodz<var/lib/NetworkManager/dhclient-{lease_id}-{interface}.leaseZ
nm_connection)Znetworkd�NetworkManagercs$eZdZ�fdd�Zdd�Z�ZS)�	NetplanIpc�t�jdddd�dS)N�ipz'Retrieve IP information from the systemF��
command_id�description�leaf��super�__init__��self��	__class__��-/usr/share/netplan/netplan/cli/commands/ip.pyr*�
�zNetplanIp.__init__cCsBt�|_|jjdddd�}|j|jj|jd�|��|��dS)NZleases�Display IP leasesF)�help�add_help)�func�commandclass)�NetplanIpLeasesZcommand_leases�
subparsers�
add_parser�set_defaults�run�
parse_args�run_command)rZp_ip_leasesrrrr!/s�z
NetplanIp.run)�__name__�
__module__�__qualname__rr!�
__classcell__rrrrr(srcs,eZdZ�fdd�Zdd�Zdd�Z�ZS)rcr)Nz	ip leasesrTr
rrrrrr>rzNetplanIpLeases.__init__cCs<|jjddd�|jjddd�|j|_|��|��dS)N�	interfacez1Interface for which to display IP lease settings.)r�
--root-dirzBSearch for configuration files in this root directory instead of /)�parser�add_argument�command_ip_leasesrr"r#rrrrr!Cs��zNetplanIpLeases.runc	s��jdkr	����fdd�}t��g}�jr|d�jg7}|d�jg7}t�d|�z	tj|dd�}Wnt	yBt
�d	�Ynwi}|�d
�}|D]}|�
��d�\}}|||<qL||�dS)Nrc	
s�fdd�}�fdd�}t|dd}t|dd}zCtd|��}ttj�d	�jr3tj��j�nd
|j�j	|d����}|�
�D]}t|���qCWd�WdS1sXwYWdSt
y�}ztd�j	t|�ftjd
�t�d�WYd}~dSd}~ww)Nc
s�tj�d�jd�}z t|��}|��d��Wd�WS1s"wYWdSty?}z
t�	d|t
|���d}~ww)Nz/sys/class/netrrzCannot read file %s: %s)�os�path�joinr(�open�	readlines�strip�	Exception�logging�debug�str)Z	ifindex_f�f�errr�lease_method_ifindexTs
(���zXNetplanIpLeases.command_ip_leases.<locals>.find_lease_file.<locals>.lease_method_ifindexc
s�z^tjddd�jgdditjd�}|jD]E}|�d�}d|vrY|�d	�d
����}tjdddd|gdditjd�}|jD]}|�d�}d
|vrX|�d	�d
����WSq=qWt	d��t	yr}zt	dt
|���d}~ww)N�nmcli�devZshow�LC_ALL�C)�env�stdoutzutf-8zGENERAL.CONNECTION�:�Zcon�idzconnection.uuidz@Could not find a NetworkManager connection for the interface: %sz<Could not find a NetworkManager connection for the interface)�
subprocess�Popenr(�PIPEr?�decode�split�rstripr2r3r6)Z
nmcli_dev_out�lineZconn_idZ
nmcli_con_outr8rrr�lease_method_nm_connection]s2�

�

 ���
���z^NetplanIpLeases.command_ip_leases.<locals>.find_lease_file.<locals>.lease_method_nm_connectionZbackendrrZ
lease_method_�/�)r(�lease_idz%No lease found for interface '%s': %s)�filerA)�
lease_path�evalr0r-r.r/�root_dir�abspath�formatr(r1�printrHr3r6�sys�stderr�exit)	�mappingr9rJZ
lease_patternZlease_methodrMr7rIr8rrr�find_lease_fileSs0	
���&����z:NetplanIpLeases.command_ip_leases.<locals>.find_lease_filer)z	--mappingzcommand ip leases: running %sT)�universal_newlinesrA�,�=)r(�print_usage�utils�get_generator_pathrQr4r5rC�check_outputrrUrWrGr2)	rrY�argv�outrXZ	mapping_sZkeyvalue�key�valuerrrr,Ns&

5�

z!NetplanIpLeases.command_ip_leases)r$r%r&rr!r,r'rrrrr<sr)
�__doc__r4r-rUrCr�netplan.cli.utils�clir^rO�NetplanCommandrrrrrr�<module>s ���