Page History
...
Besides import of objects the suggested rollout procedure considers a number of use cases:
- DeployDeploying/release releasing scheduling objects.
- Transfer Transferring existing orders to the latest version version of a workflow.
- Remove Removing inventory objects that are not included with the import archive.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
# Example for rollout of scheduling objects from an archive file # ----- begin: adjust to your environment ----- $Url = 'https://apmacwin:4243/' $Credential = ( New-Object -typename System.Management.Automation.PSCredential -ArgumentList 'root', ( 'root' | ConvertTo-SecureString -AsPlainText -Force) ) $ControllerId = "jobscheduler" $ArchiveFile = "/tmp/export.zip" $TempDir = "$env:TEMP" $debugPreference = 'continue' $verbosePreference = 'continue' # Start-Transcript -Path ./console.log # ----- end: adjust to your environment ----- # load module and authenticate Import-Module JS7 Connect-JS7 -Url $Url -Credential $Credential -Id $ControllerId # prepare $suspendedOrders = @() $blockedOrders = @() $objectTypesToFileExtensions = @{ 'WORKFLOW'='.workflow.json'; 'JOBRESOURCE'='.jobresource.json'; 'LOCK'='.lock.json'; 'NOTICEBOARD'='noticeboard.json'; 'FILEORDERSOURCE'='fileordersource.json'; 'WORKINGDAYSCALENDAR'='.calendar.json'; 'NONWORKINGDAYSCALENDAR'='.calendar.json'; 'SCHEDULE'='.schedule.json'; 'JOBTEMPLATE'='.jobtemplate.json'; 'INCLUDESCRIPT'='.includescript.json'; 'REPORT'='.report.json' } # step 1: import archive file Import-JS7InventoryItem -FilePath $ArchiveFile -TargetFolder / -Overwrite # get top-level folders from archive file $archiveDir = New-Item -Path $TempDir -Name $(New-Guid) -ItemType Directory Expand-Archive -Path $ArchiveFile -DestinationPath $archiveDir $topLevelFolders = Get-ChildItem -Path $archiveDir -Directory try { # step 2: deploy/release scheduling objects # release baseline objects foreach( $folder in $topLevelFolders ) { Publish-JS7ReleasableItem -Folder "/$($folder.Name)" -Recursive -Type 'INCLUDESCRIPT','JOBTEMPLATE' } # deployable items foreach( $folder in $topLevelFolders ) { Publish-JS7DeployableItem -ControllerId $ControllerId -Folder "/$($folder.Name)" -Recursive } # release complex scheduling objects foreach( $folder in $topLevelFolders ) { Publish-JS7ReleasableItem -Folder "/$($folder.Name)" -Recursive } # step 3: transfer orders to latest workflow version foreach( $folder in $topLevelFolders ) { $workflows = Get-JS7Workflow -Folder $folder.Name -Recursive foreach( $workflow in $workflows ) { # identify previous workflow versions if ( !$workflow.isCurrentVersion ) { # check for non-transferable orders $orders = Get-JS7Order -WorkflowPath $workflow.path -WorkflowVersionId $workflow.versionId -Blocked if ( $orders.count ) { Write-Warning "blocked orders found for workflow $($workflow.path), orders will not be transferred to latest workflow version" $blockedOrders += $orders } # check for suspended orders $orders = Get-JS7Order -WorkflowPath $workflow.path -WorkflowVersionId $workflow.versionId -Suspended if ( $orders.count ) { Write-Warning "suspended orders found for workflow $($workflow.path), orders will not be resumed" $suspendedOrders += $orders } # suspend in progress and waiting orders $orders = ( Get-JS7Order -WorkflowPath $workflow.path -WorkflowVersionId $workflow.versionId -InProgress -Waiting | Suspend-JS7Order ) # transfer orders to latest workflow version $orders | Set-JS7Order -Transfer -WorkflowPath $workflow.path -WorkflowVersionId $workflow.versionId # resume suspended orders $orders | Resume-JS7Order } } } if ( $blockedOrders.count ) { Write-Warning "The following $($blockedOrders.count) blocked orders are preseent and cannot be transferred to latest workflow versions" Write-Warning $blockedOrders } if ( $suspendedOrders.count ) { Write-Warning "The following $($suspended.count) suspended orders are preseent and have not beeen transferred to latest workflow versions" Write-Warning $suspendedOrders } # step 4: remove scheduling objects not available from archive file foreach( $folder in $topLevelFolders ) { $objects = Get-JS7InventoryFolder -Folder $folder.Name -Recursive foreach( $object in $objects.PSObject.properties.value ) { if ( $object.id ) { # Write-Output "Test-Path -Path $($archiveDir)$($object.path)$($objectTypesToFileExtensions[$object.objectType])" if ( !(Test-Path -Path "$($archiveDir)$($object.path)$($objectTypesToFileExtensions[$object.objectType])") ) { # Remove-JS7InventoryItem -Path $object.path -Type $object.objectType Write-Output "Remove-JS7InventoryItem -Path $($object.path) -Type $($object.objectType)" } } } } } catch { $message = $_.Exception | Format-List -Force | Out-String throw "Exception occurred in line number $($_.InvocationInfo.ScriptLineNumber)`n$($message)" } finally { # cleanup Remove-Item -Path $archiveDir -Force -Recurse Disconnect-JS7 # Stop-Transcript } |
...
This step works from a call to the Import-JS7InventoryItem cmdlet.
Existing objects such was as workflows, schedules etc. that are available from the archive file will be overwritten.
Step 2: Deploy/Release Scheduling Objects
This step is carried carries out in the following sub-steps:
- Release Releasing baseline scheduling objects
- Objects such as JS7 - Script Includes and JS7 - Job Templates are released to make them available for further deployment, see Publish-JS7ReleasableItem.
- Deploy Deploying scheduling objects
- Deploy objects Objects that should be available with a Controller and Agents such as as JS7 - Workflows are deployed, see Publish-JS7DeployableItem.
- Release Releasing scheduling objects
- Release objects Objects that are required for automation such as as JS7 - Calendars and Schedules are released.
Step 3: Transfer Orders to latest Workflow Version
If a new workflow version is deployed then JS7 keeps the previous version of a workflow if a new workflow version is deployedfor which orders exist. The reason being that orders assigned the previous workflow version that have been started should be able to continue in the previous workflow version. If no orders exist for a previous workflow version, then this version will disappear. For details see see JS7 - Workflows - Status Operations on Orders.
For users who wish to transfer existing orders to the latest workflow version the script Rollout Script implements the desired behavior.
- A number of order states such as INPROGRESS and WAITING for specific events do not suggest orders to be transferred. Such orders are suspended to allow transfer to the latest workflow version and are later on resumed.
- BLOCKED orders cannot be transferred as they indicate missing connections from a Controller to the related Agent.
- RUNNING orders are ignored as they are assumed to complete the workflow.
This steps step makes use of the the Get-JS7Workflow, Get-JS7Order, Suspend-JS7Order, Resume-JS7Order and Set-JS7Order cmdlets.
...