Added nd_remote_storage_location module to manage remote storage locations (DCNE-503)#165
Added nd_remote_storage_location module to manage remote storage locations (DCNE-503)#165sajagana wants to merge 8 commits intoCiscoDevNet:masterfrom
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.
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.
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.
why ignore_errors: true in check mode?
There was a problem hiding this comment.
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.
If that's the case, then can we add it a comment in the test file or make a note of this somewhere?
…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.
Is PUT op called even for the same configurations?
If yes, shall we leverage get_diff()?
There was a problem hiding this comment.
Thank you for catching this!
…e and copied module utils nd.py file changes from CiscoDevNet#166 PR
| # Copyright: (c) 2021, Lionel Hercot (@lhercot) <lhercot@cisco.com> | ||
| # Copyright: (c) 2022, Cindy Zhao (@cizhao) <cizhao@cisco.com> | ||
| # Copyright: (c) 2022, Akini Ross (@akinross) <akinross@cisco.com> | ||
| # Copyright: (c) 2025, Shreyas Srish (@shrsr) <ssrish@cisco.com> |
There was a problem hiding this comment.
should this not be your details?
There was a problem hiding this comment.
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.
should abbreviations be explained here like you do for NAS?
| - 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.
is there a reason that credential store key is not an option?
There was a problem hiding this comment.
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.
from UI these seem required upon initial create? should we document / enforce this in input?
There was a problem hiding this comment.
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.
certain options seem to not be changeable after create from UI should we document this somehow?
…age_location module documentation
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.
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.
Yes, I removed unused function from utils.py.
There was a problem hiding this comment.
@sajagana sent you a question about the tests.
| 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.
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.
c81e6d2 to
402e844
Compare
402e844 to
6015f92
Compare
…