Introduce ipflush_onchange

Change-Id: I4dc6d6db82dc4074ed247b7fc0c29bfdc867b0d6
diff --git a/README.rst b/README.rst
index 31c4701..7d67889 100644
--- a/README.rst
+++ b/README.rst
@@ -847,6 +847,26 @@
             use_interfaces:
             - eth1
 
+Debian manual proto interfaces
+
+When you are changing interface proto from static in up state to manual, you
+may need to flush ip addresses. For example, if you want to use the interface
+and the ip on the bridge. This can be done by setting the ``ipflush_onchange``
+to true.
+
+.. code-block:: yaml
+
+    linux:
+      network:
+        interface:
+          eth1:
+            enabled: true
+            type: eth
+            proto: manual
+            mtu: 9100
+            ipflush_onchange: true
+
+
 Concatinating and removing interface files
 
 Debian based distributions have `/etc/network/interfaces.d/` directory, where
diff --git a/linux/network/interface.sls b/linux/network/interface.sls
index e0bc67f..7d99ec2 100644
--- a/linux/network/interface.sls
+++ b/linux/network/interface.sls
@@ -205,6 +205,16 @@
   - mode: {{ interface.mode }}
   {%- endif %}
 
+{%- if interface.get('ipflush_onchange', False) %}
+
+linux_interface_ipflush_onchange_{{ interface_name }}:
+  cmd.run:
+  - name: "/sbin/ip address flush dev {{ interface_name }}"
+  - onchanges:
+    - network: linux_interface_{{ interface_name }}
+
+{%- endif %}
+
 {%- for network in interface.get('use_ovs_ports', []) %}
 
 remove_interface_{{ network }}_line1: