]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
SR-IOV: devstack support for SR-IOV agent
authorMoshe Levi <moshele@mellanox.com>
Tue, 25 Aug 2015 12:50:09 +0000 (15:50 +0300)
committerMoshe Levi <moshele@mellanox.com>
Wed, 9 Sep 2015 12:06:37 +0000 (15:06 +0300)
Change-Id: Ia0649962bd0c68d9c99fd54cc84ce8dd67d792e8

devstack/lib/l2_agent_sriovnicswitch [new file with mode: 0755]
devstack/lib/ml2
devstack/lib/ml2_drivers/sriovnicswitch [new file with mode: 0755]
devstack/plugin.sh

diff --git a/devstack/lib/l2_agent_sriovnicswitch b/devstack/lib/l2_agent_sriovnicswitch
new file mode 100755 (executable)
index 0000000..f422773
--- /dev/null
@@ -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
+}
index 2275c11c0727add48b172725504c61d961713e75..057d445ea384b975aa3afbe9b2128d07c22117b8 100644 (file)
@@ -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 (executable)
index 0000000..43e9566
--- /dev/null
@@ -0,0 +1,3 @@
+function configure_ml2_sriovnicswitch {
+    iniset /$Q_PLUGIN_CONF_FILE ml2_sriov agent_required True
+}
\ No newline at end of file
index 5b245490d20663d3620fc36573dcc46e227bd7dc..280489a516926431fb54a1e72b45e81a840214dd 100644 (file)
@@ -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