Skip to content
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

Add support for XML file upload pre-change (DCNE-150) #77

Merged

Conversation

adealdag
Copy link
Contributor

fixes #76

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

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

@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

@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

plugins/modules/nd_pcv.py Outdated Show resolved Hide resolved
@samiib samiib changed the title Add support for XML file upload pre-change Add support for XML file upload pre-change (DCNE-150) Aug 14, 2024
@akinross akinross force-pushed the Fix-76-nd_pcv-fails-when-file-is-XML branch from e8568bb to 26b37aa Compare October 16, 2024 08:20
@adealdag
Copy link
Contributor Author

Have modified the code according to prev conversation. Now the module is able to detect the type of file and deal with no extension or wrong extension files.

"""This method handles file download and upload operations
:arg method (str): Method can be GET or POST
:arg path (str): Path should be the resource path
:arg file (str): The absolute file path of the target file
:arg file_ext (str): The file extension, with leading dot, to be used for the file. If file has already an extension, it will be replaced
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we add a check that the file extension leads with a dot? possibly error or inject when this is not done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, added

@anvitha-jain anvitha-jain requested a review from akinross October 25, 2024 09:32
plugins/httpapi/nd.py Show resolved Hide resolved
@akinross akinross self-requested a review October 28, 2024 09:21
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

@@ -254,6 +255,14 @@ def send_file_request(self, method, path, file=None, data=None, remote_path=None
self.method = "GET"
if method is not None:
self.method = method

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please run black -l 159 to format these changes.

try:
file_ext = ".json"
extract_data = ndi.load(open(file))
except:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
except:
except BaseException:

I think this will also fix another sanity issue.

@adealdag adealdag requested a review from samiib November 28, 2024 17:30
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.

Looks like black formatting needs to run again on the new changes.
Also, there appears to be one more sanity issue.

@@ -43,7 +43,7 @@
aliases: [ site ]
file:
description:
- Optional parameter if creating new pre-change analysis from file.
- Optional parameter if creating new pre-change analysis from file. XML and JSON files are supported. If no file extension is provided, the file is assumed to be JSON.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Optional parameter if creating new pre-change analysis from file. XML and JSON files are supported. If no file extension is provided, the file is assumed to be JSON.
- Optional parameter if creating new pre-change analysis from file.
- XML and JSON files are supported. If no file extension is provided, the file is assumed to be JSON.

To fix the long line sanity issue.

@akinross akinross requested a review from sajagana as a code owner December 16, 2024 10:31
@akinross akinross requested a review from samiib December 16, 2024 10:32
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

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

@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
Member

@lhercot lhercot left a comment

Choose a reason for hiding this comment

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

LGTM

@lhercot lhercot merged commit cfa447f into CiscoDevNet:master Jan 24, 2025
18 of 19 checks passed
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.

nd_pcv fails when file is XML (DCNE-150)
7 participants