VMware Cloud Community
manuelperrot
Enthusiast
Enthusiast

vCO 5.5.2 (appliance) - Retrieve logged users and running workflows

Hi Everyone,

I would like to automate the vCO appliance reboot in our environment.

Before taking the reboot decision I would like to know if the vCO server is currently in use or not.

I'm thinking about:

1. Retrieving logged users

2. Check if they are some running/waiting workflows

I can do this one by getting the list of all existing workflows with the REST api, and then going through each of them to know if there is a running execution.

But is there a better way to do this?

function vCO_runningWorkflow ($vcoapi,$headers)

{

    $workflowlist = Invoke-WebRequest -uri:"$vcoapi/content/workflows/?keys=id" -Method:"GET" -Headers:$headers -ContentType:"application/json"

    $workflowExecutions = @()

    foreach ($workflow in (($workflowlist.Content | ConvertFrom-Json).link.attributes | where {$_.name -match "itemHref"}).value)

    {

        $workflowExecution = Invoke-WebRequest -uri:"$workflow/executions/?conditions=state=running" -Method:"GET" -Headers:$headers -ContentType:"application/json"

        if(($workflowExecution.Content | ConvertFrom-Json).relations.total -ne 0 )

        {

          

            $workflowExecutions += $workflowExecution

            $workflowExecution = $null

        }

        $workflowExecution = Invoke-WebRequest -uri:"$workflow/executions/?conditions=state=waiting" -Method:"GET" -Headers:$headers -ContentType:"application/json"

        if(($workflowExecution.Content | ConvertFrom-Json).relations.total -ne 0 )

        {

            $workflowExecutions += $workflowExecution

            $workflowExecution = $null

        }

    }

    return $workflowExecutions

}

Thanks a lot.

Manuel

Reply
0 Kudos
0 Replies