Skip to content

Commit

Permalink
Merge pull request #223 from CiscoDevNet/3.3.0
Browse files Browse the repository at this point in the history
Release 3.3.0
  • Loading branch information
praveenramoorthy authored May 23, 2023
2 parents b0a089b + cfddcdd commit 9c326e3
Show file tree
Hide file tree
Showing 24 changed files with 3,138 additions and 397 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.2.0
version: 3.3.0
```
## Using this collection
Expand Down
5 changes: 5 additions & 0 deletions docs/cisco.dcnm.dcnm_inventory_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ Parameters
<li>super_spine</li>
<li>border_super_spine</li>
<li>border_gateway_super_spine</li>
<li>access</li>
<li>aggregation</li>
<li>edge_router</li>
<li>core_router</li>
<li>tor</li>
</ul>
</td>
<td>
Expand Down
15 changes: 10 additions & 5 deletions docs/cisco.dcnm.dcnm_vrf_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ Parameters
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
Expand Down Expand Up @@ -292,7 +293,6 @@ Parameters
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
Expand Down Expand Up @@ -1099,15 +1099,20 @@ Examples
- ip_address: 192.168.1.224
- ip_address: 192.168.1.225
vrf_lite:
# All parameters under vrf_lite except peer_vrf are optional and
# will be supplied by DCNM when omitted in the playbook
- peer_vrf: test_vrf_1 # peer_vrf is mandatory
interface: Ethernet1/16 # optional
- peer_vrf: test_vrf_1 # optional
interface: Ethernet1/16 # mandatory
ipv4_addr: 10.33.0.2/30 # optional
neighbor_ipv4: 10.33.0.1 # optional
ipv6_addr: 2010::10:34:0:7/64 # optional
neighbor_ipv6: 2010::10:34:0:3 # optional
dot1q: 2 # dot1q can be got from dcnm/optional
- peer_vrf: test_vrf_2 # optional
interface: Ethernet1/17 # mandatory
ipv4_addr: 20.33.0.2/30 # optional
neighbor_ipv4: 20.33.0.1 # optional
ipv6_addr: 3010::10:34:0:7/64 # optional
neighbor_ipv6: 3010::10:34:0:3 # optional
dot1q: 3 # dot1q can be got from dcnm/optional
# The two VRFs below will be replaced in the target fabric.
- name: Replace vrfs
Expand Down
4 changes: 2 additions & 2 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: cisco
name: dcnm
version: 3.2.0
version: 3.3.0
readme: README.md
authors:
- Shrishail Kariyappanavar <nkshrishail>
Expand All @@ -13,5 +13,5 @@ description: Ansible collection for the Cisco Nexus® Dashboard Fabric Controlle
license: Apache-2.0
tags: [cisco, ndfc, dcnm, nxos, networking, vxlan]
dependencies:
"ansible.netcommon": ">=2.6.1,<=4.1.0"
"ansible.netcommon": ">=2.6.1"
repository: https://github.com/CiscoDevNet/ansible-dcnm
7 changes: 7 additions & 0 deletions plugins/action/dcnm_vrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ def run(self, tmp=None, task_vars=None):
if "vlan_id" in at:
msg = "Playbook parameter vlan_id should not be specified under the attach: block. Please specify this under the config: block instead" # noqa
return {"failed": True, "msg": msg}
if "vrf_lite" in at:
try:
for vl in at["vrf_lite"]:
continue
except TypeError:
msg = "Please specify interface parameter under vrf_lite section in the playbook"
return {"failed": True, "msg": msg}

self.result = super(ActionModule, self).run(task_vars=task_vars)
return self.result
41 changes: 29 additions & 12 deletions plugins/module_utils/network/dcnm/dcnm.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ def validate_ip_address_format(type, item, invalid_params):
subnet = item.split("/")[1]
if not subnet or int(subnet) > mask_len:
invalid_params.append(
"{0} : Invalid {1} gw/subnet syntax".format(item, addr_type)
"{0} : Invalid {1} gw/subnet syntax".format(
item, addr_type
)
)
else:
invalid_params.append(
"{0} : Invalid {1} gw/subnet syntax".format(item, addr_type)
"{0} : Invalid {1} gw/subnet syntax".format(
item, addr_type
)
)
try:
socket.inet_pton(addr_family, address)
Expand Down Expand Up @@ -138,7 +142,9 @@ def validate_list_of_dicts(param_list, spec, module=None):
module.no_log_values.add(item)
else:
msg = "\n\n'{0}' is a no_log parameter".format(param)
msg += "\nAnsible module object must be passed to this "
msg += (
"\nAnsible module object must be passed to this "
)
msg += "\nfunction to ensure it is not logged\n\n"
raise Exception(msg)

Expand All @@ -158,6 +164,7 @@ def get_fabric_inventory_details(module, fabric):
conn = Connection(module._socket_path)
if conn.get_version() == 12:
path = "/appcenter/cisco/ndfc/api/v1/lan-fabric" + path
path += "/switchesByFabric"

count = 1
while rc is False:
Expand Down Expand Up @@ -188,10 +195,13 @@ def get_fabric_inventory_details(module, fabric):
raise Exception(response)

for device_data in response.get("DATA"):
key = device_data.get("ipAddress")

if device_data.get("ipAddress", "") != "":
key = device_data.get("ipAddress")
else:
key = device_data.get("logicalName")
inventory_data[key] = device_data
rc = True

return inventory_data


Expand All @@ -204,7 +214,9 @@ def get_ip_sn_dict(inventory_data):
ip = inventory_data[device_key].get("ipAddress")
sn = inventory_data[device_key].get("serialNumber")
hn = inventory_data[device_key].get("logicalName")
ip_sn.update({ip: sn})

if ip != "":
ip_sn.update({ip: sn})
hn_sn.update({hn: sn})

return ip_sn, hn_sn
Expand Down Expand Up @@ -247,9 +259,7 @@ def dcnm_get_ip_addr_info(module, sw_elem, ip_sn, hn_sn):

msg_dict = {"Error": ""}
msg = 'Given switch elem = "{}" is not a valid one for this fabric\n'
msg1 = (
'Given switch elem = "{}" cannot be validated, provide a valid ip_sn object\n'
)
msg1 = 'Given switch elem = "{}" cannot be validated, provide a valid ip_sn object\n'

# Check if the given sw_elem is a v4 ip_addr
try:
Expand Down Expand Up @@ -377,7 +387,9 @@ def dcnm_reset_connection(module):
conn = Connection(module._socket_path)

conn.logout()
return conn.login(conn.get_option("remote_user"), conn.get_option("password"))
return conn.login(
conn.get_option("remote_user"), conn.get_option("password")
)


def dcnm_version_supported(module):
Expand All @@ -395,7 +407,10 @@ def dcnm_version_supported(module):
supported = None
data = None

paths = ["/fm/fmrest/about/version", "/appcenter/cisco/ndfc/api/about/version"]
paths = [
"/fm/fmrest/about/version",
"/appcenter/cisco/ndfc/api/about/version",
]
for path in paths:
response = dcnm_send(module, method, path)
if response["RETURN_CODE"] == 200:
Expand Down Expand Up @@ -476,7 +491,9 @@ def dcnm_get_url(module, fabric, path, items, module_name):
)
url = path.format(fabric, itemstr)
else:
itemstr = ",".join(itemlist[iter * (len(itemlist) // send_count):])
itemstr = ",".join(
itemlist[iter * (len(itemlist) // send_count):]
)
url = path.format(fabric, itemstr)

att_objects = dcnm_send(module, method, url)
Expand Down
16 changes: 12 additions & 4 deletions plugins/modules/dcnm_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
description:
- Role which needs to be assigned to the switch
choices: ['leaf', 'spine', 'border', 'border_spine', 'border_gateway', 'border_gateway_spine',
'super_spine', 'border_super_spine', 'border_gateway_super_spine']
'super_spine', 'border_super_spine', 'border_gateway_super_spine', 'access', 'aggregation',
'edge_router', 'core_router', 'tor']
type: str
required: false
default: leaf
Expand Down Expand Up @@ -947,6 +948,11 @@ def validate_input(self):
"super_spine",
"border_super_spine",
"border_gateway_super_spine",
"access",
"aggregation",
"edge_router",
"core_router",
"tor"
],
default="leaf",
),
Expand Down Expand Up @@ -1091,6 +1097,11 @@ def validate_input(self):
"super_spine",
"border_super_spine",
"border_gateway_super_spine",
"access",
"aggregation",
"edge_router",
"core_router",
"tor",
"None",
],
default="None",
Expand Down Expand Up @@ -1316,7 +1327,6 @@ def set_lancred_switch(self, set_lan):

def lancred_all_switches(self):

want_list = []
# Get Fabric Inventory Details
method = "GET"
path = "/fm/fmrest/lanConfig/getLanSwitchCredentials"
Expand Down Expand Up @@ -1356,7 +1366,6 @@ def lancred_all_switches(self):

def assign_role(self):

want_list = []
method = "GET"
path = "/rest/control/fabrics/{0}/inventory".format(self.fabric)
if self.nd:
Expand Down Expand Up @@ -1484,7 +1493,6 @@ def config_save(self):
def config_deploy(self):

# config-deploy
sernos = []
method = "POST"
path = "/rest/control/fabrics/{0}".format(self.fabric)
if self.nd:
Expand Down
Loading

0 comments on commit 9c326e3

Please sign in to comment.