-
Notifications
You must be signed in to change notification settings - Fork 33
[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
base: master
Are you sure you want to change the base?
Conversation
… macsec and ntp policies
58a768d
to
0938241
Compare
…resource templates
… pod settings policy
0938241
to
d40a58f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
plugins/modules/ndo_pod_profile.py
Outdated
- 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 |
There was a problem hiding this comment.
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 == []: |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
plugins/modules/ndo_pod_profile.py
Outdated
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") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure will remove
80f6db0
to
bea7de4
Compare
bea7de4
to
73703af
Compare
…t ndo handle error
73703af
to
7238c53
Compare
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) |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add
fixes #469