How to clear cluster configuration of Cisco Application Service Engine App

This will be a quick post on how to reset the initial configuration of Cisco Application Service Engine App cluster config. While attempting the integration for the first time I realized that I had a mistake in my initial configuration of the app, but there is no way to change it from the GUI in the current version shown above.

One might think that Even removing the APP, restarting the APIC, and then reuploading the app will leave your initial configuration still intact.

Instead we can interact with the Cisco Application Service Engine APP via the API. This can be difficult to do in Postman since you need to get the APIC token in addition too the DEVCOOKIE to your request. The DEVCOOKIE is not a true cookie, it is instead a Header. However the actual data in the token are one in the same.

 

You can see that we use the same variable without updating, this is highlighted in red.

In Blue you will see the URL for the post.

Here is a quick script.

 

import requests 
import json 
import xml 
import urllib3 
import argparse 
urllib3.disable_warnings() 


url = "https://10.201.35.209/api/aaaLogin.json" 
payload = "{ \"aaaUser\" : { \"attributes\" : { \"name\" : \"admin\", \"pwd\" : \"password1234\" }}}\n" 
post_response = requests.request("POST", url, data=payload, verify=False) 

# get token from login response structure 
auth = json.loads(post_response.text) 
login_attributes = auth['imdata'][0]['aaaLogin']['attributes'] 
auth_token = login_attributes['token'] 
# create cookie array from token 
cookies = {} 
cookies['APIC-Cookie'] = auth_token 
headers = {} 
headers['DEVCOOKIE'] = auth_token 


# Cluster Post 
url1 = "https://10.201.35.209/appcenter/Cisco/ServiceEngine/api/wipeClean.json" 

response = requests.request("POST", url1, json='', cookies=cookies, headers=headers,verify=False) 

print "query is %s" %url1 
print response.status_code 
datas = response.text 
print datas 


We could also accomplish this by using CURL, as seen below running it from the APIC CLI.

 

token=`curl -skX POST "https://127.0.0.1/api/aaaLogin.json" \
    -H "Content-Type: application/json" \
    -d '{"aaaUser":{"attributes":{"name":"admin", "pwd":"password1234"}}}' \
        | python -m json.tool | grep token | cut -d'"' -f4`
echo $token


curl -b 'APIC-Cookie=$token' \
	--header "DEVCookie: $token" \
    --header "Content-Type: application/json" \
    -skX POST "https://127.0.0.1/appcenter/Cisco/ServiceEngine/api/wipeClean.json"

 


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.