function install_apic_aim {
    echo_summary "Installing apic_aim"

    install_acitoolkit
    install_apicapi
    install_aim
    install_opflex
}

function configure_apic_aim {
    echo_summary "Configuring apic_aim"

    # devstack/lib/neutron_plugins/ml2 does not allow overriding
    # Q_PLUGIN_CLASS in override_defaults, so do it here instead

    # Neutron Configuration for AIM
    iniset $NEUTRON_CONF DEFAULT core_plugin ml2plus

    iniset /$Q_PLUGIN_CONF_FILE ml2_type_vxlan vni_ranges "10:100"
    iniset /$Q_PLUGIN_CONF_FILE ml2_type_vxlan vxlan_group "224.0.0.1"

    iniset /$Q_PLUGIN_CONF_FILE apic_aim_auth auth_plugin v3password
    iniset /$Q_PLUGIN_CONF_FILE apic_aim_auth auth_url $KEYSTONE_SERVICE_URI_V3
    iniset /$Q_PLUGIN_CONF_FILE apic_aim_auth username admin
    iniset /$Q_PLUGIN_CONF_FILE apic_aim_auth password $ADMIN_PASSWORD
    iniset /$Q_PLUGIN_CONF_FILE apic_aim_auth user_domain_name default
    iniset /$Q_PLUGIN_CONF_FILE apic_aim_auth project_domain_name default
    iniset /$Q_PLUGIN_CONF_FILE apic_aim_auth project_name admin

    # The following are used by apic_mapping and should not be needed once
    # apic_mapping is no longer called from aim_mapping
    iniset $NEUTRON_CONF keystone_authtoken identity_uri $KEYSTONE_SERVICE_URI
    iniset $NEUTRON_CONF keystone_authtoken admin_user neutron
    iniset $NEUTRON_CONF keystone_authtoken admin_tenant_name services
    iniset $NEUTRON_CONF keystone_authtoken admin_password $ADMIN_PASSWORD

    # GBP Configuration for AIM
    # Policy drivers (REVISIT: chain_mapping might needed to be added later)
    iniset $NEUTRON_CONF group_policy policy_drivers "aim_mapping"
    iniset $NEUTRON_CONF group_policy extension_drivers "aim_extension,proxy_group,apic_segmentation_label"
    # Service Chain (REVISIT: not overriding any defaults yet)

    init_aim
}

function install_acitoolkit {
    git_clone $ACITOOLKIT_REPO $ACITOOLKIT_DIR $ACITOOLKIT_BRANCH
    touch $ACITOOLKIT_DIR/setup.cfg
    setup_develop $ACITOOLKIT_DIR
}

function install_apicapi {
    git_clone $APICAPI_REPO $APICAPI_DIR $APICAPI_BRANCH
    mv $APICAPI_DIR/test-requirements.txt $APICAPI_DIR/_test-requirements.txt
    touch $APICAPI_DIR/setup.cfg
    setup_develop $APICAPI_DIR
    mv $APICAPI_DIR/_test-requirements.txt $APICAPI_DIR/test-requirements.txt
}

function install_aim {
    git_clone $AIM_REPO $AIM_DIR $AIM_BRANCH
    mv $AIM_DIR/test-requirements.txt $AIM_DIR/_test-requirements.txt
    setup_develop $AIM_DIR
    mv $AIM_DIR/_test-requirements.txt $AIM_DIR/test-requirements.txt
}

function init_aim {
    aimctl -c $NEUTRON_CONF db-migration upgrade
    aimctl -c $NEUTRON_CONF config update
}

function install_opflex {
    git_clone $OPFLEX_REPO $OPFLEX_DIR $OPFLEX_BRANCH
    mv $OPFLEX_DIR/test-requirements.txt $OPFLEX_DIR/_test-requirements.txt
    touch  $OPFLEX_DIR/setup.cfg
    setup_develop $OPFLEX_DIR
    mv $OPFLEX_DIR/_test-requirements.txt $OPFLEX_DIR/test-requirements.txt
}

# Tell emacs to use shell-script-mode
## Local variables:
## mode: shell-script
## End:
