
    f              
           U d Z ddlZddlmZ ddlmZmZ ddlmZ ddl	m
Z
 ddlmZmZ ddlmZ d	Zd
gZdddeee ed      gdgdZeed<    ee      Z  ej(                  e      ZdddZd Zdede
dededdf
dZy)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.
ubuntucc_fanFanzConfigure 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distros	frequencyexamplesactivate_by_schema_keysmetaz/etc/network/fan)configconfig_pathc                    	 | j                  d|       d}|j                  d      s|dz  }t        j                  ||d       	 | j                  d|       |rt        j	                  d	|       | j                  d|       y # t        j                  $ r#}d}t        j	                  d||       Y d }~d }~ww xY w# t        j                  $ r!}t        j	                  d
||       Y d }~{d }~ww xY w)NstopFTzfailed to stop %s: %s
womodestartzsuccess: %s startedzfailed to start %s: %senable)manage_servicer   ProcessExecutionErrorLOGwarningendswithr   
write_file)distroserviceconfig_filecontentstop_failedes         9/usr/lib/python3/dist-packages/cloudinit/config/cc_fan.pystop_update_startr/   C   s    9fg.
 D!4OOK4:gw/KK-w7 (G, %% 9+Wa889 %% :,gq99:s/   B *B; B8B33B8;C/C**C/r   cfgcloudargsreturnc                    |j                  d      }|si }t        j                  |t        g      }|j                  d      st        j                  d|        y t        j                  |j                  d      |j                  d      d       |j                  }t        j                  d      s|j                  dg       t        |d|j                  d      |j                  d      	       y )
Nr   r   z$%s: no 'fan' config entry. disablingr   r   r   fanctlz
ubuntu-fan)r)   r*   r+   )getr   mergemanydictBUILTIN_CFGr$   debugr'   r(   r   whichinstall_packagesr/   )r   r0   r1   r2   cfginmycfgr(   s          r.   handler>   Y   s    GGENE{34E99X		8$?OOEIIm,eii.AM\\F::h/IIm,		(#	    )__doc__loggingtextwrapr   	cloudinitr   r   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar   r	   cloudinit.settingsr
   MODULE_DESCRIPTIONr   r   __annotations__	getLogger__name__r$   r8   r/   strlistr>    r?   r.   <module>rO      s    +     ! # < +  *
.%		
 !&w+j 0 t
g! %-, 6 % t  r?   