-
Notifications
You must be signed in to change notification settings - Fork 20
Added nd_remote_storage_location module to manage remote storage locations (DCNE-503) #165
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
…te storage locations
type: str | ||
nas: | ||
description: | ||
- The Network-attached storage (NAS) configuration for the remote storage location. |
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 change this to?
- The Network Attached Storage (NAS) configuration for the remote storage location.
output_level: info | ||
register: nm_add_scp_remote_location_again | ||
|
||
- name: Query nas remote storage location to ensure it does not exists |
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.
is this required?
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.
When I create or delete the NAS storage location, ND displays the message "There was a problem proxying the request." This is a temporary error and typically resolves itself after a few minutes. To handle the inconsistent behavior, I have added the necessary query task and included additional ignore error statements.
check_mode: true | ||
register: cm_add_nas_remote_location | ||
when: query_nas_remote_location.current == {} | ||
ignore_errors: true |
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.
why ignore_errors: true in check mode?
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.
When I create or delete the NAS storage location, ND displays the message "There was a problem proxying the request." This is a temporary error and typically resolves itself after a few minutes. To handle the inconsistent behavior, I have added the necessary query task and included additional ignore error statements.
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 that's the case, then can we add it a comment in the test file or make a note of this somewhere?
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!
…mote_storage_location module test file
|
||
if not module.check_mode: | ||
if nd.existing: | ||
nd.request(path, method="PUT", data=payload) |
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.
Is PUT op called even for the same configurations?
If yes, shall we leverage get_diff()?
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.
Thank you for catching this!
…e and copied module utils nd.py file changes from CiscoDevNet#166 PR
@@ -3,6 +3,7 @@ | |||
# Copyright: (c) 2021, Lionel Hercot (@lhercot) <[email protected]> | |||
# Copyright: (c) 2022, Cindy Zhao (@cizhao) <[email protected]> | |||
# Copyright: (c) 2022, Akini Ross (@akinross) <[email protected]> | |||
# Copyright: (c) 2025, Shreyas Srish (@shrsr) <[email protected]> |
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 not be your details?
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 copied the changes from Shreyas PR, let it be for now.
aliases: [ default_path, export_path ] | ||
sftp_scp: | ||
description: | ||
- The SFTP/SCP configuration for the remote storage location. |
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 abbreviations be explained here like you do for NAS?
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!
- The SFTP/SCP configuration for the remote storage location. | ||
- This parameter and O(nas) are mutually exclusive. | ||
type: dict | ||
suboptions: |
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.
is there a reason that credential store key is not an option?
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.
Currently credential store is not available to test the behaviour; it will be added once the credential store is available.
server_port: | ||
description: | ||
- The port number of the remote server. | ||
type: int | ||
server_name: | ||
description: | ||
- The IP address or hostname of the remote server. | ||
type: str | ||
aliases: [ ip ] | ||
path: | ||
description: | ||
- The export path of the remote storage location. | ||
type: str | ||
aliases: [ default_path, export_path ] |
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.
from UI these seem required upon initial create? should we document / enforce this in input?
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.
Added note in the document.
argument_spec=argument_spec, | ||
supports_check_mode=True, | ||
required_if=[ | ||
["state", "present", ["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.
certain options seem to not be changeable after create from UI should we document this somehow?
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!
…age_location module documentation
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
plugins/module_utils/utils.py
Outdated
def delete_none_values(obj_to_sanitize, recursive=True): | ||
""" | ||
Removes keys with None values from a Python object, which can be either a list or a dictionary. | ||
Optionally performs the operation recursively on nested structures. | ||
|
||
:param obj_to_sanitize: The Python object to sanitize from None values. -> List or Dict | ||
:param recursive: A boolean flag indicating whether to recursively sanitize nested objects. Defaults to True. -> bool | ||
:return: A sanitized copy of the original Python object, with all keys with None values removed. -> List or Dict | ||
""" | ||
if isinstance(obj_to_sanitize, dict): | ||
sanitized_dict = {} | ||
for item_key, item_value in obj_to_sanitize.items(): | ||
if recursive and isinstance(item_value, (dict, list)): | ||
sanitized_dict[item_key] = delete_none_values(item_value, recursive) | ||
elif item_value is not None: | ||
sanitized_dict[item_key] = item_value | ||
return sanitized_dict | ||
|
||
elif isinstance(obj_to_sanitize, list): | ||
sanitized_list = [] | ||
for item in obj_to_sanitize: | ||
if recursive and isinstance(item, (dict, list)): | ||
sanitized_list.append(delete_none_values(item, recursive)) | ||
elif item is not None: | ||
sanitized_list.append(item) | ||
return sanitized_list | ||
|
||
else: | ||
raise TypeError("Object to sanitize must be of type list or dict. Got {}".format(type(obj_to_sanitize))) |
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.
Why adding this function when we already have the sanitize (with sanitize_dict and sanitize_list) function in nd.py which does the same thing and expand that even more (and I am not talking about nd.sanitize)? maybe we should rename this existing function?
I do agree with moving a lot of the utility functions from nd.py to utils.py but we should be careful about making "duplicate" functions across the module_utils
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, I removed unused function from utils.py.
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
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.
@sajagana sent you a question about the tests.
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!
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
output_level: info | ||
register: nm_add_scp_remote_location_again | ||
|
||
# To manage the NAS storage inconsistent 'There was a problem proxying the request' errors message, added ignore_errors and until statements. |
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.
Rephrase the comment, to make it more clear
To address the inconsistent 'There was a problem proxying the request' errors with NAS storage, 'ignore_errors' and 'until' statements were 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.
Done!
c81e6d2
to
402e844
Compare
402e844
to
6015f92
Compare
…