Skip to content

Commit

Permalink
Merge pull request #235 from CiscoDevNet/3.3.1
Browse files Browse the repository at this point in the history
Release 3.3.1
  • Loading branch information
praveenramoorthy authored Jul 13, 2023
2 parents 2f42736 + ccca6c3 commit 4464bbf
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 151 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ You can also include it in a `requirements.yml` file and install it with `ansibl
---
collections:
- name: cisco.dcnm
version: 3.3.0
version: 3.3.1
```
## Using this collection
Expand Down
12 changes: 0 additions & 12 deletions docs/cisco.dcnm.dcnm_network_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,8 @@ Examples
attach:
- ip_address: 192.168.1.224
ports: [Ethernet1/13, Ethernet1/14]
deploy: true
- ip_address: 192.168.1.225
ports: [Ethernet1/13, Ethernet1/14]
deploy: true
deploy: true
- net_name: ansible-net12
vrf_name: Tenant-2
Expand All @@ -819,10 +817,8 @@ Examples
attach:
- ip_address: 192.168.1.224
ports: [Ethernet1/11, Ethernet1/12]
deploy: true
- ip_address: 192.168.1.225
ports: [Ethernet1/11, Ethernet1/12]
deploy: true
deploy: false
- name: Replace networks
Expand All @@ -842,11 +838,9 @@ Examples
# Replace the ports with new ports
# ports: [Ethernet1/13, Ethernet1/14]
ports: [Ethernet1/16, Ethernet1/17]
deploy: true
# Delete this attachment
# - ip_address: 192.168.1.225
# ports: [Ethernet1/13, Ethernet1/14]
# deploy: true
deploy: true
# Dont touch this if its present on DCNM
# - net_name: ansible-net12
Expand All @@ -859,10 +853,8 @@ Examples
# attach:
# - ip_address: 192.168.1.224
# ports: [Ethernet1/11, Ethernet1/12]
# deploy: true
# - ip_address: 192.168.1.225
# ports: [Ethernet1/11, Ethernet1/12]
# deploy: true
# deploy: false
- name: Override networks
Expand All @@ -882,11 +874,9 @@ Examples
# Replace the ports with new ports
# ports: [Ethernet1/13, Ethernet1/14]
ports: [Ethernet1/16, Ethernet1/17]
deploy: true
# Delete this attachment
# - ip_address: 192.168.1.225
# ports: [Ethernet1/13, Ethernet1/14]
# deploy: true
deploy: true
# Delete this network
# - net_name: ansible-net12
Expand All @@ -899,10 +889,8 @@ Examples
# attach:
# - ip_address: 192.168.1.224
# ports: [Ethernet1/11, Ethernet1/12]
# deploy: true
# - ip_address: 192.168.1.225
# ports: [Ethernet1/11, Ethernet1/12]
# deploy: true
# deploy: false
- name: Delete selected networks
Expand Down
8 changes: 0 additions & 8 deletions docs/cisco.dcnm.dcnm_vrf_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1071,9 +1071,7 @@ Examples
service_vrf_template: null
attach:
- ip_address: 192.168.1.224
deploy: true
- ip_address: 192.168.1.225
deploy: false
- vrf_name: ansible-vrf-r2
vrf_id: 9008012
vrf_template: Default_VRF_Universal
Expand Down Expand Up @@ -1128,13 +1126,10 @@ Examples
service_vrf_template: null
attach:
- ip_address: 192.168.1.224
deploy: true
# Delete this attachment
# - ip_address: 192.168.1.225
# deploy: true
# Create the following attachment
- ip_address: 192.168.1.226
deploy: true
# Dont touch this if its present on DCNM
# - vrf_name: ansible-vrf-r2
# vrf_id: 9008012
Expand All @@ -1158,13 +1153,10 @@ Examples
service_vrf_template: null
attach:
- ip_address: 192.168.1.224
deploy: true
# Delete this attachment
# - ip_address: 192.168.1.225
# deploy: true
# Create the following attachment
- ip_address: 192.168.1.226
deploy: true
# Delete this vrf
# - vrf_name: ansible-vrf-r2
# vrf_id: 9008012
Expand Down
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: dcnm
version: 3.3.0
version: 3.3.1
readme: README.md
authors:
- Shrishail Kariyappanavar <nkshrishail>
Expand Down
77 changes: 55 additions & 22 deletions plugins/modules/dcnm_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,8 @@
attach:
- ip_address: 192.168.1.224
ports: [Ethernet1/13, Ethernet1/14]
deploy: true
- ip_address: 192.168.1.225
ports: [Ethernet1/13, Ethernet1/14]
deploy: true
deploy: true
- net_name: ansible-net12
vrf_name: Tenant-2
Expand All @@ -334,10 +332,8 @@
attach:
- ip_address: 192.168.1.224
ports: [Ethernet1/11, Ethernet1/12]
deploy: true
- ip_address: 192.168.1.225
ports: [Ethernet1/11, Ethernet1/12]
deploy: true
deploy: false
- name: Replace networks
Expand All @@ -357,11 +353,9 @@
# Replace the ports with new ports
# ports: [Ethernet1/13, Ethernet1/14]
ports: [Ethernet1/16, Ethernet1/17]
deploy: true
# Delete this attachment
# - ip_address: 192.168.1.225
# ports: [Ethernet1/13, Ethernet1/14]
# deploy: true
deploy: true
# Dont touch this if its present on DCNM
# - net_name: ansible-net12
Expand All @@ -374,10 +368,8 @@
# attach:
# - ip_address: 192.168.1.224
# ports: [Ethernet1/11, Ethernet1/12]
# deploy: true
# - ip_address: 192.168.1.225
# ports: [Ethernet1/11, Ethernet1/12]
# deploy: true
# deploy: false
- name: Override networks
Expand All @@ -397,11 +389,9 @@
# Replace the ports with new ports
# ports: [Ethernet1/13, Ethernet1/14]
ports: [Ethernet1/16, Ethernet1/17]
deploy: true
# Delete this attachment
# - ip_address: 192.168.1.225
# ports: [Ethernet1/13, Ethernet1/14]
# deploy: true
deploy: true
# Delete this network
# - net_name: ansible-net12
Expand All @@ -414,10 +404,8 @@
# attach:
# - ip_address: 192.168.1.224
# ports: [Ethernet1/11, Ethernet1/12]
# deploy: true
# - ip_address: 192.168.1.225
# ports: [Ethernet1/11, Ethernet1/12]
# deploy: true
# deploy: false
- name: Delete selected networks
Expand Down Expand Up @@ -613,6 +601,8 @@ def diff_for_attach_deploy(self, want_a, have_a, replace=False):

