08-23-2019 07:53 AM - edited 02-21-2020 11:09 AM
I have successfully created a python script that does the following:
Asks user if device is printer or workstation, and based on answer execute separate functions. From here the user is then asked several questions:
Is the endpoint new (True/False)
Enter MAC
Enter Description
return inputs;
Now based on whether the host is new or not we create the endpoint via requests.post. OR if existing we get the endpoint string, and then update that existing endpoint with the proper static group assignment.
All raw input has validation checking. I want to determine the best way to implement bulk adds. I have a separate script working only for NEW endpoint bulk adds to ISE by reading csv/txt file. I am trying to determine if I should add NEW/existing bulk add functions in my existing script and prompt user with similar questions to determine bulk adds, etc. or keep the two separate.
Pretty confident I can make this work. However, the one concern I have at the moment is that if someone from the server/imaging team creates a csv/txt file with BOTH existing and new endpoints I may have a problem since the two processes are different from a rest perspective.
Also, what is the best approach from anyone's experiences on storing several endpoint ID strings in python. I assume a list or array is what is typically used. Thoughts? Ultimately it would be nice for our server team to be able to have one script to update/create a single endpoint OR update/create endpoints in bulk.
I think one possible way would be to open/read file, readlines, create loop, run requests.get, somehow store existing endpoint IDs in one list, store MACs that do not exist in another list, then execute two separate functions. One that takes new endpoint list and loop through executing requests.post. Another function that takes the existing endpoint list and executes requests.put.
Any suggestions on the bulk update/create idea? Am I over-complicating the process?
Thanks in advance.
Solved! Go to Solution.
08-26-2019 02:23 PM
Hey Mike
Would you be open to sharing your phython code - I think you might inspire some others to do the same?
You're on the right track though - DevNet is the way to go and you have to start with something to get going. Have you found a good ISE community on the DevNet site?
I have yet to find a problem that I can neatly solve via API to ISE ... as luck would have it, as soon as I click the "Post" button, the situation will change :-)
cheers
Arne
08-25-2019 03:27 PM
If I may ask, why did you go down the route of using REST, as opposed to using the import/export in Context Visibility? I know the difference between UI/CLI etc., but what is the main problem you are hoping to solve?
I would imagine that since you're using an API, you want some kind of automation and smooth process that does not involve clicking on the UI. But an interactive script is not too far from that either ... - and now you have the dilemma of where to store your persistent data. I would argue that ISE is that storage place. The simplest solution for you would of course be a flat file that you read in and process. If the number of items is not too large then that will probably work. Storing the data in the Python script is probably not advisable unless you're just tinkering around for a lab test.
Flat file is simple and quick to implement. But I would have my fears about data corruption because it could be easy to accidentally open the file in a text editor and be tempted to edit randomly. No data integrity. Maybe a lightweight DB is the answer.
How many endpoints are you looking to manage this way?
08-26-2019 05:32 AM
If I may ask, why did you go down the route of using REST, as opposed to using the import/export in Context Visibility? I know the difference between UI/CLI etc., but what is the main problem you are hoping to solve?
The idea is/was to continue to learn how to automate certain tasks since we are getting Ansible soon. We (network team) want to keep other teams out of the ISE GUI. As of now a few python scripts I put together have gained some interest and the server team likes the ability to remove the network team from the imaging process.
I would imagine that since you're using an API, you want some kind of automation and smooth process that does not involve clicking on the UI. But an interactive script is not too far from that either ... - and now you have the dilemma of where to store your persistent data. I would argue that ISE is that storage place. The simplest solution for you would of course be a flat file that you read in and process. If the number of items is not too large then that will probably work. Storing the data in the Python script is probably not advisable unless you're just tinkering around for a lab test.
Flat file is simple and quick to implement. But I would have my fears about data corruption because it could be easy to accidentally open the file in a text editor and be tempted to edit randomly. No data integrity. Maybe a lightweight DB is the answer.
Now that I have had a few days to think about it I agree. On average most tickets may include maybe 10-15 hosts. The bulk python script drive was for one project that have 150 new workstations that need a new image.
How many endpoints are you looking to manage this way?
The idea is that the numbers will vary upon ticket request/s. So at any time it could be 1-??.
I appreciate the feedback.
08-26-2019 02:23 PM
Hey Mike
Would you be open to sharing your phython code - I think you might inspire some others to do the same?
You're on the right track though - DevNet is the way to go and you have to start with something to get going. Have you found a good ISE community on the DevNet site?
I have yet to find a problem that I can neatly solve via API to ISE ... as luck would have it, as soon as I click the "Post" button, the situation will change :-)
cheers
Arne
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide