Skip to content

[minor_change] Add module ndo_pod_profile for pod profiles in fabric resource templates (DCNE-141) #672

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 7 commits into
base: master
Choose a base branch
from

Conversation

akinross
Copy link
Collaborator

fixes #469

@github-actions github-actions bot changed the title [minor_change] Add module ndo_pod_profile for pod settings in fabric resource templates [minor_change] Add module ndo_pod_profile for pod settings in fabric resource templates (DCNE-141) May 16, 2025
@akinross akinross changed the title [minor_change] Add module ndo_pod_profile for pod settings in fabric resource templates (DCNE-141) [minor_change] Add module ndo_pod_profile for pod profiles in fabric resource templates (DCNE-141) May 19, 2025
@akinross akinross force-pushed the 469_pod_profile_module branch 3 times, most recently from 58a768d to 0938241 Compare May 19, 2025 08:17
@akinross akinross force-pushed the 469_pod_profile_module branch from 0938241 to d40a58f Compare May 19, 2025 08:27
sajagana
sajagana previously approved these changes May 19, 2025
Copy link
Collaborator

@sajagana sajagana left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines 101 to 135
- name: Create a Pod Profile
cisco.mso.ndo_pod_profile:
host: mso_host
username: admin
password: SomeSecretPassword
template: ansible_test
name: ansible_pod_profile
pod_settings: ansible_pod_settings
state: present
register: create_pod_profile

- name: Update a Pod Profile using name
cisco.mso.ndo_pod_profile:
host: mso_host
username: admin
password: SomeSecretPassword
template: ansible_test
name: ansible_pod_profile
pod_settings: ansible_pod_settings
description: Updated Pod Profile
pods:
- 1
- 2
state: present

- name: Update a Pod Profile using UUID
cisco.mso.ndo_pod_profile:
host: mso_host
username: admin
password: SomeSecretPassword
template: ansible_test
name: ansible_pod_profile_changed
uuid: "{{ create_pod_profile.current.uuid }}"
pod_settings_uuid: "{{ create_pod_settings.current.uuid }}"
state: present
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing pod_settings_template (or pod_settings_template_id) as it is required with pod_settings (or pod_settings_uuid)

if pods:
mso_values["blocks"] = pods
mso_values["kind"] = "podRange"
elif pods == []:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we're only changing the settings of pod from providing 'a range' to 'all' or 'all' to 'a range', shall we make it simple for the user by saying that if pods is not provided it is applied to all the pods every time (initial create and update)?

elif not pods:
    mso_values["kind"] = "all"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is for the update case to be set correct where we do not want to change when not provided, only on the create the we force it to all when not provided

Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this is for the update case. I was thinking should we make the behaviour consistent for both create and update where if pods is not provided means the profile is applied to all.
Let's skip this if unnecessary..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok i thought we would never update anything that was not provided?

mso.exit_json()


def set_pod_profile_policy_names(mso, mso_templates, pod_profile):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function is really useful for policy objects that are not supported by the API yet. Can we make it generic?
It will be useful for future modules to consume this function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For now I chose to include in the module since I did not want to change existing function. Shall we create a separate issue to track this feature?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, let's open another issue then

@akinross akinross requested a review from shrsr May 23, 2025 07:05
mso_values["kind"] = "all"

pod_settings_mso_template = mso_templates.get_template("fabric_policy", pod_settings_template, pod_settings_template_id)
mso_values["policy"] = pod_settings_mso_template.get_pod_settings_object(pod_settings_uuid, pod_settings, fail_module=True).details.get("uuid")
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 ignore the pod settings object lookup when the "pod_settings_uuid" is provided by the user?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure will remove

@akinross akinross force-pushed the 469_pod_profile_module branch from 80f6db0 to bea7de4 Compare May 23, 2025 13:34
@akinross akinross requested a review from sajagana May 23, 2025 13:35
@akinross akinross force-pushed the 469_pod_profile_module branch from bea7de4 to 73703af Compare May 23, 2025 13:37
@akinross akinross force-pushed the 469_pod_profile_module branch from 73703af to 7238c53 Compare May 23, 2025 13:39
search_object = self.template
existing_objects = search_object.get("fabricPolicyTemplate", {}).get("template", {}).get("podPolicyGroups", [])
if uuid or name: # Query a specific object
return self.get_object_by_key_value_pairs("Pod Settings", existing_objects, [KVPair("uuid", uuid) if uuid else KVPair("name", name)], fail_module)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be the plural Pod Settings or singular Pod Setting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The UI names it in plural form and so does the template, so I would say it would be in plural form. If you think this should be done differently let me know.

type: list
elements: int
aliases: [ blocks ]
pod_settings:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have previously been nesting this reference objects into dictionaries.
ie.

pod_settings: dictionary {
   name: str, required,
   template: str,
   template_id: str
}
pod_settings_uuid: str

Have we decided to format specs without nesting now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I do not know all the constant changes that have decided but if you can provide me this then I can change. I thought at least it was like this in the past that for required attributes we would flatten the structure, because the user input would be easier.

description:
- The description of the Pod Settings.
type: str
macsec_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 macsec_policy and ntp_policy be in a dictionary with a name option? This would be consistent with other modules.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If this is agreed upon by the team I can change, but do not see the value of nesting a single value since there is also not template selection. The user input would always be:

macsec_policy:
    name_or_uuid: value

Instead of just:

macsec_policy_name_or_uuid: value

pod_settings_template = mso_templates.get_template("fabric_policy", template.get("templateName"), template.get("templateId"))
match = pod_settings_template.get_pod_settings_object(pod_settings_uuid)
if match:
pod_profile["policyName"] = match.details.get("name")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the pod settings templateId and templateName be added?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will add

mso.exit_json()


def set_pod_profile_policy_names(mso, mso_templates, pod_profile):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this function also be adding the templateName/templateId of the pod profile?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will add

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: New module for Pod Profile in Fabric Resource Policies Template (DCNE-141)
5 participants