Enable separate pillars for OVS and SRIOV agents extensions

Currently l2 agent extensions are specified in a single pillar
and then used by ovs and sriov agents.
This is not correct since there might be different extensions for
different agents on the same compute node.

With this patch ovs agent ini file will first look for 'ovs_extension'
pillar and then fallback to 'extension'. Same for sriov agent ini.
Thus, it will allow configuring different extensions for different agents,
if needed (on the same compute).

Change-Id: I15192dfc52e05c1087f667ddac8c3a537156e276
Related-Prod: PROD-19318
diff --git a/README.rst b/README.rst
index 16a261d..36581f9 100644
--- a/README.rst
+++ b/README.rst
@@ -771,7 +771,7 @@
             autonomous_system: 64512 # Autonomous System number
             enable_rtc: True # Enable RT Constraint (RFC4684)
         backend:
-          extension:
+          ovs_extension: # for OVS agent only, not supported in SRIOV agent
             bagpipe_bgpvpn:
               enabled: True
 
@@ -1199,6 +1199,25 @@
             qos
               enabled: True
 
+Different Neutron extensions for different agents
+-------------------------------------------------
+.. code-block:: yaml
+
+    neutron:
+      server:
+        backend:
+          extension: # common extensions for OVS and SRIOV agents
+            dns:
+              enabled: True
+              ...
+            qos
+              enabled: True
+          ovs_extension: # OVS specific extensions
+            bagpipe_bgpvpn:
+              enabled: True
+          sriov_extension: # SRIOV specific extensions
+            dummy:
+              enabled: True
 
 
 Neutron with Designate
diff --git a/neutron/files/pike/openvswitch_agent.ini b/neutron/files/pike/openvswitch_agent.ini
index fa94c21..dc997df 100644
--- a/neutron/files/pike/openvswitch_agent.ini
+++ b/neutron/files/pike/openvswitch_agent.ini
@@ -197,9 +197,14 @@
 # Extensions list to use (list value)
 {# Get neutron:backend:extension mapping and prepare tmp_ext_list list with extentions where enabled = True #}
 {%- set tmp_ext_list = [] %}
-{%- for ext_name, ext_params in neutron.backend.get('extension', {}).iteritems() %}
+
+{%- for ext_name, ext_params in neutron.backend.get('ovs_extension', {}).iteritems() %}
 {%- do tmp_ext_list.append(ext_name) if ext_params.get('enabled', False)  %}
 {%- endfor %}
+
+{%- for ext_name, ext_params in neutron.backend.get('extension', {}).iteritems() %}
+{%- do tmp_ext_list.append(ext_name) if ext_params.get('enabled', False) and ext_name not in tmp_ext_list %}
+{%- endfor %}
 {# Below section is for backward compatible when extentions were separated properties without neutron:backend:extension pillar #}
 {%- do tmp_ext_list.append('qos') if neutron.get('qos', 'True') and 'qos' not in tmp_ext_list %}
 extensions={{ tmp_ext_list|join(',') }}
diff --git a/neutron/files/pike/sriov_agent.ini b/neutron/files/pike/sriov_agent.ini
index 2885f9b..734c7bd 100644
--- a/neutron/files/pike/sriov_agent.ini
+++ b/neutron/files/pike/sriov_agent.ini
@@ -124,8 +124,13 @@
 # Extensions list to use (list value)
 {# Get neutron:backend:extension mapping and prepare tmp_ext_list list with extentions where enabled = True #}
 {%- set tmp_ext_list = [] %}
+
+{%- for ext_name, ext_params in neutron.backend.get('sriov_extension', {}).iteritems() %}
+{%- do tmp_ext_list.append(ext_name) if ext_params.get('enabled', False)  %}
+{%- endfor %}
+
 {%- for ext_name, ext_params in neutron.backend.get('extension', {}).iteritems() %}
-{%- do tmp_ext_list.append(ext_name) if ext_params.get('enabled', False) and ext_name != 'bagpipe_bgpvpn'  %}
+{%- do tmp_ext_list.append(ext_name) if ext_params.get('enabled', False) and ext_name != 'bagpipe_bgpvpn' and ext_name not in tmp_ext_list %}
 {%- endfor %}
 {# Below section is for backward compatible when extentions were separated properties without neutron:backend:extension pillar #}
 {%- do tmp_ext_list.append('qos') if neutron.get('qos', 'True') and 'qos' not in tmp_ext_list %}