Skip to content

Commit

Permalink
AV-69041: [ansible-csp-se] Location to lookup SE image path in Contro…
Browse files Browse the repository at this point in the history
…ller should be changed (#28)
  • Loading branch information
chaitanyaavi authored and Gaurav Rastogi committed Sep 9, 2019
1 parent fdc7f77 commit 94f423a
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions tasks/qcow_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- name: Avi SE | CSP | Service deploy | Get CSP version

- name: Avi SE | CSP | Image deploy | Get CSP version
uri:
url: "https://{{ se_csp_host }}/api/running/resources/resource/{{ se_csp_platform }}"
method: GET
Expand All @@ -14,7 +15,7 @@
register: se_csp_resource_rsp
delegate_to: localhost

- name: Avi SE | CSP | Service deploy | Set CSP version
- name: Avi SE | CSP | Image deploy | Set CSP version
set_fact:
se_csp_resource_info: "{{ se_csp_resource_rsp.content|from_json }}"

Expand Down Expand Up @@ -46,18 +47,42 @@
when: se_image_exists.status == 200 and se_csp_resource_info['resource:resource'].csp_version >= "02.04"

- block:
- name: Avi SE | CSP | Image deploy | Set SE image path for controller version < 18.2.6
set_fact:
se_image_path: "/opt/avi/se_ova"
when: se_master_ctl_version < "18.2.6"

- block:
- name: Avi SE | CSP | Image deploy | Get controller tag
avi_api_session:
controller: "{{ se_master_ctl_ip }}"
username: "{{ se_master_ctl_username }}"
password: "{{ se_master_ctl_password }}"
api_version: "{{ se_master_ctl_version }}"
tenant: admin
http_method: get
path: "initial-data"
register: data_res
delegate_to: localhost

- name: Avi SE | CSP | Image deploy | Set SE image path for controller version >= 18.2.6
set_fact:
se_image_path: "/host/pkgs/{{ data_res.obj.version.Tag }}"

when: se_master_ctl_version >= "18.2.6"

- name: Avi SE | CSP | Image deploy | Verify qcow exists on controller
stat:
path: "/opt/avi/se_ova/{{ se_csp_qcow_image_file }}"
path: "{{ se_image_path }}/{{ se_csp_qcow_image_file }}"
register: se_qcow_status
- block:
- name: Avi SE | CSP | Image deploy | generate SE image if not exist on controller
delegate_to: localhost
avi_api_session:
controller: "{{se_master_ctl_ip}}"
username: "{{se_master_ctl_username}}"
password: "{{se_master_ctl_password}}"
api_version: "{{se_master_ctl_version}}"
controller: "{{ se_master_ctl_ip }}"
username: "{{ se_master_ctl_username }}"
password: "{{ se_master_ctl_password }}"
api_version: "{{ se_master_ctl_version }}"
http_method: post
path: 'fileservice/seova'
timeout: 600
Expand All @@ -66,11 +91,11 @@
when: (not se_qcow_status.stat.exists) or (se_csp_qcow_force_mode)

- name: Check SE file exists on controller
stat: path=/opt/avi/se_ova/{{ se_csp_qcow_image_file }}
stat: path={{ se_image_path }}/{{ se_csp_qcow_image_file }}
register: se_image_file

- name: Copy SE image to new filename
command: cp /opt/avi/se_ova/{{ se_csp_qcow_image_file }} /tmp/{{ se_csp_qcow_image_name }}
command: cp {{ se_image_path }}/{{ se_csp_qcow_image_file }} /tmp/{{ se_csp_qcow_image_name }}
when: se_image_file.stat.exists

- name: Avi SE | CSP | Image deploy | SCP qcow to csp device
Expand Down Expand Up @@ -98,11 +123,11 @@
validate_certs: false
return_content: true
status_code: 200, 204
register: con_image_verify
register: se_image_verify
delegate_to: localhost

- name: Avi SE | CSP | Image deploy | Fail if SCP verification faild
fail:
msg: "SCP to CSP host failed {{ command_result }}"
when: con_image_verify.status != 200 and con_image_verify.status != 204
when: se_image_verify.status != 200 and se_image_verify.status != 204
when: se_image_exists.status != 200

0 comments on commit 94f423a

Please sign in to comment.