CORD-2133 Automate running ng40 test
Change-Id: Ie7b0e40797dd19adeed0533c73b3b7d28d70293e
diff --git a/mcord-ng40-test-playbook.yml b/mcord-ng40-test-playbook.yml
index 89ca318..7505db0 100644
--- a/mcord-ng40-test-playbook.yml
+++ b/mcord-ng40-test-playbook.yml
@@ -65,3 +65,4 @@
- create-epc
- test-mcord-base
- epc-synced
+ - run-ng40
diff --git a/roles/run-ng40/defaults/main.yml b/roles/run-ng40/defaults/main.yml
new file mode 100644
index 0000000..0253d35
--- /dev/null
+++ b/roles/run-ng40/defaults/main.yml
@@ -0,0 +1,19 @@
+---
+
+# 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.
+
+mcord_ng40_license_email: do.not.distribute@opennetworking.org
+mcord_ng40_login: ng40
+mcord_ng40_password: ng40
\ No newline at end of file
diff --git a/roles/run-ng40/tasks/main.yml b/roles/run-ng40/tasks/main.yml
new file mode 100644
index 0000000..49dafaf
--- /dev/null
+++ b/roles/run-ng40/tasks/main.yml
@@ -0,0 +1,49 @@
+---
+
+# 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.
+
+- name: Get ID of VM
+ shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep mysite_venb|cut -d '|' -f 2"
+ register: nova_id
+ tags:
+ - skip_ansible_lint # running a sub job
+
+- name: Get mgmt IP of VM
+ shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova interface-list {{ nova_id.stdout }}|grep -o -m 1 '172\.27\.[[:digit:]]*\.[[:digit:]]*'"
+ register: mgmt_ip
+ tags:
+ - skip_ansible_lint # running a sub job
+
+- name: Get name of compute node
+ shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova show {{ nova_id.stdout }}|grep hypervisor_hostname|cut -d '|' -f 3"
+ register: node_name
+ tags:
+ - skip_ansible_lint # running a sub job
+
+- name: Write email address to file
+ shell: sshpass -p {{ mcord_ng40_password }} ssh -o ProxyCommand="ssh -W %h:%p -l ubuntu {{ node_name.stdout }}" {{ mcord_ng40_login }}@{{ mgmt_ip.stdout }} "sudo bash -c 'echo {{ mcord_ng40_license_email }} > /opt/ng4t/etc/email'"
+ tags:
+ - skip_ansible_lint # running a sub job
+
+- name: Run ./verify_quick.sh and check for VERDICT_PASS
+ shell: sshpass -p {{ mcord_ng40_password }} ssh -o ProxyCommand="ssh -W %h:%p -l ubuntu {{ node_name.stdout }}" {{ mcord_ng40_login }}@{{ mgmt_ip.stdout }} "./verify_quick.sh"
+ register: result
+ failed_when: "'VERDICT_PASS' not in result.stdout"
+ tags:
+ - skip_ansible_lint # running a sub job
+
+- name: Print result of test
+ debug:
+ var: result.stdout_lines
\ No newline at end of file