Skip to content

Resolving dcnm vpc pair keyError with ipAddress #460

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
Merged
Show file tree
Hide file tree
Changes from 2 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
18 changes: 18 additions & 0 deletions playbooks/roles/dcnm_vpc_pair/dcnm_hosts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
all:
vars:
ansible_user: "admin"
ansible_password: "password-secret"
ansible_python_interpreter: python
ansible_httpapi_validate_certs: False
ansible_httpapi_use_ssl: True
children:
dcnm:
vars:
ansible_it_fabric: fabric-stage
ansible_connection: ansible.netcommon.httpapi
ansible_network_os: cisco.dcnm.dcnm
ansible_httpapi_validate_certs: no
hosts:
nac-ndfc1:
ansible_host: 10.10.5.1

80 changes: 80 additions & 0 deletions playbooks/roles/dcnm_vpc_pair/dcnm_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
# This playbook can be used to execute integration tests for
# the role located in:
#
# tests/integration/targets/dcnm_image_policy
#
# Modify the hosts and vars sections with details for your testing
# setup and uncomment the testcase you want to run.
#
- hosts: dcnm
gather_facts: no
connection: ansible.netcommon.httpapi

vars:
switch_username: admin
switch_password: "password-secret"
ansible_it_fabric: fabric-stage
ansible_switch1: 192.168.1.1
ansible_switch2: 192.168.1.2
ansible_peer1_ip: 192.168.1.1
ansible_peer2_ip: 192.168.1.2
ipAddress: 192.168.1.5
ansible_vxlan_vpc_domain_id: 1000

config:
- peerOneId: "{{ ansible_switch1 }}"
peerTwoId: "{{ ansible_switch2 }}"
templateName: "vpc_pair" # Using the correct template name
profile:
# Required fields for VPC template
ADMIN_STATE: true
ALLOWED_VLANS: "all"
DOMAIN_ID: "{{ ansible_vxlan_vpc_domain_id }}"
FABRIC_NAME: "{{ ansible_it_fabric }}"
KEEP_ALIVE_HOLD_TIMEOUT: 3
KEEP_ALIVE_VRF: "management"
PC_MODE: "active"
PEER1_KEEP_ALIVE_LOCAL_IP: "{{ ansible_peer1_ip }}"
PEER1_MEMBER_INTERFACES: "eth1/1"
PEER1_PCID: 1
PEER2_KEEP_ALIVE_LOCAL_IP: "{{ ansible_peer2_ip }}"
PEER2_MEMBER_INTERFACES: "eth1/1"
PEER2_PCID: 2

# Additional required fields
ipAddress: "{{ ansible_peer1_ip }}"
peer1Ip: "{{ ansible_peer1_ip }}"
peer2Ip: "{{ ansible_peer2_ip }}"
vpcDomainId: "{{ ansible_vxlan_vpc_domain_id }}"
adminState: true
keepAliveVrf: "management"
keepAliveHoldTimeout: 3
keepAliveLocalIp: "{{ ansible_peer1_ip }}"
keepAliveRemoteIp: "{{ ansible_peer2_ip }}"

# Template specific fields
templateName: "vpc_pair"
templatePropId: ""
templatePropName: "vpc_pair"
templatePropDescription: "VPC Template"
templatePropDataType: "JSON"
templatePropDefaultValue: ""
templatePropDisplayName: "VPC Configuration"
templatePropIsMandatory: true
templatePropIsMultiSelect: false
templatePropIsPassword: false
templatePropIsReadOnly: false
templatePropIsRequired: true
templatePropIsSecure: false
templatePropIsSortable: false
templatePropIsVisible: true
templatePropOptions: []
templatePropRange: []
templatePropValue: ""
templatePropValueType: "STRING"
templateIPAddress: "{{ ansible_peer1_ip }}"


roles:
- dcnm_vpc_pair
1 change: 1 addition & 0 deletions plugins/module_utils/network/dcnm/dcnm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"long": "int",
"ipV4Address": "ipv4",
"ipV6Address": "ipv6",
"ipAddress": "ipv4",
"interfaceRange": "list",
"boolean": "bool",
"enum": "str",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@

- assert:
that:
- 'result.changed == false'
- 'result.changed == true'
- '(result["diff"][0]["merged"] | length) == 0'
- '(result["diff"][0]["modified"] | length) == 0'
- '(result["diff"][0]["modified"] | length) == 1'
- '(result["diff"][0]["deleted"] | length) == 0'
- '(result["diff"][0]["query"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 1'

- assert:
that:
Expand Down Expand Up @@ -163,12 +163,12 @@

- assert:
that:
- 'result.changed == false'
- 'result.changed == true'
- '(result["diff"][0]["merged"] | length) == 0'
- '(result["diff"][0]["modified"] | length) == 0'
- '(result["diff"][0]["modified"] | length) == 1'
- '(result["diff"][0]["deleted"] | length) == 0'
- '(result["diff"][0]["query"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 1'
when: (fabric_type == "VXLANFabric")

