cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1249
Views
13
Helpful
4
Replies

Does POST cliTemplateConfiguration/upload work with Global Variables?

carl.simpson2
Level 1
Level 1

Hi All,

I've been using POST cliTemplateConfiguration/upload to upload CLI Templates into Prime but I'm having issues with templates which use global variables (they're not being populated when I deploy the template).  If I post the following template with local variables I can deploy without a problem and the hostname gets set to 'carlsrouter'

<?xml version="1.0" ?>

<cliTemplate>

      <content>hostname $hostname

</content>

      <description>Applies Hostname</description>

      <deviceType>Routers</deviceType>

      <lastDeployTime>2016-10-24T17:08:32.594+01:00</lastDeployTime>

      <name>ZEN-HOSTNAME-POSTED</name>

      <path>My Templates/Zen Service Templates</path>

      <variables>

        <variable>

          <defaultValue>carlsrouter</defaultValue>

          <description>Device Host Name</description>

          <displayLabel>Hostname</displayLabel>

          <name>hostname</name>

          <required>false</required>

          <type>String</type>

        </variable>

      </variables>

</cliTemplate>

If I upload the following template into Prime via the API and deploy I get a router named '$gv.lab-hostname' :

<?xml version="1.0" ?>

<cliTemplate>

      <content>hostname $gv.lab-hostname

</content>

      <description>Applies Hostname2</description>

      <deviceType>Routers</deviceType>

      <name>ZEN-HOSTNAME-POSTED2</name>

      <path>My Templates/Provisioning Templates</path>

</cliTemplate>

If I create either template using the Web UI they work without a problem.

Is there something special I need to do when uploading templates which use global variables via the API?

Thanks,

Carl

4 Replies 4

Spencer Zier
Cisco Employee
Cisco Employee

What version of Prime Infrastructure are you using?  We tried reproducing this issue on 3.1.0 but couldn't get it to reproduce.  As long as we defined the global variable in the UI, simply specifying it in the cliTemplate/content request parameter, like you do in your ZEN-HOSTNAME-POSTED2 example, works.

Hi Spencer,

Thanks for the feedback.  I'm using Build 3.1.0.0.132

Once I've POSTed the template to Prime (e.g. curl -H "Content-Type: text/xml" --data-binary @ZEN-HOSTNAME-POSTED3.xml -X POST -u username 'https://cpi01.example.com/webacs/api/v2/op/cliTemplateConfiguration/upload')

You can see that when going to deploy the template through the Web GUI it doesn't recognise that I've provided a template with Global Variables (When the 'Form' button is selected):

Screen Shot 2016-11-04 at 11.57.45.png

But if I select the 'CLI' button you can see that the global variable is there:

Screen Shot 2016-11-04 at 11.58.08.png

Just to show the variable exists as a global variable:

Screen Shot 2016-11-04 at 11.58.32.png

If I search for and add the $gv.lab-hostname variable to the template through the Web GUI and save the template, it kicks it working using the global variables again.

i.e Web GUI update to make the template content look like this (then click save):

"

hostname $gv.lab-hostname

$gv.lab-hostname

"

Then I see the expected form values when trying to deploy:

Screen Shot 2016-11-04 at 12.50.49.png

Were you using the exact same build when you tried to replicate?

Thanks,

Carl

Carl, my apologies.  There was a UI save happening afterwards that would cause the template to function properly during deployment when we attempted to reproduce this issue.  We'll work on getting this issue fixed.  I've created CSCvc11240 to track this issue (it's not publicly visible yet but should be within 24 hours).

Workarounds we'd suggest right now is either:

  1. Use template-specific (non-global) variables and populating the values as needed during deployment
  2. After uploading the template, open it in the UI and click the save button.

Thank you for bringing this issue up and thank you for your patience.  I very much appreciate it.

Edit: bug is now visible, added link

Hi Spencer,

Thanks for the update, hopefully the fix is simple and can be rolled out quickly.

Regards,

Carl

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: