From f5a63c57879141bd9e1054de41a901cdbd802e7f Mon Sep 17 00:00:00 2001 From: Enbo Wang Date: Fri, 13 Dec 2019 19:58:23 +0800 Subject: 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 Former-commit-id: e230b8417389625b80b1e0f39405b8dc73322c78 --- .../Playbooks/ansible_huawei_activatenesw@0.00.yml | 64 ++++++++++++++++++++++ .../Playbooks/ansible_huawei_downloadnesw@0.00.yml | 64 ++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 installation/ansible-server/src/main/Playbooks/ansible_huawei_activatenesw@0.00.yml create mode 100644 installation/ansible-server/src/main/Playbooks/ansible_huawei_downloadnesw@0.00.yml (limited to 'installation/ansible-server') 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" + -- cgit 1.2.3-korg