Skip to content

Addition of aci_l4l7_policy_based_redirect and related modules (DCNE-391) #751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shrsr
Copy link
Collaborator

@shrsr shrsr commented Apr 24, 2025

No description provided.

@shrsr shrsr self-assigned this Apr 24, 2025
@shrsr shrsr added the jira-sync Sync this issue to Jira label Apr 24, 2025
@github-actions github-actions bot changed the title Addition of aci_l4l7_policy_based_redirect and related modules Addition of aci_l4l7_policy_based_redirect and related modules (DCNE-391) Apr 24, 2025
- The APIC defaults to C(false) when unset during creation.
- Only available when I(destination_type=l3)
type: bool
monitor_policy:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use full name?

Suggested change
monitor_policy:
ip_sla_monitor_policy:

policy_name=dict(type="str"),
description=dict(type="str"),
destination_type=dict(type="str", aliases=["dest_type"], choices=["l1", "l2", "l3"]),
hash_algorithm=dict(type="str", choices=["source_ip", "destination_ip", "ip_and_protocol"]),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get choices from L4L7_HASH_ALGORITHMS_MAPPING?

Suggested change
hash_algorithm=dict(type="str", choices=["source_ip", "destination_ip", "ip_and_protocol"]),
hash_algorithm=dict(type="str", choices=list(L4L7_HASH_ALGORITHMS_MAPPING),

monitor_policy:
description:
- The name of the IP SLA Monitoring Policy to bind to the L4-L7 Redirect Policy.
- To remove an existing binding to an IP SLA Monitoring Policy, submit a request with I(state=present) and no I(monitor_policy) value.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this behaviour is deviating from the decision of deleting only when specified explicitly. Should we do delete on empty "" and else not touch the child config?

#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright: (c) 2025, Tim Cragg (@timcragg)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add your name? all modules

description: More information about the internal APIC class, B(vns:SvcRedirectPol)
link: https://developer.cisco.com/docs/apic-mim-ref/
author:
- Tim Cragg (@timcragg)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add your name? all modules

module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
required_if=[["state", "absent", ["tenant", "policy"]], ["state", "present", ["tenant", "policy"]]],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you format this on multiple lines? run black after the below change

Suggested change
required_if=[["state", "absent", ["tenant", "policy"]], ["state", "present", ["tenant", "policy"]]],
required_if=[["state", "absent", ["tenant", "policy"]], ["state", "present", ["tenant", "policy"]],],

state = module.params.get("state")
pod_id = module.params.get("pod_id")

if not destination_type:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do this and not specify a default in the argument spec for destination_type? or make it required?

Comment on lines +353 to +360
if destination_type == "l1/l2" and additional_ip is not None:
aci.fail_json(msg="You cannot provide an additional_ip when configuring an l1/l2 destination")
elif destination_type == "l3" and (logical_device, concrete_device, concrete_interface) != (None, None, None):
aci.fail_json(msg="You cannot provide a logical_device, concrete_device or concrete_interface when configuring an l3 destination")
elif destination_type == "l1/l2" and (logical_device, concrete_device, concrete_interface) == (None, None, None):
aci.fail_json(msg="You must provide a logical_device, concrete_device and concrete_interface when configuring an l1/l2 destination")
elif destination_type == "l1/l2" and ip is not None:
aci.fail_json(msg="You cannot provide an ip when configuring an l1/l2 destination")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you considered creating a dictionary input for l1/l2 and l3, then deducing the type from the dictionary with a mutually exclusive in the argument spec? and adding the dicts to required if for present, that one of the two is required

this would simplify all the error handling and containerise the config on input side

health_group:
description:
- The Health Group to bind the Policy Based Redirection Destination to.
- To remove an existing binding from a Health Group, submit a request with I(state=present) and no I(health_group) value.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty "" for removal else not touch?

)
aci.payload(
aci_class=aci_class,
class_config=dict(ip=ip, mac=mac, destName=destination_name, podId=pod_id, ip2=additional_ip),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format on different lines? run black after

Suggested change
class_config=dict(ip=ip, mac=mac, destName=destination_name, podId=pod_id, ip2=additional_ip),
class_config=dict(ip=ip, mac=mac, destName=destination_name, podId=pod_id, ip2=additional_ip,),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira-sync Sync this issue to Jira
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants