- Trying to deploy CLI template using PUT REST API(Using Python). Manage to do it to one device. But I'm stuck when trying on multiple devices.
- Below is the JSON payload for one device. How does it look like for multiple devices. Able to run a FOR loop in python and PUT to each device but the problem is each PUT will create a new Job!! Hence, if you have a few hundred devices, your Job table will have hundreds over jobs
Any help will be greatly appreciated.....
{
"cliTemplateCommand" : {
"targetDevices" : {
"targetDevice" : {
"targetDeviceID" : "122421412",
"variableValues" : {
"variableValue" : {
"name" : "comString",
"value" : "API_Com_String"
}
}
}
},
"templateName" : "SNMP_Template"
}
}
you can supply a list of devices with parameters. Notice how "targetDevice" can be a list.
{
"cliTemplateCommand" : {
"targetDevices" : {
"targetDevice" : [{
"targetDeviceID" : "610622",
"variableValues" : {
"variableValue": [
{
"name": "InterfaceName",
"value": "gigabitethernet1/0/2"
},
{
"name": "Description",
"value": "Fred1"
},
{
"name": "StaticAccessVLan",
"value": "8"
},
{
"name": "A1",
"value": "Access"
},
{ "name": "NativeVLan", "value": ""},
{ "name": "duplexField","value": ""},
{ "name": "TrunkAllowedVLan","value": "" },
{ "name": "spd","value": "" },
{ "name": "VoiceVlan" ,"value": ""},
{ "name": "PortFast","value": "" }
]
}
},
{
"targetDeviceID" : "8624616",
"variableValues" : {
"variableValue": [
{
"name": "InterfaceName",
"value": "gigabitethernet1/0/2"
},
{
"name": "Description",
"value": "Fred1"
},
{
"name": "StaticAccessVLan",
"value": "8"
},
{
"name": "A1",
"value": "Access"
},
{ "name": "NativeVLan", "value": ""},
{ "name": "duplexField","value": ""},
{ "name": "TrunkAllowedVLan","value": "" },
{ "name": "spd","value": "" },
{ "name": "VoiceVlan" ,"value": ""},
{ "name": "PortFast","value": "" }
]
}
}
]
},
"templateName" : "Configure Interface"
}
}
- How do I find out the PUT status of individual device.
This “deployTemplateThroughJob” method will provide status on the Job itself. If you push 100 devices and 4 devices fail, how to find out which of that 4 devices fail. The Job run history API only give the Job status but not in device detail….
you can look at the full history of the job.
GET https://{{pi-server}}/webacs/api/v1/op/jobService/runhistory.json?jobName=JobCliTemplateDeployIOSDevices08_32_27_953_AM_08_27_2016
{
"mgmtResponse": {
"@responseType": "operation",
"@requestUrl": "https://adam-pi/webacs/api/v1/op/jobService/runhistory?jobName=JobCliTemplateDeployIOSDevices08_32_27_953_AM_08_27_2016",
"@rootUrl": "https://adam-pi/webacs/api/v1/op",
"job": {
"description": "Cli Template Deploy for IOS devices",
"jobId": 8897938,
"jobName": "JobCliTemplateDeployIOSDevices08_32_27_953_AM_08_27_2016",
"jobStatus": "COMPLETED",
"jobType": "CliTemplateDeployIOSDevices",
"runInstances": {
"runInstance": {
"completionTime": "2016-08-27T08:33:00.052+10:00",
"lastStartTime": "2016-08-27T08:32:58.024+10:00",
"resultStatus": "SUCCESS",
"results": {
"result": [
{
"property": 610622,
"value": "configlet:\n interface gigabitethernet1/0/2\n description Fred2\n switchport mode access\n switchport ACCess vlan 8 \n \n \n \n \n \n \n \n exit\n\n\n\n\n\n\n\n\n\n\n response:\n<cliChunks><cliChunk><cli>terminal width 0\nconfig t\ninterface gigabitethernet1/0/2\ndescription Fred2\nswitchport mode access\nswitchport ACCess vlan 8\nexit\n</cli><response><![CDATA[terminal width 0\n3650-dns#config t\nEnter configuration commands, one per line. End with CNTL/Z.\n3650-dns(config)#interface gigabitethernet1/0/2\n3650-dns(config-if)#description Fred2\n3650-dns(config-if)#switchport mode access\n3650-dns(config-if)#switchport ACCess vlan 8\n3650-dns(config-if)#exit\n3650-dns(config)#]]></response></cliChunk></cliChunks>"
},
{
"property": "JobCliTemplateDeployIOSDevices08_32_27_953_AM_08_27_2016",
"value": "2/2 template configurations successfully applied."
},
{
"property": 8624616,
"value": "configlet:\n interface gigabitethernet1/0/2\n description Fred2\n switchport mode access\n switchport ACCess vlan 8 \n \n \n \n \n \n \n \n exit\n\n\n\n\n\n\n\n\n\n\n response:\n<cliChunks><cliChunk><cli>terminal width 0\nconfig t\ninterface gigabitethernet1/0/2\ndescription Fred2\nswitchport mode access\nswitchport ACCess vlan 8\nexit\n</cli><response><![CDATA[terminal width 0\n3650-dhcp#config t\nEnter configuration commands, one per line. End with CNTL/Z.\n3650-dhcp(config)#interface gigabitethernet1/0/2\n3650-dhcp(config-if)#description Fred2\n3650-dhcp(config-if)#switchport mode access\n3650-dhcp(config-if)#switchport ACCess vlan 8\n3650-dhcp(config-if)#exit\n3650-dhcp(config)#]]></response></cliChunk></cliChunks>"
}
]
},
"runId": 14722720,
"runStatus": "COMPLETED"
}
}
}
You can also GET summary too:
https://{{pi-server}}/webacs/api/v1/data/JobSummary/8897938.json
https://{{pi-server}}/webacs/api/v1/data/JobSummary.json?jobName=JobCliTemplateDeployIOSDevices08_32_27_953_AM_08_27_2016
Comments
0 comments
Please sign in to leave a comment.