<?xml version="1.0" encoding="utf-8"?>
<creole>
    <files>
        <service>openvswitch-switch</service>
        <!--<file filelist='openvswitch' name='' rm='True' mkdir='True'/>-->
    </files>
    <variables>
        <family name='services'>
            <variable name='activer_openvswitch' type='oui/non' description="Activer le commutateur virtuel Open vSwitch" />
        </family>
        <family name='Interface-1'>
            <variable name='eth1_method' redefine='True' mode='expert' hidden='False'>
                <value>manuel</value>
            </variable>
        </family>

        <family name='Interface-2'>
            <variable name='eth2_method' redefine='True' mode='expert' hidden='False'>
                <value>manuel</value>
            </variable>
        </family>

        <family name='Interface-3'>
            <variable name='eth3_method' redefine='True' mode='expert' hidden='False'>
                <value>manuel</value>
            </variable>
        </family>

        <family name='Interface-4'>
            <variable name='eth4_method' redefine='True' mode='expert' hidden='False'>
                <value>manuel</value>
            </variable>
        </family>

        <family name='Commutateur virtuel' icon='cloud'>
            <variable name='ovs_sw_name' type='string' description="Nom du commutateur virtuel utilisé par les réseaux virtuels" auto_freeze="True">
                <value>vswitch</value>
            </variable>
            <variable name='ovs_sw_zones'      type='string' description="Nom du port du commutateur virtuel associé à une interface physique" multi="True"/>
            <variable name='ovs_sw_zone_iface' type='string' description="Interface physique" mandatory="True"/>
            <variable name='ovs_sw_tag_mode'   mode='expert' type='string' description="Mode du VLAN virtuel"/>
            <variable name='ovs_sw_vlan_tag'   type='string' description="Identifiant du VLAN virtuel"/>
        </family>
    </variables>

    <constraints>
        <!-- Interface1 -->
        <check name="valid_enum" target="eth1_method">
            <param>['statique','dhcp','manuel']</param>
        </check>
        <condition name='disabled_if_in' source='eth1_method'>
            <param>manuel</param>
            <target type='variable'>adresse_ip_eth1</target>
            <target type='variable'>adresse_netmask_eth1</target>
            <target type='variable'>adresse_network_eth1</target>
            <target type='variable'>adresse_broadcast_eth1</target>
            <target type='variable'>ssh_eth1</target>
            <target type='variable'>admin_eth1</target>
            <target type='variable'>alias_eth1</target>
            <target type='variable'>vlan_eth1</target>
        </condition>

        <!-- Interface2 -->
        <check name="valid_enum" target="eth2_method">
            <param>['statique','dhcp','manuel']</param>
        </check>
        <condition name='disabled_if_in' source='eth2_method'>
            <param>manuel</param>
            <target type='variable'>adresse_ip_eth2</target>
            <target type='variable'>adresse_netmask_eth2</target>
            <target type='variable'>adresse_network_eth2</target>
            <target type='variable'>adresse_broadcast_eth2</target>
            <target type='variable'>ssh_eth2</target>
            <target type='variable'>admin_eth2</target>
            <target type='variable'>alias_eth2</target>
            <target type='variable'>vlan_eth2</target>
        </condition>

        <!-- Interface3 -->
        <check name="valid_enum" target="eth3_method">
            <param>['statique','dhcp','manuel']</param>
        </check>
        <condition name='disabled_if_in' source='eth3_method'>
            <param>manuel</param>
            <target type='variable'>adresse_ip_eth3</target>
            <target type='variable'>adresse_netmask_eth3</target>
            <target type='variable'>adresse_network_eth3</target>
            <target type='variable'>adresse_broadcast_eth3</target>
            <target type='variable'>ssh_eth3</target>
            <target type='variable'>admin_eth3</target>
            <target type='variable'>alias_eth3</target>
            <target type='variable'>vlan_eth3</target>
        </condition>

        <!-- Interface4 -->
        <check name="valid_enum" target="eth4_method">
            <param>['statique','dhcp','manuel']</param>
        </check>
        <condition name='disabled_if_in' source='eth4_method'>
            <param>manuel</param>
            <target type='variable'>adresse_ip_eth4</target>
            <target type='variable'>adresse_netmask_eth4</target>
            <target type='variable'>adresse_network_eth4</target>
            <target type='variable'>adresse_broadcast_eth4</target>
            <target type='variable'>ssh_eth4</target>
            <target type='variable'>admin_eth4</target>
            <target type='variable'>alias_eth4</target>
            <target type='variable'>vlan_eth4</target>
        </condition>

        <!-- List of all physical interfaces -->
        <check name='valid_enum' target='ovs_sw_zone_iface'>
            <param>['eth1','eth2','eth3','eth4']</param>
        </check>

        <condition name='disabled_if_in' source='activer_openvswitch'>
            <param>non</param>
            <target type='filelist'>openvswitch</target>
            <target type='family'>Commutateur virtuel</target>
        </condition>

        <check name='valid_enum' target='ovs_sw_zones'>
            <param>['internet','admin','pedago','dmzpub','dmzpriv','wifi']</param>
            <param name='checkval'>False</param>
        </check>
        <check name='valid_enum' target='ovs_sw_tag_mode'>
            <param>['', 'access','native-tagged','native-untagged','trunk']</param>
        </check>
        <group master='ovs_sw_zones'>
            <slave>ovs_sw_zone_iface</slave>
            <slave>ovs_sw_vlan_tag</slave>
            <slave>ovs_sw_tag_mode</slave>
        </group>
    </constraints>
    <help>
        <family name='Commutateur virtuel'>Configuration du commutateur virtuel Open vSwitch</family>
    </help>
</creole>
