Add ability to specify additional physnets

Along with default external, tenant and ironic nets there
should be an ability to specify other physical networks
which customers may want to use in an openstack cluster.

Change-Id: I648d5095c534a58385da1880b18fe989684adcd0
Related-Prod: PROD-20255
diff --git a/README.rst b/README.rst
index 3e01825..9cbd45a 100644
--- a/README.rst
+++ b/README.rst
@@ -674,6 +674,33 @@
             ovs:
               driver: openvswitch
 
+Neutron with additional physical networks
+-----------------------------------------
+
+Neutron Server only
+
+.. code-block:: yaml
+
+    neutron:
+      server:
+        version: ocata
+        ...
+        backend:
+          engine: ml2
+          tenant_network_types: "flat,vlan" # Can be mixed flat,vlan,vxlan
+          ...
+          # also need to configure corresponding additional bridge_mappings on
+          # compute and gateway nodes
+          physnets:
+            sriov_net:
+              mtu: 9000 # Optional, defaults to 1500
+              vlan_range: '100:200' # Optional
+            ext_net2:
+              mtu: 1500
+          mechanism:
+            ovs:
+              driver: openvswitch
+
 Advanced Neutron Features (DPDK, SR-IOV)
 ----------------------------------------
 
diff --git a/neutron/files/ocata/ml2_conf.ini b/neutron/files/ocata/ml2_conf.ini
index abff949..300afce 100644
--- a/neutron/files/ocata/ml2_conf.ini
+++ b/neutron/files/ocata/ml2_conf.ini
@@ -175,6 +175,10 @@
 {%- if server.get('ironic_enabled', False) %}
 {%- do physical_network_mtus.append(['physnet3',server.backend.get('ironic_net_mtu', server.backend.get('external_mtu', '1500'))]|join(":")) %}
 {%- endif %}
+
+{%- for physnet, params in server.backend.get('physnets', {}).iteritems() %}
+{%- do physical_network_mtus.append([physnet, params.get('mtu')]|join(":")) if params.get('mtu', False) %}
+{%- endfor %}
 physical_network_mtus = {{ ','.join(physical_network_mtus) }}
 
 # Default network type for external networks when no provider attributes are
@@ -256,6 +260,10 @@
 {%- if server.get('ironic_enabled', False) %}
 {%- do network_vlan_ranges.append(['physnet3',server.backend.get('ironic_vlan_range')]|join(":")) %}
 {%- endif %}
+
+{%- for physnet, params in server.backend.get('physnets', {}).iteritems() %}
+{%- do network_vlan_ranges.append([physnet, params.get('vlan_range')]|join(":") if params.get('vlan_range', False) else physnet) %}
+{%- endfor %}
 network_vlan_ranges = {{ ','.join(network_vlan_ranges) }}
 
 [ml2_type_vxlan]
diff --git a/neutron/files/pike/ml2_conf.ini b/neutron/files/pike/ml2_conf.ini
index a9b8c97..377ecd7 100644
--- a/neutron/files/pike/ml2_conf.ini
+++ b/neutron/files/pike/ml2_conf.ini
@@ -176,6 +176,10 @@
 {%- if server.get('ironic_enabled', False) %}
 {%- do physical_network_mtus.append(['physnet3',server.backend.get('ironic_net_mtu', server.backend.get('external_mtu', '1500'))]|join(":")) %}
 {%- endif %}
+
+{%- for physnet, params in server.backend.get('physnets', {}).iteritems() %}
+{%- do physical_network_mtus.append([physnet, params.get('mtu')]|join(":")) if params.get('mtu', False) %}
+{%- endfor %}
 physical_network_mtus = {{ ','.join(physical_network_mtus) }}
 
 # Default network type for external networks when no provider attributes are
@@ -257,6 +261,10 @@
 {%- if server.get('ironic_enabled', False) %}
 {%- do network_vlan_ranges.append(['physnet3',server.backend.get('ironic_vlan_range')]|join(":")) %}
 {%- endif %}
+
+{%- for physnet, params in server.backend.get('physnets', {}).iteritems() %}
+{%- do network_vlan_ranges.append([physnet, params.get('vlan_range')]|join(":") if params.get('vlan_range', False)) %}
+{%- endfor %}
 network_vlan_ranges = {{ ','.join(network_vlan_ranges) }}
 
 [ml2_type_vxlan]
diff --git a/neutron/files/queens/ml2_conf.ini b/neutron/files/queens/ml2_conf.ini
index e30dad1..836192b 100644
--- a/neutron/files/queens/ml2_conf.ini
+++ b/neutron/files/queens/ml2_conf.ini
@@ -82,6 +82,10 @@
 {%- if server.get('ironic_enabled', False) %}
 {%- do physical_network_mtus.append(['physnet3',server.backend.get('ironic_net_mtu', server.backend.get('external_mtu', '1500'))]|join(":")) %}
 {%- endif %}
+
+{%- for physnet, params in server.backend.get('physnets', {}).iteritems() %}
+{%- do physical_network_mtus.append([physnet, params.get('mtu')]|join(":")) if params.get('mtu', False) %}
+{%- endfor %}
 physical_network_mtus = {{ ','.join(physical_network_mtus) }}
 
 # Default network type for external networks when no provider attributes are
@@ -163,6 +167,10 @@
 {%- if server.get('ironic_enabled', False) %}
 {%- do network_vlan_ranges.append(['physnet3',server.backend.get('ironic_vlan_range')]|join(":")) %}
 {%- endif %}
+
+{%- for physnet, params in server.backend.get('physnets', {}).iteritems() %}
+{%- do network_vlan_ranges.append([physnet, params.get('vlan_range')]|join(":") if params.get('vlan_range', False) else physnet) %}
+{%- endfor %}
 network_vlan_ranges = {{ ','.join(network_vlan_ranges) }}
 
 [ml2_type_vxlan]
diff --git a/tests/pillar/control_single.sls b/tests/pillar/control_single.sls
index 8c7821e..b584d72 100644
--- a/tests/pillar/control_single.sls
+++ b/tests/pillar/control_single.sls
@@ -16,6 +16,12 @@
       password: password
       token: token
       tenant: admin
+      physnets:
+        sriov_net:
+          mtu: 9000 # Optional, defaults to 1500
+          vlan_range: '100:200' # Optional
+        ext_net2:
+          mtu: 1500
     fwaas: false
     dns_domain: novalocal
     tunnel_type: vxlan