summaryrefslogtreecommitdiffstats
path: root/installation/ansible-server/src
diff options
context:
space:
mode:
authorEnbo Wang <wangenbo@huawei.com>2019-04-05 14:13:00 +0000
committerEnbo Wang <wangenbo@huawei.com>2019-04-09 13:23:08 +0000
commitb81c082fb9c4e587c8b37029aee57c68094426e4 (patch)
tree029dc4fe7c276f0b805d63acc487ec4e09e6706d /installation/ansible-server/src
parent9393046f20cfd9e8df1c3ad0a59f565737f1f3a0 (diff)
Add a new Ansible playbook for PNF software upgrade
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
Diffstat (limited to 'installation/ansible-server/src')
-rw-r--r--installation/ansible-server/src/main/Playbooks/ansible_huawei_upgrade@0.01.yml79
1 files changed, 79 insertions, 0 deletions
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
index 00000000..51402726
--- /dev/null
+++ b/installation/ansible-server/src/main/Playbooks/ansible_huawei_upgrade@0.01.yml
@@ -0,0 +1,79 @@
+---
+- hosts: all
+ tasks:
+
+ - name: compatible with parameter targetSwVersion
+ set_fact:
+ sw_to_be_downloaded: "{{targetSwVersion}}"
+ when: targetSwVersion is defined
+
+ - name: support new parameter swToBeDownloaded
+ set_fact:
+ sw_to_be_downloaded: "{{swToBeDownloaded}}"
+ when: swToBeDownloaded is defined
+
+ - name: compatible with parameter pnfId
+ set_fact:
+ ne_identifier: "{{pnfId}}"
+ when: pnfId is defined
+
+ - name: support new parameter neIdentifier
+ set_fact:
+ ne_identifier: "{{neIdentifier}}"
+ when: neIdentifier is defined
+
+ - name: execute downloadNESw operation
+ shell: ./swm/downloadNESw.sh --swToBeDownloaded {{sw_to_be_downloaded}} --neIdentifier {{ne_identifier}}
+ register: download_result
+
+ - name: parse response of downloadNESw
+ set_fact:
+ download_response: "{{ download_result.stdout | from_json }}"
+
+ - name: fetch file of Notification notifyDownloadNESwStatusChanged
+ fetch:
+ dest: /tmp/
+ src: /tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}
+
+ - name: read contents of Notification notifyDownloadNESwStatusChanged
+ set_fact:
+ download_notification: "{{ lookup('file', '/tmp/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}') | from_json }}"
+
+ - name: delete file of Notification notifyDownloadNESwStatusChanged
+ local_action: file path="/tmp/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}" state=absent
+
+ - name: execute installNESw operation
+ shell: ./swm/installNESw.sh --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}
+ register: install_result
+ with_items: "{{ download_notification.downloadedNESwInfo }}"
+
+ - name: parse responses of all the installNESws
+ set_fact:
+ install_responses: "{{ install_responses | default([]) + [item.stdout | from_json] }}"
+ with_items: "{{ install_result.results }}"
+
+ - name: fetch files of all the Notifications notifyInstallNESwStatusChanged
+ fetch:
+ dest: /tmp/
+ src: /tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}
+ with_items: "{{ install_responses }}"
+
+ - name: read contents of all the Notifications notifyInstallNESwStatusChanged
+ set_fact:
+ install_notifications: "{{ install_notifications | default([]) + [lookup('file', '/tmp/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}') | from_json] }}"
+ with_items: "{{ install_responses }}"
+
+ - name: delete files of all the Notifications notifyInstallNESwStatusChanged
+ local_action: file path="/tmp/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}" state=absent
+ with_items: "{{ install_responses }}"
+
+ - name: parse all the installed NE SW info
+ set_fact:
+ installed_ne_sw_info: "{{ installed_ne_sw_info | default([]) + item.installedNESwInfo }}"
+ with_items: "{{ install_notifications }}"
+
+ - name: execute activateNESw operation
+ shell: ./swm/activateNESw.sh --swVersionToBeActivated {{item}} --neIdentifier {{ne_identifier}}
+ register: activate_result
+ with_items: "{{ installed_ne_sw_info }}"
+