del want["isAttached"]
attach_list.append(want)
if bool(want["is_deploy"]):
dep_net = True

continue

Expand All @@ -625,6 +615,8 @@ def diff_for_attach_deploy(self, want_a, have_a, replace=False):
)
del want["isAttached"]
attach_list.append(want)
if bool(want["is_deploy"]):
dep_net = True
continue

if bool(have["isAttached"]) is not bool(want["isAttached"]):
Expand All @@ -635,21 +627,34 @@ def diff_for_attach_deploy(self, want_a, have_a, replace=False):
del have["isAttached"]
have.update({"deployment": False})
attach_list.append(have)
if bool(want["is_deploy"]):
dep_net = True
continue
del want["isAttached"]
want.update({"deployment": True})
attach_list.append(want)
if bool(want["is_deploy"]):
dep_net = True
continue

if bool(have["deployment"]) is not bool(want["deployment"]):
# We hit this section when attachment is successful, but, deployment is stuck in PENDING or
# OUT-OF-SYNC. In such cases, we just add the object to deploy list only. have['deployment']
# is set to False when deployment is PENDING or OUT-OF-SYNC - ref - get_have()
dep_net = True
if bool(want["is_deploy"]):
dep_net = True

if bool(want["is_deploy"]) is not bool(have["is_deploy"]):
if bool(want["is_deploy"]):
dep_net = True

if not found:
if bool(want["isAttached"]):
del want["isAttached"]
want["deployment"] = True
attach_list.append(want)
if bool(want["is_deploy"]):
dep_net = True

for attach in attach_list[:]:
for ip, ser in self.ip_sn.items():
Expand All @@ -671,6 +676,7 @@ def diff_for_attach_deploy(self, want_a, have_a, replace=False):
havtoattach = copy.deepcopy(hav)
havtoattach.update({"switchPorts": ""})
del havtoattach["isAttached"]
havtoattach["deployment"] = True
attach_list.append(havtoattach)
break

Expand Down Expand Up @@ -713,11 +719,15 @@ def update_attach_params(self, attach, net_name, deploy):
attach.update({"vlan": 0})
attach.update({"dot1QVlan": 0})
attach.update({"untagged": False})
attach.update({"deployment": deploy})
# This flag is not to be confused for deploy of attachment.
# "deployment" should be set True for attaching an attachment
# and set to False for detaching an attachment
attach.update({"deployment": True})
attach.update({"isAttached": True})
attach.update({"extensionValues": ""})
attach.update({"instanceValues": ""})
attach.update({"freeformConfig": ""})
attach.update({"is_deploy": deploy})
if "deploy" in attach:
del attach["deploy"]
del attach["ports"]
Expand Down Expand Up @@ -1384,7 +1394,7 @@ def get_have(self):
attach.update({"fabric": self.fabric})
attach.update({"vlan": vlan})
attach.update({"serialNumber": sn})
attach.update({"deployment": deployed})
attach.update({"deployment": deploy})
attach.update({"extensionValues": ""})
attach.update({"instanceValues": ""})
attach.update({"freeformConfig": ""})
Expand All @@ -1393,6 +1403,7 @@ def get_have(self):
attach.update({"detachSwitchPorts": ""})
attach.update({"switchPorts": ports})
attach.update({"untagged": False})
attach.update({"is_deploy": deployed})

