Active IQ Unified Manager Discussions

Having trouble calling a Function from a Command

SCOTT_LINDLEY
3,396 Views

I am trying to update a Command and some of the information that it needs to function needs to be pulled from a couple of Functions. The Command and one of the Functions are custom items written by NetApp PS, and the other Function is a custom function that I wrote. While I cannot include the source here due to company policy, I can provide code fragments that might help you to diagnose the issue. The error message that I receive is “The term 'nextRuleClientMatch' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.”. A fragment of the Command code looks like this:

    $message += @"
*) Add new netgroups to netgroup file
    +) $(nextRuleClientMatch(2,$($splitText[1]),$($splitText[2]),$($splitText[6])))
    +) $(nextRuleClientMatch(3,$($splitText[1]),$($splitText[2]),$($splitText[6])))
    +) $(nextRuleClientMatch(4,$($splitText[1]),$($splitText[2]),$($splitText[6])))
*)    Make sure netgroups are not empty, this can break all NFS access. If there are no servers, add ADMIN_PROD
"@

According to the error message, I should be able to call Functions from a Command. I have not been able to locate any documentation on coding in WFA, so all I can do it assume and base new code code on existing examples. If there is any decent documentation on coding in WFA, please point me to it. I'd be so happy to read it!

Update: I am using WFA 2.1, looking forward to 2.2GA!

Thanks,

     Scott L

1 REPLY 1

sinhaa
3,396 Views

Scott,

“The term 'nextRuleClientMatch' is not recognized as the name of a cmdlet, function, script file, or operable program."

The above Error is thrown by Powershell and the word function above is in context of a Powershell function and NOT WFA function(s). The WFA fuctions are in MVEL ( and not powershell) and can't be used inside a command Code. WFA commands are essentially a Powershell script and can't access WFA MVEL fuctions inside the code. MVEL expressions, functions can be used in a workflow at parameter value for the commands its having.

To elaborate, I'll take an example.

I have a function named return_value which just returns the passed value:

=======

def return_string(value)

{

       return value;

}

=======

I have command which take message as a parameter:

==========

param (

  [parameter(Mandatory=$true, HelpMessage="Message to print")]

  [string]$Message

)

Get-WFALogger -Info -message "Message is : $Message"

===========

I want to print the message "Hello World!". Now if I want to call the function to set the value of the Parameter Message, I can't call this MVEL function in the cmd code. To do this, I've to put the command in a workflow in details I can set the parameter like :

===

return_value("Hello ")+return_value("World!")

===

See the image here.

So to solve your problem of using function to set the message, Declare the message as a Parameter of the command and then in the workflow, you can call the function at the workflow.



If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
Public