3
\me @ s U d Z ddlZddlmZ ddlmZmZ ddlmZ ddl m
Z
ddlmZm
Z
ddlmZ d Zd
gZddd
eeeedgdgdZee
eZ ejeZdddZdd Zee
eeddddZdS )z$Fan: Configure ubuntu fan networking N)dedent)subputil)Cloud)Config)
MetaSchemaget_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)idnametitledescriptiondistrosZ frequencyZexamplesZactivate_by_schema_keysz/etc/network/fan)configconfig_pathc C s y| j d| d}W n6 tjk
rJ } zd}tjd|| W Y d d }~X nX |jds^|d7 }tj||dd y | j d| |rtjd | W n2 tjk
r } ztjd
|| W Y d d }~X nX | j d| d S )NstopFTzfailed to stop %s: %s
w)omodestartzsuccess: %s startedzfailed to start %s: %senable)Zmanage_servicer ZProcessExecutionErrorLOGZwarningendswithr
write_file)distroserviceconfig_filecontentZstop_failede r /usr/lib/python3.6/cc_fan.pystop_update_startC s
r" )r cfgcloudargsreturnc C s |j d}|si }tj|tg}|j ds:tjd| d S tj|j d|j ddd |j}tj dsr|j
dg t|d|j d|j dd d S )
Nr
r z$%s: no 'fan' config entry. disablingr r )r Zfanctlz
ubuntu-fan)r r r )getr Z
mergemanydictBUILTIN_CFGr debugr r r ZwhichZinstall_packagesr" )r r# r$ r% ZcfginZmycfgr r r r! handleY s
r* )__doc__Zloggingtextwrapr Z cloudinitr r Zcloudinit.cloudr Zcloudinit.configr Zcloudinit.config.schemar r Zcloudinit.settingsr ZMODULE_DESCRIPTIONr metaZ getLogger__name__r r( r" strlistr* r r r r!