<?xml version="1.0" encoding="utf-8"?>
<creole>

    <files>
        <service servicelist='nut-server'>nut-server</service>
        <service servicelist='nut-server'>nut-driver</service>
        <service servicelist='nut'>nut-monitor</service>
        <service_access service='nut'>
            <port>3493</port>
            <tcpwrapper>upsd</tcpwrapper>
        </service_access>
        <service_restriction service='nut'>
            <ip interface='auto' netmask='nut_monitor_netmask' netmask_type='SymLinkOption' ip_type='SymLinkOption'>nut_monitor_host</ip>
        </service_restriction>
        <file name="/etc/nut/nut.conf"/>
        <file name="/etc/nut/ups.conf"    owner="nut" group="nut" mode="640" filelist="nutmaster" rm='True'/>
        <file name="/etc/nut/upsd.conf"   owner="nut" group="nut" mode="640" filelist="nutmaster" rm='True'/>
        <file name="/etc/nut/upsd.users"  owner="nut" group="nut" mode="640" filelist="nutmaster" rm='True'/>
        <file name="/etc/nut/upsmon.conf" owner="nut" group="nut" mode="640" filelist="nut" rm='True'/>
    </files>

    <variables>

        <family name="services">
            <variable name="activer_nut" type="oui/non" description="Activer la gestion de l'onduleur NUT">
                <value>non</value>
            </variable>
        </family>

        <family name='onduleur' icon='bolt'>

            <variable name="nut_ups_daemon" type="oui/non" description="Configuration sur un serveur maître">
                <value>oui</value>
            </variable>

            <!--l'onduleur est distant-->
            <variable name="nut_monitor_foreign_name" type="string" description="Nom de l'onduleur distant" mandatory='True' multi='True'/>
            <variable name="nut_monitor_foreign_host" type="domain" description="Hôte gérant l'onduleur" mandatory='True' multi='True'/>
            <variable name="nut_monitor_foreign_user" type="unix_user" description="Utilisateur de l'hôte distant" mandatory='True' multi='True'/>
            <!-- Le mot de passe ne doit contenir que des chiffres ou des lettres -->
            <variable name="nut_monitor_foreign_password" type="password" description="Mot de passe de l'hôte distant" mandatory='True' multi='True'/>

            <!--si l'onduleur est local-->
            <variable name="nut_ups_name" type="hostname_strict" description="Nom de l'onduleur" multi="True" mandatory='True'/>
            <variable name="nut_ups_driver" type="string" description="Pilote de communication de l'onduleur">
                <value>usbhid-ups</value>
            </variable>
            <variable name="nut_ups_port" type="string" description="Port de communication de l'onduleur" mandatory='True'>
                <value>auto</value>
            </variable>
            <variable name="nut_ups_serial" type="string" description="Numéro de série de l'onduleur (facultatif)"/>
            <variable name="nut_ups_productid" type="string" description="Productid de l'onduleur (facultatif)"/>
            <variable name="nut_ups_upstype" type="string" description="Upstype de l'onduleur (facultatif)"/>
            <variable name="nut_ups_community" type="string" description="SNMP community" mandatory="True">
                <value>public</value>
            </variable>
            <variable name="nut_ups_snmp_version" type="string" description="SNMP version" mandatory="True">
                <value>v1</value>
            </variable>
            <variable name="nut_ups_mibs" type="string" description="MIBS SNMP" mandatory="True">
                <value>auto</value>
            </variable>
            <variable name="nut_ups_pollfreq" type="number" description="Fréquence d'interrogation de upsmon" mode="expert"/>

            <!-- Le mot de passe ne doit contenir que des chiffres ou des lettres -->
            <variable name="nut_ups_password" type="password" description="Mot de passe de l'administrateur local de l'onduleur" hidden="True"/>

            <!--autoriser utilisateur distant-->
            <variable name="nut_monitor" type='oui/non' description="Autoriser des esclaves distants à se connecter">
                <value>non</value>
            </variable>
            <variable name="nut_monitor_user" type="unix_user" description="Utilisateur de surveillance de l'onduleur" multi="True" mandatory='True'/>
            <!-- Le mot de passe ne doit contenir que des chiffres ou des lettres -->
            <variable name="nut_monitor_password" type="password" description="Mot de passe de surveillance de l'onduleur" mandatory='True'/>
            <variable name="nut_monitor_host" type="network" description="Adresse IP du réseau de l'esclave"  mandatory='True'/>
            <variable name="nut_monitor_netmask" type="netmask" description="Masque de l'IP du réseau de l'esclave" mandatory='True'/>

        </family>
        <family name='Interface-0'>
            <variable name="nut_monitor_host_eth0" type="ip" description="Hôte gérant l'onduleur sur l'interface 0" multi='True'/>
        </family>
        <family name='Interface-1'>
            <variable name="nut_monitor_host_eth1" type="ip" description="Hôte gérant l'onduleur sur l'interface 1" multi='True'/>
        </family>
        <family name='Interface-2'>
            <variable name="nut_monitor_host_eth2" type="ip" description="Hôte gérant l'onduleur sur l'interface 2" multi='True'/>
        </family>
        <family name='Interface-3'>
            <variable name="nut_monitor_host_eth3" type="ip" description="Hôte gérant l'onduleur sur l'interface 3" multi='True'/>
        </family>
        <family name='Interface-4'>
            <variable name="nut_monitor_host_eth4" type="ip" description="Hôte gérant l'onduleur sur l'interface 4" multi='True'/>
        </family>

        <separators>
            <separator name="nut_monitor">Esclaves distants</separator>
        </separators>

    </variables>

    <constraints>

        <check name="valid_networknetmask" target="nut_monitor_netmask">
            <param type='eole'>nut_monitor_host</param>
        </check>

        <fill name='gen_random' target='nut_ups_password'/>

        <fill name='calc_multi_condition' target='nut_ups_pollfreq'>
            <param>snmp-ups</param>
            <param type='eole' name='condition_1' hidden="False">nut_ups_driver</param>
            <param name='match' type="number">15</param>
            <param name='default_mismatch'>None</param>
        </fill>

        <auto name='get_ips_from_interface' target='nut_monitor_host_eth0'>
            <param type='eole'>nut_monitor_host</param>
            <param type='eole'>nom_zone_eth0</param>
        </auto>

        <auto name='get_ips_from_interface' target='nut_monitor_host_eth1'>
            <param type='eole'>nut_monitor_host</param>
            <param type='eole'>nom_zone_eth1</param>
        </auto>

        <auto name='get_ips_from_interface' target='nut_monitor_host_eth2'>
            <param type='eole'>nut_monitor_host</param>
            <param type='eole'>nom_zone_eth2</param>
        </auto>

        <auto name='get_ips_from_interface' target='nut_monitor_host_eth3'>
            <param type='eole'>nut_monitor_host</param>
            <param type='eole'>nom_zone_eth3</param>
        </auto>

        <auto name='get_ips_from_interface' target='nut_monitor_host_eth4'>
            <param type='eole'>nut_monitor_host</param>
            <param type='eole'>nom_zone_eth4</param>
        </auto>

        <condition name="disabled_if_in" source="nut_ups_daemon">
            <param>non</param>
            <target type="servicelist">nut-server</target>
        </condition>

        <condition name="disabled_if_not_in" source="nut_ups_driver">
            <param>snmp-ups</param>
            <target type="variable">nut_ups_community</target>
            <target type="variable">nut_ups_snmp_version</target>
            <target type="variable">nut_ups_mibs</target>
        </condition>

        <condition name="disabled_if_in" source="activer_nut">
            <param>non</param>
            <target type="family">onduleur</target>
            <target type="servicelist">nut</target>
            <target type="filelist">nut</target>
        </condition>

        <condition name="disabled_if_in" source="nut_ups_daemon">
            <param>oui</param>
            <target type="variable">nut_monitor_foreign_name</target>
            <target type="variable">nut_monitor_foreign_host</target>
            <target type="variable">nut_monitor_foreign_user</target>
            <target type="variable">nut_monitor_foreign_password</target>
        </condition>

        <condition name="disabled_if_in" source="nut_ups_daemon">
            <param>non</param>
            <target type="variable">nut_ups_name</target>
            <target type="variable">nut_ups_driver</target>
            <target type="variable">nut_ups_port</target>
            <target type="variable">nut_ups_serial</target>
            <target type="variable">nut_ups_productid</target>
            <target type="variable">nut_ups_upstype</target>
            <target type="variable">nut_ups_community</target>
            <target type="variable">nut_ups_snmp_version</target>
            <target type="variable">nut_ups_mibs</target>
            <target type="variable">nut_ups_pollfreq</target>
            <target type="variable">nut_monitor</target>
        </condition>

        <condition name='disabled_if_in' source='nut_monitor'>
            <param>non</param>
            <target type="variable">nut_monitor_user</target>
            <target type="variable">nut_monitor_password</target>
            <target type="variable">nut_monitor_host</target>
            <target type="variable">nut_monitor_netmask</target>
            <target type="variable">nut_monitor_host_eth0</target>
            <target type="variable">nut_monitor_host_eth1</target>
            <target type="variable">nut_monitor_host_eth2</target>
            <target type="variable">nut_monitor_host_eth3</target>
            <target type="variable">nut_monitor_host_eth4</target>
        </condition>

        <condition name="disabled_if_in" source="nut_ups_daemon">
            <param>non</param>
            <target type="filelist">nutmaster</target>
        </condition>

        <check name="valid_enum" target="nut_ups_mibs">
            <param>['auto', 'ietf', 'mge', 'apcc', 'netvision', 'pw', 'pxgx_ups', 'aphel_genesisII', 'aphel_revelation', 'raritan', 'baytech', 'cpqpower', 'cyberpower', 'huawei']</param>
            <param name="checkval">False</param>
        </check>
        <check name="valid_enum" target="nut_ups_snmp_version">
            <param>['v1', 'v2c', 'v3']</param>
        </check>
        <check name="valid_enum" target="nut_ups_driver">
            <param type="python">eosfunc.list_files('/lib/nut/', default=['al175', 'apcsmart', 'apcsmart-old', 'apcupsd-ups', 'bcmxcp', 'bcmxcp_usb', 'belkin', 'belkinunv', 'bestfcom', 'bestfortress', 'bestuferrups', 'bestups', 'blazer_ser', 'blazer_usb', 'clone', 'clone-outlet', 'dummy-ups', 'etapro', 'everups', 'gamatronic', 'genericups', 'isbmex', 'ivtscd', 'liebert', 'liebert-esp2', 'masterguard', 'metasys', 'mge-shut', 'mge-utalk', 'microdowell', 'nutdrv_atcl_usb', 'nutdrv_qx', 'oldmge-shut', 'oneac', 'optiups', 'powercom', 'powerpanel', 'rhino', 'richcomm_usb', 'riello_ser', 'riello_usb', 'safenet', 'snmp-ups', 'solis', 'tripplite', 'tripplite_usb', 'tripplitesu', 'upscode2', 'usbhid-ups', 'victronups'], exception=['upsd', 'upsmon'], substring=False)</param>
            <param name="checkval">False</param>
        </check>

        <check name="valid_enum" target="nut_ups_port">
            <param>['auto','/dev/ttyS0','/dev/ttyS1']</param>
            <param name="checkval">False</param>
        </check>

        <group master='nut_monitor_user'>
            <slave>nut_monitor_password</slave>
            <slave>nut_monitor_host</slave>
            <slave>nut_monitor_netmask</slave>
        </group>

        <group master='nut_ups_name'>
            <slave>nut_ups_port</slave>
            <slave>nut_ups_driver</slave>
            <slave>nut_ups_serial</slave>
            <slave>nut_ups_productid</slave>
            <slave>nut_ups_upstype</slave>
            <slave>nut_ups_community</slave>
            <slave>nut_ups_snmp_version</slave>
            <slave>nut_ups_mibs</slave>
            <slave>nut_ups_pollfreq</slave>
        </group>

        <group master='nut_monitor_foreign_name'>
            <slave>nut_monitor_foreign_host</slave>
            <slave>nut_monitor_foreign_user</slave>
            <slave>nut_monitor_foreign_password</slave>
        </group>

    </constraints>

    <help>

        <family name='onduleur'>Paramétrage de la gestion des onduleurs par NUT</family>
        <variable name="activer_nut">NUT (Network UPS Tools) est un ensemble d'outils permettant de gérer et de superviser un système relié à un ou des onduleurs</variable>
        <variable name="nut_ups_daemon">Activer la gestion d'onduleur. Ce service est a activer si ce serveur est connecté à un onduleur (cable RS232 ou USB). Sinon, le service se connecte à un autre serveur NUT.</variable>
        <variable name="nut_ups_name">Nom de l'onduleur géré par le service NUT.</variable>
        <variable name="nut_ups_driver">Pilote de communication de l'onduleur.</variable>
        <variable name="nut_ups_port">Port de communication de l'onduleur. Pour les onduleurs USB ce port doit être "auto".</variable>
        <variable name="nut_ups_serial">Valeur spécifique pour le champ "serial" associé à l'onduleur dans /etc/ups/ups.conf</variable>
        <variable name="nut_ups_productid">Valeur spécifique pour le champ "productid" associé à l'onduleur dans /etc/ups/ups.conf</variable>
        <variable name="nut_ups_upstype">Valeur spécifique pour le champ "upstype" associé à l'onduleur dans /etc/ups/ups.conf</variable>
        <variable name="nut_ups_pollfreq">Attention cette valeur peut entraîner des deadlocks, se référer au manuel de upsmon.conf</variable>
        <variable name="nut_monitor_user">Nom d'utilisateur de surveillance de l'onduleur.</variable>
        <variable name="nut_monitor_password">Mot de passe de l'utilisateur de surveillance de l'onduleur.</variable>

    </help>

</creole>
<!-- vim: ts=4 sw=4 expandtab
-->
