Skip to content

Commit

Permalink
Merge pull request #1 from avinetworks/grastogi
Browse files Browse the repository at this point in the history
Grastogi
  • Loading branch information
rahulrphadke21 authored Mar 9, 2018
2 parents 2f8bc1f + ed1f1d0 commit 947c32f
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 18 deletions.
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ con_csp_mgmt_ip: ~
con_csp_mgmt_mask: ~
con_csp_default_gw: ~
con_csp_disk_size: 64
con_csp_disk_type: virtio
con_csp_service_name: avi-controller
con_csp_metafile_name: avi_meta_{{ con_csp_service_name }}.yml
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
78 changes: 60 additions & 18 deletions tasks/service_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
---
- name: Avi Controller | CSP | Service deploy | Get CSP version
uri:
url: "https://{{ inventory_hostname }}/api/running/resources/resource/{{ con_csp_platform }}"
method: GET
user: "{{ con_csp_user }}"
password: "{{ con_csp_password }}"
force_basic_auth: yes
headers:
Accept: '*/*'
validate_certs: false
return_content: true
failed_when: con_csp_resource_rsp.status != 200
register: con_csp_resource_rsp
delegate_to: localhost

- name: Avi Controller | CSP | Service deploy | Set CSP version
set_fact:
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 resource info
debug: msg="{{con_csp_resource_info['resource:resource']}}"

- name: Avi Controller | CSP | Service deploy | Check if service already exists
uri:
url: "https://{{ inventory_hostname }}/api/running/services/service/{{ con_csp_service_name }}"
Expand All @@ -20,20 +43,13 @@
- 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 | 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:

- 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')}}"
name: "{{ con_csp_service_name }}"
power: 'on'
iso_name: "{{ con_csp_qcow_image_name }}"
Expand All @@ -43,8 +59,34 @@
vnics:
vnic:
"{{ con_csp_vnics }}"
return_content: true
register: con_csp_service
failed_when: con_csp_service.status != 201
delegate_to: localhost
when: con_csp_service_exists.status != 200

- 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

0 comments on commit 947c32f

Please sign in to comment.