From 7eb24fa377b9285766bd9a536dfd2b95af342bbe Mon Sep 17 00:00:00 2001
From: Sean Mooney <sean.k.mooney@intel.com>
Date: Tue, 15 Aug 2017 15:12:25 +0000
Subject: [PATCH] automate ovs datapath configuration

- This change automates generation of
  the datapath_type paramater in the ml2_conf.ini
- If enable_ovs_dpdk is no the datapath type
  will be system else it will be netdev which maintains
  the current default behaviour when dpdk is not enabled.

Change-Id: Iedbf39c621f3c0237f9b9934492b12c600f2c4d3
partial-implementes: bp/ovs-dpdk
---
 ansible/group_vars/all.yml                      |  1 +
 ansible/roles/neutron/templates/ml2_conf.ini.j2 |  2 ++
 ansible/roles/ovs-dpdk/defaults/main.yml        |  1 -
 doc/source/reference/networking-guide.rst       | 17 -----------------
 4 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml
index fda3a75322..6142b30847 100644
--- a/ansible/group_vars/all.yml
+++ b/ansible/group_vars/all.yml
@@ -440,6 +440,7 @@ enable_vmtp: "no"
 enable_watcher: "no"
 enable_zun: "no"
 
+ovs_datapath: "{{ 'netdev' if enable_ovs_dpdk | bool else 'system' }}"
 designate_keystone_user: "designate"
 ironic_keystone_user: "ironic"
 neutron_keystone_user: "neutron"
diff --git a/ansible/roles/neutron/templates/ml2_conf.ini.j2 b/ansible/roles/neutron/templates/ml2_conf.ini.j2
index 5e02d6061a..c6ba1918ac 100644
--- a/ansible/roles/neutron/templates/ml2_conf.ini.j2
+++ b/ansible/roles/neutron/templates/ml2_conf.ini.j2
@@ -78,6 +78,8 @@ extensions = {{ neutron_agent_extensions|map(attribute='name')|join(',') }}
 bridge_mappings = {% for bridge in neutron_bridge_name.split(',') %}physnet{{ loop.index0 + 1 }}:{{ bridge }}{% if not loop.last %},{% endif %}{% endfor %}
 {% endif %}
 
+{# NOTE: newline above is required for correct config generation. Do not remove. #}
+datapath_type = {{ ovs_datapath }}
 ovsdb_connection = tcp:127.0.0.1:{{ ovsdb_port }}
 {% if enable_nova_fake | bool %}
 integration_bridge = br-int-{{ item }}
diff --git a/ansible/roles/ovs-dpdk/defaults/main.yml b/ansible/roles/ovs-dpdk/defaults/main.yml
index 2244eef3c7..9413a01a2f 100644
--- a/ansible/roles/ovs-dpdk/defaults/main.yml
+++ b/ansible/roles/ovs-dpdk/defaults/main.yml
@@ -48,7 +48,6 @@ ovsdpdk_services:
 ####################
 # OVS
 ####################
-ovs_datapath: "netdev"
 ovs_bridge_mappings: "{% for bridge in neutron_bridge_name.split(',') %}physnet{{ loop.index0 + 1 }}:{{ bridge }}{% if not loop.last %},{% endif %}{% endfor %}"
 ovs_port_mappings: "{% for bridge in neutron_bridge_name.split(',') %} {{ neutron_external_interface.split(',')[loop.index0] }}:{{ bridge }}{% if not loop.last %},{% endif %}{% endfor %}"
 dpdk_tunnel_interface : "{{neutron_external_interface}}"
diff --git a/doc/source/reference/networking-guide.rst b/doc/source/reference/networking-guide.rst
index 86b299c496..52fd39971a 100644
--- a/doc/source/reference/networking-guide.rst
+++ b/doc/source/reference/networking-guide.rst
@@ -254,23 +254,6 @@ the future, a new config option will be introduced to allow systemd to be used
 on all host distros for those who do not wish to enable the network manager
 service on ubuntu.
 
-To manage ovs-dpdk the neutron ovs agent must be configured to use
-the netdev datapath_type in the ml2.conf. At present this is not automated
-and must be set via kolla's external config support. To set the datapath_type
-create a file with the following content at
-/etc/kolla/config/neutron/ml2_conf.ini
-
-::
-
-    [ovs]
-    datapath_type = netdev
-
-
-In the future, the requirement to use the external config will be removed by
-automatically computing the value of ovs_datapath based on the value of
-enable_ovs_dpdk and then using the ovs_datapath variable to template out this
-setting in the ml2_conf.ini automatically.
-
 Limitations
 -----------