- assert:
Expand All @@ -184,7 +184,7 @@
- name: Delete VPC switch pair
cisco.dcnm.dcnm_vpc_pair:
src_fabric: "{{ ansible_it_fabric }}"
deploy: true
deploy: true # Flag indicating whether changes are to be deployed, Mandatory: False, Type: bool, default: True
state: deleted # only choose form [merged, replaced, deleted, overridden, query. fetch]
config:
- peerOneId: "{{ ansible_switch1 }}" # IP Address/Host Name of Peer1 of VPC switch pair, Mandatory: True, Type: str
Expand All @@ -205,7 +205,6 @@
- 'item["RETURN_CODE"] == 200'
loop: '{{ result.response }}'


##############################################
## MERGE ##
##############################################
Expand Down Expand Up @@ -239,7 +238,7 @@
- '(result["diff"][0]["modified"] | length) == 0'
- '(result["diff"][0]["deleted"] | length) == 0'
- '(result["diff"][0]["query"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 1'
- '(result["diff"][0]["deploy"] | length) == 0'
when: (fabric_type == "LANClassic")

- assert:
Expand Down Expand Up @@ -270,7 +269,7 @@
- '(result["diff"][0]["modified"] | length) == 0'
- '(result["diff"][0]["deleted"] | length) == 1'
- '(result["diff"][0]["query"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 1'
when: (fabric_type == "LANClassic")

- assert:
Expand All @@ -286,6 +285,8 @@
- name: Create VPC switch pair without state and deploy flag
cisco.dcnm.dcnm_vpc_pair:
src_fabric: "{{ ansible_it_fabric }}"
deploy: true
state: merged
config:
- peerOneId: "{{ ansible_switch1 }}" # IP Address/Host Name of Peer1 of VPC switch pair, Mandatory: True, Type: str
peerTwoId: "{{ ansible_switch2 }}" # IP Address/Host Name of Peer2 of VPC switch pair, Mandatory: True, Type: str
Expand Down Expand Up @@ -352,7 +353,7 @@
cisco.dcnm.dcnm_vpc_pair:
src_fabric: "{{ ansible_it_fabric }}"
state: merged # only choose form [merged, replaced, deleted, overridden, query. fetch]
deploy: false # Flag indicating whether changes are to be deployed, Mandatory: False, Type: bool, default: True
deploy: true # Flag indicating whether changes are to be deployed, Mandatory: False, Type: bool, default: True
config:
- peerOneId: "{{ ansible_switch1 }}" # IP Address/Host Name of Peer1 of VPC switch pair, Mandatory: True, Type: str
peerTwoId: "{{ ansible_switch2 }}" # IP Address/Host Name of Peer2 of VPC switch pair, Mandatory: True, Type: str
Expand All @@ -376,7 +377,7 @@
- '(result["diff"][0]["modified"] | length) == 0'
- '(result["diff"][0]["deleted"] | length) == 0'
- '(result["diff"][0]["query"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 1'

- assert:
that:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,7 @@
- '(result["diff"][0]["deleted"] | length) == 0'
- '(result["diff"][0]["query"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 1'
when: (fabric_type == "LANClassic")

- assert:
that:
- 'result.changed == false'
- '(result["diff"][0]["merged"] | length) == 0'
- '(result["diff"][0]["modified"] | length) == 0'
- '(result["diff"][0]["deleted"] | length) == 0'
- '(result["diff"][0]["query"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 0'
when: (fabric_type == "VXLANFabric")
when: (fabric_type == "LANClassic" or fabric_type == "VXLANFabric")

- assert:
that:
Expand All @@ -138,12 +128,12 @@

- assert:
that:
- 'result.changed == false'
- 'result.changed == true'
- '(result["diff"][0]["merged"] | length) == 0'
- '(result["diff"][0]["modified"] | length) == 0'
- '(result["diff"][0]["modified"] | length) == 1'
- '(result["diff"][0]["deleted"] | length) == 0'
- '(result["diff"][0]["query"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 1'

- assert:
that:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,7 @@
- '(result["diff"][0]["deleted"] | length) == 0'
- '(result["diff"][0]["query"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 1'
when: (fabric_type == "LANClassic")

- assert:
that:
- 'result.changed == false'
- '(result["diff"][0]["merged"] | length) == 0'
- '(result["diff"][0]["modified"] | length) == 0'
- '(result["diff"][0]["deleted"] | length) == 0'
- '(result["diff"][0]["query"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 0'
when: (fabric_type == "VXLANFabric")
when: (fabric_type == "LANClassic" or fabric_type == "VXLANFabric")

- assert:
that:
Expand All @@ -146,12 +136,12 @@

- assert:
that:
- 'result.changed == false'
- 'result.changed == true'
- '(result["diff"][0]["merged"] | length) == 0'
- '(result["diff"][0]["modified"] | length) == 0'
- '(result["diff"][0]["modified"] | length) == 1'
- '(result["diff"][0]["deleted"] | length) == 0'
- '(result["diff"][0]["query"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 0'
- '(result["diff"][0]["deploy"] | length) == 1'

- assert:
that:
Expand Down