From ca2885889f5244d7bef037654551d66909091908 Mon Sep 17 00:00:00 2001
From: Slawek Kaplonski <skaplons@redhat.com>
Date: Wed, 4 Aug 2021 14:08:24 +0200
Subject: [PATCH] Add devstack plugin to enable ovs distributed dhcp service

Partially-Implements: bp/distributed-dhcp-for-ml2-ovs
Related-Bug: #1900934
Change-Id: I5617a72fcd4ec0de9aa7d1444d515e713029fa76
---
 devstack/lib/distributed_dhcp | 4 ++++
 devstack/plugin.sh            | 6 ++++++
 2 files changed, 10 insertions(+)
 create mode 100644 devstack/lib/distributed_dhcp

diff --git a/devstack/lib/distributed_dhcp b/devstack/lib/distributed_dhcp
new file mode 100644
index 00000000000..ac61316ef99
--- /dev/null
+++ b/devstack/lib/distributed_dhcp
@@ -0,0 +1,4 @@
+function configure_ovs_distributed_dhcp {
+    plugin_agent_add_l2_agent_extension "dhcp"
+    iniset $NEUTRON_CONF DEFAULT enable_traditional_dhcp False
+}
diff --git a/devstack/plugin.sh b/devstack/plugin.sh
index 21f87e30312..b34502d5b32 100644
--- a/devstack/plugin.sh
+++ b/devstack/plugin.sh
@@ -1,5 +1,6 @@
 LIBDIR=$DEST/neutron/devstack/lib
 
+source $LIBDIR/distributed_dhcp
 source $LIBDIR/dns
 source $LIBDIR/flavors
 source $LIBDIR/l2_agent
@@ -79,6 +80,11 @@ if [[ "$1" == "stack" ]]; then
             if is_service_enabled neutron-network-segment-range; then
                 configure_network_segment_range
             fi
+            if is_service_enabled q-distributed-dhcp neutron-distributed-dhcp; then
+                if [ $Q_AGENT = openvswitch ]; then
+                    configure_ovs_distributed_dhcp
+                fi
+            fi
             if is_service_enabled q-agt neutron-agent; then
                 configure_l2_agent
             fi