Active IQ Unified Manager Discussions

REST output

brycedeutsche
3,398 Views

Hi

I'm getting in a bit of a tangle here;

I'm trying to provide output to the REST process which is calling my workflow.

<atom:link rel="out-parameter" href="http://loninasu0005.uk.db.com/rest/workflows/d50d03f0-93ca-4a34-a50a-af8fc0766fe9/out

The workflow creates ACL groups in the domain via a PoSH script and I need to pass these values back to the REST process once complete so they can be passed on to the initiator.

The ACL names are logged in a log file which takes the name of the Job ID so easy to track. So far I have been tinkering with the Return Parameters option but not getting far.

In the command I want to interogate the log file for the ACL values and return these if possible.

Any help appreciated.

<command>

Get-WFALogger -Info -message $("Triggering Provisiong command")

$output = get-host
Get-WFALogger -Info -message $output

$PSLogfile =   $(Get-WfaRestParameter "jobId")

$expression = $("c:\PROGRA~1\NetApp\WFA-Scripts\VFS_add_new_array-uat-v3.ps1 $dbArray $dbThin $dbCapacity $dbDatacentre $dbReparray $PSLogFile")

Get-WFALogger -Info -message $("Command to invoke: " + $expression)

Get-WFALogger -Info -message "ENV - $env:path "

$output = Invoke-Expression $expression

function OutVars ([string] $var)
{
foreach ($line in $file)
    {
    if ($line.contains($var))
        {
        $var = $line.substring($line.indexof(":") +2)
        return $var
        }
    }
}

$file = Get-Content c:\PROGRA~1\NetApp\WFA-PSLogs\LOG-ID-$PSLogfile.log

$aclr = OutVars "ACLR"
$aclc = OutVars "ACLC"


Add-WfaWorkflowParameter -Name ACLR -Value $aclr -AddAsReturnParameter
Add-WfaWorkflowParameter -Name ACLC -Value $aclc -AddAsReturnParameter


# print the output of the exe
Get-WFALogger -Info -message "----------------------------------------------------------------------------------"

foreach($line in $output)
{
    if($line)
    {
        Get-WFALogger -Info -message $line
    }   
}

Get-WFALogger -Info -message "----------------------------------------------------------------------------------"

1 REPLY 1

ranjeetr
3,398 Views

Do the following in order:

1. Execute the  workflow with your custom command and put logs in POSH command  for ACL to be created  e.g:

POST :  http://localhost/rest/workflows/4aa88c6d-4dd3-49da-8546-0385deca8535/jobs

with input like:

<workflowInput>

  <userInputValues>

    <userInputEntry key="aggr" value="aggr1" />

  

  </userInputValues>

</workflowInput>

2.get the job status of executed workflow here jobid is 4.

GET : http://localhost/rest/workflows/4aa88c6d-4dd3-49da-8546-0385deca8535/jobs/4

if status is completed.

3. get the log message saved during command execution. Here 4 is workflow executionID same as job id in step 1 output and 0 is the command index.

GET : http://localhost/rest/workflows/executions/4/log/0

output will be like:

<collection>

    <log-message>

        <level>INFO</level>

        <date>1385534550309</date>

        <message>### Command 'Create and configure Storage Virtual Machine' ###</message>

    </log-message>

    <log-message>

        <level>INFO</level>

        <date>1385534570892</date>

        <message>Executing command: ./Create_and_configure_Storage_Virtual_Machine922462921215618622.ps1 -CifsAllowed $false -Cluster 10.238.63.45 -DnsDomainNames @('ctl.gdl.englab.netapp.com') -DnsServers @('10.229.184.239') -FcpAllowed $false -IscsiAllowed $false -Language c -RootVolumeAggregate aggr_krish -RootVolumeName restTest_root -SecurityStyle unix -VserverName restTest </message>

    </log-message>

    <log-message>

        <level>INFO</level>

        <date>1385534571283</date>

        <message>Get-WfaCredentials -Host 10.238.63.45</message>

    </log-message>

    <log-message>

        <level>INFO</level>

        <date>1385534571361</date>

        <message>Credentials successfully provided for '10.238.63.45'</message>

    </log-message>

    <log-message>

        <level>INFO</level>

        <date>1385534571470</date>

        <message>Connect-Controller -Type CLUSTER -Name 10.238.63.45 -Credential System.Management.Automation.PSCredential -Vserver  -Timeout 60000</message>

    </log-message>

    <log-message>

        <level>INFO</level>

        <date>1385534571611</date>

        <message>Connect-NcController (with credentials) -Name 10.238.63.45 -Timeout 60000 -ErrorAction Stop</message>

    </log-message>

Public