11-18-2016 03:54 AM
Hello,
I have a CLI template that utilises global variables. This works fine through the GUI but trying to use it via REST API fails.
I have found that if I omit the global vars from the deployment payload I receive an HTTP 500 error but if I put them in with the same value as they're currently configured for the job result shows "Invalid var Values for given template\u0027s variable"
So has anyone used the api/v1/op/cliTemplateConfiguration/deployTemplateThroughJob call to successfully deploy a template that uses global variables?
Here is an example payload that doesn't include the global variables:
{
"cliTemplateCommand": {
"targetDevices": {
"targetDevice": [
{
"targetDeviceID": "187661131",
"variableValues": {
"variableValue": [
{
"name": "interfaceNames",
"value": "GigabitEthernet1/0/10,GigabitEthernet1/0/11"
},
{
"name": "interfaceType",
"value": "CCTV"
}
]
}
}
]
},
"templateName" : "change access port"
}
}
If I try to deploy this I receive the following job result:
{
"mgmtResponse": {
"@responseType": "operation",
"@requestUrl": "https://x/webacs/api/v1/op/jobService/runhistory?jobName=JobCliTemplateDeployIOSDevices10_57_15_550_AM_11_18_2016",
"@rootUrl": "https://x/webacs/api/v1/op",
"job": {
"description": "Cli Template Deploy for IOS devices",
"jobId": 2949589697,
"jobName": "JobCliTemplateDeployIOSDevices10_57_15_550_AM_11_18_2016",
"jobStatus": "COMPLETED",
"jobType": "CliTemplateDeployIOSDevices",
"runInstances": {
"runInstance": {
"completionTime": "2016-11-18T10:57:46.622Z",
"lastStartTime": "2016-11-18T10:57:45.595Z",
"resultStatus": "FAILURE",
"results": {
"result": [
{
"property": "JobCliTemplateDeployIOSDevices10_57_15_550_AM_11_18_2016",
"value": "0/1 template configurations successfully applied."
},
{
"property": 187661131,
"value": "Invalid var Values for given template\u0027s variables"
}
]
},
"runId": 3024865985,
"runStatus": "COMPLETED"
}
}
}
}
}
Here is a payload containing the global variables with values set to the same as they are already:
{
"cliTemplateCommand": {
"targetDevices": {
"targetDevice": [
{
"targetDeviceID": "187661131",
"variableValues": {
"variableValue": [
{
"name": "interfaceNames",
"value": "GigabitEthernet1/0/10,GigabitEthernet1/0/11"
},
{
"name": "interfaceType",
"value": "CCTV"
},
{
"name": "gv.ACCESS_VLAN_DEFAULT",
"value": "11"
},
{
"name": "gv.ACCESS_VLAN_CCTV",
"value": "31"
},
{
"name": "gv.ACCESS_VLAN_UPS",
"value": "2"
},
{
"name": "gv.ACCESS_VLAN_AP",
"value": "11"
},
{
"name": "gv.ACCESS_VLAN_GUEST",
"value": "2106"
}
]
}
}
]
},
"templateName": "change access port"
}
}
If I try to deploy this I get an HTTP 500 error and no job is created.
Running PI version 3.1.4.
Thanks,
Dave
Solved! Go to Solution.
11-23-2016 11:53 AM
OK, I've identified a few issues around deployment for global variables that we'll address in CSCvc11240, which is currently targeting 3.1.5.
A workaround for this issue would be to transition your global variables to template variables and specify them during deployment.
Thank you for sending your template over! My apologies regarding this, we'll work to address this issue as quickly as we can.
11-18-2016 06:50 AM
As an update to this, I've duplicated the template and removed all the global variables (replacing with hard coded vlan IDs) and a deploy works fine on this new template so its definitely an issue with global variables.
11-22-2016 01:13 PM
Dave, are you creating the template with the global variables via the API? If so, you're probably running into issues around CSCvc11240 that were reported in another thread.
I tried creating a template with a mixture of template and global variables on a 3.1.4 instance (via the UI, to get around CSCvc11240), but it seems that the template deploys correctly. I was not able to reproduce the errors you reported. Can you please share the template (/webacs/api/v2/data/CliTemplate?.full=true&name="change access port" should do the trick)? If you don't wish to share it publicly, then feel free to contact me via email (my address is on my profile).
11-23-2016 01:10 AM
Hi Spencer,
Thanks for the reply, I created the template itself in the GUI so that bug wouldn't apply in this case. I guess what I need to know is how I should approach the payload when a template uses GVs -
1) Do I include them at all?
2) If so, what do I set the value to? What it currently is configured as or nothing ("")?
There's a couple of company-specific things in the template so I've sent it to you via email. One thing I did notice is the GVs have 'rangeFrom' and 'rangeTo' fields specified as 10 and 100 (I didn't set these, they must be defaults) even though one of the variables is set outside that range.
Dave
11-23-2016 09:08 AM
For GVs, the values (and any reference to the variables) should not be included in the deploy payload. The rangeFrom and rangeTo fields can be ignored, because GVs are not subject to the normal variable validation process.
I've received your email; I'm currently working to see if I can reproduce the issue with your template.
11-23-2016 09:35 AM
Hi,
Ah, that'll be it then, I was trying to set the value of the gv to what it already was. Tomorrow I'll try it again with the GVs included but with no values, sounds like that'll fix it, I just couldn't find any documentation on using GVs in API.
Thanks for your help.
Dave
11-23-2016 09:40 AM
Sorry for the confusion, no. I mean that your first deploy payload "that doesn't include the global variables" ought to be correct. I'm still looking into why it isn't working.
11-23-2016 11:53 AM
OK, I've identified a few issues around deployment for global variables that we'll address in CSCvc11240, which is currently targeting 3.1.5.
A workaround for this issue would be to transition your global variables to template variables and specify them during deployment.
Thank you for sending your template over! My apologies regarding this, we'll work to address this issue as quickly as we can.
11-24-2016 01:43 AM
Perfect, thanks Spencer, glad it wasn't me going mad! Whilst you're looking at template variables any chance of squeezing multidimensional array variables into 3.1.5 as well? It'd make the CLI templates a lot more flexible and powerful as per my post here. Just being cheeky, I don't know the official way to request new features!
Thanks,
Dave
11-28-2016 01:16 PM
Dave, to request new features, I'd suggest using the Feedback feature built into the UI of Prime Infrastructure. Navigate to the template page and then select the top right menu > Feedback > I wish this page would... and make your request there. I can promise that each and every submission via that tool is reviewed and considered.
Alternatively, you can reach out to the ask-prime-infrastructure@cisco.com mailing list.
01-31-2017 12:13 AM
Hey Spencer,
I see 3.1.5 is now released but I don't see that bug ID in the release notes as either open or resolved? The bug page says fixed but doesn't specify the ver, do you know if it's in 3.1.5 or if its been pushed to 3.1.6/3.2?
Cheers,
Dave
01-31-2017 08:31 AM
Dave, I just checked and yes, the fix content should be in the 3.1.5 patch. I'm not sure why release notes didn't include the bug ID, but it should be there.
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