3 \�me � @ s� U d Z ddlZddlmZ ddlmZmZ ddlmZ ddl m Z ddlmZm Z ddlmZ d Zd gZddd eeeed�gdgd�Zee e�Z eje�Zddd�Zdd� Zee eedd�dd�ZdS )z$Fan: Configure ubuntu fan networking� N)�dedent)�subp�util)�Cloud)�Config)� MetaSchema�get_meta_doc)�PER_INSTANCEa 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) Additionally, the ``ubuntu-fan`` package will be automatically installed if not present. ZubuntuZcc_fanZFanzConfigure ubuntu fan networkinga 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 �fan)�id�name�title�description�distrosZ frequencyZexamplesZactivate_by_schema_keysz/etc/network/fan)�config�config_pathc C s� y| j d|� d}W n6 tjk rJ } zd}tjd||� W Y d d }~X nX |jd�s^|d7 }tj||dd� y | j d|� |r�tjd |� W n2 tjk r� } ztjd ||� W Y d d }~X nX | j d|� d S )N�stopFTzfailed to stop %s: %s� �w)�omode�startzsuccess: %s startedzfailed to start %s: %s�enable)Zmanage_servicer ZProcessExecutionError�LOGZwarning�endswithr � write_file)�distro�service�config_file�contentZstop_failed�e� r �/usr/lib/python3.6/cc_fan.py�stop_update_startC s r"