Skip to content

Commit

Permalink
Fix module name from network_device_config__info to configuration_arc…
Browse files Browse the repository at this point in the history
…hive_details_info.
  • Loading branch information
bvargasre committed Jun 3, 2024
1 parent b164d67 commit c914c94
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The following table shows the supported versions.
| 2.2.3.3 | 6.4.0 | 2.4.11 |
| 2.3.3.0 | 6.6.4 | 2.5.5 |
| 2.3.5.3 | 6.13.3 | 2.6.11 |
| 2.3.7.6 | ^6.14.0 | ^2.7.1 |
| 2.3.7.6 | ^6.14.1 | ^2.7.1 |

If your Ansible collection is older please consider updating it first.

Expand Down
6 changes: 6 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -909,3 +909,9 @@ releases:
- network_device_user_defined_field_delete - new module
- users_external_authentication - new module
- users_external_servers_aaa_attribute - new module
6.14.1:
release_date: "2024-06-03"
changes:
release_summary: Fix module name.
bugfixes:
- Fix module name from network_device_config__info to configuration_archive_details_info.
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: cisco
name: dnac
version: 6.14.0
version: 6.14.1
readme: README.md
authors:
- Rafael Campos <rcampos@altus.cr>
Expand Down
99 changes: 99 additions & 0 deletions plugins/action/configuration_archive_details_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2021, Cisco Systems
# 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
from ansible.plugins.action import ActionBase
try:
from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
AnsibleArgSpecValidator,
)
except ImportError:
ANSIBLE_UTILS_IS_INSTALLED = False
else:
ANSIBLE_UTILS_IS_INSTALLED = True
from ansible.errors import AnsibleActionFail
from ansible_collections.cisco.dnac.plugins.plugin_utils.dnac import (
DNACSDK,
dnac_argument_spec,
)

# Get common arguments specification
argument_spec = dnac_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
deviceId=dict(type="str"),
fileType=dict(type="str"),
createdTime=dict(type="str"),
createdBy=dict(type="str"),
offset=dict(type="float"),
limit=dict(type="float"),
headers=dict(type="dict"),
))

required_if = []
required_one_of = []
mutually_exclusive = []
required_together = []


class ActionModule(ActionBase):
def __init__(self, *args, **kwargs):
if not ANSIBLE_UTILS_IS_INSTALLED:
raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
super(ActionModule, self).__init__(*args, **kwargs)
self._supports_async = False
self._supports_check_mode = True
self._result = None

# Checks the supplied parameters against the argument spec for this module
def _check_argspec(self):
aav = AnsibleArgSpecValidator(
data=self._task.args,
schema=dict(argument_spec=argument_spec),
schema_format="argspec",
schema_conditionals=dict(
required_if=required_if,
required_one_of=required_one_of,
mutually_exclusive=mutually_exclusive,
required_together=required_together,
),
name=self._task.action,
)
valid, errors, self._task.args = aav.validate()
if not valid:
raise AnsibleActionFail(errors)

def get_object(self, params):
new_object = dict(
device_id=params.get("deviceId"),
file_type=params.get("fileType"),
created_time=params.get("createdTime"),
created_by=params.get("createdBy"),
offset=params.get("offset"),
limit=params.get("limit"),
headers=params.get("headers"),
)
return new_object

def run(self, tmp=None, task_vars=None):
self._task.diff = False
self._result = super(ActionModule, self).run(tmp, task_vars)
self._result["changed"] = False
self._check_argspec()

self._result.update(dict(dnac_response={}))

dnac = DNACSDK(params=self._task.args)

response = dnac.exec(
family="configuration_archive",
function='get_configuration_archive_details',
params=self.get_object(self._task.args),
)
self._result.update(dict(dnac_response=response))
self._result.update(dnac.exit_json())
return self._result
135 changes: 135 additions & 0 deletions plugins/modules/configuration_archive_details_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright (c) 2021, Cisco Systems
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)

DOCUMENTATION = r"""
---
module: configuration_archive_details_info
short_description: Information module for Network Device Config
description:
- Get all Network Device Config.
- >
Returns the historical device configurations running configuration , startup configuration , vlan if applicable by
specified criteria.
version_added: '6.14.1'
extends_documentation_fragment:
- cisco.dnac.module_info
author: Rafael Campos (@racampos)
options:
headers:
description: Additional headers.
type: dict
deviceId:
description:
- >
DeviceId query parameter. Comma separated device id for example
cf35b0a1-407f-412f-b2f4-f0c3156695f9,aaa38191-0c22-4158-befd-779a09d7cec1. If device id is not provided it
will fetch for all devices.
type: str
fileType:
description:
- FileType query parameter. Config File Type can be RUNNINGCONFIG or STARTUPCONFIG.
type: str
createdTime:
description:
- CreatedTime query parameter. Supported with logical filters GT,GTE,LT,LTE & BT time in milliseconds (epoc format).
type: str
createdBy:
description:
- >
CreatedBy query parameter. Comma separated values for createdBy - SCHEDULED, USER, CONFIG_CHANGE_EVENT,
SCHEDULED_FIRST_TIME, DR_CALL_BACK, PRE_DEPLOY.
type: str
offset:
description:
- Offset query parameter.
type: float
limit:
description:
- Limit query parameter.
type: float
requirements:
- dnacentersdk >= 2.7.1
- python >= 3.5
seealso:
- name: Cisco DNA Center documentation for Configuration Archive GetConfigurationArchiveDetails
description: Complete reference of the GetConfigurationArchiveDetails API.
link: https://developer.cisco.com/docs/dna-center/#!get-configuration-archive-details
notes:
- SDK Method used are
configuration_archive.ConfigurationArchive.get_configuration_archive_details,
- Paths used are
get /dna/intent/api/v1/network-device-config,
"""

EXAMPLES = r"""
- name: Get all Network Device Config
cisco.dnac.configuration_archive_details_info :
dnac_host: "{{dnac_host}}"
dnac_username: "{{dnac_username}}"
dnac_password: "{{dnac_password}}"
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_version: "{{dnac_version}}"
dnac_debug: "{{dnac_debug}}"
headers: "{{my_headers | from_json}}"
deviceId: string
fileType: string
createdTime: string
createdBy: string
offset: 0
limit: 0
register: result
"""
RETURN = r"""
dnac_response:
description: A dictionary or list with the response returned by the Cisco DNAC Python SDK
returned: always
type: list
elements: dict
sample: >
[
{
"ipAddress": "string",
"deviceId": "string",
"versions": [
{
"files": [
{
"fileType": "string",
"fileId": "string",
"downloadPath": "string"
}
],
"createdBy": "string",
"configChangeType": "string",
"syslogConfigEventDto": [
{
"userName": "string",
"deviceUuid": "string",
"outOfBand": true,
"configMethod": "string",
"terminalName": "string",
"loginIpAddress": "string",
"processName": "string",
"syslogTime": 0
}
],
"createdTime": 0,
"startupRunningStatus": "string",
"id": "string",
"tags": [
"string"
],
"lastUpdatedTime": 0
}
],
"deviceName": "string"
}
]
"""

0 comments on commit c914c94

Please sign in to comment.