Update Ansible playbook for PNF software upgrade 49/86049/1
authorEnbo Wang <wangenbo@huawei.com>
Tue, 23 Apr 2019 13:01:04 +0000 (13:01 +0000)
committerEnbo Wang <wangenbo@huawei.com>
Tue, 23 Apr 2019 13:01:04 +0000 (13:01 +0000)
Change-Id: I040cd9e18ce4487977b0715ff19b9830ca1a9eb9
Issue-ID: SDNC-677
Signed-off-by: Enbo Wang <wangenbo@huawei.com>
Former-commit-id: 433d1365c80e001bda8d4461057ad333d3589316

installation/ansible-server/src/main/Playbooks/ansible_huawei_upgrade@0.01.yml

index 5140272..4ebe69f 100644 (file)
       ne_identifier: "{{neIdentifier}}"\r
     when: neIdentifier is defined\r
 \r
+  - name: support new parameter swToBeInstalled\r
+    set_fact:\r
+      sw_to_be_installed: "{{swToBeInstalled}}"\r
+    when: swToBeInstalled is defined\r
+\r
+  - name: check if swToBeInstalled is empty\r
+    fail:\r
+    when: swToBeInstalled is defined and sw_to_be_installed | length == 0\r
+\r
+  - name: support new parameter swVersionToBeActivated\r
+    set_fact:\r
+      sw_version_to_be_activated: "{{swVersionToBeActivated}}"\r
+    when: swVersionToBeActivated is defined\r
+\r
   - name: execute downloadNESw operation\r
-    shell: ./swm/downloadNESw.sh --swToBeDownloaded {{sw_to_be_downloaded}} --neIdentifier {{ne_identifier}}\r
+    shell: ./swm/downloadNESw --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
+    when: swToBeInstalled is not defined\r
 \r
   - name: fetch file of Notification notifyDownloadNESwStatusChanged\r
     fetch:\r
-      dest: /tmp/\r
-      src: /tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}\r
+      dest: "{{inventory_dir}}"\r
+      src: "/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}"\r
+    when: swToBeInstalled is not defined\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
+      download_notification: "{{ lookup('file', '{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}') | from_json }}"\r
+    when: swToBeInstalled is not defined\r
 \r
   - name: delete file of Notification notifyDownloadNESwStatusChanged\r
-    local_action: file path="/tmp/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}" state=absent\r
+    local_action: file path="{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyDownloadNESwStatusChanged-{{download_response.downloadProcessId}}" state=absent\r
+    when: swToBeInstalled is not defined\r
+\r
+  - name: set downloadedNESwInfo\r
+    set_fact:\r
+      downloaded_ne_sw_info: "{{ download_notification.downloadedNESwInfo }}"\r
+    when: swToBeInstalled is not defined\r
 \r
   - name: execute installNESw operation\r
-    shell: ./swm/installNESw.sh --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}\r
+    shell: ./swm/installNESw --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}\r
     register: install_result\r
-    with_items: "{{ download_notification.downloadedNESwInfo }}"\r
+    with_items: "{{ downloaded_ne_sw_info | default([]) }}"\r
+\r
+  - name: execute installNESw operation using new parameter\r
+    shell: ./swm/installNESw --swToBeInstalled {{item}} --neIdentifier {{ne_identifier}}\r
+    register: install_result_new\r
+    with_items: "{{ sw_to_be_installed | default([]) }}"\r
+\r
+  - name: unify install result\r
+    set_fact:\r
+      install_result: "{{ install_result_new }}"\r
+    when: swToBeInstalled is defined\r
+\r
+  - name: set install results list\r
+    set_fact:\r
+      install_results_list: "{{ install_result.results }}"\r
+    when: swVersionToBeActivated is not defined\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
+    with_items: "{{ install_results_list | default([]) }}"\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
+      dest: "{{inventory_dir}}"\r
+      src: "/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}"\r
+    with_items: "{{ install_responses | default([]) }}"\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
+      install_notifications: "{{ install_notifications | default([]) + [lookup('file', '{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}') | from_json] }}"\r
+    with_items: "{{ install_responses | default([]) }}"\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
+    local_action: file path="{{inventory_dir}}/{{inventory_hostname}}/tmp/notifyInstallNESwStatusChanged-{{item.installProcessId}}" state=absent\r
+    with_items: "{{ install_responses | default([]) }}"\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
+    with_items: "{{ install_notifications | default([]) }}"\r
 \r
   - name: execute activateNESw operation\r
-    shell: ./swm/activateNESw.sh --swVersionToBeActivated {{item}} --neIdentifier {{ne_identifier}}\r
+    shell: ./swm/activateNESw --swVersionToBeActivated {{item}} --neIdentifier {{ne_identifier}}\r
     register: activate_result\r
-    with_items: "{{ installed_ne_sw_info }}"\r
+    with_items: "{{ installed_ne_sw_info | default([]) }}"\r
+\r
+  - name: execute activateNESw operation using new parameter\r
+    shell: ./swm/activateNESw --swVersionToBeActivated {{sw_version_to_be_activated}} --neIdentifier {{ne_identifier}}\r
+    register: activate_result_new\r
+    when: swVersionToBeActivated is defined\r
+\r
+  - name: unify activate result\r
+    set_fact:\r
+      activate_result: "{{ activate_result_new }}"\r
+    when: swVersionToBeActivated is defined\r
 \r