if dep_net:
dep_networks.append(dep_net)
Expand Down Expand Up @@ -1428,7 +1439,7 @@ def get_want(self):
if not net.get("attach"):
continue
for attach in net["attach"]:
deploy = net_deploy if "deploy" not in attach else attach["deploy"]
deploy = net_deploy
networks.append(
self.update_attach_params(attach, net["net_name"], deploy)
)
Expand Down Expand Up @@ -1912,7 +1923,8 @@ def get_diff_merge(self, replace=False):
del base["lanAttachList"]
base.update({"lanAttachList": diff})
diff_attach.append(base)
dep_net = want_a["networkName"]
if net:
dep_net = want_a["networkName"]
else:
if (
net
Expand Down Expand Up @@ -1957,9 +1969,12 @@ def get_diff_merge(self, replace=False):
del base["lanAttachList"]
base.update({"lanAttachList": atch_list})
diff_attach.append(base)
if bool(attach["deployment"]):
if bool(attach["is_deploy"]):
dep_net = want_a["networkName"]

for atch in atch_list:
atch["deployment"] = True

if dep_net:
all_nets.append(dep_net)

Expand Down Expand Up @@ -2278,6 +2293,10 @@ def push_to_remote(self, is_rollback=False):
# Update the fabric name to specific fabric which the switches are part of.
self.update_ms_fabric(self.diff_detach)

for d_a in self.diff_detach:
for v_a in d_a["lanAttachList"]:
del v_a["is_deploy"]

resp = dcnm_send(
self.module, method, detach_path, json.dumps(self.diff_detach)
)
Expand Down Expand Up @@ -2406,6 +2425,10 @@ def push_to_remote(self, is_rollback=False):
# Update the fabric name to specific fabric which the switches are part of.
self.update_ms_fabric(self.diff_attach)

for d_a in self.diff_attach:
for v_a in d_a["lanAttachList"]:
del v_a["is_deploy"]

for attempt in range(0, 50):
resp = dcnm_send(
self.module, method, attach_path, json.dumps(self.diff_attach)
Expand Down Expand Up @@ -2453,7 +2476,12 @@ def validate_input(self):

if state == "query":

if self.dcnm_version > 11:
# If ingress replication is enabled multicast group address should be set to "" as default.
# If ingress replication is not enabled, the default value for multicast group address
# is different for DCNM and NDFC.
if self.fabric_det.get("replicationMode") == "Ingress":
mcast_group_addr = ""
elif self.dcnm_version > 11:
mcast_group_addr = "239.1.1.1"
else:
mcast_group_addr = "239.1.1.0"
Expand Down Expand Up @@ -2533,8 +2561,12 @@ def validate_input(self):

else:

# The default value for multicast group address is different for DCNM and NDFC.
if self.dcnm_version > 11:
# If ingress replication is enabled multicast group address should be set to "" as default.
# If ingress replication is not enabled, the default value for multicast group address
# is different for DCNM and NDFC.
if self.fabric_det.get("replicationMode") == "Ingress":
mcast_group_addr = ""
elif self.dcnm_version > 11:
mcast_group_addr = "239.1.1.1"
else:
mcast_group_addr = "239.1.1.0"
Expand All @@ -2544,7 +2576,7 @@ def validate_input(self):
net_id=dict(type="int", range_max=16777214),
vrf_name=dict(type="str", length_max=32),
attach=dict(type="list"),
deploy=dict(type="bool"),
deploy=dict(type="bool", default=True),
gw_ip_subnet=dict(type="ipv4_subnet", default=""),
vlan_id=dict(type="int", range_max=4094),
routing_tag=dict(type="int", default=12345, range_max=4294967295),
Expand Down Expand Up @@ -2596,6 +2628,7 @@ def validate_input(self):
)
net["attach"] = valid_att
for attach in net["attach"]:
attach["deploy"] = net["deploy"]
if attach.get("ports"):
attach["ports"] = [port.capitalize() for port in attach["ports"]]
invalid_params.extend(invalid_att)
Expand Down
Loading

0 comments on commit 4464bbf

Please sign in to comment.