#!/bin/bash
#
# Override few things here as early as we can

Q_ML2_PLUGIN_MECHANISM_DRIVERS=${Q_ML2_PLUGIN_MECHANISM_DRIVERS:-"logger,opendaylight_v2"}

# This triggers the provisioning of L3 resources like routers and
# external network, if not overridden.
Q_L3_ENABLED=${Q_L3_ENABLED:-True}

# We have to disable the neutron L2 agent. OpenDaylight does not use the
# L2 agent, it instead uses a combination of OpenFlow and OVSDB commands
# to program OVS on each compute and network node host.

# TODO(rajivk) Both are to be supported for now therefore disabled explicitly
# both of them. Can be removed once moved to lib/neutron
if is_service_enabled "neutron-agent"; then
    disable_service neutron-agent
fi
if is_service_enabled "q-agt"; then
    disable_service q-agt
fi

# If ODL_L3 is enabled, then we don't need the L3 agent and OpenDaylight
# is going to act as the ML2's L3 service plugin.
# NETVIRT_VPNSERVICE feature enables ODL L3 by default, so ODL_L3 is disregarded.
if [[ ",$ODL_NETVIRT_KARAF_FEATURE," =~ ",$ODL_NETVIRT_KARAF_FEATURE_VPNSERVICE," ]] || [ "$ODL_L3" == "True" ]; then
    # TODO(rajivk) Both are to be supported for now therefore disabled explicitly
    # both of them. Can be removed once moved to lib/neutron
    if is_service_enabled "neutron-l3"; then
        disable_service neutron-l3
    fi
    if is_service_enabled "q-l3"; then
        disable_service q-l3
    fi
fi

# bug work around
# https://bugs.launchpad.net/neutron/+bug/1614766
# ODL ovsdb listens to 6640 and
# neutron agent with native uses also 6640 to connect to ovsdb-server
# If ODL server and neutron agent run in same box, alternative port is needed.
export ODL_OVSDB_ALTPORT=${ODL_OVSDB_ALTPORT:-6641}
