summaryrefslogtreecommitdiffstats
path: root/installation/ansible-server/src
diff options
context:
space:
mode:
authorEnbo Wang <wangenbo@huawei.com>2019-12-13 19:58:23 +0800
committerEnbo Wang <wangenbo@huawei.com>2019-12-13 19:58:23 +0800
commitf5a63c57879141bd9e1054de41a901cdbd802e7f (patch)
treef86d00350fb204f5c3f8290f24263f789c541e30 /installation/ansible-server/src
parentb9af5d6e4625a9eab2f235f3b437f54fa963ed88 (diff)
Add DGs and Ansible playbooks for downloadNESw and activateNESw
Provide DGs and Ansible playbooks for downloadNESw and activateNESw. Change-Id: Ie1986c5fa9296be64f5f5a7daba9b37568c49710 Issue-ID: SDNC-857 Signed-off-by: Enbo Wang <wangenbo@huawei.com> Former-commit-id: e230b8417389625b80b1e0f39405b8dc73322c78
Diffstat (limited to 'installation/ansible-server/src')
-rw-r--r--installation/ansible-server/src/main/Playbooks/ansible_huawei_activatenesw@0.00.yml64
-rw-r--r--installation/ansible-server/src/main/Playbooks/ansible_huawei_downloadnesw@0.00.yml64
2 files changed, 128 insertions, 0 deletions
diff --git a/installation/ansible-server/src/main/Playbooks/ansible_huawei_activatenesw@0.00.yml b/installation/ansible-server/src/main/Playbooks/ansible_huawei_activatenesw@0.00.yml
new file mode 100644
index 00000000..bee98aa7
--- /dev/null
+++ b/installation/ansible-server/src/main/Playbooks/ansible_huawei_activatenesw@0.00.yml
@@ -0,0 +1,64 @@
+---
+- hosts: all
+ tasks:
+
+ - name: parameter neIdentifier
+ set_fact:
+ ne_identifier: "{{neIdentifier}}"
+ when: neIdentifier is defined
+
+ - name: parameter swVersionToBeActivated
+ set_fact:
+ sw_version_to_be_activated: "{{swVersionToBeActivated}}"
+ when: swVersionToBeActivated is defined
+
+ - name: compatible with parameter pnfId
+ set_fact:
+ ne_identifier: "{{pnfId}}"
+ when: neIdentifier is not defined and pnfId is defined
+
+ - name: execute activateNESw operation
+ shell: ./swm/activateNESw --swVersionToBeActivated {{sw_version_to_be_activated}} --neIdentifier {{ne_identifier}}
+ ignore_errors: yes
+ register: activate_result
+
+ - name: parse response of activateNESw
+ set_fact:
+ activate_response: "{{ activate_result.stdout | from_json }}"
+
+ - name: build failure message
+ set_fact:
+ activate_failure_msg: "{{ activate_result.stdout }}"
+ when: activate_result is failed
+
+ - name: write failure message to file
+ local_action: copy content="{{activate_failure_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
+ when: activate_result is failed
+
+ - name: use result of activateNESw as the result of Playbook
+ fail:
+ msg: "{{activate_failure_msg}}"
+ when: activate_result is failed
+
+ - name: fetch file of Notification notifyActivateNESwStatusChanged
+ fetch:
+ dest: "{{inventory_dir}}"
+ src: "/tmp/notifyActivateNESwStatusChanged-{{activate_response.activateProcessId}}"
+
+ - name: read contents of Notification notifyActivateNESwStatusChanged
+ set_fact:
+ activate_notification: "{{ lookup('file', '{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyActivateNESwStatusChanged-{{activate_response.activateProcessId}}') | from_json }}"
+
+ - name: delete file of Notification notifyActivateNESwStatusChanged
+ local_action: file path="{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyActivateNESwStatusChanged-{{activate_response.activateProcessId}}" state=absent
+
+ - name: build success message
+ set_fact:
+ activate_success_msg:
+ "result": "Success"
+ when: activate_notification.activateOperationStatus == "NE_SWACTIVATION_SUCCESSFUL"
+
+ - name: write success message to file
+ local_action: copy content="{{activate_success_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
+ when: activate_notification.activateOperationStatus == "NE_SWACTIVATION_SUCCESSFUL"
+
diff --git a/installation/ansible-server/src/main/Playbooks/ansible_huawei_downloadnesw@0.00.yml b/installation/ansible-server/src/main/Playbooks/ansible_huawei_downloadnesw@0.00.yml
new file mode 100644
index 00000000..77bc21b3
--- /dev/null
+++ b/installation/ansible-server/src/main/Playbooks/ansible_huawei_downloadnesw@0.00.yml
@@ -0,0 +1,64 @@
+---
+- hosts: all
+ tasks:
+
+ - name: parameter neIdentifier
+ set_fact:
+ ne_identifier: "{{neIdentifier}}"
+ when: neIdentifier is defined
+
+ - name: parameter swToBeDownloaded
+ set_fact:
+ sw_to_be_downloaded: "{{swToBeDownloaded}}"
+ when: swToBeDownloaded is defined
+
+ - name: compatible with parameter pnfId
+ set_fact:
+ ne_identifier: "{{pnfId}}"
+ when: neIdentifier is not defined and pnfId is defined
+
+ - name: execute downloadNESw operation
+ shell: ./swm/downloadNESw --neIdentifier {{ne_identifier}} --swToBeDownloaded {{sw_to_be_downloaded}}
+ ignore_errors: yes
+ register: download_result
+
+ - name: parse response of downloadNESw
+ set_fact:
+ download_response: "{{ download_result.stdout | from_json }}"
+
+ - name: build failure message
+ set_fact:
+ download_failure_msg: "{{ download_result.stdout }}"
+ when: download_result is failed
+
+ - name: write failure message to file
+ local_action: copy content="{{download_failure_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
+ when: download_result is failed
+
+ - name: use result of downloadNESw as the result of Playbook
+ fail:
+ msg: "{{download_failure_msg}}"
+ when: download_result is failed
+
+ - name: fetch file of Notification notifyDownloadNESwStatusChanged
+ fetch:
+ dest: "{{inventory_dir}}"
+ src: "/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}"
+
+ - name: read contents of Notification notifyDownloadNESwStatusChanged
+ set_fact:
+ download_notification: "{{ lookup('file', '{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}') | from_json }}"
+
+ - name: delete file of Notification notifyDownloadNESwStatusChanged
+ local_action: file path="{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}" state=absent
+
+ - name: build success message
+ set_fact:
+ download_success_msg:
+ "result": "Success"
+ when: download_notification.downloadOperationStatus == "NE_SWDOWNLOAD_SUCCESSFUL"
+
+ - name: write success message to file
+ local_action: copy content="{{download_success_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"
+ when: download_notification.downloadOperationStatus == "NE_SWDOWNLOAD_SUCCESSFUL"
+