From bd07b74045d93c46483aa261b8686072d9b448e8 Mon Sep 17 00:00:00 2001 From: Moshe Levi Date: Tue, 25 Aug 2015 15:50:09 +0300 Subject: [PATCH] SR-IOV: devstack support for SR-IOV agent Change-Id: Ia0649962bd0c68d9c99fd54cc84ce8dd67d792e8 --- devstack/lib/l2_agent_sriovnicswitch | 23 +++++++++++++++++++++++ devstack/lib/ml2 | 16 ++++++++++++++++ devstack/lib/ml2_drivers/sriovnicswitch | 3 +++ devstack/plugin.sh | 23 +++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100755 devstack/lib/l2_agent_sriovnicswitch create mode 100755 devstack/lib/ml2_drivers/sriovnicswitch diff --git a/devstack/lib/l2_agent_sriovnicswitch b/devstack/lib/l2_agent_sriovnicswitch new file mode 100755 index 00000000000..f422773b0a8 --- /dev/null +++ b/devstack/lib/l2_agent_sriovnicswitch @@ -0,0 +1,23 @@ +SRIOV_AGENT_CONF="${Q_PLUGIN_CONF_PATH}/sriov_agent.ini" +SRIOV_AGENT_BINARY="${NEUTRON_BIN_DIR}/neutron-sriov-nic-agent" + +function configure_l2_agent_sriovnicswitch { + if [[ -n "$PHYSICAL_NETWORK" ]] && [[ -n "$PHYSICAL_INTERFACE" ]]; then + PHYSICAL_DEVICE_MAPPINGS=$PHYSICAL_NETWORK:$PHYSICAL_INTERFACE + fi + if [[ -n "$PHYSICAL_DEVICE_MAPPINGS" ]]; then + iniset /$SRIOV_AGENT_CONF sriov_nic physical_device_mappings $PHYSICAL_DEVICE_MAPPINGS + fi + + iniset /$SRIOV_AGENT_CONF securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver + + iniset /$SRIOV_AGENT_CONF agent extensions "$L2_AGENT_EXTENSIONS" +} + +function start_l2_agent_sriov { + run_process q-sriov-agt "$SRIOV_AGENT_BINARY --config-file $NEUTRON_CONF --config-file /$SRIOV_AGENT_CONF" +} + +function stop_l2_agent_sriov { + stop_process q-sriov-agt +} diff --git a/devstack/lib/ml2 b/devstack/lib/ml2 index 2275c11c072..057d445ea38 100644 --- a/devstack/lib/ml2 +++ b/devstack/lib/ml2 @@ -1,3 +1,6 @@ +source $LIBDIR/ml2_drivers/sriovnicswitch + + function enable_ml2_extension_driver { local extension_driver=$1 if [[ -z "$Q_ML2_PLUGIN_EXT_DRIVERS" ]]; then @@ -11,3 +14,16 @@ function enable_ml2_extension_driver { function configure_qos_ml2 { enable_ml2_extension_driver "qos" } + + +function configure_ml2 { + OIFS=$IFS; + IFS=","; + mechanism_drivers_array=($Q_ML2_PLUGIN_MECHANISM_DRIVERS); + IFS=$OIFS; + for mechanism_driver in "${mechanism_drivers_array[@]}"; do + if [ "$(type -t configure_ml2_$mechanism_driver)" = function ]; then + configure_ml2_$mechanism_driver + fi + done +} \ No newline at end of file diff --git a/devstack/lib/ml2_drivers/sriovnicswitch b/devstack/lib/ml2_drivers/sriovnicswitch new file mode 100755 index 00000000000..43e9566a911 --- /dev/null +++ b/devstack/lib/ml2_drivers/sriovnicswitch @@ -0,0 +1,3 @@ +function configure_ml2_sriovnicswitch { + iniset /$Q_PLUGIN_CONF_FILE ml2_sriov agent_required True +} \ No newline at end of file diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 5b245490d20..280489a5169 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -1,6 +1,7 @@ LIBDIR=$DEST/neutron/devstack/lib source $LIBDIR/l2_agent +source $LIBDIR/l2_agent_sriovnicswitch source $LIBDIR/ml2 source $LIBDIR/qos @@ -15,4 +16,26 @@ if [[ "$1" == "stack" && "$2" == "post-config" ]]; then if is_service_enabled q-agt; then configure_l2_agent fi + #Note: sriov agent should run with OVS or linux bridge agent + #because they are the mechanisms that bind the DHCP and router ports. + #Currently devstack lacks the option to run two agents on the same node. + #Therefore we create new service, q-sriov-agt, and the q-agt should be OVS + #or linux bridge. + if is_service_enabled q-sriov-agt; then + configure_$Q_PLUGIN + configure_l2_agent + configure_l2_agent_sriovnicswitch + fi fi + +if [[ "$1" == "stack" && "$2" == "extra" ]]; then + if is_service_enabled q-sriov-agt; then + start_l2_agent_sriov + fi +fi + +if [[ "$1" == "unstack" ]]; then + if is_service_enabled q-sriov-agt; then + stop_l2_agent_sriov + fi +fi \ No newline at end of file