cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1643
Views
12
Helpful
9
Replies

Trouble configuring a VLAN on switch using CLI Template

jdurkin
Cisco Employee
Cisco Employee

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:

Get: https://secure-web.cisco.com/1pswGAuiGTC_kWKabUvh-SvMS_oG5823vXcOMOAiQeg5X5lPpnUk94J8bM70eBzHHXUDLu4WuWw2_iKCZivlwgfarIt2KJMBVNGcnKf6UU0BRdAdY8nml8-Z3PeH_ug2DMZ5NdFQXoeYPx8AyIGdW2n2epDFyoUbz_eSpfcn15mQzN7d8DyQP_DzZlAVtW4yL_dut0XzbHCRPdvXTnHvr7PXM1Wwv...VLAN"

Response:

{

  "queryResponse": {

    "@last": "0",

    "@first": "0",

    "@count": "1",

    "@type": "CliTemplate",

    "@responseType": "listEntityInstances",

    "@requestUrl": "https://secure-web.cisco.com/1xYYE3p_CL7zAgngIMt5jldt8CStQMgNol0VJTKxG8SVx1YJTSKI13c_vJZ4RucxFhkXXiBAL6jpjOf6YTBtk37fteux2T6AyAN0dJJ8QKp193RcyntQgMaY3bgjAjCXM23u-t6V5m4_mbRylh9OIsejI9_ABRRbhPt3h1xS-ixNUD3H6hVHKl8PPXhOXGAyOVntwV1h47sTO-0DMDmjXmFkDVx64...VLAN"",

    "@rootUrl": "https://secure-web.cisco.com/1d2PYcp5G6EnBMCiNdRRtsHrvIGgbEXXfQTflOjNGXP3qdm4qbK9ktn7tpwuXEaA6qWASG-Pf_Y8cVguZlVVLQw9m-OsgLYWjLB1KIU04P_vfC_EnYdfkzI21uscXQGbrQzBZQ70_yaEnI4wMbftFa8Y9bawzUBLVGjNYe5ub18jYdhg_8PMIUJULM69nYbGenxzTIUsEUh_rNTt0S0D63XTvEbq6...;,

    "entity": [

      {

        "@dtoType": "cliTemplateDTO",

        "@type": "CliTemplate",

        "@url": "https://secure-web.cisco.com/12b8YG7r5gTsbB3rLiLbkIgRrXVip998yTsoh9KeFOdYtYeG10JQAKBaY3Jdrj7uri_Zc5Bsib-HXq6cWFPTmILEKC0Tq3fzVc1NZkZryNc0rT-J4jX_YmiDbZQ7_a5cSCvmziTRob2S_X-mP5f_a9xsOO7BgNPTn1rfNDk-APd73iNrcQmsEpDsTnP2gt9Ox5gBn2VEbUZRNx0nfsrdAJFtCZ478...;,

        "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:

GET  https://secure-web.cisco.com/1Xo_EmwPKhuGspOTJlcAKEtTKJs_1HDAjKqYmNnrF39KWSOG_Aj8DmLlSSUCBTZQya_SW5ejBIRkvpcECPb7Uch4sGKSaN5KpmibPp-ngwO5xBwvulcUv4VsLnUIjfYAGb-tHIJqLee1b4wrgysemOxlAg1qptaZZTRvZl4vjUXuK0WimcPPVJgrSZvIFvG8zfmcJ4c0bnqjfMtByFhkUCDKHFr4Y...        

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>&lt;status&gt;&lt;general code="SUCCESS"/&gt;&lt;/status&gt;</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:

               PUT https://secure-web.cisco.com/1umRKEDn7LLzEavczcwkSc0Vo04kO_3QZBXEhqRz473k4C89WLlcx7FzJbl7lIRACvh0pTzJB3kxdGPCjND0zuqSqfCTWtdvwAhrjNd12REE5-WU0bVXtSBU33dcLu1oStJG4Mcghxsq8MchTvL_33gaurRI5IBqCd-SpM7E9qBDrQz3Wyr_ZUTRa1JzWcCoZGRWWIorGaSH_KQ347muUJwf5g1Nj...

               Body:

               {

               "cliTemplateCommand" : {

               "targetDevices" : {

               "targetDevice" : {

                "targetDeviceID" : "1363362",    -- also use the displayID -- 1349348

               "variableValues" : {

               "variableValue" : {

               "name" : "vlanid",

               "value" : "5"

               }

               }

               }

               },

               "templateName" : "Configure VLAN"

               }

}

Response:

{

  "mgmtResponse": {

    "@responseType": "operation",

    "@requestUrl": "https://secure-web.cisco.com/1C7z4lzruui2B2txtkfJUkNn-pGOe5sfz5hrisl90P3Zjerp6kxmiqBjnt4fs9Fo-fNR1P-5R_Ry4llqKntosn13pnbe8R_fS8UCrq5kAVD0qZTW0U76Ehf_lJvePMthqk2QltBB_I6aNvp37bJ6W4p4yg8G0IIzbBJ2h6lxH6Iy4XD2iu9lXrkYoID3jt57T7-e98eWRM0h6Os1GdLTWqq-XLU2_...;,

    "@rootUrl": "https://secure-web.cisco.com/1UENZS9WFeb0-srCtF0NSgnk_7BIl_0pkkudJkC7MZc2jaYR2qpylvjfGALPDvhNd3ha6fMcnPp9ZceBXKkkse-TgGnkZ1Q8wW9w8OOiolPrjl2FZyQDxW0KSt2K8fgRQIDajsol8lzqI5q65hGZlgkkKtTgqODOfkA9_A1yRQJuw23KzooqJBxEopQeIX-vqUJ8WPUGKnGFASDk14CUU4QYe9YQ4...;,

    "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:

               GET https://secure-web.cisco.com/1mmL6PxsndMJutA0jtiyw7AzsbYAHnZRYps-I4E6zwaRml9yPLs-jkt1AhAH8dLTnrNFYvJaiPXMgl-cXRr4htMlkQNxxNNyvxvrZ2xQm6ZN-_eLrN9t-7Sf4eD84CNBP3SPMfg8VLDWJi90Kc9JbKJcKEOMpfhZhVsaAUVXD8RABablBS_S-RIPVuP6XL6cUTSoUPSgKdcO1pxM13thBz2MUieb4...

Response:

https://secure-web.cisco.com/1mmL6PxsndMJutA0jtiyw7AzsbYAHnZRYps-I4E6zwaRml9yPLs-jkt1AhAH8dLTnrNFYvJaiPXMgl-cXRr4htMlkQNxxNNyvxvrZ2xQm6ZN-_eLrN9t-7Sf4eD84CNBP3SPMfg8VLDWJi90Kc9JbKJcKEOMpfhZhVsaAUVXD8RABablBS_S-RIPVuP6XL6cUTSoUPSgKdcO1pxM13thBz2MUieb4...

{

  "mgmtResponse": {

    "@responseType": "operation",

    "@requestUrl": "https://secure-web.cisco.com/1Pr-b1LFmIeV0uuAFmdgBdyXh29DPxzPix-Uo1m-4T048lk0ISHNe3j-jM5r2WPqGRvNckkO_nv2udx275P2d83kG4EBO3pvTatPpDn2IRasg4C0SJcPkhFJGjo_6ajMKTCIP6owAlx8HIYEN74O4R71ylBBk3kr87Un2m37ng8joeHhsEkGakQsFQUoezyI8Q7bb_hpI7UeVXA0B57dapbNO6h4B...,

    "@rootUrl": "https://secure-web.cisco.com/1UENZS9WFeb0-srCtF0NSgnk_7BIl_0pkkudJkC7MZc2jaYR2qpylvjfGALPDvhNd3ha6fMcnPp9ZceBXKkkse-TgGnkZ1Q8wW9w8OOiolPrjl2FZyQDxW0KSt2K8fgRQIDajsol8lzqI5q65hGZlgkkKtTgqODOfkA9_A1yRQJuw23KzooqJBxEopQeIX-vqUJ8WPUGKnGFASDk14CUU4QYe9YQ4...;,

    "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"

        }

      }

    }

  }

}

9 Replies 9

Spencer Zier
Cisco Employee
Cisco Employee

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.

We are using the latest version of PI. 

What are the Dropdown variables? 

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").

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"

              }

No no.  I'm saying in the deployTemplateThroughJob request, to specify those variables, along with a value, in the request payload.

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"

               }

}

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" : ""

        }

     ]}

Thanks!  In the next major release (3.2) do you need to specify all of the variable values?

Jim

Correct, it was a defect in 3.1.  The issue has been corrected in 3.2.