Skip to content

Commit

Permalink
address block changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnilGadiyarHJ committed Dec 10, 2024
1 parent 9ce03fb commit f239a20
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 18 deletions.
142 changes: 124 additions & 18 deletions plugins/modules/ipam_address_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@
- "The shared DHCP configuration that controls how leases are issued for the address block."
type: dict
suboptions:
abandoned_reclaim_time:
description:
- "The abandoned reclaim time in seconds for IPV4 clients."
type: int
abandoned_reclaim_time_v6:
description:
- "The abandoned reclaim time in seconds for IPV6 clients."
type: int
allow_unknown:
description:
- "Disable to allow leases only for known IPv4 clients, those for which a fixed address is configured."
Expand Down Expand Up @@ -466,6 +474,32 @@
- "The inheritance configuration for I(dhcp_config) field."
type: dict
suboptions:
abandoned_reclaim_time:
description:
- "The inheritance configuration for I(abandoned_reclaim_time) field from I(DHCPConfig) object."
type: dict
suboptions:
action:
description:
- "The inheritance setting for a field."
- "Valid values are:"
- "* I(inherit): Use the inherited value."
- "* I(override): Use the value set in the object."
- "Defaults to I(inherit)."
type: str
abandoned_reclaim_time_v6:
description:
- "The inheritance configuration for I(abandoned_reclaim_time_v6) field from I(DHCPConfig) object."
type: dict
suboptions:
action:
description:
- "The inheritance setting for a field."
- "Valid values are:"
- "* I(inherit): Use the inherited value."
- "* I(override): Use the value set in the object."
- "Defaults to I(inherit)."
type: str
allow_unknown:
description:
- "The inheritance configuration for I(allow_unknown) field from I(DHCPConfig) object."
Expand Down Expand Up @@ -747,6 +781,10 @@
dhcp_config:
lease_time:
action: override
abandoned_reclaim_time:
action: inherit
abandoned_reclaim_time_v6:
action: inherit
allow_unknown:
action: inherit
allow_unknown_v6:
Expand Down Expand Up @@ -936,6 +974,16 @@
type: dict
returned: Always
contains:
abandoned_reclaim_time:
description:
- "The abandoned reclaim time in seconds for IPV4 clients."
type: int
returned: Always
abandoned_reclaim_time_v6:
description:
- "The abandoned reclaim time in seconds for IPV6 clients."
type: int
returned: Always
allow_unknown:
description:
- "Disable to allow leases only for known IPv4 clients, those for which a fixed address is configured."
Expand Down Expand Up @@ -1624,6 +1672,66 @@
type: dict
returned: Always
contains:
abandoned_reclaim_time:
description:
- "The inheritance configuration for I(abandoned_reclaim_time) field from I(DHCPConfig) object."
type: dict
returned: Always
contains:
action:
description:
- "The inheritance setting for a field."
- "Valid values are:"
- "* I(inherit): Use the inherited value."
- "* I(override): Use the value set in the object."
- "Defaults to I(inherit)."
type: str
returned: Always
display_name:
description:
- "The human-readable display name for the object referred to by I(source)."
type: str
returned: Always
source:
description:
- "The resource identifier."
type: str
returned: Always
value:
description:
- "The inherited value."
type: int
returned: Always
abandoned_reclaim_time_v6:
description:
- "The inheritance configuration for I(abandoned_reclaim_time_v6) field from I(DHCPConfig) object."
type: dict
returned: Always
contains:
action:
description:
- "The inheritance setting for a field."
- "Valid values are:"
- "* I(inherit): Use the inherited value."
- "* I(override): Use the value set in the object."
- "Defaults to I(inherit)."
type: str
returned: Always
display_name:
description:
- "The human-readable display name for the object referred to by I(source)."
type: str
returned: Always
source:
description:
- "The resource identifier."
type: str
returned: Always
value:
description:
- "The inherited value."
type: int
returned: Always
allow_unknown:
description:
- "The inheritance configuration for I(allow_unknown) field from I(DHCPConfig) object."
Expand Down Expand Up @@ -2273,16 +2381,8 @@ def __init__(self, *args, **kwargs):
self.params["address"], netmask = self.params["address"].split("/")
self.params["cidr"] = int(netmask)

exclude = [
"state",
"csp_url",
"api_key",
"id",
"abandoned_reclaim_time",
"abandoned_reclaim_time_v6",
"echo_client_id",
]

exclude = ["state", "csp_url", "api_key", "id","abandoned_reclaim_time","abandoned_reclaim_time_v6",
"echo_client_id"]
self._payload_params = {k: v for k, v in self.params.items() if v is not None and k not in exclude}
self._payload = AddressBlock.from_dict(self._payload_params)

Expand All @@ -2291,14 +2391,6 @@ def __init__(self, *args, **kwargs):
self._payload.dhcp_config.abandoned_reclaim_time = None
self._payload.dhcp_config.abandoned_reclaim_time_v6 = None
self._payload.dhcp_config.echo_client_id = None

# Handle inheritance sources safely
if self._payload.inheritance_sources and self._payload.inheritance_sources.dhcp_config:
inherited_dhcp_config = self._payload.inheritance_sources.dhcp_config
setattr(inherited_dhcp_config, "abandoned_reclaim_time", None)
setattr(inherited_dhcp_config, "abandoned_reclaim_time_v6", None)
setattr(inherited_dhcp_config, "echo_client_id", None)

self._existing = None

@property
Expand Down Expand Up @@ -2440,6 +2532,8 @@ def main():
dhcp_config=dict(
type="dict",
options=dict(
abandoned_reclaim_time=dict(type="int"),
abandoned_reclaim_time_v6=dict(type="int"),
allow_unknown=dict(type="bool"),
allow_unknown_v6=dict(type="bool"),
echo_client_id=dict(type="bool"),
Expand Down Expand Up @@ -2576,6 +2670,18 @@ def main():
dhcp_config=dict(
type="dict",
options=dict(
abandoned_reclaim_time=dict(
type="dict",
options=dict(
action=dict(type="str"),
),
),
abandoned_reclaim_time_v6=dict(
type="dict",
options=dict(
action=dict(type="str"),
),
),
allow_unknown=dict(
type="dict",
options=dict(
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/targets/ipam_address_block/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@
dhcp_config:
lease_time:
action: override
abandoned_reclaim_time:
action: inherit
abandoned_reclaim_time_v6:
action: inherit
allow_unknown:
action: inherit
allow_unknown_v6:
Expand Down

0 comments on commit f239a20

Please sign in to comment.