Merge "Add an ability to set base_mac and dvr_base_mac in neutron."
diff --git a/README.rst b/README.rst
index 42ad76b..60b6fd0 100644
--- a/README.rst
+++ b/README.rst
@@ -264,6 +264,40 @@
           enabled: false
 
 
+Setting mac base address
+------------------------
+
+By default neutron uses fa:16:3f:00:00:00 basement for mac generator.
+One can set it's own mac base both for dvr and nondvr cases.
+
+NOTE: dvr_base_mac and base_mac SHOULD differ.
+
+.. code-block:: yaml
+
+    neutron:
+      server:
+        base_mac: fa:16:3f:00:00:00
+        dvr_base_mac: fa:16:3f:a0:00:00
+
+gateways:
+
+.. code-block:: yaml
+
+    neutron:
+      gateway:
+        base_mac: fa:16:3f:00:00:00
+        dvr_base_mac: fa:16:3f:a0:00:00
+
+compute nodes:
+
+.. code-block:: yaml
+
+    neutron:
+      compute:
+        base_mac: fa:16:3f:00:00:00
+        dvr_base_mac: fa:16:3f:a0:00:00
+
+
 Disable physnet1 bridge
 -----------------------
 
diff --git a/neutron/files/pike/neutron-generic.conf b/neutron/files/pike/neutron-generic.conf
index b8d0b90..03954cc 100644
--- a/neutron/files/pike/neutron-generic.conf
+++ b/neutron/files/pike/neutron-generic.conf
@@ -48,6 +48,9 @@
 # remain unchanged. If the 4th octet is not 00, it will also be used. The
 # others will be randomly generated. (string value)
 #base_mac = fa:16:3e:00:00:00
+{%- if neutron.base_mac is defined %}
+base_mac = {{ neutron.base_mac }}
+{%- endif %}
 
 # Allow the usage of the bulk API (boolean value)
 #allow_bulk = true
@@ -259,6 +262,15 @@
 # tenant ports. A 4 octet example would be dvr_base_mac = fa:16:3f:4f:00:00.
 # The default is 3 octet (string value)
 #dvr_base_mac = fa:16:3f:00:00:00
+{%- if neutron.dvr_base_mac is defined %}
+  {%- if neutron.base_mac is defined %}
+    {%- if neutron.base_mac != neutron.dvr_base_mac %}
+dvr_base_mac = {{ neutron.dvr_base_mac }}
+    {%- endif %}
+  {%- else %}
+dvr_base_mac = {{ neutron.dvr_base_mac }}
+  {%- endif %}
+{%- endif %}
 
 # System-wide flag to determine the type of router that tenants can create.
 # Only admin can override. (boolean value)
diff --git a/neutron/files/pike/neutron-server.conf b/neutron/files/pike/neutron-server.conf
index 49e8006..3ba83b5 100644
--- a/neutron/files/pike/neutron-server.conf
+++ b/neutron/files/pike/neutron-server.conf
@@ -94,6 +94,9 @@
 # remain unchanged. If the 4th octet is not 00, it will also be used. The
 # others will be randomly generated. (string value)
 #base_mac = fa:16:3e:00:00:00
+{%- if server.base_mac is defined %}
+base_mac = {{ server.base_mac }}
+{%- endif %}
 
 # Allow the usage of the bulk API (boolean value)
 #allow_bulk = true
@@ -322,6 +325,15 @@
 # tenant ports. A 4 octet example would be dvr_base_mac = fa:16:3f:4f:00:00.
 # The default is 3 octet (string value)
 #dvr_base_mac = fa:16:3f:00:00:00
+{%- if server.dvr_base_mac is defined %}
+  {%- if server.base_mac is defined %}
+    {%- if server.base_mac != server.dvr_base_mac %}
+dvr_base_mac = {{ server.dvr_base_mac }}
+    {%- endif %}
+  {%- else %}
+dvr_base_mac = {{ server.dvr_base_mac }}
+  {%- endif %}
+{%- endif %}
 
 # System-wide flag to determine the type of router that tenants can create.
 # Only admin can override. (boolean value)
diff --git a/neutron/files/queens/neutron-generic.conf b/neutron/files/queens/neutron-generic.conf
index 6025078..096cb69 100644
--- a/neutron/files/queens/neutron-generic.conf
+++ b/neutron/files/queens/neutron-generic.conf
@@ -48,6 +48,9 @@
 # remain unchanged. If the 4th octet is not 00, it will also be used. The
 # others will be randomly generated. (string value)
 #base_mac = fa:16:3e:00:00:00
