File: //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_fan.cpython-39.pyc
a
��`h � @ sb d Z ddlmZ ddlmZ ddlmZ ddlmZ e�e �Z
eZddd�Zdd
d�Z
dd
� 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_pathFc s� |r$dd� gdd� gdd� gd�}nddgddgd�}� fdd �}||d d
� d� }|� d�sj|d7 }tj||d
d� ||d d� d�}|r�|r�t�d� � d|v r�||d d� d�}|S )NZ systemctl�stop�start�enable)r r r
�service)r r c
sN zt j | dd�W S t jyH } zt�d� | |� W Y d }~dS d }~0 0 d S )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_filer r )r �config_file�content�systemdZcmdsr Zstop_failed�retr r r �stop_update_start7 s&