Merge "Add a new Ansible playbook for PNF software upgrade"
authorDan Timoney <dtimoney@att.com>
Tue, 9 Apr 2019 16:44:49 +0000 (16:44 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 9 Apr 2019 16:44:49 +0000 (16:44 +0000)
Former-commit-id: 018fccd75b035292c12b2ba6ebe98800dc5db8bb

installation/ansible-server/src/main/Playbooks/ansible_huawei_upgrade@0.01.yml [new file with mode: 0644]

diff --git a/installation/ansible-server/src/main/Playbooks/ansible_huawei_upgrade@0.01.yml b/installation/ansible-server/src/main/Playbooks/ansible_huawei_upgrade@0.01.yml
new file mode 100644 (file)
index 0000000..5140272
--- /dev/null
@@ -0,0 +1,79 @@
+---\r
+- hosts: all\r
+  tasks:\r
+\r
+  - name: compatible with parameter targetSwVersion\r
+    set_fact:\r
+      sw_to_be_downloaded: "{{targetSwVersion}}"\r
+    when: targetSwVersion is defined\r
+\r
+  - name: support new parameter swToBeDownloaded\r
+    set_fact:\r
+      sw_to_be_downloaded: "{{swToBeDownloaded}}"\r
+    when: swToBeDownloaded is defined\r
+\r
+  - name: compatible with parameter pnfId\r
+    set_fact:\r
+      ne_identifier: "{{pnfId}}"\r
+    when: pnfId is defined\r
+\r
+  - name: support new parameter neIdentifier\r
+    set_fact:\r
+      ne_identifier: "{{neIdentifier}}"\r
+    when: neIdentifier is defined\r
+\r
+  - name: execute downloadNESw operation\r
+    shell: ./swm/downloadNESw.sh --swToBeDownloaded {{sw_to_be_downloaded}} --neIdentifier {{ne_identifier}}\r
+    register: download_result\r
+\r
+  - name: parse response of downloadNESw\r
+    set_fact:\r
+      download_response: "{{ download_result.stdout | from_json }}"\r
+\r
+  - name: fetch file of Notification notifyDownloadNESwStatusChanged\r
+    fetch:\r
+      dest: /tmp/\r
+      src: /tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}\r
+\r
+  - name: read contents of Notification notifyDownloadNESwStatusChanged\r
+    set_fact:\r
+      download_notification: "{{ lookup('file', '/tmp/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}') | from_json }}"\r
+\r
+  - name: delete file of Notification notifyDownloadNESwStatusChanged\r
+    local_action: file path="/tmp/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}" state=absent\r
+\r
+  - name: execute installNESw operation\r
+    shell: ./swm/installNESw.sh --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}\r
+    register: install_result\r
+    with_items: "{{ download_notification.downloadedNESwInfo }}"\r
+\r
+  - name: parse responses of all the installNESws\r
+    set_fact:\r
+      install_responses: "{{ install_responses | default([]) + [item.stdout | from_json] }}"\r
+    with_items: "{{ install_result.results }}"\r
+\r
+  - name: fetch files of all the Notifications notifyInstallNESwStatusChanged\r
+    fetch:\r
+      dest: /tmp/\r
+      src: /tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}\r
+    with_items: "{{ install_responses }}"\r
+\r
+  - name: read contents of all the Notifications notifyInstallNESwStatusChanged\r
+    set_fact:\r
+      install_notifications: "{{ install_notifications | default([]) + [lookup('file', '/tmp/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}') | from_json] }}"\r
+    with_items: "{{ install_responses }}"\r
+\r
+  - name: delete files of all the Notifications notifyInstallNESwStatusChanged\r
+    local_action: file path="/tmp/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}" state=absent\r
+    with_items: "{{ install_responses }}"\r
+\r
+  - name: parse all the installed NE SW info\r
+    set_fact:\r
+      installed_ne_sw_info: "{{ installed_ne_sw_info | default([]) + item.installedNESwInfo }}"\r
+    with_items: "{{ install_notifications }}"\r
+\r
+  - name: execute activateNESw operation\r
+    shell: ./swm/activateNESw.sh --swVersionToBeActivated {{item}} --neIdentifier {{ne_identifier}}\r
+    register: activate_result\r
+    with_items: "{{ installed_ne_sw_info }}"\r
+\r