Wireless Access

Reply
Occasional Contributor II
Posts: 58
Registered: ‎05-22-2016

Clearpass Clear all endpoints via API

Hi guys, I want to delete all endpoints from the endpoint database using the API, i am able to delete 1 by 1 but is there a way to delete them all?

 

below is what i am using but it is only matching the element id which is different for every endpoint

 

 

[root@mx ~]# curl -sk -u apiadmin:eTIPS123 -d '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <TipsApiRequest xmlns="http://www.avendasys.com/tipsapiDefs/1.0">
> <TipsHeader version="6.5"/>
> <Filter entity="Endpoint">
> <Criteria fieldName="macAddress" filterString="dcef09e1cecc" match="contains"/>
> </Filter>
> </TipsApiRequest>' https://192.168.50.10/tipsapi/config/deleteConfirm/Endpoint

 

 

 

 

 

 

curl -sk -u apiadmin:eTIPS123 -d '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TipsApiRequest xmlns="http://www.avendasys.com/tipsapiDefs/1.0">
<TipsHeader version="6.4"/>
<Delete>
<Element-Id>Endpoint_dcef09e1cecc_eOH</Element-Id>
</Delete>
</TipsApiRequest>' https://192.168.50.10/tipsapi/config/delete/Endpoint

MVP
Posts: 447
Registered: ‎11-04-2011

Re: Clearpass Clear all endpoints via API

Ricardo,

In most cases, it is better to use the automatic cleanup feature in ClearPass. If you go to Administration » Server Manager » Server Configuration, then Cluster-wide parameters, you can set automatic cleanup parameters:

cleanup.png

As you are explicitly asking for cleanup via the API, you will probably need some scripting around this. I would advise you first to move away from the (deprecated) legacy API (/tipsapi/) and use the REST API (/api-docs) instead. For the new API, you will need to generate an access token which can be done through ClearPass Guest: Administration » API Services » API Clients.

--
If you have urgent issues, please contact your Aruba partner or Aruba TAC.
MVP
Posts: 447
Registered: ‎11-04-2011

Re: Clearpass Clear all endpoints via API

Just created a small python script that deletes all endpoints (max 1000 at a time) via the API:

#!/usr/bin/python

import string
import random
import time
import requests
import json

# Chenge this to your Access Token
token='Bearer b4d61285743b8b3a341210ff58e44a1ee8f934a6'

# Change IP here; Get list of endpoints (max 1000, which is the maximum value); Run script multiple times if you have over 1000 endpoints.
resp = requests.get('https://10.1.50.11/api/endpoint?limit=1000',
headers={ 'Authorization':token}, verify=False)
endpoints=resp.json()
print("-----\nDeleting: ", end='')
# Walk through all endpoint items:
for endpoint in endpoints['_embedded']['items']:
print("%s " % (endpoint['id']), end='')
# Change IP here; Delete the endpoint with the given id
resp = requests.delete('https://10.1.50.11/api/endpoint/'+str(endpoint['id']),
headers={ 'Authorization':token}, verify=False)
print(resp)
exit

print()

The token should be changed as does the ClearPass server IP address. To get a token go to ClearPass Guest, Administration » API Services » API Clients; then in the API client that you created: Generate Access Token.

 

You will need to have the Python modules json and request installed, which might be default as I cannot remember installing those manually.

 

As stated in my first response, you probably are better off with the cleanup intervals, this example does remove all endpoint via the API.

--
If you have urgent issues, please contact your Aruba partner or Aruba TAC.
Occasional Contributor II
Posts: 58
Registered: ‎05-22-2016

Re: Clearpass Clear all endpoints via API

Thanks, i will give it a try and let you know if it worked.

Search Airheads
Showing results for 
Search instead for 
Did you mean: