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

Develop #95

Merged
merged 6 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The following table shows the supported versions.
| 2.1.1 | 3.0.0 | 2.2.5 |
| 2.2.2.3 | 3.3.1 | 2.3.3 |
| 2.2.3.3 | 6.4.0 | 2.4.11 |
| 2.3.3.0 | 6.6.3 | 2.5.5 |
| 2.3.3.0 | 6.6.4 | 2.5.5 |

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

Expand Down Expand Up @@ -89,7 +89,7 @@ dnac_server
Then, create a playbook `myplaybook.yml` ([example](https://github.com/cisco-en-programmability/dnacenter-ansible/blob/main/playbooks/tag.yml)) referencing the variables in your credentials.yml file and specifying the full namespace path to the module, plugin and/or role:
```
- hosts: dnac_servers
gather_facts: no
gather_facts: false
tasks:
- name: Create tag with name "MyNewTag"
cisco.dnac.tag:
Expand Down Expand Up @@ -129,7 +129,7 @@ Then, create a playbook `myplaybook.yml` ([example](https://github.com/cisco-en-
- hosts: dnac_servers
vars_files:
- credentials.yml
gather_facts: no
gather_facts: false
tasks:
- name: Create tag with name "MyNewTag"
cisco.dnac.tag:
Expand Down
9 changes: 8 additions & 1 deletion changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -623,4 +623,11 @@ releases:
bugfixes:
- netconf_credential - Removed to search by username.
- snmpv2_read_community_credential - Removed to search by username.
- snmpv2_write_community_credential - Removed to search by username.
- snmpv2_write_community_credential - Removed to search by username.
6.6.4:
release_date: "2023-03-14"
changes:
release_summary: New method to compare changes
bugfixes:
- A new method to compare changes for specific cases has been added.
- network_device - Used a new method to compare changes.
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.6.3
version: 6.6.4
readme: README.md
authors:
- Rafael Campos <[email protected]>
Expand Down
6 changes: 3 additions & 3 deletions playbooks/template_pnp_intent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
vars_files:
- credentials.yml
- device_details.yml
gather_facts: no
gather_facts: false
connection: local
tasks:
#
Expand All @@ -16,7 +16,7 @@
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_debug: "{{ dnac_debug }}"
dnac_log: True
dnac_log: true
state: "merged"
#ignore_errors: true #Enable this to continue execution even the task fails
config:
Expand All @@ -43,7 +43,7 @@
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_debug: "{{dnac_debug}}"
dnac_log: True
dnac_log: true
config:
- site_name: "{{ item.site_name }}"
project_name: "{{ item.proj_name }}"
Expand Down
4 changes: 2 additions & 2 deletions playbooks/test_swim_module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
vars_files:
- credentials_245.yml
- image_details.yml #Contains image and device details
gather_facts: no
gather_facts: false
connection: local
tasks:
#
Expand All @@ -17,7 +17,7 @@
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_debug: "{{ dnac_debug }}"
dnac_log: True
dnac_log: true
config:
- importImageDetails:
type: "{{ item.import_type }}"
Expand Down
6 changes: 3 additions & 3 deletions plugins/action/network_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from ansible_collections.cisco.dnac.plugins.plugin_utils.dnac import (
DNACSDK,
dnac_argument_spec,
dnac_compare_equality,
dnac_compare_equality2,
get_dict_result,
)
from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import (
Expand Down Expand Up @@ -323,8 +323,8 @@ def requires_update(self, current_obj):
]
# Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) params
# If any does not have eq params, it requires update
return any(not dnac_compare_equality(current_obj.get(dnac_param),
requested_obj.get(ansible_param))
return any(not dnac_compare_equality2(current_obj.get(dnac_param),
requested_obj.get(ansible_param))
for (dnac_param, ansible_param) in obj_params)

def create(self):
Expand Down
22 changes: 22 additions & 0 deletions plugins/plugin_utils/dnac.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,28 @@ def dnac_compare_equality(current_value, requested_value):
return current_value == requested_value


def fn_comp_key2(k, dict1, dict2):
return dnac_compare_equality2(dict1.get(k), dict2.get(k))


def dnac_compare_equality2(current_value, requested_value, is_query_param=False):
if is_query_param:
return True
if requested_value is None and current_value is None:
return True
if requested_value is None:
return False
if current_value is None:
return False
if isinstance(current_value, dict) and isinstance(requested_value, dict):
all_dict_params = list(current_value.keys()) + list(requested_value.keys())
return not any((not fn_comp_key2(param, current_value, requested_value) for param in all_dict_params))
elif isinstance(current_value, list) and isinstance(requested_value, list):
return compare_list(current_value, requested_value)
else:
return current_value == requested_value


def simple_cmp(obj1, obj2):
return obj1 == obj2

Expand Down