Current File : //proc/self/root/lib/python3/dist-packages/cloudinit/net/__pycache__/dhcp.cpython-312.pyc
�

 NhЏ����ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZddlmZmZmZmZmZmZddlZddlmZmZmZddlmZmZej<e�Z dZ!d	Z"d
Z#dZ$Gd�d
e%�Z&Gd�de&�Z'Gd�de&�Z(Gd�de&�Z)	d!dee*effd�Z+d�Z,d"d�Z-d"d�Z.Gd�dej^�Z0Gd�de0�Z1Gd�de0�Z2Gd�d e0�Z3e2e1e3gZ4y)#�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��eZdZdZy)�NoDHCPLeaseErrorz'Raised when unable to get a DHCP lease.N��__name__�
__module__�__qualname__�__doc__���4/usr/lib/python3/dist-packages/cloudinit/net/dhcp.pyrrAs��1rrc��eZdZdZy)�InvalidDHCPLeaseFileErrorz�Raised when parsing an empty or invalid dhclient.lease file.

    Current uses are DataSourceAzure and DataSourceEc2 during ephemeral
    boot to scrape metadata.
    NrrrrrrEs��rrc��eZdZdZy)�NoDHCPLeaseInterfaceErrorz7Raised when unable to find a viable interface for DHCP.NrrrrrrMs��Arrc��eZdZdZy)�NoDHCPLeaseMissingDhclientErrorz$Raised when unable to find dhclient.Nrrrrr r Qs��.rr �returnc��|xs|j}|�tjd�t��|jj|||�S)aPerform 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.
    z1Skip dhcp_discovery: Unable to find fallback nic.)�fallback_interface�LOG�debugr�dhcp_client�dhcp_discovery)�distro�nic�
dhcp_log_func�	interfaces    r�maybe_perform_dhcp_discoveryr,UsK���0�v�0�0�I����	�	�E�F�'�)�)����,�,�Y�
�v�N�Nrc�T�ttjt|�d���S)z�Parse a systemd lease file content as in /run/systemd/netif/leases/

    Parse this (almost) ini style file even though it says:
      # This is private data. Do not parse.

    Simply return a dictionary of key/values.F)�list_values)�dict�	configobj�	ConfigObjr)�contents r�networkd_parse_leaser3ls!���	�#�#�H�W�$5�5�I�J�Jrc	��|�t}i}tjj|�s|Stj|�D]A}tt
jtjj||���||<�C|S)z�Return a dictionary of dictionaries representing each lease
    found in lease_d.i

    The top level key will be the filename, which is typically the ifindex.)	�NETWORKD_LEASES_DIR�os�path�isdir�listdirr3r�load_text_file�join)�leases_d�ret�lfiles   r�networkd_load_leasesr?wss����&���C�
