Automating Repeatable Tasks in Cisco Identity Service Engine
Madhuri D.
Security Automation Consultant @ Fortinet | Ex-Cisco | CKA, Azure | DevNet P | CCNP(S) | NSE-1,2,3,4
Continuing the previous post where I had shared how we can setup Ansible for Cisco Identity Service Engine
[Please Note: this was before ISE 3.0 introduced where additional feature for automation where introduced. For further details please refer this ].
In this post we shall be looking at how we can use Python to Automate tasks related to Endpoint Onboarding, Fetch and Deletion from Cisco ISE.
Certain tasks in ISE are repeatable and can be automated which can then allow the benefit of automation like
In this post, we will be going through the script and its usage which can enable above mentioned points.
Applicability of automation usecases where administrator is required to add endpoint to Cisco ISE can be observed in
Breakdown of Script
Script is designed as Class to enable which has various features defined as function of class like
领英推荐
This will the capability to extend the features of the class in future.
The complete detail of the Requirement, Usecases and Usage has been explained at Github Page
Following Sequence of action will be seen post successful execution of script.
Code Snippet
def postendpoint(self)
uri = self.getendpointurl(False)
url = "https://" + str(self.getiseip()) + ":9060" + str(uri)
rawdata = open("endpoint.json",'r')
payload = json.loads(rawdata.read())
resp = self.apicall("POST", url, json.dumps(payload))
if resp.status_code == 201:
logger.info("Endpoint is Added Successfully.")
else:
logger.error("Issue with Adding Endpoint. For more Details, Response from ISE was --->\n {}".format(resp.text))
def postbulkendpoint(self):
uri = self.getendpointurl(True)
url = "https://" + str(self.getiseip()) + ":9060" + str(uri)
rawdata = open("bulkendpoint.xml", 'r')
resp = self.apicall("PUT", url, rawdata)
if resp.status_code == 202:
logger.info("All Endpoints are Added Successfully.")
else:
logger.error("Issue with Adding Endpoint. For more Details, Response from ISE was --->\n {}".format(resp.text))
def delendpoint(self,endpointid):
uri = self.getdeleteurl()
url = "https://" + str(self.getiseip()) + ":9060" + str(uri) + str(endpointid)
resp = self.apicall("DELETE", url,{})
if resp.status_code == 204:
logger.info("{} is Deleted Successfully.")
else:
logger.error("Issue with Deleting Endpoint with UUID {}. For more Details, Response from ISE was --->\n {}".format(endpointid,resp.text)):
Feel free to explore the code and add your feedbacks !!
Thanks!!