-
Notifications
You must be signed in to change notification settings - Fork 20
Added ND backup schedule module to manage backup schedule jobs on ND 4.1 and later (DCNE-496) #162
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?
Changes from 2 commits
115ef93
d484dba
efb003a
af223b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2025, Sabari Jaganathan (@sajagana) <[email protected]> | ||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
__metaclass__ = type | ||
|
||
|
||
def snake_to_camel(snake_str, upper_case_components=None): | ||
if snake_str is not None and "_" in snake_str: | ||
if upper_case_components is None: | ||
upper_case_components = [] | ||
components = snake_str.split("_") | ||
camel_case_str = components[0] | ||
|
||
for component in components[1:]: | ||
if component in upper_case_components: | ||
camel_case_str += component.upper() | ||
else: | ||
camel_case_str += component.title() | ||
|
||
return camel_case_str | ||
else: | ||
return snake_str |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,205 @@ | ||||||
#!/usr/bin/python | ||||||
# -*- coding: utf-8 -*- | ||||||
|
||||||
# Copyright: (c) 2025, Sabari Jaganathan (@sajagana) <[email protected]> | ||||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) | ||||||
|
||||||
from __future__ import absolute_import, division, print_function | ||||||
|
||||||
__metaclass__ = type | ||||||
|
||||||
ANSIBLE_METADATA = {"metadata_version": "1.1", "status": ["preview"], "supported_by": "community"} | ||||||
|
||||||
DOCUMENTATION = r""" | ||||||
--- | ||||||
module: nd_backup_schedule | ||||||
version_added: "0.5.0" | ||||||
short_description: Manages backup schedule on Cisco Nexus Dashboard. | ||||||
description: | ||||||
- Manage backup schedule on Cisco Nexus Dashboard. | ||||||
|
- Manage backup schedule on Cisco Nexus Dashboard. | |
- Manage backup schedules on Cisco Nexus Dashboard. |
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!
Outdated
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.
- The encryption_key for a backup file. | |
- The encryption key for a backup file. |
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.
Can we add a description for backup_type?
- This parameter specifies the kind of snapshot created for the Nexus Dashboard.
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!
Outdated
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.
This only returns the schedule with the 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.
if not value and response_data and data_key and data_key in response_data:
return response_data.get(data_key)
elif not response_data:
return None
I changed the suggested code to support query one and query all objects based on the input value. Should I revert this change?
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 think it's best to let the function do what its name suggests
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 simplify this as shown below if applicable?
payload = {
"encryptionKey": encryption_key,
"name": name,
"type": backup_type,
"frequency": frequency,
"remoteLocation": remote_location,
"startTime": start_date_time,
}
if nd.existing and nd.existing.get("name") == name:
payload["frequency"] = frequency or nd.existing.get("frequency")
payload["remoteLocation"] = remote_location or nd.existing.get("remoteLocation")
payload["startTime"] = start_date_time or nd.existing.get("startTime")
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.
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!