Skip to content

Commit

Permalink
AV-35742 #commit Fixed the CSP role to check for disk size based on C…
Browse files Browse the repository at this point in the history
…SP version
  • Loading branch information
Gaurav Rastogi committed Mar 9, 2018
1 parent 8cee4c9 commit ed1f1d0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 67 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ con_csp_num_cpu: 4
con_csp_memory_gb: 16
con_csp_memory_mb: "{{ con_csp_memory_gb|int * 1024 }}"
con_csp_platform: csp-2100
con_csp_compat_version: 02.02.04.00
con_csp_vnics:
- nic: '0'
type: access
Expand Down
116 changes: 49 additions & 67 deletions tasks/service_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
---
- name: Avi Controller | CSP | Service deploy | Check if service already exists
uri:
url: "https://{{ inventory_hostname }}/api/running/services/service/{{ con_csp_service_name }}"
method: GET
user: "{{ con_csp_user }}"
password: "{{ con_csp_password }}"
force_basic_auth: yes
headers:
Accept: '*/*'
validate_certs: false
return_content: true
failed_when: false
register: con_csp_service_exists
delegate_to: localhost

- block:
- set_fact:
con_csp_service_exists_json: "{{ con_csp_service_exists.content|from_json }}"
- debug: msg="Service {{ con_csp_service_exists_json['vsb:service'].name }} already exists."
when: con_csp_service_exists.status == 200

- name: Avi Controller | CSP | Service deploy | Get CSP version
uri:
url: "https://{{ inventory_hostname }}/api/running/resources/resource/{{ con_csp_platform }}"
Expand All @@ -31,7 +10,7 @@
Accept: '*/*'
validate_certs: false
return_content: true
failed_when: false
failed_when: con_csp_resource_rsp.status != 200
register: con_csp_resource_rsp
delegate_to: localhost

Expand All @@ -40,57 +19,37 @@
con_csp_resource_info: "{{ con_csp_resource_rsp.content|from_json }}"
when: con_csp_resource_rsp.status == 200

- name: Avi Controller | CSP | Service deploy | CSP Info
debug: msg="{{con_csp_resource_info.resource:resource}}"
- name: Avi Controller | CSP | Service deploy | CSP resource info
debug: msg="{{con_csp_resource_info['resource:resource']}}"

- name: Avi Controller | CSP < 2.2.4| Service deploy | Create the service
- name: Avi Controller | CSP | Service deploy | Check if service already exists
uri:
url: "https://{{ inventory_hostname }}/api/running/services/"
method: POST
url: "https://{{ inventory_hostname }}/api/running/services/service/{{ con_csp_service_name }}"
method: GET
user: "{{ con_csp_user }}"
password: "{{ con_csp_password }}"
force_basic_auth: yes
headers:
Accept: '*/*'
validate_certs: false
body_format: json
body:
service:
disk_size: "{{ con_csp_disk_size|int }}"
disk_type: "{{ con_csp_disk_type | default("virtio")}}
name: "{{ con_csp_service_name }}"
power: 'on'
iso_name: "{{ con_csp_qcow_image_name }}"
day0_filename: "{{ con_csp_metafile_name }}"
numcpu: "{{ con_csp_num_cpu|int }}"
memory: "{{ con_csp_memory_mb|int }}"
vnics:
vnic:
"{{ con_csp_vnics }}"
return_content: true
register: con_csp_service
failed_when: con_csp_service.status != 201
failed_when: false
register: con_csp_service_exists
delegate_to: localhost
when:
- con_csp_service_exists.status != 200
- con_csp_resource_info.csp_version < "02.02.04"

- name: Avi Controller | CSP >= 2.2.4| Service deploy | Create the service
uri:
url: "https://{{ inventory_hostname }}/api/running/services/"
method: POST
user: "{{ con_csp_user }}"
password: "{{ con_csp_password }}"
force_basic_auth: yes
headers:
Accept: '*/*'
validate_certs: false
body_format: json
body:
service:
- block:
- set_fact:
con_csp_service_exists_json: "{{ con_csp_service_exists.content|from_json }}"
- debug: msg="Service {{ con_csp_service_exists_json['vsb:service'].name }} already exists."
when: con_csp_service_exists.status == 200

- block:

- name: Avi Controller | CSP | Service deploy | Create CSP service info
set_fact:
con_csp_service_info:
disk_size: "{{ con_csp_disk_size|int }}"
disk_type: "{{ con_csp_disk_type | default("virtio")}}
disk-resize: true
disk_type: "{{ con_csp_disk_type | default('virtio')}}"
name: "{{ con_csp_service_name }}"
power: 'on'
iso_name: "{{ con_csp_qcow_image_name }}"
Expand All @@ -100,11 +59,34 @@
vnics:
vnic:
"{{ con_csp_vnics }}"
return_content: true
register: con_csp_service
failed_when: con_csp_service.status != 201
delegate_to: localhost

- name: Avi Controller | CSP | Service deploy | Update service info for CSP > 2.2.4
set_fact:
con_csp_service_info: "{{con_csp_service_info | combine({'disk-resize': true})}}"
when:
- con_csp_resource_info['resource:resource'].csp_version >= "02.02.04.00"

- name: Avi Controller | CSP | Service deploy | Using service info
debug: msg="{{con_csp_service_info}}"

- name: Avi Controller | CSP | Service deploy | Create the service
uri:
url: "https://{{ inventory_hostname }}/api/running/services/"
method: POST
user: "{{ con_csp_user }}"
password: "{{ con_csp_password }}"
force_basic_auth: yes
headers:
Accept: '*/*'
validate_certs: false
body_format: json
body:
service: "{{ con_csp_service_info }}"
return_content: true
register: con_csp_service
failed_when: con_csp_service.status != 201
changed_when: con_csp_service.status == 201
delegate_to: localhost

when:
- con_csp_service_exists.status != 200
- con_csp_resource_info.csp_version >= "2.2.4"

0 comments on commit ed1f1d0

Please sign in to comment.