+{%- if neutron.base_mac is defined %}
+base_mac = {{ neutron.base_mac }}
+{%- endif %}
 
 # Allow the usage of the bulk API (boolean value)
 #allow_bulk = true
@@ -265,6 +268,15 @@
 # tenant ports. A 4 octet example would be dvr_base_mac = fa:16:3f:4f:00:00.
 # The default is 3 octet (string value)
 #dvr_base_mac = fa:16:3f:00:00:00
+{%- if neutron.dvr_base_mac is defined %}
+  {%- if neutron.base_mac is defined %}
+    {%- if neutron.base_mac != neutron.dvr_base_mac %}
+dvr_base_mac = {{ neutron.dvr_base_mac }}
+    {%- endif %}
+  {%- else %}
+dvr_base_mac = {{ neutron.dvr_base_mac }}
+  {%- endif %}
+{%- endif %}
 
 # System-wide flag to determine the type of router that tenants can create.
 # Only admin can override. (boolean value)
diff --git a/neutron/files/queens/neutron-server.conf b/neutron/files/queens/neutron-server.conf
index 9d60d06..4f35a5b 100644
--- a/neutron/files/queens/neutron-server.conf
+++ b/neutron/files/queens/neutron-server.conf
@@ -80,6 +80,9 @@
 # remain unchanged. If the 4th octet is not 00, it will also be used. The
 # others will be randomly generated. (string value)
 #base_mac = fa:16:3e:00:00:00
+{%- if server.base_mac is defined %}
+base_mac = {{ server.base_mac }}
+{%- endif %}
 
 # Allow the usage of the bulk API (boolean value)
 #allow_bulk = true
@@ -301,6 +304,15 @@
 # tenant ports. A 4 octet example would be dvr_base_mac = fa:16:3f:4f:00:00.
 # The default is 3 octet (string value)
 #dvr_base_mac = fa:16:3f:00:00:00
+{%- if server.dvr_base_mac is defined %}
+  {%- if server.base_mac is defined %}
+    {%- if server.base_mac != server.dvr_base_mac %}
+dvr_base_mac = {{ server.dvr_base_mac }}
+    {%- endif %}
+  {%- else %}
+dvr_base_mac = {{ server.dvr_base_mac }}
+  {%- endif %}
+{%- endif %}
 
 # System-wide flag to determine the type of router that tenants can create.
 # Only admin can override. (boolean value)
diff --git a/tests/pillar/compute_dvr.sls b/tests/pillar/compute_dvr.sls
index f172d70..9213e38 100644
--- a/tests/pillar/compute_dvr.sls
+++ b/tests/pillar/compute_dvr.sls
@@ -1,5 +1,7 @@
 neutron:
   compute:
+    base_mac: fa:16:3f:00:00:00
+    dvr_base_mac: fa:16:3f:a0:00:00
     agent_mode: dvr
     backend:
       engine: ml2
@@ -22,4 +24,4 @@
       host: 127.0.0.1
       password: password
       workers: 2
-    version: mitaka
\ No newline at end of file
+    version: pike
diff --git a/tests/pillar/control_dvr.sls b/tests/pillar/control_dvr.sls
index 1bf7b7a..5e797d0 100644
--- a/tests/pillar/control_dvr.sls
+++ b/tests/pillar/control_dvr.sls
@@ -1,5 +1,7 @@
 neutron:
   server:
+    base_mac: fa:16:3f:00:00:00
+    dvr_base_mac: fa:16:3f:a0:00:00
     api_workers: 2
     rpc_workers: 2
     rpc_state_report_workers: 2
@@ -47,7 +49,7 @@
       port: 5672
       user: openstack
       virtual_host: /openstack
-    version: mitaka
+    version: pike
     policy:
       create_subnet: 'rule:admin_or_network_owner'
       'get_network:queue_id': 'rule:admin_only'
diff --git a/tests/pillar/gateway_dvr.sls b/tests/pillar/gateway_dvr.sls
index fb3acd6..2751c75 100644
--- a/tests/pillar/gateway_dvr.sls
+++ b/tests/pillar/gateway_dvr.sls
@@ -1,5 +1,7 @@
 neutron:
   gateway:
+    base_mac: fa:16:3f:00:00:00
+    dvr_base_mac: fa:16:3f:a0:00:00
     agent_mode: dvr_snat
     backend:
       engine: ml2
@@ -22,4 +24,4 @@
       host: 127.0.0.1
       password: password
       workers: 2
-    version: mitaka
\ No newline at end of file
+    version: pike