-
Notifications
You must be signed in to change notification settings - Fork 32
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
Added mso_schema_template_anp_epg_annotation to manage EPG annotations (DCNE-60) #588
base: master
Are you sure you want to change the base?
Conversation
extends_documentation_fragment: cisco.mso.modules | ||
notes: | ||
- The O(schema) and O(template) must exist before using this module in your playbook. | ||
Use M(cisco.mso.mso_schema_template) to create the schema template. |
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.
-> Use M(cisco.mso.mso_schema_template) to create the schema and template.
Use M(cisco.mso.mso_schema_template) to create the schema template. | ||
- The O(anp) must exist before using this module in your playbook. | ||
Use M(cisco.mso.mso_schema_template_anp) to create the ANP. | ||
- The O(epg) must exist before using this module in your playbook. |
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.
Shall we actually combine all of them?
- The O(schema), O(template), O(anp) and O(epg) must exist before using this module in your playbook.
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.
Done 👍
template: Template 1 | ||
anp: ANP 1 | ||
epg: EPG 1 | ||
annotation_key: "annotation_key_1_updated" |
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.
annotation_key: annotation_key_1_updated
template: Template 1 | ||
anp: ANP 1 | ||
epg: EPG 1 | ||
annotation_key: "annotation_key_1_updated" |
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.
annotation_key: annotation_key_1_updated
template: Template 1 | ||
anp: ANP 1 | ||
epg: EPG 1 | ||
annotation_key: "annotation_key_1_updated" |
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.
annotation_key: annotation_key_1_updated
anp: ANP 1 | ||
epg: EPG 1 | ||
annotation_key: "annotation_key_1_updated" | ||
annotation_value: "annotation_value_1" |
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.
annotation_value: annotation_value_1
template: Template 1 | ||
anp: ANP 1 | ||
epg: EPG 1 | ||
annotation_key: "annotation_key_1" |
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.
annotation_key: annotation_key_1
anp: ANP 1 | ||
epg: EPG 1 | ||
annotation_key: "annotation_key_1" | ||
annotation_value: "annotation_value_1" |
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.
annotation_value: annotation_value_1
mso_values = {"tagKey": annotation_key, "tagValue": annotation_value} | ||
mso.sanitize(mso_values) | ||
if mso.existing: | ||
# An error from MSO prevents the "replace" operation from updating existing annotation values. |
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.
Just out of curiosity, what errors do you get from this exactly? on which MSO versions?
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.
MSO Error 400: json: cannot unmarshal string into Go struct field Schema2.templates of type common.Epg2
Version 4.3.1 - This is the only version I have access to right now.
However, I have found a way to use the replace op instead.
def append_add_op(ops, path, mso_values): | ||
ops.append({"op": "add", "path": "{0}/-".format(path), "value": mso_values}) | ||
|
||
|
||
def append_remove_op(ops, path, index): | ||
ops.append({"op": "remove", "path": "{0}/{1}".format(path, index)}) |
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.
These could be moved to one of the files in module_utils folder, probably something like in utils.py.
Nonetheless, to be honest, I don't think these functions are very useful, I think they don't specially make the code easier to read.
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, these could be moved if anyone would like to use them. However, most modules will use append_update_ops_data
instead and only remove op once and there is no need to encapsulate it.
I had to construct the same dictionary for add and remove ops twice in this module. These functions are useful when added to reduce code duplication not necessarily to increase code readability, which can be subjective.
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.
However, now that I have found a way to use the replace op, the code duplication doesn't exist anymore and the functions aren't needed.
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
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
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
Fixes #509