- Got a CLI template that utilises global variables. This works fine through the GUI but trying to use it via REST API fails.
- If the global vars are omitted from the deployment payload you receive an HTTP 500 error but if you 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"
- Trying to use 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 you try to deploy this you 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 you try to deploy this you will get an HTTP 500 error and no job is created.
Running PI version 3.1.4.
As an update to this, Have 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.
If 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.
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. Unable to reproduce the errors reported. Check the template (/webacs/api/v2/data/CliTemplate?.full=true&name="change access port" should do the trick.
Created the template itself in the GUI so that bug wouldn't apply in this case. Need to know is how you should approach the payload when a template uses GVs -
1) Is it needed to include them at all.
2) If so, what do is needed to set the value to. What it currently is configured as or nothing ("").
There's a couple of company-specific things in the template so You have sent it to you via email. One thing noticed is the GVs have 'rangeFrom' and 'rangeTo' fields specified as 10 and 100 (unable to set these, they must be defaults) even though one of the variables is set outside that range.
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.
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.
To request new features, would 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. 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.
The fix content should be in the 3.1.5 patch.
Comments
0 comments
Please sign in to leave a comment.