Skip to content

Commit

Permalink
Merge branch 'main' into feat/pbr
Browse files Browse the repository at this point in the history
  • Loading branch information
Gevorg-Khachatryaan authored and Gevorg-Khachatryaan committed Feb 17, 2022
2 parents b324177 + f9691a5 commit 13c5831
Show file tree
Hide file tree
Showing 21 changed files with 1,312 additions and 435 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nutanix-ncp-*
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
---
- name: create Floating IP with External Subnet uuid
- name: Create floating ip with external subnet uuid
ntnx_floating_ips:
validate_certs: False
state: present
nutanix_host: "{{ IP }}"
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
wait: False
external_subnet:
uuid: "{{external_subnet.subnet_uuiid}}"
uuid: "{{ external_subnet.uuid }}"
register: result
ignore_errors: True

- set_fact:
todelete: "{{ todelete + [ result.fip_uuid ] }}"
##############################################################
- name: Create floating ip with vpc name and external subnet uuid
ntnx_floating_ips:
validate_certs: False
state: present
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
external_subnet:
uuid: "{{external_subnet.uuid}}"
vpc:
name: "{{ vpc.name }}"
private_ip: "{{ private_ip }}"
register: result
ignore_errors: True

Expand All @@ -16,80 +35,144 @@
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
fail_msg: " Unable to create Floating ip "
success_msg: " Floating ip created successfully "
fail_msg: " Unable to create floating ip with vpc "
success_msg: " Floating ip with vpc name and external subnet uuid created successfully "

- set_fact:
todelete: "{{ todelete + [ result.fip_uuid ] }}"
##########################################################
- name: Delete all created floating ips
ntnx_floating_ips:
state: absent
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
validate_certs: false
fip_uuid: "{{ item }}"
register: result
loop: "{{ todelete }}"

- set_fact:
todelete: []
###########################################################
- name: Create floating ip with external subnet name
ntnx_floating_ips:
validate_certs: False
state: present
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
wait: False
external_subnet:
name: "{{ external_subnet.name }}"
register: result
ignore_errors: True

- name: create Floating IP with vpc Name with external subnet uuid
- set_fact:
todelete: "{{ todelete + [ result.fip_uuid ] }}"
############################################################
- name: Create floating ip with vpc uuid and external subnet name
ntnx_floating_ips:
validate_certs: False
state: present
nutanix_host: "{{ IP }}"
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
external_subnet:
uuid: "{{external_subnet.subnet_uuiid}}"
name: "{{ external_subnet.name }}"
vpc:
name: "{{vpc.vpc_name}}"
private_ip: "{{private_ip}}"
uuid: "{{ vpc.uuid }}"
private_ip: "{{ private_ip }}"
register: result
ignore_errors: True

- set_fact:
todelete: "{{ todelete + [ result.fip_uuid ] }}"
############################################################
- name: Delete all created floating ips
ntnx_floating_ips:
state: absent
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
validate_certs: false
fip_uuid: "{{ item }}"
register: result
loop: "{{ todelete }}"
ignore_errors: True

- set_fact:
todelete: []
##########################################################
- name: Create floating ip with external subnet and vm name
ntnx_floating_ips:
validate_certs: False
state: present
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
external_subnet:
name: "{{ vm_subnet_name }}"
vm:
name: "{{ vm.name }}"
ignore_errors: True
register: result

- name: Creation Status
assert:
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
fail_msg: " Unable to create Floating ip with vpc "
success_msg: " Floating ip with vpc created successfully "

fail_msg: " Unable to create floating ip with vm"
success_msg: " Floating ip with external subnet and vm created successfully "

- name: Delete the Floating IP with vpc Name with external subnet uuid
- set_fact:
todelete: "{{ todelete + [ result.fip_uuid ] }}"
##########################################################
- name: Delete all created floating ips
ntnx_floating_ips:
state: absent
nutanix_host: "{{ IP }}"
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
validate_certs: false
fip_uuid: "{{result.fip_uuid}}"
fip_uuid: "{{ item }}"
register: result
ignore_errors: True


- name: create Floating IP with External Subnet with vm
loop: "{{ todelete }}"
ignore_errors: True

