Add a new Ansible playbook for PNF software upgrade 53/84353/3
authorEnbo Wang <wangenbo@huawei.com>
Fri, 5 Apr 2019 14:13:00 +0000 (14:13 +0000)
committerEnbo Wang <wangenbo@huawei.com>
Tue, 9 Apr 2019 13:23:08 +0000 (13:23 +0000)
Use sub-operations from 3GPP (downloadNESw, installNESw and activateNESw) to
implement PNF software upgrade.

Change-Id: I5aa42ca480b022c644c806bb4dc49cb01d331e2c
Issue-ID: SDNC-677
Signed-off-by: Enbo Wang <wangenbo@huawei.com>
Former-commit-id: ea56262eac852b10354fe4d4fdd6a56a8d74663c

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