-
Notifications
You must be signed in to change notification settings - Fork 46
Print Diff for DCNM_Inventory Results, Fix for Issue #90 #465
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
@AKDRG Format looks good overall but I did notice that if I add pre-provisioned switches they get added twice. Sample Playbook: - name: Add NDFC Fabric Devices
cisco.dcnm.dcnm_inventory:
fabric: "{{ fabric_name }}"
config:
- seed_ip: 10.122.84.57
auth_proto: MD5
user_name: admin
password: password
max_hops: 0 # this is the default value as it is not defined into the data model
role: spine
preserve_config: false
- seed_ip: 10.122.84.62
auth_proto: MD5
user_name: admin
password: password
max_hops: 0 # this is the default value as it is not defined into the data model
role: spine
preserve_config: false
- seed_ip: 10.122.84.55
auth_proto: MD5
user_name: admin
password: password
max_hops: 0 # this is the default value as it is not defined into the data model
role: leaf
preserve_config: false
- seed_ip: 10.122.84.56
auth_proto: MD5
user_name: admin
password: password
max_hops: 0 # this is the default value as it is not defined into the data model
role: leaf
preserve_config: false
- seed_ip: 10.122.84.58
auth_proto: MD5
user_name: admin
password: password
max_hops: 0 # this is the default value as it is not defined into the data model
role: leaf
preserve_config: false
- seed_ip: 10.122.84.59
auth_proto: MD5
user_name: admin
password: password
max_hops: 0 # this is the default value as it is not defined into the data model
role: leaf
preserve_config: false
- seed_ip: 10.122.84.63
auth_proto: MD5
user_name: admin
password: password
max_hops: 0 # this is the default value as it is not defined into the data model
role: border
preserve_config: false
- seed_ip: 192.168.22.55
auth_proto: MD5
user_name: admin
password: password
max_hops: 0 # this is the default value as it is not defined into the data model
role: leaf
preserve_config: false
poap:
- preprovision_serial: 550K4YPFFFF
model: N9K-C9300v
version: 15.5(2)
config_data:
modulesModel: ['N9K-X9364v', 'N9K-vSUP']
gateway: 192.168.22.1/24
hostname: preprov-leaf55
- seed_ip: 192.168.22.56
auth_proto: MD5
user_name: admin
password: idgeR09!
max_hops: 0 # this is the default value as it is not defined into the data model
role: leaf
preserve_config: false
poap:
- preprovision_serial: 560K4YPFFFF
model: N9K-C9300v
version: 15.5(2)
config_data:
modulesModel: ['N9K-X9364v', 'N9K-vSUP']
gateway: 192.168.22.1/24
hostname: preprov-leaf56
deploy: false
save: false
state: merged
vars:
ansible_command_timeout: 3000
ansible_connect_timeout: 3000Diff Output changed: [nac-fabric1] => {
"changed": true,
"diff": [
{
"action": "create",
"switches": [
{
"hostname": "netascode-spine1",
"ip_address": "10.122.84.57",
"platform": "N9K-C9500v",
"preserve_config": false,
"role": "spine",
"serial_number": "99H2TUPCVFK",
"version": "10.4(1)"
},
{
"hostname": "netascode-spine2",
"ip_address": "10.122.84.62",
"platform": "N9K-C9500v",
"preserve_config": false,
"role": "spine",
"serial_number": "941L30Q8ZYI",
"version": "10.4(1)"
},
{
"hostname": "netascode-leaf1",
"ip_address": "10.122.84.55",
"platform": "N9K-C9500v",
"preserve_config": false,
"role": "leaf",
"serial_number": "94HIZLNUVCI",
"version": "10.4(1)"
},
{
"hostname": "netascode-leaf2",
"ip_address": "10.122.84.56",
"platform": "N9K-C9500v",
"preserve_config": false,
"role": "leaf",
"serial_number": "90SRMMW6APK",
"version": "10.4(1)"
},
{
"hostname": "netascode-leaf3",
"ip_address": "10.122.84.58",
"platform": "N9K-C9500v",
"preserve_config": false,
"role": "leaf",
"serial_number": "9M2TXMZ7D3N",
"version": "10.4(1)"
},
{
"hostname": "netascode-leaf4",
"ip_address": "10.122.84.59",
"platform": "N9K-C9500v",
"preserve_config": false,
"role": "leaf",
"serial_number": "982YGMKUY2B",
"version": "10.4(1)"
},
{
"hostname": "netascode-border1",
"ip_address": "10.122.84.63",
"platform": "N9K-C9500v",
"preserve_config": false,
"role": "border",
"serial_number": "9AH5QNPD6XG",
"version": "10.4(1)"
}
]
},
{
"hostname": "preprov-leaf55",
"ip_address": "192.168.22.55",
"platform": "N9K-C9300v",
"preprovision_serial": "550K4YPFFFF",
"role": "leaf",
"version": "15.5(2)"
},
{
"hostname": "preprov-leaf56",
"ip_address": "192.168.22.56",
"platform": "N9K-C9300v",
"preprovision_serial": "560K4YPFFFF",
"role": "leaf",
"version": "15.5(2)"
},
{
"action": "preprovision",
"preprovision_switches": [
{
"hostname": "preprov-leaf55",
"ip_address": "192.168.22.55",
"platform": "N9K-C9300v",
"preprovision_serial": "550K4YPFFFF",
"role": "leaf",
"version": "15.5(2)"
},
{
"hostname": "preprov-leaf56",
"ip_address": "192.168.22.56",
"platform": "N9K-C9300v",
"preprovision_serial": "560K4YPFFFF",
"role": "leaf",
"version": "15.5(2)"
}
]
}
],Looks like you are adding here and then again below? Specifically: for poap in self.want_create_poap:
item = {...}
if poap.get("preprovisionSerial"):
item["preprovision_serial"] = poap.get("preprovisionSerial")
preprovision_list.append(item)
diff.append(item) # <-- This adds the individual item
...
if preprovision_list:
diff.append({
"action": "preprovision",
"preprovision_switches": preprovision_list
}) # <-- This adds the grouped entry |
|
Hi Mike, Thanks, |
mikewiebe
approved these changes
Jul 15, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue:
#90
Fix:
Add function to read through the create, delete, rma and poap diff and populate the list of dictionaries containing the switches that are modified in the operation corresponding to each type of operation.
Output: