HEX
Server: Apache/2.4.65 (Debian)
System: Linux kubikelcreative 5.10.0-35-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64
User: www-data (33)
PHP: 8.4.13
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_fan.cpython-39.pyc
a

��`h�@sbdZddlmZddlmZddlmZddlmZe�e	�Z
eZddd�Zdd
d�Z
dd
�ZdS)a<
Fan
---
**Summary:** configure ubuntu fan networking

This module installs, configures and starts the ubuntu fan network system. For
more information about Ubuntu Fan, see:
``https://wiki.ubuntu.com/FanNetworking``.

If cloud-init sees a ``fan`` entry in cloud-config it will:

    - write ``config_path`` with the contents of the ``config`` key
    - install the package ``ubuntu-fan`` if it is not installed
    - ensure the service is started (or restarted if was previously running)

**Internal name:** ``cc_fan``

**Module frequency:** per instance

**Supported distros:** ubuntu

**Config keys**::

    fan:
        config: |
            # fan 240
            10.0.0.0/8 eth0/16 dhcp
            10.0.0.0/8 eth1/16 dhcp off
            # fan 241
            241.0.0.0/8 eth0/16 dhcp
        config_path: /etc/network/fan
�)�log)�PER_INSTANCE)�subp)�utilNz/etc/network/fan)�config�config_pathFcs�|r$dd�gdd�gdd�gd�}nddgddgd�}�fdd	�}||dd
�d�}|�d�sj|d7}tj||d
d�||dd�d�}|r�|r�t�d��d|vr�||dd�d�}|S)NZ	systemctl�stop�start�enable)rr	r
�service)rr	c
sNztj|dd�WStjyH}zt�d�||�WYd}~dSd}~00dS)NT)�capturezfailed: %s (%s): %sF)r�ProcessExecutionError�LOG�warning)�cmd�msg�e�r��9/usr/lib/python3/dist-packages/cloudinit/config/cc_fan.py�run@s
zstop_update_start.<locals>.runzstop %s)r�
�w��omodezstart %szsuccess: %s startedz	enable %s)�endswithr�
write_filerr)r�config_file�content�systemdZcmdsrZstop_failed�retrrr�stop_update_start7s&��
r!cCs�|�d�}|si}t�|tg�}|�d�s:t�d|�dStj|�d�|�d�dd�|j}t�	d�sr|�
dg�td|�d�|�d�|��d	�dS)
NZfanrz$%s: no 'fan' config entry. disablingrrrZfanctlz
ubuntu-fan)rrrr)
�getr�
mergemanydict�BUILTIN_CFGr�debugr�distror�which�install_packagesr!�uses_systemd)�name�cfg�cloudr�argsZcfginZmycfgr&rrr�handleVs



�r.)F)�__doc__�	cloudinitr�logging�cloudinit.settingsrrr�	getLogger�__name__r�	frequencyr$r!r.rrrr�<module>s!
