D
dbeavon
Guest
As far as I can tell, the REST URL that you gave me didn't have harmful side effects. I've never seen it terminate sessions that are "active" (which was my main fear - the REST URL itself doesn't seem to indicate one way or another if it will disconnect/terminate active sessions). REST API's aren't very self-descriptive and unfortunately they seem to require quite a lot of guess-work. I haven't fully convinced myself that REST is better than SOAP. For now I'll assume that this REST request does NOT impact active sessions and is SAFE for production (ie. if we swap out the r-code during a mid-day deployment to production, then we consider using this REST API as a mechanism for ensuring that the new code gets applied to all idle appserver sessions). Here is the start of another powershell script: param ( [string]$ablapp = "abl_application", [Parameter(Mandatory=$true)][int]$portnumber ) $agent= $null $response = $null $response2 = $null # Store credentials $pass="tomcat" | ConvertTo-SecureString -AsPlainText -Force $cred = New-Object System.Management.Automation.PsCredential('tomcat',$pass) # Retrieve available agents $response = Invoke-RestMethod -Uri (hddp://localhost:' + $portnumber.ToString() + '/oemanager/applications/' + $ablapp + '/agents') -Credential $cred # Parse out the results into JSON $jsonstring = ConvertTo-Json -InputObject $response -Depth 3 $json = ConvertFrom-Json -InputObject $jsonstring # Retrieve an available agent $agent = $json.result.agents | Where-Object -Property 'state' -EQ 'AVAILABLE' # Delete the agent sessions $response2 = Invoke-RestMethod -Method Delete -Uri (hddp://localhost:' + $portnumber.ToString() + '/oemanager/applications/' + $ablapp + '/' + $agent.agentId + '/sessions') -Credential $cred # Display summary Write-Output "Delete sessions operation was sent to oemanager REST URI" Write-Output ("Deleted ID : " + $agent.agentId + " - " + $response2.outcome + " " + $response2.result ) As I noted earlier, this works pretty well for swapping out the r-code that was previously loaded by a session. I was pleasantly surprised that even MS-agent processes started with "-q" will be able to receive refreshed code, without the need to restart the entire process. It appears that r-code must be independently maintained for each session within the agent process. Thanks for the help with this. David
Continue reading...
Continue reading...