Server IP : 23.254.227.96 / Your IP : 216.73.216.7 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/lib/python3.6/site-packages/cloudinit/config/__pycache__/ |
Upload File : |
3 ?q,d� � @ s@ d Z ddlZddlmZ ddlmZ G dd� de�Zdd� ZdS ) a� Set Hostname ------------ **Summary:** set hostname and fqdn This module handles setting the system hostname and 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 wil 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, it is distro dependent whether ``hostname`` or ``fqdn`` is used, unless the ``prefer_fqdn_over_hostname`` option is true and fqdn is set it will force the use of FQDN in all distros, and if false then it will force the hostname use. 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 preformed on these platforms where dynamic DNS is based on initial hostname. **Internal name:** ``cc_set_hostname`` **Module frequency:** always **Supported distros:** all **Config keys**:: preserve_hostname: <true/false> prefer_fqdn_over_hostname: <true/false> fqdn: <fqdn> hostname: <fqdn/hostname> � N)�util)� write_jsonc @ s e Zd ZdZdS )�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__� r r �%/usr/lib/python3.6/cc_set_hostname.pyr 7 s r c C sH t j|dd�r|jd| � d S t j|dd �}|d k rB|jjd|� t j||�\}}tjj|j d�d�}i } tjj |�r�tj|�jdkr�t j t j|��} || jd�kp�|| jd �k} | s�|jd � d S |jd||� y|jj||� W nN tk �r2 } z0d||f }t j||� td ||f �|�W Y d d }~X nX t|||d�� d S )NZpreserve_hostnameFzVConfiguration option 'preserve_hostname' is set, not setting the hostname in module %sZprefer_fqdn_over_hostname�datazset-hostnamer �hostname�fqdnz*No hostname changes. Skipping set-hostnamezSetting the hostname to %s (%s)z%Failed to set the hostname to %s (%s)z%s: %s)r r )r Zget_cfg_option_bool�debugZdistroZ set_optionZget_hostname_fqdn�os�path�joinZ get_cpath�exists�stat�st_sizeZ load_jsonZ load_file�getZset_hostname� ExceptionZlogexcr r ) �nameZcfgZcloud�logZ_argsZ hostname_fqdnr r Zprev_fnZ prev_hostnameZhostname_changed�e�msgr r r �handle? s8 $r ) r r Z cloudinitr Zcloudinit.atomic_helperr r r r r r r r �<module>/ s