- set_fact:
todelete: []
#########################################################
- name: Create floating ip with external subnet and vm uuid
ntnx_floating_ips:
validate_certs: False
state: present
nutanix_host: "{{ IP }}"
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
external_subnet:
name: "{{vm_subnet_name}}"
name: "{{ vm_subnet_name }}"
vm:
name: "{{vm.vm_name}}"
uuid: "{{ vm.uuid }}"
ignore_errors: True

register: result

- name: Creation Status
assert:
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
fail_msg: " Unable to create Floating ip with vm"
success_msg: " Floating ip created successfully with vm "
fail_msg: " Unable to create floating ip with vm"
success_msg: " Floating ip with external subnet and vm created successfully "

- set_fact:
todelete: "{{ todelete + [ result.fip_uuid ] }}"


- name: Delete all Created Floating ips
###########################################################
- name: Delete all created floating ips
ntnx_floating_ips:
state: absent
nutanix_host: "{{ IP }}"
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
validate_certs: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
- block:
- import_tasks: "create_floating_ips.yml"

- import_tasks: "negative_scenarios.yml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
- debug:
msg: "Started Negative Creation Cases"
- name: Create floating ip with unknown external subnet name
ntnx_floating_ips:
validate_certs: False
state: present
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
external_subnet:
name: "external_subnet"
register: result
ignore_errors: True

- name: Creation Status
assert:
that:
- result.failed==True
- result.msg=="Failed generating floating_ip spec"
success_msg: ' Success: returned error as expected '
#################################################################
- name: Create floating ip with unknown external subnet uuid
ntnx_floating_ips:
validate_certs: False
state: present
wait: false
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
external_subnet:
uuid: 54e295c3-16d3-49de-96ba-b921948b3a
register: result
ignore_errors: True

- name: Creation Status
assert:
that:
- result.status_code==422
success_msg: ' Success: returned error as expected '
###############################################################
- name: Create floating ip with unknown vpc
ntnx_floating_ips:
validate_certs: False
state: present
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
external_subnet:
name: "{{ external_subnet.name}}"
vpc:
name: vpc
private_ip: "{{ private_ip }}"
register: result
ignore_errors: True

- name: Creation Status
assert:
that:
- result.failed==True
- result.msg=="Failed generating floating_ip spec"
success_msg: ' Success: returned error as expected '
###############################################################
- name: Create floating ip with unknown vpc uuid
ntnx_floating_ips:
validate_certs: False
state: present
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
external_subnet:
name: "{{ external_subnet.name }}"
vpc:
uuid: 471181f8-eb2d-4303-9a61-6b25a1b3
private_ip: "{{ private_ip }}"
register: result
ignore_errors: True

- name: Creation Status
assert:
that:
- result.status_code==422
success_msg: ' Success: returned error as expected '
##############################################################
- name: Delete floating ip with unknown uuid
ntnx_floating_ips:
state: absent
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
validate_certs: false
fip_uuid: 5
register: result
ignore_errors: True

- name: Creation Status
assert:
that:
- result.status_code==400
success_msg: ' Success: returned error as expected '
24 changes: 15 additions & 9 deletions tests/integration/targets/nutanix_floating_ips/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
IP: 10.44.76.88
ip: 10.44.76.88
username: admin
password: Nutanix.123

external_subnet:
subnet_name: ET_7
subnet_uuiid: 54e295c3-16d3-49de-96ba-b921948b3a4d
name: Ext-Nat
uuid: 581b6d25-4064-4cd0-b8ef-5aa0f3b98700

vpc:
vpc_name: ET_8
vpc_uuiid: 471181f8-eb2d-4303-9a61-6b25a1b3553e
name: ET_8
uuid: 55c50dad-7b45-4067-9ee9-97c0275a69f5

vm:
vm_name: ET_11
vm_uuid: 83c9c094-2b18-4e65-bf6f-234640e07bc0
private_ip: 192.168.1.153
name: ET_11
uuid: a34604ae-a092-4994-ae29-50c906da41fa

private_ip: 192.168.0.10

vm_subnet_name: Ext-Nat

todelete: []
vm_subnet_name: Prod-NAT
Loading

0 comments on commit 13c5831

Please sign in to comment.