cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2330
Views
5
Helpful
2
Replies

Difficulty in deploying template that uses DB variables through API

Dave Lewis
Level 1
Level 1

Hello,

Using PI 3.1.5

I'm having trouble deploying a template I've written which uses a DB variable to perform a show command (enable mode). . Here's an example template content:

#if ($interfaceNames !="")

#MODE_ENABLE

  #foreach ($intf in $interfaceNames)

   #if ($intf.toString().contains("Te"))

     show idprom interface $intf | inc Name

   #end

  #end

#MODE_END_ENABLE

#end

This is basically designed to show the vendor of any SFP in a 10Gb interface. The interfaceNames variable is a DB lookup using "UpIntfName" as the default value.

This works fine through the GUI and I can see the vendor name (see attached screenshot), my next step was going to be to deploy through the API and use some string manipulation to extract the vendor name. However when deploying through the API I get a result something like this:

#MODE_ENABLE

   #MODE_END_ENABLE

response:

<cliChunks><cliChunk><cli>terminal width 0

config t

exit

config t

</cli><response><![CDATA[terminal width 0

***#config t

Enter configuration commands, one per line.  End with CNTL/Z.

***(config)#exit

***#config t

Enter configuration commands, one per line.  End with CNTL/Z.

***(config)#]]></response></cliChunk></cliChunks>

Which seems to suggest that no commands were generated (either the foreach didn't work or the if statement didn't match).

I then tried something really simple thus:

#MODE_ENABLE

show $DeviceName

#MODE_END_ENABLE

$DeviceName is a DB variable using the built-in DeviceName value

I know this isn't a valid CLI command but what's interesting is the output. Through the GUI it correctly tried to execute 'show XXXXX' where XXXX is the device name. However through the API the output is:

0/3 template configurations successfully applied.

Error occured while executing the command show $DeviceName.Command Output : show $DeviceName

show $DeviceName

^

% Invalid input detected at '^' marker.

Error occured while executing the command show $DeviceName.Command Output : show $DeviceName

show $DeviceName

^

% Invalid input detected at '^' marker.

Error occured while executing the command show $DeviceName.Command Output : show $DeviceName

show $DeviceName

^

% Invalid input detected at '^' marker.

Which seems to suggest that the DB variables aren't getting evaluated when deploying a template through the API?

Has anyone successfully deployed templates using DB variables?

Two more related questions:

1) When deploying a job through API you cannot see the results of that job through the GUI, the jobs go into the CliTemplateDeployIOSDevices section but if you click the 'job detail view' link it returns 'Could not find the Job Results.'

2) When deploying through the GUI you get options for 'continue' or 'stop' if errors are encountered, is there any equivalent option when using cliTemplateConfiguration/deployTemplateThroughJob ?

Thanks,

Dave

1 Accepted Solution

Accepted Solutions

Spencer Zier
Cisco Employee
Cisco Employee

Regarding DB variables not having their values populated, this is a known issue which we are fixing in 3.1.6 (https://bst.cloudapps.cisco.com/bugsearch/bug/CSCvc98615).

Seeing results in the job dashboard will be supported in 3.2.  To get detailed job results in versions prior to 3.2, we recommend using the GET op/jobService/runhistory resource (https://developer.cisco.com/media/prime-infrastructure-api-reference-v3-1/192.168.115.187/webacs/api/v1/op/jobService/runhistory-GETcc3b.html?_docs).

No, there is no such option via the API.  If one device fails deployment then the next device, if there is one, will be configured.

View solution in original post

2 Replies 2

Spencer Zier
Cisco Employee
Cisco Employee

Regarding DB variables not having their values populated, this is a known issue which we are fixing in 3.1.6 (https://bst.cloudapps.cisco.com/bugsearch/bug/CSCvc98615).

Seeing results in the job dashboard will be supported in 3.2.  To get detailed job results in versions prior to 3.2, we recommend using the GET op/jobService/runhistory resource (https://developer.cisco.com/media/prime-infrastructure-api-reference-v3-1/192.168.115.187/webacs/api/v1/op/jobService/runhistory-GETcc3b.html?_docs).

No, there is no such option via the API.  If one device fails deployment then the next device, if there is one, will be configured.

Thanks for confirming, good to know I'm not going mad yet.

I was hoping a workaround might be to deploy the template through the GUI and then collect the job results through the API to do my string manipulation but I'm finding that getting results of jobs deployed through GUI doesn't give you the configlet results. Here is the output from a GUI deployed job:

{

    "mgmtResponse":  {

                         "@responseType":  "operation",

                         "@requestUrl":  "https://primeserver/webacs/api/v1/op/jobService/runhistory?jobId=4963923144",

                         "@rootUrl":  "https://primeserver/webacs/api/v1/op",

                         "job":  {

                                     "description":  "undefined",

                                     "jobId":  4963923144,

                                     "jobName":  "DL Show idprom_1",

                                     "jobStatus":  "COMPLETED",

                                     "jobType":  "Config Deploy - Deploy View",

                                     "runInstances":  {

                                                          "runInstance":  {

                                                                              "completionTime":  "2017-02-08T11:43:18.422Z",

                                                                              "lastStartTime":  "2017-02-08T11:43:13.391Z",

                                                                              "resultStatus":  "SUCCESS",

                                                                              "results":  "",

                                                                              "runId":  5153806929,

                                                                              "runStatus":  "COMPLETED"

                                                                          }

                                                      }

                                 }

                     }

}

The results value is empty, I tried using the runId as a job ID but that doesn't work:

{

    "mgmtResponse":  {

                         "@responseType":  "operation",

                         "@requestUrl":  "https://primeserver/webacs/api/v1/op/jobService/runhistory?jobId=5153806929",

                         "@rootUrl":  "https://primeserver/webacs/api/v1/op"

                     }

}

So I think I'll need to wait for 3.1.6.

Dave