Skip to content

Commit 4b805fc

Browse files
authored
Merge branch 'master' into ClientGroups
2 parents a35bd3d + 1f33c6b commit 4b805fc

File tree

18 files changed

+1511
-278
lines changed

18 files changed

+1511
-278
lines changed

Modules/Commvault.CommCell/Commvault.CommCell.psm1

Lines changed: 351 additions & 6 deletions
Large diffs are not rendered by default.
Binary file not shown.

Modules/Commvault.FileSystem/Commvault.FileSystem.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function Search-CVClientFileSystem {
225225
[String] $BackupSetId,
226226

227227
[Parameter(Mandatory = $False)]
228-
[CVCopyPrecedence] $CopyPrecedence = 'Primary',
228+
[Int32] $CopyPrecedence,
229229

230230
[Parameter(Mandatory = $False)]
231231
[ValidateNotNullorEmpty()]
@@ -358,7 +358,7 @@ function Search-CVClientFileSystem {
358358
if ($null -ne $subclientObj) { $sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{subclientId}', $subclientObj.subclientId) }
359359
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{path}', $Path)
360360
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{backupsetId}', $BackupSetId)
361-
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{copyPrecedence}', $CopyPrecedence.value__)
361+
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{copyPrecedence}', $CopyPrecedence)
362362
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{jobId}', $JobId)
363363
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{proxy}', $Proxy)
364364
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{ma}', $MediaAgent)
Binary file not shown.

Modules/Commvault.JobManager/Commvault.JobManager.psm1

Lines changed: 196 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function Get-CVJob {
1818
1919
.DESCRIPTION
2020
Get the list of all jobs. Based on parameters this commandlet filters the output.
21+
This method is implemented with Powershell paging support.
2122
2223
.PARAMETER ClientName
2324
Filter output based on ClientName.
@@ -37,8 +38,32 @@ function Get-CVJob {
3738
.PARAMETER Details
3839
Retrieves the details for a job.
3940
41+
.PARAMETER limit
42+
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.
43+
44+
.PARAMETER First
45+
Get list of jobs with paging support -First 20 (20 per page).
46+
47+
.PARAMETER Skip
48+
Get list of jobs with paging support -First 20 -Skip 5 (20 per page, skip first 5 jobs).
49+
50+
.PARAMETER IncludeTotalCount
51+
Include total count of result record set.
52+
4053
.EXAMPLE
4154
Get-CVJob
55+
56+
.EXAMPLE
57+
Get-CVJob -CompletedTime 8 -IncludeTotalCount
58+
59+
.EXAMPLE
60+
Get-CVJob -CompletedTime 72 -IncludeTotalCount -First 5
61+
62+
.EXAMPLE
63+
Get-CVJob -CompletedTime 240 -IncludeTotalCount -First 10 -Skip 0
64+
65+
.EXAMPLE
66+
Get-CVJob -CompletedTime 240 -IncludeTotalCount -First 10 -Skip 20
4267
4368
.EXAMPLE
4469
Get-CVJob -Details
@@ -68,7 +93,7 @@ function Get-CVJob {
6893
Author: Gary Stoops
6994
Company: Commvault
7095
#>
71-
[CmdletBinding(DefaultParameterSetName = 'Default')]
96+
[CmdletBinding(SupportsPaging = $True, DefaultParameterSetName = 'Default')]
7297
[OutputType([PSCustomObject])]
7398
param(
7499
[Parameter(Mandatory = $False, ParameterSetName = 'ById', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
@@ -96,6 +121,10 @@ function Get-CVJob {
96121
[ValidateNotNullorEmpty()]
97122
[Int32] $CompletedTime = 24, # default 24 hours
98123

124+
[Parameter(Mandatory = $False, ParameterSetName = 'Default')]
125+
[ValidateNotNullorEmpty()]
126+
[Int32] $limit = 100,
127+
99128
[Switch] $Details
100129
)
101130

@@ -150,10 +179,13 @@ function Get-CVJob {
150179
}
151180
else {
152181
if (-not [String]::IsNullOrEmpty($ClientName)) {
153-
$clientObj = Get-CVClient -Client $ClientName
182+
$clientObj = Get-CVId -ClientName $ClientName
154183
if ($null -ne $clientObj) {
155184
$sessionObj.requestProps.endpoint += '&clientId=' + $clientObj.clientId
156185
}
186+
else {
187+
return
188+
}
157189
}
158190

159191
if (-not [String]::IsNullOrEmpty($SubclientName)) {
@@ -167,7 +199,9 @@ function Get-CVJob {
167199
$subclientId = $subclientObj.subclientId
168200
}
169201
}
170-
202+
203+
$sessionObj.requestProps.endpoint += "&hideAdminjobs=false"
204+
171205
if (-not [String]::IsNullOrEmpty($JobFilter)) {
172206
$sessionObj.requestProps.endpoint += '&jobFilter=' + $JobFilter
173207
}
@@ -182,8 +216,26 @@ function Get-CVJob {
182216
else {
183217
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{completedJobLookupTime}', $null)
184218
}
219+
220+
if ($limit) {
221+
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{limit}', $limit)
222+
}
223+
else {
224+
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{limit}', $null)
225+
}
185226

186-
$headerObj = Get-CVRESTHeader $sessionObj
227+
if ($PSCmdlet.PagingParameters.First -eq [Uint64]::MaxValue) { # MaxValue is system default
228+
if ($PSCmdlet.PagingParameters.IncludeTotalCount.IsPresent) {
229+
$headerObj = Get-CVRESTHeader $sessionObj -Limit 0 -Offset 0
230+
}
231+
else {
232+
$headerObj = Get-CVRESTHeader $sessionObj
233+
}
234+
}
235+
else {
236+
$headerObj = Get-CVRESTHeader $sessionObj -Limit $PSCmdlet.PagingParameters.First -Offset $PSCmdlet.PagingParameters.Skip
237+
}
238+
187239
$body = ''
188240
$payload = @{ }
189241
$payload.Add('headerObject', $headerObj)
@@ -240,12 +292,16 @@ function Get-CVJob {
240292
}
241293

242294
end { Write-Debug -Message "$($MyInvocation.MyCommand): end"
295+
if ($PSCmdlet.PagingParameters.IncludeTotalCount) {
296+
[double] $accuracy = 1.0
297+
$PSCmdlet.PagingParameters.NewTotalCount($response.Content.totalRecordsWithoutPaging, $accuracy)
298+
}
243299
}
244300
}
245301

246302

247303
function Get-CVJobDetail {
248-
<#
304+
<#
249305
.SYNOPSIS
250306
Gets extended details for a job.
251307
@@ -255,6 +311,9 @@ function Get-CVJobDetail {
255311
.PARAMETER Id
256312
Gets extended details for the job specified by Id.
257313
314+
.PARAMETER InfoType
315+
Gets additional job information.
316+
258317
.PARAMETER JobObject
259318
Gets extended details for the job specified by piped JobObject.
260319
@@ -276,6 +335,9 @@ function Get-CVJobDetail {
276335
.EXAMPLE
277336
Get-CVJobDetail -Id 175 | Select-Object -ExpandProperty progressInfo
278337
338+
.EXAMPLE
339+
Get-CVJobDetail -Id 175 InfoType 1
340+
279341
.OUTPUTS
280342
Outputs [PSCustomObject] containing result.
281343
@@ -292,53 +354,91 @@ function Get-CVJobDetail {
292354
[ValidateNotNullorEmpty()]
293355
[Int32] $Id,
294356

357+
[Parameter(Mandatory = $False, ParameterSetName = 'ById', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
358+
[ValidateNotNullorEmpty()]
359+
[Int32] $InfoType,
360+
295361
[Parameter(Mandatory = $True, ParameterSetName = 'ByObject', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
296362
[ValidateNotNullorEmpty()]
297363
[System.Object] $JobObject
298364
)
299365

300-
begin { Write-Debug -Message "$($MyInvocation.MyCommand): begin"
366+
begin {
367+
Write-Debug -Message "$($MyInvocation.MyCommand): begin"
301368

302369
try {
303-
$sessionObj = Get-CVSessionDetail $MyInvocation.MyCommand.Name
304-
$endpointSave = $sessionObj.requestProps.endpoint
370+
if ($InfoType -eq 0) {
371+
$sessionObj = Get-CVSessionDetail $MyInvocation.MyCommand.Name
372+
$endpointSave = $sessionObj.requestProps.endpoint
373+
}
374+
else {
375+
$sessionObj = Get-CVSessionDetail 'GetJobById'
376+
$endpointSave = $sessionObj.requestProps.endpoint
377+
}
305378
}
306379
catch {
307380
throw $_
308381
}
309382
}
310383

311-
process { Write-Debug -Message "$($MyInvocation.MyCommand): process"
384+
process {
385+
Write-Debug -Message "$($MyInvocation.MyCommand): process"
312386

313387
try {
314-
$sessionObj.requestProps.endpoint = $endpointSave
388+
if ($InfoType -gt 0) {
389+
if ($PSCmdlet.ParameterSetName -eq 'ById') {
390+
$job_id = $Id
391+
}
392+
else {
393+
$job_id = $JobObject.jobId
394+
}
395+
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{jobId}', ($job_id))
396+
$sessionObj.requestProps.endpoint = -join ($sessionObj.requestProps.endpoint, "/AdvancedDetails?infoType=", $InfoType)
397+
$body = ''
398+
$headerObj = Get-CVRESTHeader $sessionObj
399+
$payload = @{ }
400+
$payload.Add('headerObject', $headerObj)
401+
$payload.Add('body', $body)
402+
$validate = ''
315403

316-
$headerObj = Get-CVRESTHeader $sessionObj
317-
$jobObj = @{ }
318-
if ($PSCmdlet.ParameterSetName -eq 'ById') {
319-
$jobObj.Add('jobId', $Id)
404+
$response = Submit-CVRESTRequest $payload $validate
405+
406+
if ($response.IsValid) {
407+
Write-Output $response.Content
408+
}
320409
}
321410
else {
322-
$jobObj.Add('jobId', $JobObject.jobId)
323-
}
324-
$body = $jobObj | ConvertTo-Json -Depth 10
325-
$payload = @{ }
326-
$payload.Add('headerObject', $headerObj)
327-
$payload.Add('body', $body)
328-
$validate = 'job'
329-
330-
$response = Submit-CVRESTRequest $payload $validate
411+
$sessionObj.requestProps.endpoint = $endpointSave
331412

332-
if ($response.IsValid) {
333-
Write-Output $response.Content.job.jobDetail
413+
$headerObj = Get-CVRESTHeader $sessionObj
414+
$jobObj = @{ }
415+
if ($PSCmdlet.ParameterSetName -eq 'ById') {
416+
$jobObj.Add('jobId', $Id)
417+
}
418+
else {
419+
$jobObj.Add('jobId', $JobObject.jobId)
420+
}
421+
$body = $jobObj | ConvertTo-Json -Depth 10
422+
$payload = @{ }
423+
$payload.Add('headerObject', $headerObj)
424+
$payload.Add('body', $body)
425+
$validate = 'job'
426+
427+
$response = Submit-CVRESTRequest $payload $validate
428+
429+
if ($response.IsValid) {
430+
Write-Output $response.Content.job.jobDetail
431+
}
334432
}
433+
335434
}
336435
catch {
337436
throw $_
338437
}
339438
}
340439

341-
end { Write-Debug -Message "$($MyInvocation.MyCommand): end"
440+
end {
441+
Write-Debug -Message "$($MyInvocation.MyCommand): end"
342442
}
343443
}
344444

@@ -485,7 +585,75 @@ function Resume-CVJob {
485585
end { Write-Debug -Message "$($MyInvocation.MyCommand): end"
486586
}
487587
}
488-
588+
function Resubmit-CVJob {
589+
<#
590+
.SYNOPSIS
591+
Resubmit the job specified by job Id.
592+
593+
.DESCRIPTION
594+
Resubmit the job specified by job Id.
595+
596+
.PARAMETER JobId
597+
Resubmit the job specified by JobId.
598+
599+
.EXAMPLE
600+
Resubmit-CVJob -JobId 78
601+
602+
.OUTPUTS
603+
Outputs [PSCustomObject] containing result.
604+
605+
.NOTES
606+
Author: Jnanesh D
607+
Company: Commvault
608+
#>
609+
[CmdletBinding()]
610+
[OutputType([PSCustomObject])]
611+
param(
612+
[Parameter(Mandatory = $True)]
613+
[ValidateNotNullorEmpty()]
614+
[Int32] $JobId
615+
)
616+
617+
begin { Write-Debug -Message "$($MyInvocation.MyCommand): begin"
618+
619+
try {
620+
$sessionObj = Get-CVSessionDetail $MyInvocation.MyCommand.Name
621+
$endpointSave = $sessionObj.requestProps.endpoint
622+
}
623+
catch {
624+
throw $_
625+
}
626+
}
627+
628+
process { Write-Debug -Message "$($MyInvocation.MyCommand): process"
629+
630+
try {
631+
$sessionObj.requestProps.endpoint = $endpointSave
632+
$sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace ('{jobId}', $JobId)
633+
634+
$headerObj = Get-CVRESTHeader $sessionObj
635+
$body = ''
636+
$payload = @{ }
637+
$payload.Add('headerObject', $headerObj)
638+
$payload.Add('body', $body)
639+
640+
$response = Submit-CVRESTRequest $payload 'jobIds'
641+
642+
if ($response.IsValid) {
643+
Write-Output $response.Content
644+
}
645+
else {
646+
Write-Information -InformationAction Continue -MessageData "INFO: $($MyInvocation.MyCommand): resume request was not succesfully submitted for job [$JobId]"
647+
}
648+
}
649+
catch {
650+
throw $_
651+
}
652+
}
653+
654+
end { Write-Debug -Message "$($MyInvocation.MyCommand): end"
655+
}
656+
}
489657

490658
function Stop-CVJob {
491659
<#
@@ -1603,4 +1771,4 @@ function PrepareSendLogFilesBodyJson ($PrepInputs) {
16031771
catch {
16041772
throw $_
16051773
}
1606-
}
1774+
}
Binary file not shown.

0 commit comments

Comments
 (0)