Skip to content

Commit

Permalink
Merge branch 'master' into ClientGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
JnaneshD05 authored Feb 21, 2023
2 parents a35bd3d + 1f33c6b commit 4b805fc
Show file tree
Hide file tree
Showing 18 changed files with 1,511 additions and 278 deletions.
357 changes: 351 additions & 6 deletions Modules/Commvault.CommCell/Commvault.CommCell.psm1

Large diffs are not rendered by default.

Binary file modified Modules/Commvault.FileSystem/Commvault.FileSystem.psd1
Binary file not shown.
4 changes: 2 additions & 2 deletions Modules/Commvault.FileSystem/Commvault.FileSystem.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function Search-CVClientFileSystem {
[String] $BackupSetId,

[Parameter(Mandatory = $False)]
[CVCopyPrecedence] $CopyPrecedence = 'Primary',
[Int32] $CopyPrecedence,

[Parameter(Mandatory = $False)]
[ValidateNotNullorEmpty()]
Expand Down Expand Up @@ -358,7 +358,7 @@ function Search-CVClientFileSystem {
if ($null -ne $subclientObj) { $sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{subclientId}', $subclientObj.subclientId) }
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{path}', $Path)
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{backupsetId}', $BackupSetId)
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{copyPrecedence}', $CopyPrecedence.value__)
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{copyPrecedence}', $CopyPrecedence)
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{jobId}', $JobId)
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{proxy}', $Proxy)
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{ma}', $MediaAgent)
Expand Down
Binary file modified Modules/Commvault.JobManager/Commvault.JobManager.psd1
Binary file not shown.
224 changes: 196 additions & 28 deletions Modules/Commvault.JobManager/Commvault.JobManager.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function Get-CVJob {
.DESCRIPTION
Get the list of all jobs. Based on parameters this commandlet filters the output.
This method is implemented with Powershell paging support.
.PARAMETER ClientName
Filter output based on ClientName.
Expand All @@ -37,8 +38,32 @@ function Get-CVJob {
.PARAMETER Details
Retrieves the details for a job.
.PARAMETER limit
The number of results to be listed in a page. Used for changing the paging limits. By default, the limit is 100 results per page.
.PARAMETER First
Get list of jobs with paging support -First 20 (20 per page).
.PARAMETER Skip
Get list of jobs with paging support -First 20 -Skip 5 (20 per page, skip first 5 jobs).
.PARAMETER IncludeTotalCount
Include total count of result record set.
.EXAMPLE
Get-CVJob
.EXAMPLE
Get-CVJob -CompletedTime 8 -IncludeTotalCount
.EXAMPLE
Get-CVJob -CompletedTime 72 -IncludeTotalCount -First 5
.EXAMPLE
Get-CVJob -CompletedTime 240 -IncludeTotalCount -First 10 -Skip 0
.EXAMPLE
Get-CVJob -CompletedTime 240 -IncludeTotalCount -First 10 -Skip 20
.EXAMPLE
Get-CVJob -Details
Expand Down Expand Up @@ -68,7 +93,7 @@ function Get-CVJob {
Author: Gary Stoops
Company: Commvault
#>
[CmdletBinding(DefaultParameterSetName = 'Default')]
[CmdletBinding(SupportsPaging = $True, DefaultParameterSetName = 'Default')]
[OutputType([PSCustomObject])]
param(
[Parameter(Mandatory = $False, ParameterSetName = 'ById', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
Expand Down Expand Up @@ -96,6 +121,10 @@ function Get-CVJob {
[ValidateNotNullorEmpty()]
[Int32] $CompletedTime = 24, # default 24 hours

[Parameter(Mandatory = $False, ParameterSetName = 'Default')]
[ValidateNotNullorEmpty()]
[Int32] $limit = 100,

[Switch] $Details
)

Expand Down Expand Up @@ -150,10 +179,13 @@ function Get-CVJob {
}
else {
if (-not [String]::IsNullOrEmpty($ClientName)) {
$clientObj = Get-CVClient -Client $ClientName
$clientObj = Get-CVId -ClientName $ClientName
if ($null -ne $clientObj) {
$sessionObj.requestProps.endpoint += '&clientId=' + $clientObj.clientId
}
else {
return
}
}

if (-not [String]::IsNullOrEmpty($SubclientName)) {
Expand All @@ -167,7 +199,9 @@ function Get-CVJob {
$subclientId = $subclientObj.subclientId
}
}


$sessionObj.requestProps.endpoint += "&hideAdminjobs=false"

if (-not [String]::IsNullOrEmpty($JobFilter)) {
$sessionObj.requestProps.endpoint += '&jobFilter=' + $JobFilter
}
Expand All @@ -182,8 +216,26 @@ function Get-CVJob {
else {
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{completedJobLookupTime}', $null)
}

if ($limit) {
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{limit}', $limit)
}
else {
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{limit}', $null)
}

$headerObj = Get-CVRESTHeader $sessionObj
if ($PSCmdlet.PagingParameters.First -eq [Uint64]::MaxValue) { # MaxValue is system default
if ($PSCmdlet.PagingParameters.IncludeTotalCount.IsPresent) {
$headerObj = Get-CVRESTHeader $sessionObj -Limit 0 -Offset 0
}
else {
$headerObj = Get-CVRESTHeader $sessionObj
}
}
else {
$headerObj = Get-CVRESTHeader $sessionObj -Limit $PSCmdlet.PagingParameters.First -Offset $PSCmdlet.PagingParameters.Skip
}

$body = ''
$payload = @{ }
$payload.Add('headerObject', $headerObj)
Expand Down Expand Up @@ -240,12 +292,16 @@ function Get-CVJob {
}

end { Write-Debug -Message "$($MyInvocation.MyCommand): end"
if ($PSCmdlet.PagingParameters.IncludeTotalCount) {
[double] $accuracy = 1.0
$PSCmdlet.PagingParameters.NewTotalCount($response.Content.totalRecordsWithoutPaging, $accuracy)
}
}
}


function Get-CVJobDetail {
<#
<#
.SYNOPSIS
Gets extended details for a job.
Expand All @@ -255,6 +311,9 @@ function Get-CVJobDetail {
.PARAMETER Id
Gets extended details for the job specified by Id.
.PARAMETER InfoType
Gets additional job information.
.PARAMETER JobObject
Gets extended details for the job specified by piped JobObject.
Expand All @@ -276,6 +335,9 @@ function Get-CVJobDetail {
.EXAMPLE
Get-CVJobDetail -Id 175 | Select-Object -ExpandProperty progressInfo
.EXAMPLE
Get-CVJobDetail -Id 175 InfoType 1
.OUTPUTS
Outputs [PSCustomObject] containing result.
Expand All @@ -292,53 +354,91 @@ function Get-CVJobDetail {
[ValidateNotNullorEmpty()]
[Int32] $Id,

[Parameter(Mandatory = $False, ParameterSetName = 'ById', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
[ValidateNotNullorEmpty()]
[Int32] $InfoType,

[Parameter(Mandatory = $True, ParameterSetName = 'ByObject', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
[ValidateNotNullorEmpty()]
[System.Object] $JobObject
)

begin { Write-Debug -Message "$($MyInvocation.MyCommand): begin"
begin {
Write-Debug -Message "$($MyInvocation.MyCommand): begin"

try {
$sessionObj = Get-CVSessionDetail $MyInvocation.MyCommand.Name
$endpointSave = $sessionObj.requestProps.endpoint
if ($InfoType -eq 0) {
$sessionObj = Get-CVSessionDetail $MyInvocation.MyCommand.Name
$endpointSave = $sessionObj.requestProps.endpoint
}
else {
$sessionObj = Get-CVSessionDetail 'GetJobById'
$endpointSave = $sessionObj.requestProps.endpoint
}
}
catch {
throw $_
}
}

process { Write-Debug -Message "$($MyInvocation.MyCommand): process"
process {
Write-Debug -Message "$($MyInvocation.MyCommand): process"

try {
$sessionObj.requestProps.endpoint = $endpointSave
if ($InfoType -gt 0) {
if ($PSCmdlet.ParameterSetName -eq 'ById') {
$job_id = $Id
}
else {
$job_id = $JobObject.jobId
}
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{jobId}', ($job_id))
$sessionObj.requestProps.endpoint = -join ($sessionObj.requestProps.endpoint, "/AdvancedDetails?infoType=", $InfoType)
$body = ''
$headerObj = Get-CVRESTHeader $sessionObj
$payload = @{ }
$payload.Add('headerObject', $headerObj)
$payload.Add('body', $body)
$validate = ''

$headerObj = Get-CVRESTHeader $sessionObj
$jobObj = @{ }
if ($PSCmdlet.ParameterSetName -eq 'ById') {
$jobObj.Add('jobId', $Id)
$response = Submit-CVRESTRequest $payload $validate

if ($response.IsValid) {
Write-Output $response.Content
}
}
else {
$jobObj.Add('jobId', $JobObject.jobId)
}
$body = $jobObj | ConvertTo-Json -Depth 10
$payload = @{ }
$payload.Add('headerObject', $headerObj)
$payload.Add('body', $body)
$validate = 'job'

$response = Submit-CVRESTRequest $payload $validate
$sessionObj.requestProps.endpoint = $endpointSave

if ($response.IsValid) {
Write-Output $response.Content.job.jobDetail
$headerObj = Get-CVRESTHeader $sessionObj
$jobObj = @{ }
if ($PSCmdlet.ParameterSetName -eq 'ById') {
$jobObj.Add('jobId', $Id)
}
else {
$jobObj.Add('jobId', $JobObject.jobId)
}
$body = $jobObj | ConvertTo-Json -Depth 10
$payload = @{ }
$payload.Add('headerObject', $headerObj)
$payload.Add('body', $body)
$validate = 'job'

$response = Submit-CVRESTRequest $payload $validate

if ($response.IsValid) {
Write-Output $response.Content.job.jobDetail
}
}

}
catch {
throw $_
}
}

end { Write-Debug -Message "$($MyInvocation.MyCommand): end"
end {
Write-Debug -Message "$($MyInvocation.MyCommand): end"
}
}

Expand Down Expand Up @@ -485,7 +585,75 @@ function Resume-CVJob {
end { Write-Debug -Message "$($MyInvocation.MyCommand): end"
}
}

function Resubmit-CVJob {
<#
.SYNOPSIS
Resubmit the job specified by job Id.
.DESCRIPTION
Resubmit the job specified by job Id.
.PARAMETER JobId
Resubmit the job specified by JobId.
.EXAMPLE
Resubmit-CVJob -JobId 78
.OUTPUTS
Outputs [PSCustomObject] containing result.
.NOTES
Author: Jnanesh D
Company: Commvault
#>
[CmdletBinding()]
[OutputType([PSCustomObject])]
param(
[Parameter(Mandatory = $True)]
[ValidateNotNullorEmpty()]
[Int32] $JobId
)

begin { Write-Debug -Message "$($MyInvocation.MyCommand): begin"

try {
$sessionObj = Get-CVSessionDetail $MyInvocation.MyCommand.Name
$endpointSave = $sessionObj.requestProps.endpoint
}
catch {
throw $_
}
}

process { Write-Debug -Message "$($MyInvocation.MyCommand): process"

try {
$sessionObj.requestProps.endpoint = $endpointSave
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{jobId}', $JobId)

$headerObj = Get-CVRESTHeader $sessionObj
$body = ''
$payload = @{ }
$payload.Add('headerObject', $headerObj)
$payload.Add('body', $body)

$response = Submit-CVRESTRequest $payload 'jobIds'

if ($response.IsValid) {
Write-Output $response.Content
}
else {
Write-Information -InformationAction Continue -MessageData "INFO: $($MyInvocation.MyCommand): resume request was not succesfully submitted for job [$JobId]"
}
}
catch {
throw $_
}
}

end { Write-Debug -Message "$($MyInvocation.MyCommand): end"
}
}

function Stop-CVJob {
<#
Expand Down Expand Up @@ -1603,4 +1771,4 @@ function PrepareSendLogFilesBodyJson ($PrepInputs) {
catch {
throw $_
}
}
}
Binary file modified Modules/Commvault.Policies/Commvault.Policies.psd1
Binary file not shown.
Loading

0 comments on commit 4b805fc

Please sign in to comment.