Skip to content

Commit

Permalink
mend
Browse files Browse the repository at this point in the history
  • Loading branch information
ybhalchim committed Dec 11, 2024
1 parent 0a3ffce commit fc7287e
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 49 deletions.
2 changes: 1 addition & 1 deletion plugins/modules/ipam_address_block_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ def __init__(self, *args, **kwargs):

def find_by_id(self):
try:
resp = AddressBlockApi(self.client).read(self.params["id"], inherit="full")
resp = AddressBlockApi(self.client).read(self.params["id"])
return [resp.result]
except NotFoundException as e:
return None
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/ipam_address/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
dependencies: [setup_address]
dependencies: [setup_address]
154 changes: 113 additions & 41 deletions tests/integration/targets/ipam_address/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
block:

# Basic tests for Address
- name: Create a Address (check mode)
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
space: "{{ ip_space.id }}"
state: "present"
check_mode: true
register: address

- name: Create a Address
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
Expand All @@ -30,7 +38,8 @@
that:
- address is changed
- address is not failed
- address_info.objects | length != 0
- address_info.objects | length == 1
- address_info.objects[0].id == address.id

- name: Create a Address(idempotent)
infoblox.bloxone.ipam_address:
Expand All @@ -43,25 +52,64 @@
- address is not changed
- address is not failed

- name: Create the Address with Name
- name: Delete a Address (check mode)
infoblox.bloxone.ipam_address:
address: "10.0.0.8"
names: [{"name": "test-1", "type": "user"}]
address: "10.0.0.3"
space: "{{ ip_space.id }}"
state: "present"
state: "absent"
check_mode: true

- name: Delete a Address
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
space: "{{ ip_space.id }}"
state: "absent"
register: address
- name: Get information about the Address
infoblox.bloxone.ipam_address_info:
filters: {
address: "10.0.0.8",
space: "{{ ip_space.id }}"
address: "10.0.0.3",
space: "{{ ip_space.id }}"
}
register: address_info
- assert:
that:
- address is changed
- address is not failed
- address_info.objects | length > 0
- address_info.objects | length == 0

- name: Delete a Address(idempotent)
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
space: "{{ ip_space.id }}"
state: "absent"
register: address
- assert:
that:
- address is not changed
- address is not failed

- name: Create the Address with Name
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
names:
- name: "test-1"
type: "user"
space: "{{ ip_space.id }}"
state: "present"
register: address
- name: Get information about the Address
infoblox.bloxone.ipam_address_info:
filters:
address: "10.0.0.3"
space: "{{ ip_space.id }}"
register: address_info
- assert:
that:
- address is changed
- address is not failed
- address_info.objects | length == 1
- address_info.objects[0].names[0].name == address.object.names[0].name

- name: Create the Address with comment
infoblox.bloxone.ipam_address:
Expand All @@ -81,64 +129,88 @@
that:
- address is changed
- address is not failed
- address_info.objects[0].comment == "some comment"
- address_info.objects | length == 1
- address_info.objects[0].id == address.id
- address_info.objects[0].comment == address.object.comment

- name: Create the Address with hwaddr (check mode)
- name: Create the Address with hwaddr
infoblox.bloxone.ipam_address:
address: "10.0.0.8"
address: "10.0.0.6"
hwaddr: "00:11:22:33:44:55"
space: "{{ ip_space.id }}"
state: "present"
check_mode: true
register: address
- name: Get information about the Address
infoblox.bloxone.ipam_address_info:
filters: {
address: "10.0.0.6",
space: "{{ ip_space.id }}",
hwaddr: "00:11:22:33:44:55"
}
register: address_info
- assert:
that:
- address is changed
- address is not failed
- address_info.objects | length == 1
- address_info.objects[0].id == address.id
- address_info.objects[0].hwaddr == address.object.hwaddr

- name: Create the Address with Interface (check mode)
- name: Create the Address with Interface
infoblox.bloxone.ipam_address:
address: "10.0.0.8"
address: "10.0.0.7"
interface: "eth0"
space: "{{ ip_space.id }}"
state: "present"
register: address
check_mode: true
- name: Get information about the Address
infoblox.bloxone.ipam_address_info:
filters: {
address: "10.0.0.7",
space: "{{ ip_space.id }}",
interface: "eth0"
}
register: address_info
- assert:
that:
- address is changed
- address is not failed
- address_info.objects | length == 1
- address_info.objects[0].id == address.id
- address_info.objects[0].interface == address.object.interface

- name: Create the Address with Tags (check mode)
- name: Create the Address with Tags
infoblox.bloxone.ipam_address:
address: "10.0.0.8"
tags: {"tag1": "value1", "tag2": "value2"}
space: "{{ ip_space.id }}"
state: "present"
check_mode: true

- name: Delete a Address
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
space: "{{ ip_space.id }}"
state: "absent"

- name: Delete a Address
infoblox.bloxone.ipam_address:
address: "10.0.0.5"
space: "{{ ip_space.id }}"
state: "absent"

- name: Delete a Address
infoblox.bloxone.ipam_address:
address: "10.0.0.8"
space: "{{ ip_space.id }}"
state: "absent"

- name: Get information about the address
register: address
- name: Get information about the Address
infoblox.bloxone.ipam_address_info:
filters: {
address: "10.0.0.3",
space: "{{ ip_space.id }}"
address: "10.0.0.8",
space: "{{ ip_space.id }}",
}
register: address_info
- name: Debug address
debug:
var: address

- name: Debug address_info
debug:
var: address_info
- assert:
that:
- address is changed
- address is not failed
- address_info.objects | length == 0
- address_info.objects | length == 1
- address_info.objects[0].id == address.id
- address_info.objects[0].tags.tag1 == "value1"
- address_info.objects[0].tags.tag2 == "value2"

always:
# Cleanup if the test fails
- name: Delete a Subnet
infoblox.bloxone.ipam_subnet:
address: "10.0.0.0/16"
Expand All @@ -150,4 +222,4 @@
infoblox.bloxone.ipam_ip_space:
name: "{{ ip_name }}"
state: "absent"
register: ip_space
register: ip_space
2 changes: 1 addition & 1 deletion tests/integration/targets/ipam_address_info/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
dependencies: [setup_address]
dependencies: [setup_address]
17 changes: 16 additions & 1 deletion tests/integration/targets/ipam_address_info/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,19 @@
infoblox.bloxone.ipam_ip_space:
name: "{{ ip_name }}"
state: "absent"
register: ip_space
register: ip_space

always:
# Cleanup if the test fails
- name: Delete a Subnet
infoblox.bloxone.ipam_subnet:
address: "10.0.0.0/16"
space: "{{ ip_space.id }}"
state: "absent"
register: subnet

- name: Delete IP Space
infoblox.bloxone.ipam_ip_space:
name: "{{ ip_name }}"
state: "absent"
register: ip_space
4 changes: 0 additions & 4 deletions tests/integration/targets/setup_address/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
state: "present"
register: ip_space

- name: Debug the IP space name created
debug:
var: ip_space.object.name

- name: Create a Subnet
infoblox.bloxone.ipam_subnet:
address: "10.0.0.0/16"
Expand Down

0 comments on commit fc7287e

Please sign in to comment.