Playbook for setting up XOS for MWC demo

Change-Id: I43ca514c2d16f757715d8047478b91c35c6ddab7
diff --git a/test/roles/test-mcord-base/defaults/main.yml b/test/roles/test-mcord-base/defaults/main.yml
new file mode 100644
index 0000000..f4572f7
--- /dev/null
+++ b/test/roles/test-mcord-base/defaults/main.yml
@@ -0,0 +1,48 @@
+---
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# test-mcord-base/defaults/main.yml
+
+test_networks:
+  - management
+  - sgi_network
+  - s11_network
+  - s1mme_network
+  - sbi_network
+  - nbi_network
+
+test_services:
+  - internetemulator
+  - vmme
+  - vspgwc
+  - sdncontroller
+  - vspgwu
+
+test_ports:
+  - { vm: vmme, network: management }
+  - { vm: vmme, network: s11_network }
+  - { vm: vmme, network: s1mme_network }
+  - { vm: vspgwc, network: management }
+  - { vm: vspgwc, network: s11_network }
+  - { vm: vspgwc, network: nbi_network }
+  - { vm: sdncontroller, network: management }
+  - { vm: sdncontroller, network: nbi_network }
+  - { vm: sdncontroller, network: sbi_network }
+  - { vm: vspgwu, network: management }
+  - { vm: vspgwu, network: s1u_network }
+  - { vm: vspgwu, network: sgi_network }
+  - { vm: vspgwu, network: sbi_network }
+  - { vm: internetemulator, network: management }
+  - { vm: internetemulator, network: sgi_network }
diff --git a/test/roles/test-mcord-base/tasks/main.yml b/test/roles/test-mcord-base/tasks/main.yml
new file mode 100644
index 0000000..111e019
--- /dev/null
+++ b/test/roles/test-mcord-base/tasks/main.yml
@@ -0,0 +1,68 @@
+---
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# test-mcord-base/tasks/main.yml
+# Run tests to check that the base elements of M-CORD are present
+
+- name: Wait for networks to be synchronized
+  shell: source /opt/cord_profile/admin-openrc.sh; neutron net-list|grep '{{ item }}' > /dev/null
+  args:
+    executable: /bin/bash
+  register: result
+  until: result | success
+  retries: 10
+  delay: 60
+  with_items: "{{ test_networks }}"
+  tags:
+    - skip_ansible_lint # running a sub job
+
+- name: Wait for VMs to appear in Nova
+  shell: source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item }}' > /dev/null
+  args:
+    executable: /bin/bash
+  register: result
+  until: result | success
+  retries: 10
+  delay: 60
+  with_items: "{{ test_services }}"
+  tags:
+    - skip_ansible_lint # running a sub job
+
+- name: Delete any VMs that are in ERROR state (XOS will re-create them)
+  shell: source /opt/cord_profile/admin-openrc.sh; for vm in $(nova list --all-tenants|grep 'ERROR'|awk '{ print $2 }'); do nova delete $vm; done
+  args:
+    executable: /bin/bash
+  tags:
+    - skip_ansible_lint # running a sub job
+
+- name: Wait for VMs to come up
+  shell: source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item }}.*ACTIVE' > /dev/null
+  args:
+    executable: /bin/bash
+  register: result
+  until: result | success
+  retries: 10
+  delay: 60
+  with_items: "{{ test_services }}"
+  tags:
+    - skip_ansible_lint # running a sub job
+
+- name: Verify that VMs are properly networked
+  shell: source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item.vm }}.*ACTIVE.*{{ item.network }}' > /dev/null
+  args:
+    executable: /bin/bash
+  with_items: "{{ test_ports }}"
+  tags:
+    - skip_ansible_lint # running a sub job