HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_update_hostname.cpython-310.pyc
o

�Ad��@s�UdZddlZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZdd	lmZd
ZdgZdd
deeed�ed�ed�ed�ed�gegd�Ze
ed<ee�Zdedede	dededdfdd�ZdS)z)Update Hostname: Update hostname and fqdn�N)�Logger)�dedent)�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�
PER_ALWAYSz�This module will update the system hostname and fqdn. If ``preserve_hostname``
is set ``true``, then the hostname will not be altered.

.. note::
    for instructions on specifying hostname and fqdn, see documentation for
    ``cc_set_hostname``
�all�cc_update_hostnamezUpdate HostnamezUpdate hostname and fqdna�        # By default: when ``preserve_hostname`` is not specified cloud-init
        # updates ``/etc/hostname`` per-boot based on the cloud provided
        # ``local-hostname`` setting. If you manually change ``/etc/hostname``
        # after boot cloud-init will no longer modify it.
        #
        # This default cloud-init behavior is equivalent to this cloud-config:
        preserve_hostname: false
        zh        # Prevent cloud-init from updating the system hostname.
        preserve_hostname: true
        ze        # Prevent cloud-init from updating ``/etc/hostname``
        preserve_hostname: true
        z�        # Set hostname to "external.fqdn.me" instead of "myhost"
        fqdn: external.fqdn.me
        hostname: myhost
        prefer_fqdn_over_hostname: true
        z�        # Set hostname to "external" instead of "external.fqdn.me" when
        # cloud metadata provides the ``local-hostname``: "external.fqdn.me".
        prefer_fqdn_over_hostname: false
        )�id�name�title�description�distros�examples�	frequency�activate_by_schema_keys�metar
�cfg�cloud�log�args�returnc
	Cs�t�|dd�r|�d|�dSt�|dd�}|dur!|j�d|�t�||�\}}}|r7|dkr7|�d�dSztj�|�	d�d�}	|�d	||�|j�
|||	�WdStyct�|d
||��w)N�preserve_hostnameFzWConfiguration option 'preserve_hostname' is set, not updating the hostname in module %s�prefer_fqdn_over_hostname�	localhostz6Hostname is localhost. Let other services handle this.�datazprevious-hostnamezUpdating hostname to %s (%s)z(Failed to update the hostname to %s (%s))
r�get_cfg_option_bool�debug�distro�
set_option�get_hostname_fqdn�os�path�join�	get_cpath�update_hostname�	Exception�logexc)
r
rrrr�
hostname_fqdn�hostname�fqdn�
is_default�prev_fn�r/�E/usr/lib/python3/dist-packages/cloudinit/config/cc_update_hostname.py�handleUs2��
��r1)�__doc__r#�loggingr�textwrapr�	cloudinitr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemarr�cloudinit.settingsr	�MODULE_DESCRIPTIONrr�__annotations__�str�listr1r/r/r/r0�<module>sb	������(�2������