Skip to content

Commit

Permalink
Merge pull request #198 from CiscoDevNet/3.0.0
Browse files Browse the repository at this point in the history
* Changes to add retry limit to send API on DCNM 401 return code scenarios

* Fix for mcast unicast issue

* Update license key (#186)

* RMA support for Inventory module (#189)

* Fix in dcnm_policy module to consider deploy flag during DELETE operations

* Update galaxy.yml

* Update README.md

* Update CHANGELOG.md

---------

Co-authored-by: Mike Wiebe <[email protected]>
Co-authored-by: mmudigon <[email protected]>
  • Loading branch information
3 people authored Feb 22, 2023
2 parents c7ba577 + 0c58b03 commit c19fbdc
Show file tree
Hide file tree
Showing 13 changed files with 898 additions and 111 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ You can also include it in a `requirements.yml` file and install it with `ansibl
---
collections:
- name: cisco.dcnm
version: 2.4.0
version: 3.0.0
```
## Using this collection
Expand Down
159 changes: 156 additions & 3 deletions docs/cisco.dcnm.dcnm_inventory_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Parameters
</td>
<td>
<div>Name of the authentication protocol to be used.</div>
<div>For POAP configurations authentication protocol should be <em>MD5</em>.</div>
<div>For POAP and RMA configurations authentication protocol should be <em>MD5</em>.</div>
</td>
</tr>
<tr>
Expand All @@ -81,7 +81,7 @@ Parameters
<b>max_hops</b>
<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: purple">integer</span>
</div>
</td>
<td>
Expand Down Expand Up @@ -276,6 +276,137 @@ Parameters
<div>Set this to false for greenfield deployment and true for brownfield deployment</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>rma</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
/ <span style="color: purple">elements=dictionary</span>
</div>
</td>
<td>
</td>
<td>
<div>RMA an existing switch with a new one</div>
<div>Please note that the existing switch should be configured and deployed in maintenance mode</div>
<div>Please note that the existing switch being replaced should be shutdown state or out of network</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>config_data</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">dictionary</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>Basic config data of switch to Bootstrap for RMA.</div>
<div><code>modulesModel</code> and <code>gateway</code> are mandatory.</div>
<div><code>modulesModel</code> is list of model of modules in switch to Bootstrap for RMA.</div>
<div><code>gateway</code> is the gateway IP with mask for the switch to Bootstrap for RMA.</div>
<div>For other supported config data please refer to NDFC/DCNM configuration guide.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>image_policy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
<div>Name of the image policy to be applied on switch during Bootstrap for RMA.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>model</b>
<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>
</td>
<td>
<div>Model of switch to Bootstrap for RMA.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>old_serial</b>
<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>
</td>
<td>
<div>Serial number of switch to be replaced by RMA.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>serial_number</b>
<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>
</td>
<td>
<div>Serial number of switch to Bootstrap for RMA.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>version</b>
<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>
</td>
<td>
<div>Software version of switch to Bootstrap for RMA.</div>
</td>
</tr>

<tr>
<td class="elbow-placeholder"></td>
<td colspan="2">
Expand Down Expand Up @@ -335,7 +466,7 @@ Parameters
</td>
<td>
<div>Login username to the switch.</div>
<div>For POAP configurations username should be <em>admin</em></div>
<div>For POAP and RMA configurations username should be <em>admin</em></div>
</td>
</tr>

Expand Down Expand Up @@ -394,6 +525,7 @@ Parameters
<td>
<div>The state of DCNM after module completion.</div>
<div><em>merged</em> and <em>query</em> are the only states supported for POAP.</div>
<div><em>merged</em> is the only state supported for RMA.</div>
</td>
</tr>
</table>
Expand Down Expand Up @@ -631,6 +763,27 @@ Examples
state: query # merged / query
query_poap: True
# The following switch which is part of fabric will be replaced with a new switch
# with same configurations through RMA.
# Please note that the existing switch should be configured in maintenance mode and in shutdown state
- name: RMA switch Configuration
cisco.dcnm.dcnm_inventory:
fabric: vxlan-fabric
state: merged # Only merged is supported for rma config
config:
- seed_ip: 192.168.0.4
user_name: switch_username
password: switch_password
rma:
- serial_number: 2A3BCDEFJKL
old_serial: 2A3BCDEFGHI
model: 'N9K-C9300v'
version: '9.3(7)'
image_policy: "rma_image_policy"
config_data:
modulesModel: [N9K-X9364v, N9K-vSUP]
gateway: 192.168.0.1/24
Expand Down
6 changes: 3 additions & 3 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: cisco
name: dcnm
version: 2.4.0
version: 3.0.0
readme: README.md
authors:
- Shrishail Kariyappanavar <nkshrishail>
Expand All @@ -10,8 +10,8 @@ authors:
- Mike Wiebe <mikewiebe>
- Praveen Ramoorthy <praveenramoorthy>
description: Ansible collection for the Cisco Nexus® Dashboard Fabric Controller (NDFC) - formerly DCNM
license_file: LICENSE
license: LICENSE
tags: [cisco, ndfc, dcnm, nxos, networking, vxlan]
dependencies:
"ansible.netcommon": "*"
"ansible.netcommon": ">=2.6.1"
repository: https://github.com/CiscoDevNet/ansible-dcnm
25 changes: 20 additions & 5 deletions plugins/httpapi/dcnm.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def __init__(self, *args, **kwargs):
self.headers = {"Content-Type": "application/json"}
self.txt_headers = {"Content-Type": "text/plain"}
self.version = None
# Retry count for send API
self.retrycount = 5

def get_version(self):
return self.version
Expand Down Expand Up @@ -271,21 +273,27 @@ def send_request(self, method, path, json=None):

self.check_url_connection()

msg = '". Please verify your login credentials, access permissions and fabric details and try again '

try:
# Perform some very basic path input validation.
path = str(path)
if path[0] != "/":
msg = "Value of <path> does not appear to be formated properly"
raise ConnectionError(self._return_info(None, method, path, msg))
response, rdata = self.connection.send(
path, json, method=method, headers=self.headers, force_basic_auth=True
path, json, self.retrycount, method=method, headers=self.headers, force_basic_auth=True
)
return self._verify_response(response, method, path, rdata)
except Exception as e:
eargs = e.args[0]
# In some cases netcommon raises execeptions without arguments, so check for exception args.
if e.args:
eargs = e.args[0]
else:
eargs = e
if isinstance(eargs, dict) and eargs.get("METHOD"):
return eargs
raise ConnectionError(str(e))
raise ConnectionError(str(e) + msg)

def send_txt_request(self, method, path, txt=None):
"""This method handles all DCNM REST API requests other then login"""
Expand All @@ -294,6 +302,8 @@ def send_txt_request(self, method, path, txt=None):

self.check_url_connection()

msg = '". Please verify your login credentials, access permissions and fabric details and try again '

try:
# Perform some very basic path input validation.
path = str(path)
Expand All @@ -303,16 +313,21 @@ def send_txt_request(self, method, path, txt=None):
response, rdata = self.connection.send(
path,
txt,
self.retrycount,
method=method,
headers=self.txt_headers,
force_basic_auth=True,
)
return self._verify_response(response, method, path, rdata)
except Exception as e:
eargs = e.args[0]
# In some cases netcommon raises execeptions without arguments, so check for exception args.
if e.args:
eargs = e.args[0]
else:
eargs = e
if isinstance(eargs, dict) and eargs.get("METHOD"):
return eargs
raise ConnectionError(str(e))
raise ConnectionError(str(e) + msg)

def _verify_response(self, response, method, path, rdata):
"""Process the return code and response object from DCNM"""
Expand Down
Loading

0 comments on commit c19fbdc

Please sign in to comment.