Are there more examples available?
Closed this issue · 3 comments
OlegPekar commented
I need to add NetworkDevice with RADIUS protocol enabled and some settings around. How can I do that? Are there more examples that allow understanding of how to configure specific things?
einarnn commented
do you want to use Ansible or just the Python ciscoisesdk
?
1homas commented
See the Cisco DevNet Sandbox: ISE 3.1 with Ansible Automation
import requests
import json
url = "https://ise-1.lab.devnetsandbox.local:9060/ers/config/networkdevice"
payload = json.dumps({
"NetworkDevice": {
"name": "simulator",
"description": "",
"authenticationSettings": {
"networkProtocol": "RADIUS",
"radiusSharedSecret": "C1sco12345"
},
"tacacsSettings": {
"sharedSecret": "C1sco12345",
"connectModeOptions": "OFF"
},
"NetworkDeviceIPList": [
{
"ipaddress": "10.10.20.32",
"mask": 32
}
],
"NetworkDeviceGroupList": [
"Location#All Locations",
"IPSEC#Is IPSEC Device#No",
"Device Type#All Device Types"
]
}
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Basic ZXJzLWFkbWluOkMxc2NvMTIzNDU=',
'Cookie': 'APPSESSIONID=DF86EDFE44A735F15628A87FE73CC643; JSESSIONIDSSO=B8E53F0E34AB665C9D18A54B1C170912'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
And here is another:
#!/usr/bin/env python3
import json
from ciscoisesdk import api, ApiError
api_ = api.IdentityServicesEngineAPI(
username='admin',
password='C1sco12345',
base_url='https://ise-1.lab.devnetsandbox.local',
verify=False)
try:
response = api_.network_device.create_network_device(
name="test_device",
description="",
profile_name="Cisco",
authentication_settings={
"networkProtocol": "RADIUS",
"radiusSharedSecret": "C1sco12345"
},
tacacs_settings={
"sharedSecret": "C1sco12345",
"connectModeOptions": "OFF"
},
network_device_iplist=[
{
"ipaddress": "10.10.20.33",
"mask": 32
}
],
network_device_group_list=[
"Location#All Locations",
"IPSEC#Is IPSEC Device#No",
"Device Type#All Device Types"
]
)
if (response.headers["Location"]) :
print(response.headers["Location"])
else :
print(json.dumps(response.response, indent=2))
except ApiError as e:
print(e)
I prefer to do this with Ansible so it much cleaner with YAML:
bvargasre commented
Hi @OlegPekar Is the information provided sufficient to clarify your doubts?
If so, feel free to close the issue.
If there are no other questions, the issue will be closed within 48 hours.