Introduction
For JS7 - Management of Agent Clusters a number of users wish to create Cluster Agents and Subagent Clusters automatically from individual sources such as a database.
- The JS7 - REST Web Service API allows to perform the same operations to manage Cluster Agents as offered from the JOC Cockpit GUI.
- The JS7 - PowerShell Module offers simplified access to the REST Web Service API for scripting purposes.
- The PowerShell examples when executed might prove to be instructive for logging of REST API calls when used with the
-debug
option.
- The PowerShell examples when executed might prove to be instructive for logging of REST API calls when used with the
Documentation
The REST Web Service API provides the functionality to automate JS7 operation.
To add the REST Web Service API calls in your preferred language or to use the PowerShell cmdlets
- find the Technical Documentation of the REST Web Service API
find the documentation for PowerShell CLI 2.0 - Cmdlets - Agent Cluster Management and
Examples
The following examples makes use of the JS7 PowerShell Module to manage Standalone Agents:
Example for use of PowerShell cmdlets
#!/usr/bin/env pwsh # Parameterization $Url = "http://localhost:4446" $ControllerId = "controller" $TestCaseClusterAgentId = "TestCase_ClusterAgentID" $TestCaseClusterAgentName = "TestCase_ClusterAgentName" $TestCaseClusterAgentUrl = "https://TestCase_ClusterAgentUrl" $TestCaseSubagentId = "TestCase_SubagentID" $TestCaseSubagentUrl = "http://TestCase_SubagentUrl" $TestCaseSubagentClusterId = "TestCase_SubagentClusterID" # Connection Import-Module JS7 -Force Connect-JS7 -Url $Url -Id $ControllerId | Out-Null # ----- Create Cluster Agent and Subagents ----- # create one Director Agent and two additional Subagents $subagents = @() $subagents += New-JS7Subagent -SubagentId "$TestCaseSubagentId-001" -Url "$TestCaseSubagentUrl-001:4443" -DirectorType 'PRIMARY_DIRECTOR' $subagents += New-JS7Subagent -SubagentId "$TestCaseSubagentId-002" -Url "$TestCaseSubagentUrl-002:4443" $subagents += New-JS7Subagent -SubagentId "$TestCaseSubagentId-003" -Url "$TestCaseSubagentUrl-003:4443" # create the Cluster Agent referencing the list of Subagents Set-JS7ClusterAgent -AgentId "$TestCaseClusterAgentId-001" -AgentName "$TestCaseClusterAgentName-001" -Url "$TestCaseClusterAgentUrl-001:4443" -Subagents $subagents -ControllerId $ControllerId # ----- Manage Cluster Agent ----- # read the Cluster Agent configuration $agent = Get-JS7Agent -AgentId "$TestCaseClusterAgentId-001" # deploy Cluster Agent and Subagents to Controller Publish-JS7ClusterAgent -AgentId "$TestCaseClusterAgentId-001" # reset Subagents if required Reset-JS7Subagent -SubagentId "$TestCaseSubagentId-001" Reset-JS7Subagent -SubagentId "$TestCaseSubagentId-002" -Force # disable Subagents that should not be considered for job execution Disable-JS7Subagent -SubagentId "$TestCaseSubagentId-001","$TestCaseSubagentId-002" Enable-JS7Subagent -SubagentId "$TestCaseSubagentId-001","$TestCaseSubagentId-002" # revoke the Cluster Agent from the Controller Revoke-JS7ClusterAgent -AgentId "$TestCaseClusterAgentId-001" Publish-JS7ClusterAgent -AgentId "$TestCaseClusterAgentId-001" # ----- Manage Subagent Cluster ----- # create an active-active Subagent Cluster from two Subagents using the same priorities Set-JS7SubagentCluster -AgentId "$TestCaseClusterAgentId-001" -SubagentClusterId "$TestCaseSubagentClusterId-001" -SubagentId "$TestCaseSubagentId-001","$TestCaseSubagentId-002" -Priority 1,1 # create an active-passive Subagent Cluster from two Subagents using different priorities Set-JS7SubagentCluster -AgentId "$TestCaseClusterAgentId-001" -SubagentClusterId "$TestCaseSubagentClusterId-002" -SubagentId "$TestCaseSubagentId-001","$TestCaseSubagentId-002" -Priority 2,1 # deploy Subagent Clusters to Controller Publish-JS7SubagentCluster -SubagentClusterId "$TestCaseSubagentClusterId-001","$TestCaseSubagentClusterId-002" # revoke Subagent Clusters from Controller Revoke-JS7SubagentCluster -SubagentClusterId "$TestCaseSubagentClusterId-001","$TestCaseSubagentClusterId-002" # ----- Remove Agent Cluster, Subagent Clusters, Subagents ----- # remove Subagent Clusters individually Remove-JS7SubagentCluster -SubagentClusterId "$TestCaseSubagentClusterId-001","$TestCaseSubagentClusterId-002" # remove Subagents individually Remove-JS7Subagent -SubagentId "$TestCaseSubagentId-002","$TestCaseSubagentId-003" # remove the Cluster Agent and any Subagents and Subagent Clusters included Remove-JS7Agent -AgentId "$TestCaseClusterAgentId-001" # Connection Disconnect-JS7
Explanation:
- Line 1: A shebang is used to invoke PowerShell on Unix platforms. For Windows platforms replace this line with:
@@findstr
/v
"^@@f.*&"
"%~f0"
|pwsh.exe -&goto:eof
- Optionally adjust
pwsh.exe
bypowershell.exe
or similar to locate the PowerShell interpreter.
- Line 5: The URL to JOC Cockpit is specified. This is the same URL as used from a user browser to access JOC Cockpit.
- Line 6: The Controller ID is specified during setup of a Controller. Find the Controller ID in the right upper corner of any JOC Cockpit page.
Overview
Content Tools