VTN initialization checks

Change-Id: I4f971d24dc520c6b2782a9526629de0e4ad52820
diff --git a/cord-post-deploy-playbook.yml b/cord-post-deploy-playbook.yml
index a562c5b..343fd98 100644
--- a/cord-post-deploy-playbook.yml
+++ b/cord-post-deploy-playbook.yml
@@ -11,6 +11,12 @@
         - vars/cord.yml
         - vars/example_keystone.yml
 
+- name: Run platform checks
+  hosts: head
+  become: no
+  roles:
+    - platform-check
+
 - name: Create test client
   hosts: head
   become: yes
diff --git a/roles/platform-check/tasks/main.yml b/roles/platform-check/tasks/main.yml
new file mode 100644
index 0000000..035945f
--- /dev/null
+++ b/roles/platform-check/tasks/main.yml
@@ -0,0 +1,38 @@
+---
+# platform-check/tasks/main.yml
+
+- name: Ensure br-int exists on all compute nodes (check VTN)
+  shell: ansible -i /etc/maas/ansible/pod-inventory compute -u ubuntu -m shell -s -a "ovs-vsctl br-exists br-int"
+  register: result
+  until: result | success
+  retries: 6
+  delay: 10
+  ignore_errors: yes
+  tags:
+    - skip_ansible_lint # running a sub job
+
+# Work around issues with ONOS intialization
+- name: Restart ONOS when VTN initialization failed
+  when: result | failed
+  shell: docker-compose stop; docker-compose rm -f; docker-compose up -d
+  args:
+    chdir: "{{ onos_cord_dest }}"
+  tags:
+    - skip_ansible_lint
+
+- name: Tell XOS to refresh VTN configuration
+  when: result | failed
+  make:
+    chdir: "{{ service_profile_repo_dest }}/{{ xos_configuration }}"
+    target: vtn
+
+- name: Ensure br-int exists on all compute nodes (check VTN #2)
+  when: result | failed
+  shell: ansible -i /etc/maas/ansible/pod-inventory compute -u ubuntu -m shell -s -a "ovs-vsctl br-exists br-int"
+  register: result2
+  until: result2 | success
+  retries: 12
+  delay: 10
+  tags:
+    - skip_ansible_lint # running a sub job
+
diff --git a/roles/test-exampleservice/tasks/main.yml b/roles/test-exampleservice/tasks/main.yml
index 7462e75..331dfcf 100644
--- a/roles/test-exampleservice/tasks/main.yml
+++ b/roles/test-exampleservice/tasks/main.yml
@@ -8,11 +8,6 @@
     chdir: "{{ service_profile_repo_dest }}/{{ xos_configuration }}"
     target: exampleservice
 
-- name: Re-run 'make vtn' (work around bug in synchronizer)
-  make:
-    chdir: "{{ service_profile_repo_dest }}/{{ xos_configuration }}"
-    target: vtn
-
 - name: Wait for ExampleService VM to come up
   shell: bash -c "source ~/admin-openrc.sh; nova list --all-tenants|grep 'exampleservice.*ACTIVE' > /dev/null"
   register: result
diff --git a/roles/test-vsg/tasks/main.yml b/roles/test-vsg/tasks/main.yml
index fa0502b..4a44e7b 100644
--- a/roles/test-vsg/tasks/main.yml
+++ b/roles/test-vsg/tasks/main.yml
@@ -8,26 +8,12 @@
     chdir: "{{ service_profile_repo_dest }}/{{ xos_configuration }}"
     target: cord-subscriber
 
-- name: Re-run 'make vtn' (work around bug in synchronizer)
-  make:
-    chdir: "{{ service_profile_repo_dest }}/{{ xos_configuration }}"
-    target: vtn
-
 - name: Get name of compute node
   shell: bash -c "source ~/admin-openrc.sh; nova service-list|grep nova-compute|cut -d '|' -f 3"
   register: node_name
   tags:
     - skip_ansible_lint # running a sub job
 
-- name: Ensure br-int has been created on compute node
-  shell: ssh -l ubuntu {{ node_name.stdout }} sudo ovs-vsctl br-exists br-int
-  register: result
-  until: result | success
-  retries: 10
-  delay: 10
-  tags:
-    - skip_ansible_lint # running a sub job
-
 - name: Wait for vSG VM to come up
   shell: bash -c "source ~/admin-openrc.sh; nova list --all-tenants|grep 'vsg.*ACTIVE' > /dev/null"
   register: result