Simulate vtep when baremetal_tor is defined

This patch allows to connect ironic VMs to the ovs switch
and setup vtep simulator that will allow to use it by
openctonrail.

Change-Id: I03d793cef99ac4486848b87c0024be5ca3849f12
diff --git a/baremetal_simulator/init.sls b/baremetal_simulator/init.sls
index 1cfdfa4..36247e6 100644
--- a/baremetal_simulator/init.sls
+++ b/baremetal_simulator/init.sls
@@ -11,6 +11,64 @@
     - require:
       - simulator_pkgs
 
+{%- if baremetal_simulator.get('tor', {}).get('enabled', False) %}
+
+openvswitch-vtep-pkg:
+  pkg.installed:
+    - name: openvswitch-vtep
+
+openvswitch-vtep.init:
+  file.managed:
+    - name: /etc/init.d/openvswitch-vtep
+    - source: salt://baremetal_simulator/files/openvswitch/openvswitch-vtep.init
+    - require:
+      - openvswitch-vtep-pkg
+
+openvswitch-vtep.default:
+  file.managed:
+    - name: /etc/default/openvswitch-vtep
+    - source: salt://baremetal_simulator/files/openvswitch/openvswitch-vtep.default
+    - require:
+      - openvswitch-vtep-pkg
+
+openvswitch-vtep:
+  service.running:
+    - watch:
+      - file: /etc/init.d/openvswitch-vtep
+      - file: /etc/default/openvswitch-vtep
+    - require:
+      - openvswitch-vtep.init
+      - openvswitch-vtep.default
+
+br_simulator_ps_present:
+  cmd.run:
+    - name: vtep-ctl add-ps br-simulator
+    - unless: vtep-ctl ps-exists br-simulator
+
+br_simulator_vtep_tunnel:
+  cmd.run:
+    - name: vtep-ctl set Physical_Switch br-simulator tunnel_ips={{ baremetal_simulator.tor.tunnel_ips }}
+    - unless: vtep-ctl show br-baremetal | grep -q "tunnel_ips.*{{ baremetal_simulator.tor.tunnel_ips }}"
+    - require:
+      - br_simulator_ps_present
+
+br_simulator_vtep_management:
+  cmd.run:
+    - name: vtep-ctl set Physical_Switch br-simulator management_ips={{ baremetal_simulator.tor.tunnel_ips }}
+    - unless: vtep-ctl show br-baremetal | grep -q "management_ips.*{{ baremetal_simulator.tor.tunnel_ips }}"
+    - require:
+      - br_simulator_ps_present
+
+br_simulator_vtep:
+  cmd.run:
+    - name: /usr/share/openvswitch/scripts/ovs-vtep --log-file=/var/log/openvswitch/ovs-vtep.log --pidfile=/var/run/openvswitch/ovs-vtep.pid --detach br-simulator
+    - unless: ps xafu |grep -v grep |grep -q "ovs-vtep .* br-simulator"
+    - require:
+      - br_simulator_vtep_management
+      - br_simulator_vtep_tunnel
+
+{%- endif %}
+
 libvirt-bin:
   service.running:
     - watch: