Release Automation

Expand all | Collapse all

How can I programatically set the value of a String Array Parameter?

Jump to Best Answer
  • 1.  How can I programatically set the value of a String Array Parameter?

    Posted 07-14-2016 03:44 PM

    I have parameter-ized the fields in a "REST Operation" action, so that I can use a subflow that contains the action repeatedly without having to duplicate a bunch of actions. To use the "REST Operation" action, I create a collection of "Set Parameter" actions to populate parameters in the "REST Operation" action fields. I am having trouble setting the value for the "REST action" "Http Headers" String Array field.

     

    I have been trying to use the "ROC - Update String Array Parameter" action, but I keep getting errors of the following kind:

     

    "Failed to update parameter [AVIWorker/AVILoadBalancer-Shared/RESTCalls/_RESTHttpHeaders].

    Reason: [Cannot find parameter [03_DeploySW/AVIWorker/AVILoadBalancer-Shared/RESTCalls/_RESTHttpHeaders].]"

     

    The documentation for the "ROC - Update String Array Parameter" action states that for the Parameter Name field:

     

    "The name of the parameter (use the "Full Path" attribute of the parameter as it appears in the ROC)"

     

    In the error, CARA indicates that it pre-pends the the process name to the Parameter Name provided in the "ROC - Update String Array Parameter", where...

     

    • process name = 03_DeploySW
    • server type = AVIWorker
    • parameter path = AVILoadBalancer-Shared/RESTCalls/_RESTHttpHeaders

     

    I have tried including the server type (as shown above) and excluding the server type from the Parameter Name provided in the "ROC - Update String Array Parameter" action. Both paths failed.

     

    Here are some screenshots that might further help illustrate the scenario...

     

     

     

     



  • 2.  Re: How can I programatically set the value of a String Array Parameter?

    Posted 07-14-2016 03:49 PM

    Can you provide some screenshots with your actions settings / parameters tree and error message

    This can assist understanding the root cause

    Thanks

    Jacky 



  • 3.  Re: How can I programatically set the value of a String Array Parameter?

    Posted 07-14-2016 04:08 PM

    Just added. I had to post prematurely because of a problem I had with the description field locking up somehow. I'll add a screen shot of the error message too.



  • 4.  Re: How can I programatically set the value of a String Array Parameter?

    Posted 07-15-2016 01:01 AM

    Hi

    I see that you set the server type name (AVIWorker) along the path of the parameter name.

    If you see the action inputs , one of optional inputs is the server type name

    Try to put the server type name in that field and remove it from the parameter name input..

    BTW

    You can see the release parameter path in your deployment plan --> steps that use the parameter --> release parameters

    Thanks

    Jacky



  • 5.  Re: How can I programatically set the value of a String Array Parameter?

    Posted 07-15-2016 11:23 AM

    Thanks Jacky, but no luck.

     

    I still get the same error when I put the Server Type into the "Server Type Name" field. It looks like CARA just sticks teh the "Server Type Name" field value onto the front of the "Parameter Name" field value. Also, I cannot see my parameter path using the method you suggested because it is an internal parameter.

     

    (Note: I have renamed the parameter used in the "Parameter value" field, so don't be confused that it looks different from the screen shots above.)

     

    Also, I've tried an alternative approach using other actions to...

     

    1. Initialize the _RESTHttpHeaders String Array parameter, using  "Arrays - Initialize Array" action.
    2. Loop through _AVIGetPoolHeaders tring Array parameter, to re-populate _RESTHttpHeaders using "Arrays - Add a Value to an Array" action.

     

    Unfortunately, once the _RESTHttpHeaders String Array parameter is initialized, any attempt to use  "Arrays - Add a Value to an Array" action with that parameter results in "Error occurred during action execution: 0" as shown here:

     

     

    • I believe this is a bug with the "Arrays - Add a Value to an Array" action not handling an initialized string array parameter.
    • I've tried a variety of ways to work around this problem, including:
      • Looping through the _RESTHttpHeaders String Array parameter to remove each element until it's empty
      • Setting the Index field value on the "Arrays - Add a Value to an Array" action explicitly to 1.
      • Setting the Index field value on the "Arrays - Add a Value to an Array" action explicitly to, in case it was trying to address the array as a 0-based array.

     

    So now that I've attempted 2 different methods to solve the problem of re-populating an array parameter, and both have failed, I'm forced to point out that this problem is proving to be *FAR* to much work to solve in CARA than it should be.

     

    I have one more idea to try that involves using the "Arrays - Write Array to Text File" and "Arrays - Read String Array from Text File" actions. I hate the idea of having to resort to writing out to a file just to read it back in again, but if it works as a work around, it might just have to do for now.



  • 6.  Re: How can I programatically set the value of a String Array Parameter?

    Broadcom Employee
    Posted 07-15-2016 12:18 PM

    Mark I am jumping in at the end so apologies if I might have missed something.  From your screen shot it would appear that the array parameter is not a release parameter so you cant use the ROC action you are using.  I use two actions

    Arrays - Initialize Array

    Arrays - String Insert

    For the action, Arrays - String Insert, you have to use an array as one of the input parameters along with your string and then have an output array.  I simply make them same.  So something like this

    I will have one action for each item I want to add to the array.

     

    hope this helps



  • 7.  Re: How can I programatically set the value of a String Array Parameter?
    Best Answer

    Posted 07-15-2016 03:49 PM

    Thank you Billy.

     

    I ended up writing one array parameter out to a file and reading the file back into my target array parameter. Although I don't like having to write out to a file like that, it is the only approach I tried that worked. Honestly, I wish I'd gone with that yesterday when I first thought of it and saved myself hours of headaches troubleshooting the other 2 approaches.

     

     

    WRT the ROC action, there appear to be 2 to choose from:

     

    • ROC - Update String Array Parameter
    • ROC - Update String Array Release Parameter

     

    I agree that the second one would be expected to only with Release Parameters, but the documentation for the first one does not indicate any such limitation. If the first does have that limitation, then why does the second exist?

     

    I do not have the Arrays - String Insert action. What version of CARA are you using?

     



  • 8.  Re: How can I programatically set the value of a String Array Parameter?

    Broadcom Employee
    Posted 07-15-2016 06:36 PM

    I got my wires crossed.  You are right about the two ROC actions (as shown above).  They do two separate things.  I was wrong about the action, ROC - Update String Array Parameter.  In release 5 and above, you basically have 3 types of parameters for a deployment step.    Release, Environment, User Input .   When using the actions such as ROC - Update String Array Parameter or ROC - Update String Parameter in order for the parameter to be in context it must be set with a scope of "user input".  Thus it will show up when you view it in the ROC deployment step.  for example

    If you don't see the parameter here, be it an application or component, then the action is going to fail with parameter not found.  Similar to what you are seeing.  The problem is that once you do this you are going to hit another problem which I think is a bug and I will open a support issue for it.

    Second mistake on my part....the action "array string insert" is an action I picked up a while back from a colleague of mine.  It is a custom action and it is not part of the out of the box RA action packs. Probably got created for the exact problem you are seeing.   Apologies for misleading you on this one.

    At least now you have come up with a work around so that is good news.  If I get any feedback on the support issue I will update this thread with my findings.