�7�7�=�=��"��
����H�%�
��)���������X�u� =�>�
��E�
�
��Jrc��|�t}t|��}t|j��D]\}}|j	|�s�||cSy)N)r<)r5r?�sorted�items�get)�keynamer<�leases�_ifindex�datas     r�networkd_get_option_from_leasesrH�sP����&��
!�8�
4�F� �����0�!���$��8�8�G����=� �!�rc
�.�eZdZdZdZd�Zed��Zed��Zede	fd��Z
ede	fd��Zejd	e	d
ee	effd��Zeejde	d
eee	e	ffd
���Zej		dd	e	deed
ee	effd��Zy)�
DhcpClient��
c�x�tj|j�|_|js
t	��y�N)r�which�client_name�dhcp_client_pathr )�selfs r�__init__zDhcpClient.__init__�s0�� $�
�
�4�+;�+;� <����$�$�1�3�3�%rc�N�tjd|jgddg��y)N�pkillr���rcs)rrP)�clss r�kill_dhcp_clientzDhcpClient.kill_dhcp_client�s���	�	�7�C�O�O�,�1�a�&�9rc��|j�tjd�}|D]}tj|��y)Nz/var/lib/dhcp/*)rZ�globr6�remove)rY�files�files   r�clear_leaseszDhcpClient.clear_leases�s7�������	�	�+�,���	�D��I�I�d�O�	r�dhcp_interfacec�F�|jd|j|ddg��y)N�startrrVrW��manage_servicerP�rYrar(s   r�
start_servicezDhcpClient.start_service�s&������S�_�_�n�1�a�&�	�	
rc�D�|jd|jddg��y)N�stoprrVrWrdrfs   r�stop_servicezDhcpClient.stop_service�s�����f�c�o�o�A�q�6��Brr+r!c��iS)z�Get the most recent lease from the ephemeral phase as a dict.

        Return a dict of dhcp options. The dict contains key value
        pairs from the most recent lease.
        r�rRr+s  r�get_newest_leasezDhcpClient.get_newest_lease�s	���	r�routesc��gS)ap
        parse classless static routes from string

        The tuple is composed of the network_address (including net length) and
        gateway for a parsed static route.

        @param routes: string containing classless static routes
        @returns: list of tuple(str, str) for all valid parsed routes until the
                  first parsing error.
        r)rns r�parse_static_routeszDhcpClient.parse_static_routes�s	���	rNr*c��iS)a�Run dhcp client on the interface without scripts or filesystem
        artifacts.

        @param interface: Name of the network interface on which to send a
            dhcp request
        @param dhcp_log_func: A callable accepting the client output and
            error streams.
        @param distro: a distro object for network interface manipulation
        @return: dict of lease options representing the most recent dhcp lease
            parsed from the dhclient.lease file
        r)rRr+r*r(s    rr'zDhcpClient.dhcp_discovery�s	��$�	r�NN)rrrrP�timeoutrS�classmethodrZr`�strrgrj�abc�abstractmethodrrrm�staticmethodr	rrpr
rr'rrrrJrJ�s*���K��G�4�
�:��:������
�3�
��
�
�C�#�C��C�	����#��$�s�C�x�.���������C��D��s�C�x��,A�����	���-1��	��� ��)��

�c�3�h����rrJc	����eZdZdZ�fd�Zededeeee	ffd��Z
ed��Zdedeee	ffd�Z		dded	e
edeee	ffd
�Zededeeeeffd��Zede
efd
��Zdefd�Z�xZS)�IscDhclient�dhclientc�0��t�|��d|_y)Nz/run/dhclient.lease��superrS�
lease_file�rR�	__class__s �rrSzIscDhclient.__init__�s���
����/��r�
lease_contentr!c���tjdtj�}g}|sgS|j|�D]�}g}|j	d�D]V}|j�j
dd�j
dd�}|s�6|j|j	dd���Xt|�}|jd�}|rtj|�|d<|j|���|S)	z�parse the content of a lease file

        @param lease_content: a string containing the contents of an
            isc-dhclient lease
        @return: a list of leases, most recent last
        zlease {(?P<lease>.*?)}\n�;�"rKzoption � rV�unknown-245)�re�compile�DOTALL�findall�split�strip�replace�appendr/rCrz�get_ip_from_lease_value)r��lease_regex�dhcp_leases�lease�
lease_options�line�options�opt_245s        r�parse_leaseszIscDhclient.parse_leases�s����j�j�!<�b�i�i�H��"$����I� �(�(��7�
	(�E��M����C�(�
=���z�z�|�+�+�C��4�<�<�Y��K���!�(�(����C��);�<�	
=�
�=�)�G��k�k�-�0�G��)4�)L�)L��*��
�&�
���w�'�
	(��rc	�P�|jdd�}t|�dkDrad}|jd�D]}t|�dk(rd|z}||z
}�tjdt|jdd�d��}n|j
d	�}tj|�S)
N�\rK��:rV�0z>L�zutf-8)	r��lenr��struct�pack�int�encode�socket�	inet_ntoa)�fallback_lease_value�unescaped_value�
hex_string�hex_pair�packed_bytess     rr�z#IscDhclient.get_ip_from_lease_values���.�6�6�t�R�@�����!�#��J�+�1�1�#�6�
'���x�=�A�%�"�X�~�H��h�&�
�
'�"�;�;��c�*�,�,�S�"�5�r�:��L�+�1�1�'�:�L�����-�-rr+c���tt�5tj|j�}|r!|j|�}|r|dcddd�Sddd�iS#1swYiSxYw)a�Get the most recent lease from the ephemeral phase as a dict.

        Return a dict of dhcp options. The dict contains key value
        pairs from the most recent lease.

        @param interface: an interface string - not used in this class, but
            required for function signature compatibility with other classes
            that require a distro object
        @raises: InvalidDHCPLeaseFileError on empty or unparsable leasefile
            content.
        ���N)r�FileNotFoundErrorrr:rr�)rRr+r2r�s    rrmzIscDhclient.get_newest_leasesf���'�
(�	+��)�)�$�/�/�:�G��"�/�/��8���&�r�?�	+�	+�	+��	�
	+��	�s�9A�A'r*c	��tjd|�d}d}d}t|j|z�}t|jdz�}t	t
�5t
j|�t
j|j�ddd�|jj|�t|�ridt|�ddz}	d|�d	|	�d
�}
tjd��}tjj!||d
z�}t#j$||
�	t'j&|j)|j*|j|||��\}}
t#j6||jg|d��}|r.tj9ddj!d�|D���iSd}d}d}d}t;|�D]�}	t#j<|�j?�}t|�}|jA|�}|dk(r>tjd|�t
jB|tDjF�d}n,tKjL|���tj|�|stjOd||d�|�	|||
�|jQ|�}|r|StS��#1swY��6xYw#t&j,$rB}tjd|j.|j0|j2�t4|�d}~wwxYw#t
$r	d|�d�}Y��tH$r	d|�d�}Y��wxYw)a�Run dhclient on the interface without scripts/filesystem artifacts.

        @param interface: Name of the network interface on which to send a
            dhcp request
        @param dhcp_log_func: A callable accepting the dhclient output and
            error streams.
        @param distro: a distro object for network interface manipulation
        @return: dict of lease options representing the most recent dhcp lease
            parsed from the dhclient.lease file
        �!Performing a dhcp discovery on %sz/run/dhclient.pidN�{�G�z�?�z20:%s�$zinterface "z" {send dhcp-client-identifier z;}T��	needs_exez-dhclient.confz3dhclient exited with code: %s stderr: %r stdout: %r)�maxwait�naplenz+dhclient did not produce expected files: %sz, c3�ZK�|]#}tjj|����%y�wrN)r6r7�basename)�.0�fs  r�	<genexpr>z-IscDhclient.dhcp_discovery.<locals>.<genexpr>}s����?�!�"�'�'�*�*�1�-�?�s�)+�unknownFrKrVzkilling dhclient with pid=%s�No PID file found at z, dhclient is still running�PID file contained [z], dhclient is still runningzCdhclient(pid=%s, parentpid=%s) failed to daemonize after %s secondsg$@)*r$r%r�rsrr�r6r]r�net_ops�link_uprrr
�get_tmp_ancestorr7r;r�
write_filer�build_dhclient_cmdrQ�ProcessExecutionError�	exit_code�stderr�stdoutr�wait_for_files�warning�ranger:r��
get_proc_ppid�kill�signal�SIGKILL�
ValueError�time�sleep�errorrmr)rRr+r*r(�pid_file�config_file�
sleep_time�sleep_cyclesr��dhcp_client_identifier�interface_dhclient_content�tmp_dir�out�errr��missing�ppid�
daemonized�pid_content�	debug_msg�_�pidr�s                       rr'zIscDhclient.dhcp_discovery&s"�� 	�	�	�5�y�A�
'�����
��4�<�<�*�4�5���d�l�l�Q�&�'���'�
(�	'��I�I�h���I�I�d�o�o�&�	'�	�����y�)�
�9�%��+�I�6�r�s�;�;�
#��4�6�
'�
!�1�1�D�A�G��'�'�,�,�w�	�<L�0L�M�K��O�O�K�)C�D�	.��y�y��)�)��)�)��O�O������H�C��2�%�%�
�t���'���
����K�K�=��	�	�?�w�?�?�
��I����
����	��|�$�	!�A�
�"�1�1�(�;�A�A�C���+�&���+�+�C�0���1�9��I�I�<�c�B��G�G�C����0�!%�J���J�J�z�"�+	!�.
�I�I�i� ���I�I�����
��$��#�s�#��%�%�i�0����L�'�)�)�Q	'�	'��H�)�)�	.��I�I�E����������	
�#��-��	.��D%�
�+�H�:�60�0���
�*�;�-�80�0��
�s<�5K�)?K�.L*�K�L'�%=L"�"L'�*M�;M�Mrnc
���|jd��tjd��D�cgc]}|s�|��	}}g}d�vr"|D�cgc]}tt	|d����}}�fd�}d}t|�D�]�\}}||kr�
t	|�}|t
dd�vrhd	}t||d
�|kr|||t||d
��|cSdj||dz|d
z�}	dj||d
z||z�}
||z}�n�|t
dd�vrld}t||d
�|kr|||t||d
��|cSdj||dz|dzdgz�}	dj||dz||z�}
||z}�nb|t
d	d�vrld}t||d
�|kr|||t||d
��|cSdj||dz|dzddgz�}	dj||dz||z�}
||z}n�|t
dd	�vrld}t||d
�|kr|||t||d
��|cSdj||dz|dzgd�z�}	dj||dz||z�}
||z}nn|dk(rOd
}t||d
�|kr|||t||d
��|cSd}	dj||dz||z�}
||z}ntjd|�|cS|j|	�d|��|
f����|Scc}wcc}w)a(
        parse rfc3442 format and return a list containing tuple of strings.

        The tuple is composed of the network_address (including net length) and
        gateway for a parsed static route.  It can parse two formats of
        rfc3442, one from dhcpcd and one from dhclient (isc).

        @param rfc3442: string in rfc3442 format (isc or dhcpd)
        @returns: list of tuple(str, str) for all valid parsed routes until the
            first parsing error.

        e.g.:

        sr=parse_static_routes(        "32,169,254,169,254,130,56,248,255,0,130,56,240,1")
        sr=[
            ("169.254.169.254/32", "130.56.248.255"),         ("0.0.0.0/0", "130.56.240.1")
        ]

        sr2 = parse_static_routes(        "24.191.168.128 192.168.128.1,0 192.168.128.1")
        sr2 = [
            ("191.168.128.0/24", "192.168.128.1"),        ("0.0.0.0/0", "192.168.128.1")
        ]

        # unknown-121 option format
        sr3 = parse_static_routes(        "0:a:0:0:1:20:a8:3f:81:10:a:0:0:1:20:a9:fe:a9:fe:a:0:0:1")
        sr3 = [
            ("0.0.0.0/0", "10.0.0.1"),
            ("168.63.129.16/32", "10.0.0.1"),
            ("169.254.169.254/32", "10.0.0.1"),
        ]

        Python version of isc-dhclient's hooks:
           /etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes
        r�z[, . :]r�r�c�L��d|�d|�d|�d���}tj|�y)Nz5RFC3442 string malformed.  Current route has CIDR of z and requires z significant octets, but only z< remain. Verify DHCP rfc3442-classless-static-routes value: )r$r�)�cidr�required�remain�msg�rfc3442s    �r�_trunc_errorz5IscDhclient.parse_static_routes.<locals>._trunc_error�s%���
��6�7�4�
�
�I�I�c�Nrr��!�	N�.rV���r�r����r�)r�r�r�z0.0.0.0zSParsed invalid net length "%s".  Verify DHCP rfc3442-classless-static-routes value.�/)�rstripr�r�rur��	enumerater�r�r;r$r�r�)rn�tok�tokens�
static_routesr��current_idx�idx�
net_length�req_toks�net_address�gatewayr�s           @rrpzIscDhclient.parse_static_routes�s~���T�-�-��$��!#���*�g�!>�F�#�#�#�F��F�/1�
��'�>�39�:�C�c�#�c�2�,�'�:�F�:�	���!�&�)�8	�H�C���[� ���S��J��U�2�r�]�*����v�c�d�|�$�x�/� ��X�s�6�#�$�<�7H�I�(�(�!�h�h�v�c�A�g��a��'@�A���(�(�6�#��'�C�(�N�#C�D��!�H�n���u�R��}�,����v�c�d�|�$�x�/� ��X�s�6�#�$�<�7H�I�(�(�!�h�h�v�c�A�g��a��'@�C�5�'H�I���(�(�6�#��'�C�(�N�#C�D��!�H�n���u�Q��|�+����v�c�d�|�$�x�/� ��X�s�6�#�$�<�7H�I�(�(�!�h�h�v�c�A�g��a��'@�C��:�'M�N���(�(�6�#��'�C�(�N�#C�D��!�H�n���u�Q��{�*����v�c�d�|�$�x�/� ��X�s�6�#�$�<�7H�I�(�(�!�h�h��3��7�S�1�W�-��?����(�(�6�#��'�C�(�N�#C�D��!�H�n���q�����v�c�d�|�$�x�/� ��X�s�6�#�$�<�7H�I�(�(�'���(�(�6�#��'�C�(�N�#C�D��!�H�n���	�	�=���
%�$�� � �'��4�g�>�
�m8	�t���WG��
;s�K:�K:�K?c��d}|j|jfttffD]�\}}|s�	g}	t	j
|�}d}|D]b}tj||�s�tjj||�}tjj|�}||kDs�_|}|}�d|s��|cSy#t$rY��wxYw)z�Get the latest lease file from a distro-managed dhclient

        Doesn't consider the ephemeral timeframe lease.

        @param distro: used for distro-specific lease location and filename
        @return: The most recent lease file, or None
        Ng�)�dhclient_lease_directory�dhclient_lease_file_regex�DHCLIENT_FALLBACK_LEASE_DIR�DHCLIENT_FALLBACK_LEASE_REGEXr6r9r�r��searchr7r;�getmtime)	r(�latest_file�	directory�regex�lease_files�latest_mtime�fname�abs_path�mtimes	         r�!get_newest_lease_file_from_distroz-IscDhclient.get_newest_lease_file_from_distro%s�����
�/�/��0�0�
�)�*G�H�!
�	#��I�u����K�
� �j�j��3�� �L�$�
+���y�y���.���7�7�<�<�	�5�9�����(�(��2���<�'�#(�L�"*�K�
+��"�"�;	#�<��#%�
��
�s�B:�:	C�C�keyc���|j|�}|rOtj|�}|r7t|j	|��D]}|j|�}|s�|cSyyy)a8Get a key from the latest lease from distro-managed dhclient

        Doesn't consider the ephemeral timeframe lease.

        @param lease_dir: distro-specific lease to check
        @param lease_file_regex: distro-specific regex to match lease name
        @return: The most recent lease file, or None
        N)rrr:�reversedr�rC)rRr(rrr2r��servers       r�get_key_from_latest_leasez%IscDhclient.get_key_from_latest_leaseQsh���;�;�F�C�
���)�)�*�5�G��%�d�&7�&7��&@�A�&�E�"�Y�Y�s�^�F��%�
�&��rrr)rrrrPrSrxrur	rrr�r�rmr
rr'rrprr�
__classcell__�r�s@rrzrz�s����K�0���C��D��c�3�h��,@����6�
.��
.��#��$�s�C�x�.��.-1��	E*��E*� ��)�E*�

�c�3�h��E*�N�u�C�u�D��s�C�x��,A�u��u�n�)�X�c�]�)��)�V&�S�&rrzc	���eZdZdZdZ		ddedeedeee	ffd�Z
eded	e
deefd
��Zedededefd��Zdedeee	ffd
�Zededeeeeffd��Zy)�Dhcpcd�dhcpcdi,Nr+r*r!c�B�tjd|�d}t|j|z�}g}|jj|�	t
|�rdg}|jdddddg|�|�}tj||j�	�\}}	|�	|||	�|j|�}
|
r�tjg|�d��jj�}d
}d}
d
}t|�D]�}	tj|�j�}t|�}|j|�}
|
r>tjd||
�t!j"|
t$j&�|
S	|
cStj|�|
St3d��#t($rtjd|
�Y|
St*$r	d|�d�}Ynt,$r	d|�d�}YnwxYwt/j0|���	#t4$rB}tjd|j|j6|j�t2|�d
}~wtj8$rB}tjd|j:|j6|j�t2|�d
}~wwxYw)a�Run dhcpcd on the interface without scripts/filesystem artifacts.

        @param interface: Name of the network interface on which to send a
            dhcp request
        @param dhcp_log_func: A callable accepting the client output and
            error streams.
        @param distro: a distro object for network interface manipulation
        @return: dict of lease options representing the most recent dhcp lease
            parsed from the dhclient.lease file
        r�r�z
--clientid�
--ipv4onlyz--waitipz--persistentz--noarpz--script=/bin/true)rsNz-PFrKz!killing dhcpcd with pid=%s gid=%sz9Process group id [%s] has already exited, nothing to killr�z, dhcpcd is still runningr�z], dhcpcd is still runningzNo lease foundz8dhcpcd timed out after %s seconds: stderr: %r stdout: %r�1dhcpcd exited with code: %s stderr: %r stdout: %r)r$r%r�rsr�r�rrPrrmr�r�r�rr:�
get_proc_pgidr6�killpgr�r��ProcessLookupErrorr�r�r�r�rrr�r�r�)rRr+r*r(r�r��infiniband_argument�commandr�r�r�r�r��gidr�r�r�r�s                  rr'zDhcpcd.dhcp_discoveryhs��� 	�	�	�5�y�A��
��4�<�<�*�4�5�� ��	�����y�)�[	.��y�)�'3�n�#�� � �����$�
	�%�	��	�G��y�y������H�C���(��c�3�'��)�)�)�4�E�� �9�9�%5�w�%5��%5�6�=�=�C�C�E��"�����	��|�,� )�A�%�&*�&9�&9�(�&C�&I�&I�&K��!�+�.��$�2�2�3�7����I�I� C�S�#���I�I�c�6�>�>�:�!�.��9�0 %��; )�@�I�I�i�(���"�#3�4�4��/.���	�	�.���
� ��-��3�H�:�>6�6�"�&��2�;�-�@6�6�"����J�J�z�*���	.��I�I�J��
�
�������	
�#��-���)�)�	.��I�I�C����������	
�#��-��	.�st�B+H�;A<F"�7H�;H�?H�H�"G&�H�G&�H�G&�#H�%G&�&H�	J�	=I�J�=J�JrG�dhcp_option_numberc�\�d}dtdtfd�}|||�D]\}}||k(s�|cSy)aVget a specific option from a binary lease file

        This is required until upstream dhcpcd supports unknown option 245
        upstream bug: https://github.com/NetworkConfiguration/dhcpcd/issues/282

        @param data: Binary lease data
        @param number: Option number to return
        @return: the option (bytes) or None
        ��rG�indexc3�K�t|�|dzk\r<||}|d|z}|d|zd|z|z}||f��d|z|z}t|�|dzk\r�;yy�w)z�options are variable length, and consist of the following format

            option number: 1 byte
            option length: 1 byte
            option data: variable length (see length field)
            r�rVN)r�)rGr'�code�length�options     r�iter_optionsz>Dhcpcd.parse_unknown_options_from_packet.<locals>.iter_options�sq�����d�)�u�q�y�(��E�{���a�%�i����a�%�i�!�e�)�f�*<�=���F�l�"��F�
�U�*���d�)�u�q�y�(�s�AA�AN)�bytesr�)rGr$�INDEXr,r)r+s      r�!parse_unknown_options_from_packetz(Dhcpcd.parse_unknown_options_from_packet�sK��.��	+�u�	+�S�	+�)��u�5�	�L�D�&��)�)��
�	�r�
lease_dumpc	��tjd||�	t|j�j	dd�jd�D�cgc]}d|vr|jdd����c}�}|s&d}tj
||�t||z��	||d<|j�D��cic]\}}|j	dd
�|��}}}ddd�}|j�D]\}	}
|	|vs�|j|	�||
<� tjd|�d��}tj|d�}|rtj |�|d<|Scc}w#t$r"}tj
d	|�t|�d
}~wwxYwcc}}w)a`parse the output of dhcpcd --dump

        map names to the datastructure we create from dhclient

        example dhcpcd output:

        broadcast_address='192.168.15.255'
        dhcp_lease_time='3600'
        dhcp_message_type='5'
        dhcp_server_identifier='192.168.0.1'
        domain_name='us-east-2.compute.internal'
        domain_name_servers='192.168.0.2'
        host_name='ip-192-168-0-212'
        interface_mtu='9001'
        ip_address='192.168.0.212'
        network_number='192.168.0.0'
        routers='192.168.0.1'
        subnet_cidr='20'
        subnet_mask='255.255.240.0'
        z)Parsing dhcpcd lease for interface %s: %r�'rK�
�=rV)�maxsplitz;No valid DHCP lease configuration found in dhcpcd lease: %rzError parsing dhcpcd lease: %rNr+r��-z
fixed-addressr�)z
ip-addresszclassless-static-routesz/var/lib/dhcpcd/z.lease�r�)r$r%r/r�r�r�r�rr�rB�popr�load_binary_filerr/r�r�)
r0r+�ar�r�r�r�value�name_map�source�destination�dhcp_messager�s
             r�parse_dhcpcd_leasezDhcpcd.parse_dhcpcd_leases���,	�	�	�7��J�	
�
	7��(�-�-�/�7�7��R�@�F�F�t�L����a�x��G�G�C�!�G�,���E��0���	�	�#�z�*�/��j�0@�A�A�
�'��k��AF���
�N�*�#�u����S�#�&��-�N��N�*�'6�
��$,�>�>�#3�	7��F�K����%*�Y�Y�v�%6��k�"�	7��,�,��y�k��0�
���:�:�<��M���#)�#3�#3�G�#<�E�-� ����U���	7��I�I�6�
�C�+��6��	7��Os/�6E�E�-/E�5F	�E�	F�$F�Fc�.�	|jtj|jdd|g�j|�S#tj$rB}t
j
d|j|j|j�t|�d}~wwxYw)z�Return a dict of dhcp options.

        @param interface: which interface to dump the lease from
        @raises: InvalidDHCPLeaseFileError on empty or unparsable leasefile
            content.
        z--dumpleaserrN)
r@rrPr�r�r$r%r�r�r)rRr+r�s   rrmzDhcpcd.get_newest_leaseTs���	.��*�*��	�	��(�(�%�$�!�	���&��
�

���)�)�	.��I�I�C����������	
�#��-��	.�s�<?�B�=B�Brnc��|j�}|r&t|ddd�|ddd��D�cgc]}|��c}Stjd|�gScc}w)a�
        classless static routes as returned from dhcpcd --dumplease and return
        a list containing tuple of strings.

        The tuple is composed of the network_address (including net length) and
        gateway for a parsed static route.

        @param routes: string containing classless static routes
        @returns: list of tuple(str, str) for all valid parsed routes until the
                  first parsing error.

        e.g.:

        sr=parse_static_routes(
            "0.0.0.0/0 10.0.0.1 168.63.129.16/32 10.0.0.1"
        )
        sr=[
            ("0.0.0.0/0", "10.0.0.1"),
            ("169.63.129.16/32", "10.0.0.1"),
        ]
        Nr�rVz'Malformed classless static routes: [%s])r��zipr$r��rnr��is   rrpzDhcpcd.parse_static_routesqsX��.����
��"�=��1��#5�}�Q�T��T�7J�K�L�!�A�L�L����=�v�F��	��Ms�	Arr)rrrrPrsrur
rrrr'rxr-r�r/r@rmr	rrprrrrrds����K��G�
-1��	u.��u.� ��)�u.�

�c�3�h��u.�n�)��)�),�)�	�%��)��)�V�F�s�F�s�F�t�F��F�P.�#�.�$�s�C�x�.�.�:��C��D��s�C�x��,A���rrc	���eZdZdZ�fd�Z		d
dedeedeee	ffd�Z
dedeee	ffd�Zedede
eeeffd	��Z�xZS)�Udhcpc�udhcpcc�0��t�|��d|_y)NrKr}r�s �rrSzUdhcpc.__init__�s���
������rr+r*r!c���tjd|�tjd��}tj
j
||dz�|_tt�5t	j|j�ddd�|jj|�tj
j
|d�}tj|td�|j dd	d
|d|dd
ddg}t#|�r>|j%ddj't)|�ddj+dd��g�	t-j,|d|jid��\}}|�	|||�|j9|�S#1swY��xYw#t,j.$rB}	tjd|	j0|	j2|	j4�t6|	�d}	~	wwxYw)arRun udhcpc on the interface without scripts or filesystem artifacts.

        @param interface: Name of the network interface on which to run udhcpc.
        @param dhcp_log_func: A callable accepting the udhcpc output and
            error streams.
        @return: A list of dicts of representing the dhcp leases parsed from
            the udhcpc lease file.
        r�Tr�z.lease.jsonN�
udhcpc_scripti�z-O�staticroutesz-iz-sz-nz-qz-fz-vz-xz	0x3d:20{}r�r�rK�
LEASE_FILE)�
update_env�capturez1udhcpc exited with code: %s stderr: %r stdout: %r)r$r%r
r�r6r7r;rrr�r]r�r�rr��
UDHCPC_SCRIPTrPr�extend�formatrr�rr�r�r�r�rrm)
rRr+r*r(r�rK�cmdr�r�r�s
          rr'zUdhcpc.dhcp_discovery�s���	�	�	�5�y�A��-�-��=���'�'�,�,�w�	�M�0I�J���
�'�
(�	'��I�I�d�o�o�&�	'�	�����y�)������W�o�>�
����
�}�e�<�
�������������
��$�9�%��J�J���&�&�)�)�4�R�S�9�A�A�#�r�J���
�	.��y�y���t��� ?���H�C���$��#�s�#��$�$�Y�/�/�i	'�	'��P�)�)�	.��I�I�C����������	
�#��-��	.�s$�$ F�'F�F�G(�&=G#�#G(c�f�tjtj|j��S)a�Get the most recent lease from the ephemeral phase as a dict.

        Return a dict of dhcp options. The dict contains key value
        pairs from the most recent lease.

        @param interface: an interface name - not used in this class, but
            required for function signature compatibility with other classes
            that require a distro object
        @raises: InvalidDHCPLeaseFileError on empty or unparsable leasefile
            content.
        )r�	load_jsonr:rrls  rrmzUdhcpc.get_newest_lease�s"���~�~�d�1�1�$�/�/�B�C�Crrnc��|j�}|r&t|ddd�|ddd��D�cgc]}|��c}SgScc}w)Nr�rV)r�rCrDs   rrpzUdhcpc.parse_static_routes�sG������
��"�=��1��#5�}�Q�T��T�7J�K�L�!�A�L�L��	��Ms�	;rr)rrrrPrSrur
rrrr'rmrxr	rrprrs@rrGrG�s�����K��-1��	F0��F0� ��)�F0�

�c�3�h��F0�PD�#�D�$�s�C�x�.�D���C��D��s�C�x��,A���rrGrrrN)5rvr\�loggingr6r�r�r�r�r��
contextlibr�ior�
subprocessr�typingrrrr	r
rr0�	cloudinitrr
r�
cloudinit.netrr�	getLoggerrr$r5rrrP�	Exceptionrrrr rur,r3r?rH�ABCrJrzrrG�ALL_DHCP_CLIENTSrrr�<module>rbs�����	�	�
�
�
����%�=�=��,�,�<��g����!��1��1�� /���
�B2�y�2�� 0��B� 0�B�/�&6�/�
%)�O�	�#�s�(�^�O�.K��&�H����H�VB&�*�B&�Ji�Z�i�X	c�Z�c�L�K��0�r
¿Qué es la limpieza dental de perros? - Clínica veterinaria


Es la eliminación del sarro y la placa adherida a la superficie de los dientes mediante un equipo de ultrasonidos que garantiza la integridad de las piezas dentales a la vez que elimina en profundidad cualquier resto de suciedad.

A continuación se procede al pulido de los dientes mediante una fresa especial que elimina la placa bacteriana y devuelve a los dientes el aspecto sano que deben tener.

Una vez terminado todo el proceso, se mantiene al perro en observación hasta que se despierta de la anestesia, bajo la atenta supervisión de un veterinario.

¿Cada cuánto tiempo tengo que hacerle una limpieza dental a mi perro?

A partir de cierta edad, los perros pueden necesitar una limpieza dental anual o bianual. Depende de cada caso. En líneas generales, puede decirse que los perros de razas pequeñas suelen acumular más sarro y suelen necesitar una atención mayor en cuanto a higiene dental.


Riesgos de una mala higiene


Los riesgos más evidentes de una mala higiene dental en los perros son los siguientes:

  • Cuando la acumulación de sarro no se trata, se puede producir una inflamación y retracción de las encías que puede descalzar el diente y provocar caídas.
  • Mal aliento (halitosis).
  • Sarro perros
  • Puede ir a más
  • Las bacterias de la placa pueden trasladarse a través del torrente circulatorio a órganos vitales como el corazón ocasionando problemas de endocarditis en las válvulas. Las bacterias pueden incluso acantonarse en huesos (La osteomielitis es la infección ósea, tanto cortical como medular) provocando mucho dolor y una artritis séptica).

¿Cómo se forma el sarro?

El sarro es la calcificación de la placa dental. Los restos de alimentos, junto con las bacterias presentes en la boca, van a formar la placa bacteriana o placa dental. Si la placa no se retira, al mezclarse con la saliva y los minerales presentes en ella, reaccionará formando una costra. La placa se calcifica y se forma el sarro.

El sarro, cuando se forma, es de color blanquecino pero a medida que pasa el tiempo se va poniendo amarillo y luego marrón.

Síntomas de una pobre higiene dental
La señal más obvia de una mala salud dental canina es el mal aliento.

Sin embargo, a veces no es tan fácil de detectar
Y hay perros que no se dejan abrir la boca por su dueño. Por ejemplo…

Recientemente nos trajeron a la clínica a un perro que parpadeaba de un ojo y decía su dueño que le picaba un lado de la cara. Tenía molestias y dificultad para comer, lo que había llevado a sus dueños a comprarle comida blanda (que suele ser un poco más cara y llevar más contenido en grasa) durante medio año. Después de una exploración oftalmológica, nos dimos cuenta de que el ojo tenía una úlcera en la córnea probablemente de rascarse . Además, el canto lateral del ojo estaba inflamado. Tenía lo que en humanos llamamos flemón pero como era un perro de pelo largo, no se le notaba a simple vista. Al abrirle la boca nos llamó la atención el ver una muela llena de sarro. Le realizamos una radiografía y encontramos una fístula que llegaba hasta la parte inferior del ojo.

Le tuvimos que extraer la muela. Tras esto, el ojo se curó completamente con unos colirios y una lentilla protectora de úlcera. Afortunadamente, la úlcera no profundizó y no perforó el ojo. Ahora el perro come perfectamente a pesar de haber perdido una muela.

¿Cómo mantener la higiene dental de tu perro?
Hay varias maneras de prevenir problemas derivados de la salud dental de tu perro.

Limpiezas de dientes en casa
Es recomendable limpiar los dientes de tu perro semanal o diariamente si se puede. Existe una gran variedad de productos que se pueden utilizar:

Pastas de dientes.
Cepillos de dientes o dedales para el dedo índice, que hacen más fácil la limpieza.
Colutorios para echar en agua de bebida o directamente sobre el diente en líquido o en spray.

En la Clínica Tus Veterinarios enseñamos a nuestros clientes a tomar el hábito de limpiar los dientes de sus perros desde que son cachorros. Esto responde a nuestro compromiso con la prevención de enfermedades caninas.

Hoy en día tenemos muchos clientes que limpian los dientes todos los días a su mascota, y como resultado, se ahorran el dinero de hacer limpiezas dentales profesionales y consiguen una mejor salud de su perro.


Limpiezas dentales profesionales de perros y gatos

Recomendamos hacer una limpieza dental especializada anualmente. La realizamos con un aparato de ultrasonidos que utiliza agua para quitar el sarro. Después, procedemos a pulir los dientes con un cepillo de alta velocidad y una pasta especial. Hacemos esto para proteger el esmalte.

La frecuencia de limpiezas dentales necesaria varía mucho entre razas. En general, las razas grandes tienen buena calidad de esmalte, por lo que no necesitan hacerlo tan a menudo e incluso pueden pasarse la vida sin requerir una limpieza. Sin embargo, razas pequeñas como el Yorkshire o el Maltés, deben hacérselas todos los años desde cachorros si se quiere conservar sus piezas dentales.

Otro factor fundamental es la calidad del pienso. Algunas marcas han diseñado croquetas que limpian la superficie del diente y de la muela al masticarse.

Ultrasonido para perros

¿Se necesita anestesia para las limpiezas dentales de perros y gatos?

La limpieza dental en perros no es una técnica que pueda practicarse sin anestesia general , aunque hay veces que los propietarios no quieren anestesiar y si tiene poco sarro y el perro es muy bueno se puede intentar…… , pero no se va a poder pulir ni acceder a todas la zona de la boca …. Además los limpiadores dentales van a irrigar agua y hay riesgo de aspiración a vías respiratorias si no se realiza una anestesia correcta con intubación traqueal . En resumen , sin anestesia no se va hacer una correcta limpieza dental.

Tampoco sirve la sedación ya que necesitamos que el animal esté totalmente quieto, y el veterinario tenga un acceso completo a todas sus piezas dentales y encías.

Alimentos para la limpieza dental

Hay que tener cierto cuidado a la hora de comprar determinados alimentos porque no todos son saludables. Algunos tienen demasiado contenido graso, que en exceso puede causar problemas cardiovasculares y obesidad.

Los mejores alimentos para los dientes son aquellos que están elaborados por empresas farmacéuticas y llevan componentes químicos con tratamientos específicos para el diente del perro. Esto implica no solo limpieza a través de la acción mecánica de morder sino también un tratamiento antibacteriano para prevenir el sarro.

Conclusión

Si eres como la mayoría de dueños, por falta de tiempo , es probable que no estés prestando la suficiente atención a la limpieza dental de tu perro. Por eso te animamos a que comiences a limpiar los dientes de tu perro y consideres atender a su higiene bucal con frecuencia.

Estas simples medidas pueden conllevar a que tu perro tenga una vida más larga y mucho más saludable.

Si te resulta imposible introducir un cepillo de dientes a tu perro en la boca, pásate con él por clínica Tus Veterinarios y te explicamos cómo hacerlo.

Necesitas hacer una limpieza dental profesional a tu mascota?
Llámanos al 622575274 o contacta con nosotros

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

¡Hola!