Active IQ Unified Manager Discussions

Command to run/execute workflows ready for production in workflow automation tool...

shariq_aijaz
7,082 Views

Hi,

Can we use command line(or any command) to run(execute) already created production workflows?

If yes, what are those commands and what is the process to do?

Regards

Shariq

1 ACCEPTED SOLUTION

hill
6,990 Views

Hi Shariq,

I'm not certain of what you're asking.

If you're asking if WFA can execute CLI commands against systems, the answer is "yes", but those wouldn't be workflows... those would be individual tasks.  I also would like to point out that a recommendation and effectively a best practice is to leverage the API's via PowerShell or Perl in the WFA commands.

If you're asking if it is possible to call WFA workflows remotely, the answer to that question is also "yes".  However, that's not exactly a 'cli'.  WFA does have Web Services via REST and SOAP (REST is preferred) that allow you to programatically call WFA workflows.  If that is what you're interested in, then I would suggest the following documents:

Hope this helps,

Kevin

View solution in original post

6 REPLIES 6

hill
6,991 Views

Hi Shariq,

I'm not certain of what you're asking.

If you're asking if WFA can execute CLI commands against systems, the answer is "yes", but those wouldn't be workflows... those would be individual tasks.  I also would like to point out that a recommendation and effectively a best practice is to leverage the API's via PowerShell or Perl in the WFA commands.

If you're asking if it is possible to call WFA workflows remotely, the answer to that question is also "yes".  However, that's not exactly a 'cli'.  WFA does have Web Services via REST and SOAP (REST is preferred) that allow you to programatically call WFA workflows.  If that is what you're interested in, then I would suggest the following documents:

Hope this helps,

Kevin

shariq_aijaz
6,990 Views

Thanks Kevin,

Yes, I was asking that is it possible to call WFA workflows remotely via a command line. Actually, my problem statement is that I am looking to call and execute WFA workflows through Microsoft System Center Orchestrator. I think these WFA web services call should work.

So I will take a look at these documents. Thanks...

Regards

Shariq

hill
6,990 Views

Hi Shariq,

In that case, I think it might also be worthwhile if you check out this communities document: https://communities.netapp.com/docs/DOC-25899.  This is where Jeremy shows how to initiate WFA workflows from vCenter Orchestrator... great stuff!

I also have a couple of requests... Please share your results when you're ready to share.  Also, can you please mark if this post was helpful, or is answered?  We're just trying to make sure we close out all open questions.

Thanks!

Kevin

shariq_aijaz
6,990 Views

Hi Kevin,

Sure; once I am done, will share the results with the community.

Further, I have marked the answer "Correct".

Thanks for your prompt support!!!

Regards

Shariq

goodrum
6,990 Views

Ask and ye, shall receive.  I actually built this little diddy a few days ago because I was trying to test for an intermittent error that I was getting with a command.  (thousands of executions and finally found that the issue was the actual command (not the script... the actual command... strange).  Anyway, I haven't had time to 'clean' this up but it will get you going.  This is a simple script to execute a hard coded workflow with no User inputs though I do have the user inputs section definable in the script.  The script executes the workflow and waits for the job to complete

Jeremy Goodrum, NetApp

The Pirate

Twitter: @virtpirate

Blog: www.virtpirate.com

--------------------------------------------

function Execute-HTTPPostCommand() {

    param(

        [string] $target = $null

    )

    $username = "admin"

    $password = "admin"

    $webRequest = [System.Net.WebRequest]::Create($target)

    $auth = [System.Text.Encoding]::UTF8.GetBytes($username+":"+$password)

    $base64 = [System.Convert]::ToBase64String($auth)

    $webRequest.Headers.Add("AUTHORIZATION", "Basic $base64");

    $webRequest.PreAuthenticate = $true

    $webRequest.Method = "POST"

    $webRequest.ContentType = "application/xml"

    $bytes = [System.Text.Encoding]::UTF8.GetBytes($post.OuterXML)

    $webRequest.ContentLength = $bytes.Length

    [System.IO.Stream] $requestStream = [System.IO.Stream]$webRequest.GetRequestStream()

    $requestStream.Write($bytes,0,$bytes.Length) 

    $requestStream.Close()

    [System.Net.WebResponse] $resp = $webRequest.GetResponse();

    $rs = $resp.GetResponseStream();

    [System.IO.StreamReader] $sr = New-Object System.IO.StreamReader -argumentList $rs;

    [string] $results = $sr.ReadToEnd();

    return $results;

}

function Execute-HTTPGetCommand() {

    param(

        [string] $target = $null

    )

    $username = "admin"

    $password = "admin"

    $webRequest = [System.Net.WebRequest]::Create($target)

    $auth = [System.Text.Encoding]::UTF8.GetBytes($username+":"+$password)

    $base64 = [System.Convert]::ToBase64String($auth)

    $webRequest.Headers.Add("AUTHORIZATION", "Basic $base64");

    $webRequest.PreAuthenticate = $true

    [System.Net.WebResponse] $resp = $webRequest.GetResponse();

    $rs = $resp.GetResponseStream();

    [System.IO.StreamReader] $sr = New-Object System.IO.StreamReader -argumentList $rs;

    [string] $results = $sr.ReadToEnd();

    return $results;

}

# <userInputEntry key='vcs' value='192.168.0.31'/>

$post = [xml] "<workflowInput><userInputValues></userInputValues></workflowInput>"

$URL = "http://192.168.0.5/rest/workflows/66187d17-1092-4d2d-9072-2e5b06d9e723/jobs"

for ($i=1;$i -lt 101;$i++) {

    $wait = 0

    Write-Host "Starting Iteration #$i"

    $results = Execute-HTTPPostCommand $URL

    $jobs = [xml] $results

    $JobURL = $URL + "/" + $jobs.job.jobId

    DO {

      $results = Execute-HTTPGetCommand $JobURL

      $job = [xml] $results

      $jobStatus = $job.job.jobStatus.jobStatus

      switch ($jobStatus) {

        "SCHEDULED" {$wait = 0;break;}

        "PENDING" {$wait = 0;break;}

        "EXECUTING" {$wait = 0;break;}

        "COMPLETED" {$wait = 1;Write-Host "--Workflow Run $i Completed" -foregroundcolor "magenta";break;}

        "FAILED" {$wait = 1;Write-Host "--Workflow Failed!!!!"  -foregroundcolor "red"; Write-Host $job.job.jobStatus.errorMessage -foregroundcolor "red"; exit -1;break;}

        "PLANNING" {$wait =0;break;}

        default {$wait = 1;Write-Host "--Unexpected Message - $jobStatus" -foregroundcolor "red"; exit -1;break;}

      }

    } UNTIL ($wait -eq 1)

}

--------------------------------------------

shariq_aijaz
6,990 Views

Thanks...

I think this will help, though I am just in an initial phases of learning PowerShell scripting but it seems to be very helpful.

I will try this and let you know.

Regards

Shariq

Public