Skip to content

Conversation

sajagana
Copy link
Collaborator

@sajagana sajagana commented Aug 8, 2025

@sajagana sajagana changed the title Added nd_remote_storage_location module to manage remote storage locations Added nd_remote_storage_location module to manage remote storage locations (DCNE-503) Aug 8, 2025
type: str
nas:
description:
- The Network-attached storage (NAS) configuration for the remote storage location.
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 change this to?

  • The Network Attached Storage (NAS) configuration for the remote storage location.

@sajagana sajagana requested a review from shrsr August 12, 2025 05:23
output_level: info
register: nm_add_scp_remote_location_again

- name: Query nas remote storage location to ensure it does not exists
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this required?

Copy link
Collaborator Author

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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@sajagana sajagana requested a review from anvitha-jain August 13, 2025 15:10

if not module.check_mode:
if nd.existing:
nd.request(path, method="PUT", data=payload)
Copy link
Collaborator

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()?

Copy link
Collaborator Author

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!

@sajagana sajagana requested a review from shrsr August 18, 2025 04:43
@@ -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]>
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 not be your details?

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 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.
Copy link
Collaborator

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?

Copy link
Collaborator Author

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:
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Comment on lines 32 to 45
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 ]
Copy link
Collaborator

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?

Copy link
Collaborator Author

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"]],
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@sajagana sajagana requested a review from akinross August 19, 2025 08:06
Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@akinross akinross 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 39 to 67
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)))
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

@sajagana sajagana requested review from gmicol, shrsr and akinross August 20, 2025 08:16
Copy link
Collaborator

@gmicol gmicol left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@anvitha-jain anvitha-jain left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@samiib samiib left a 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.
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@sajagana sajagana force-pushed the 503_remote_storage_location branch from c81e6d2 to 402e844 Compare September 11, 2025 10:40
@sajagana sajagana force-pushed the 503_remote_storage_location branch from 402e844 to 6015f92 Compare September 11, 2025 10:42
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.

6 participants