Layer7 API Management

  • 1.  Templatized Value for a Context Variable

    Posted Apr 07, 2016 01:16 PM

    Hello,

    Does anyone have a good way to templatize values for a context variable?

     

    I currently use the GMU to export policy and then use the templatize feature to property drive certain values.  This works out okay. However, I noticed that when policy changes, the name of the properties also change.  This throws off my template scheme a bit.

     

    Here is an example... I could have a policy template property start out as:

     

    template.service.foo.Resources.ResourceSet.xml.All.OneOrMore.HttpRoutingAssertion.HttpRoutingAssertion.ProtectedServiceUrl.stringValue=http://dev.foo.com

     

    Then later, I might add additional logic with an "At least one" or "All" assertions, which changes the template property name to something like this:

     

    template.service.foo.Resources.ResourceSet.xml.All.OneOrMore.Required.All.Required.HttpRoutingAssertion.HttpRoutingAssertion.ProtectedServiceUrl.stringValue

     

    Additional segments are being added to qualify the property.  This breaks my templating approach since I then need to figure out what has been modified and adjust accordingly.

     

    What I'd like to do instead is define context variables up front thereby reducing the likelihood that they will change.  However, I do not see a way to "templatize" their value in the same way as what I've described above.  I know that I could get close to what I need with cluster-wide properties for this.  However, I don't like that approach as I will have several services to deal with.

     

    Thanks,

     

    Alejandro



  • 2.  Re: Templatized Value for a Context Variable
    Best Answer

    Broadcom Employee
    Posted Aug 28, 2016 11:49 PM

    Alejandro,

     

    Good evening. I've read through your post and wonder if another approach may make it easier to work with and for migrations. We normally recommend the usage of the Cluster Wide Properties (CWP). As these not only system configurations settings, they can be used for cluster wide context variables. When you create a new CWP it can be referenced in policy as ${gateway.<cwp name>} and when you migrate the policies between environment removes the need to modify the policy just the CWP to reference specific settings. Lastly the CWP can be modified through the Restman interface removing the need to modify individual policies.

     

    Sincerely,

     

    Stephen Hughes

    Director, CA Support



  • 3.  Re: Templatized Value for a Context Variable

    Posted Aug 28, 2016 11:56 PM

    Hi Alejandro,

      I agree with Stephen. Here is a community thread Updating cluster-wide properties without creating templates  where I had raised a similar question few months ago to which I have had the same answer. I employed this method and it works just fine. I believe the variables which change between environments like the endpoints are a classic case to have them as cluster properties. 

    Regards,

    Trinath