02-07-2017 01:54 PM
Hi,
Trouble configuring a VLAN on our switch, using the “Configure VLAN” template. Below are the steps followed along with the results with each call. The goal here is to create a new VLAN on the switch with the Id of 5.
Can someone please verify that the following is the correct process of if there is a bug in the API?
Thanks,
Jim
---------------
Verify the “Configure VLAN” template exists:
Request:
Response:
{
"queryResponse": {
"@last": "0",
"@first": "0",
"@count": "1",
"@type": "CliTemplate",
"@responseType": "listEntityInstances",
"entity": [
{
"@dtoType": "cliTemplateDTO",
"@type": "CliTemplate",
"cliTemplateDTO": {
"@displayName": "538555",
"@id": "538555",
"author": "Cisco Systems",
"content": "\n#if ($option==\"Create\")\n\t#if ($vlanid !=\"\")\n\t\tvlan $vlanid\n\t\t#if ($vlanName !=\"\")\n\t\t\tname $vlanName\n\t\t#end\n\t\t#if ($mtu !=\"\")\n\t\t\tmtu $mtu\n\t\t#end\n\t\texit\n\t\t#if ($interfaceName !=\"\")\n\t\t\tinterface $interfaceName\n\t\t\t#if(${mode} == \"Access\")\n \t\t\t\tswitchport mode access\n \t\t\t\tswitchport access vlan $vlanid \n\t\t\t#end\n\t\t\t#if(${mode} == \"Trunk\")\n \t\t\t\tswitchport mode trunk\n \t\t\t\tswitchport trunk allowed vlan $vlanid \n\t\t\t#end\n\t\t\t#if ($encapsulation !=\"\")\n\t\t\t\tswitchport trunk encapsulation $encapsulation \n\t\t\t#end\n\t\t#end\n\t\texit\n\t#end\n#end\n\n#if ($option==\"Delete\")\n\t#if ($vlanid !=\"\")\n\t\tno vlan $vlanid\n\t\t#if ($interfaceName !=\"\")\n\t\t\tinterface $interfaceName\n\t\t\t#if(${mode} == \"Access\")\n \t\t\t\tno switchport mode access\n \t\t\t\tno switchport access vlan $vlanid \n\t\t\t#end\n\t\t\t#if(${mode} == \"Trunk\")\n \t\t\t\tno switchport mode trunk\n \t\t\t\tno switchport trunk allowed vlan $vlanid \n\t\t\t#end\n\t\t\texit\n\t\t#end\n\t#end\n#end\t\n",
"createdOn": "2017-01-23T05:51:31.256-06:00",
"deployCount": 2,
"description": "Configure VLAN",
"deviceType": "Switches and Hubs,Wireless Controller/Cisco 5760 Series Wireless LAN Controller",
"lastDeployTime": "2017-02-06T04:07:23.187-06:00",
"name": "Configure VLAN",
"path": "CLI Templates/System Templates - CLI",
"templateId": 538555,
"variables": {
"variable": [
{
"description": "Encapsulation (Enter dot1q/isl/negotiate)",
"displayLabel": "Encapsulation (Enter dot1q/isl/negotiate)",
"name": "encapsulation",
"required": false,
"type": "String"
},
{
"description": "InterfaceName",
"displayLabel": "Interface Name",
"name": "interfaceName",
"required": false,
"type": "String"
},
{
"description": "MTU size [576-18190]",
"displayLabel": "MTU size [576-18190]",
"name": "mtu",
"required": false,
"type": "Integer"
},
{
"description": "VlanId",
"displayLabel": "VlanId",
"name": "vlanid",
"required": true,
"type": "Integer"
},
{
"description": "VlanName",
"displayLabel": "Vlan Name(Vlan name should be a single word)",
"name": "vlanName",
"required": false,
"type": "String"
},
{
"defaultValue": "Access,Trunk",
"description": "Access,Trunk",
"displayLabel": "Mode",
"name": "mode",
"required": false,
"type": "Dropdown"
},
{
"defaultValue": "Create,Delete",
"description": "Create,Delete",
"displayLabel": "Operation",
"name": "option",
"required": false,
"type": "Dropdown"
}
]
}
}
}
]
}
}
Verify the Switch Devices exist:
Request:
Response:
<?xml version="1.0" ?>
<queryResponse type="Devices" responseType="getEntity" requestUrl="https://secure-web.cisco.com/1Q1Jh5GJp_S7GMbImv8Di7nlgsU3x3H_UchhnoHnM6fcUzGWUJcHOh8EHty54ibpozOfa1eTJR3lZUUAVw0Ah9C-X7J-qHMB0UXecdMGX67kz-dEZ052XXnVo2dij5zYf8iCnDAQSCqBeNqZFdb8WG1iIsbwdCF7yUZR52zeBH2gywC3uOqG1vduNapSYHC-klEa3qzNFRgv9Tr1DnaqwptmcPshU...; rootUrl="https://secure-web.cisco.com/14EtTv3iX5dcSzOX0T8SjrR_hKoLUMXlbjHn3dllfUErdxwQz46FaGa506oumH0_FIALFnqSWMccN7vlX0qZpnjBHFPH-EKsXpq2YyEChpLUDaNAk7jr_19CjEGpEq5kZnmz40dvzXvBjOnLx1xFOtrDihx6ezLKO3V4LygHye_mGaDfHQmHQsbwhEG60APetDc-aJG84Gu7i_PdHrWI-Ugq4DmBy...;
<entity dtoType="devicesDTO" type="Devices" url="https://secure-web.cisco.com/124hFXj3PRUubBI30G6BtByszg7sYYRNFPLxD3USz1JvC5aS_QR7h_7EqDHrzRqgp-TzXLoteIEhj9Hmj8UA6ET1qPMMbipenhABhyOB-gbXdqncpPdwapOf2Vxj6lUSXwLw4DKpTKvozvLNieIJlIIv8OlJ7v8OxImrMODW-ZM-_gTSO4-Xa5M4YPqQ94VhJEgPRZwvn0m-BNl64I02jg3x6v2z6...;
<devicesDTO displayName="1349348" id="1349348">
<clearedAlarms>1</clearedAlarms>
<collectionDetail><status><general code="SUCCESS"/></status></collectionDetail>
<collectionTime>2017-02-02T22:02:29.580-06:00</collectionTime>
<creationTime>2017-02-02T02:56:32.894-06:00</creationTime>
<criticalAlarms>0</criticalAlarms>
<deviceId>1363362</deviceId>
<deviceName>CC-SW01.attwifi.com</deviceName>
<deviceType>Cisco Catalyst 3560CX-12PC-S Switch</deviceType>
<informationAlarms>0</informationAlarms>
<ipAddress>192.168.104.34</ipAddress>
<location>CC-SW01 in MDF</location>
<majorAlarms>0</majorAlarms>
<managementStatus>MANAGED_AND_SYNCHRONIZED</managementStatus>
<manufacturerPartNrs>
<manufacturerPartNr>WS-C3560CX-12PC-S</manufacturerPartNr>
</manufacturerPartNrs>
<minorAlarms>0</minorAlarms>
<productFamily>Switches and Hubs</productFamily>
<reachability>Reachable</reachability>
<softwareType>IOS</softwareType>
<softwareVersion>15.2(4)E2</softwareVersion>
<warningAlarms>0</warningAlarms>
</devicesDTO>
</entity>
</queryResponse>
Run Template Job on the device
Request:
Body:
{
"cliTemplateCommand" : {
"targetDevices" : {
"targetDevice" : {
"targetDeviceID" : "1363362", -- also use the displayID -- 1349348
"variableValues" : {
"variableValue" : {
"name" : "vlanid",
"value" : "5"
}
}
}
},
"templateName" : "Configure VLAN"
}
}
Response:
{
"mgmtResponse": {
"@responseType": "operation",
"cliTemplateCommandJobResult": {
"jobName": "JobCliTemplateDeployIOSDevices02_00_12_201_AM_02_07_2017",
"message": "An deploy job has been successfully created. "
}
}
}
Check the Status of the Job:
Request:
Response:
{
"mgmtResponse": {
"@responseType": "operation",
"job": {
"description": "Cli Template Deploy for IOS devices",
"jobId": 87203,
"jobName": "JobCliTemplateDeployIOSDevices02_00_12_201_AM_02_07_2017",
"jobStatus": "COMPLETED",
"jobType": "CliTemplateDeployIOSDevices",
"runInstances": {
"runInstance": {
"completionTime": "2017-02-07T02:00:43.248-06:00",
"lastStartTime": "2017-02-07T02:00:42.232-06:00",
"resultStatus": "FAILURE",
"results": {
"result": [
{
"property": 1349348,
"value": "Invalid var Values for given template's variables"
},
{
"property": "JobCliTemplateDeployIOSDevices02_00_12_201_AM_02_07_2017",
"value": "0/1 template configurations successfully applied."
}
]
},
"runId": 1852766,
"runStatus": "COMPLETED"
}
}
}
}
}
02-07-2017 02:10 PM
Are you accessing PI via a proxy?
Which version of PI are you using? What patches and maintenance releases have you installed?
Have you tried specifying values for the Dropdown type variables during deployment? I know they are listed as not required, but I think that might be an error.
02-07-2017 02:17 PM
We are using the latest version of PI.
What are the Dropdown variables?
02-07-2017 02:21 PM
So 3.1? Have you installed any of the maintenance releases or are you on 3.1.0?
In this case, the dropdowns are "mode" and "option" (they come back where "type" is "Dropdown").
02-07-2017 02:39 PM
Ok, checking on version in my customer's POC.
So, are you saying to change the value of "name" below? If so, to what value?
{
"defaultValue": "Access,Trunk",
"description": "Access,Trunk",
"displayLabel": "Mode",
"name": "mode",
"required": false,
"type": "Dropdown"
},
{
"defaultValue": "Create,Delete",
"description": "Create,Delete",
"displayLabel": "Operation",
"name": "option",
"required": false,
"type": "Dropdown"
}
02-07-2017 02:42 PM
No no. I'm saying in the deployTemplateThroughJob request, to specify those variables, along with a value, in the request payload.
02-08-2017 08:53 AM
PI is running at: 3.1.0.0.132
I read somewhere that All variables need to be present in the deployTemplateThroughJob, even if they are not being used. If this is true, don't I need to specify the other variables and put a blank as the value for this to work?
Would the following work?
Body:
{
"cliTemplateCommand" : {
"targetDevices" : {
"targetDevice" : {
"targetDeviceID" : "1363362", -- also use the displayID -- 1349348
"variableValues" : {
"variableValue" : {
"name" : "vlanid",
"value" : "5"
"name" : "mode",
"value" : "Access,Trunk",
"name" : "option",
"value" : "Create,Delete",
}
}
}
},
"templateName" : "Configure VLAN"
}
}
02-08-2017 04:24 PM
So yes, on 3.1.0, you'll want to specify all of the variable values. A couple corrections on this request body: first, you'll need to use an array for the multiple variable values. Second, you'll want to use the ID of the device as reported in the displayName and id attributes, not the deviceId parameter. Third, you'll want to specify either "Access" or "Trunk" for mode and either "Create" or "Delete" for option (you can also leave them blank, but should not specify both).
"variableValues" : {
"variableValue" : [{
"name" : "vlanid",
"value" : "5"
}
, {
"name" : "mtu",
"value" : ""
}
, {
"name" : "interfaceName",
"value" : ""
}
, {
"name" : "vlanName",
"value" : ""
}
, {
"name" : "encapsulation",
"value" : ""
}
, {
"name" : "mode",
"value" : ""
}
, {
"name" : "option",
"value" : ""
}
]}
02-08-2017 04:27 PM
Thanks! In the next major release (3.2) do you need to specify all of the variable values?
Jim
02-09-2017 08:45 AM
Correct, it was a defect in 3.1. The issue has been corrected in 3.2.
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