Microsoft Virtualization Discussions
Microsoft Virtualization Discussions
Hi,
when running get-ncjob we found, that there are missing information. So essential the Job-ID and JobName.
IsRestarted :
JobAffinity :
JobCategory :
JobCompletion : success
JobDescription : DELETE /api/storage/volumes/fc72f0e5-1817-11ef-9f60-00a098ff672f/snapshots/d11c4011-28bc-4c8e-9452-93157cf46bb2
JobDropdeadTime :
JobDropdeadTimeDT :
JobEndTime : 1744703715
JobEndTimeDT : 15.04.2025 09:55:15
JobId :
JobName :
JobNode :
JobPriority :
JobProcess :
JobProgress : success
JobQueueTime :
JobQueueTimeDT :
JobSchedule :
JobStartTime : 1744703715
JobStartTimeDT : 15.04.2025 09:55:15
JobState : success
JobStatusCode : 0
JobType :
JobUsername :
JobUuid : f73e0950-19ce-11f0-94b4-00a098ff672f
JobVserver : XXXXXXX
NcController : XXXXXXXXX
Error :
Svm : DataONTAP.C.Types.RestAttributes.Svm
JobNodeName :
IsRestartedSpecified : False
JobDropdeadTimeSpecified : False
JobEndTimeSpecified : True
JobIdSpecified : False
JobQueueTimeSpecified : False
JobStartTimeSpecified : True
JobStatusCodeSpecified : True
This was in older version not. As we have scripts which bases on this information, these scripts are not running anymore.
Any ideas what we can do, to get this run again.
THX
Michael
Solved! See The Solution
Hi Michael,
Looking at the REST API endpoint "/cluster/jobs" there is no field for "id" or "name" and that would explain why the "Get-NcJob" CmdLet doesn't return a value for these fields. The PSTK will query the ONTAP version and if you are running >= 9.6 the CmdLet's will default to invoking REST API's. Unfortunately the parameter mapping between ZAPI -> REST doesn't always match of is missing functionality. Your options here are to either using the private REST CLI (as provided in the example) or add the "-ZapiCall" to the "Connect-NcController" CmdLet in your script which will force the PSTK to explicitly revert to using ZAPI instead of REST and then the Job ID and Name will be displayed.
Hope this helps
/Matt
Hi Michael,
I'm not sure why the Get-NcJob CmdLet is missing the values for Name and ID however you can always revert to using the private REST CLI if there is an issue with a CmdLet. You could query the job via the UUID. EG
PS C:\Scripts> .\GetJobCli.ps1 -Cluster 192.168.100.2 -JobID 17b165e7-dea3-11ef-8613-00a098bd46e0 -Credential $credentials
Executing Command: job show -uuid 17b165e7-dea3-11ef-8613-00a098bd46e0 -fields id,name
Enumerated Job "17b165e7-dea3-11ef-8613-00a098bd46e0" on cluster "192.168.100.2" using URL: "https://192.168.100.2/api/private/cli/job?uuid=17b165e7-dea3-11ef-8613-00a098bd46e0&fields=id,name"
id vserver name uuid
-- ------- ---- ----
27 svm_01 SnapMirror Service Job 17b165e7-dea3-11ef-8613-00a098bd46e0
Here's the example source code:
Param(
[Parameter(Mandatory = $True, HelpMessage = "The name or IP Address of the Cluster")]
[String]$Cluster,
[Parameter(Mandatory = $True, HelpMessage = "The Job UUID")]
[String]$JobID,
[Parameter(Mandatory = $True, HelpMessage = "The Credentials to authenticate to the Cluster")]
[System.Management.Automation.PSCredential]$Credential
)
#'------------------------------------------------------------------------------
#'Set the certificate policy and TLS version.
#'------------------------------------------------------------------------------
Add-Type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
#[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
#'------------------------------------------------------------------------------
#'Disable SSL Check.
#'------------------------------------------------------------------------------
$sslHandler = @"
public class SSLHandler{
public static System.Net.Security.RemoteCertificateValidationCallback GetSSLHandler(){
return new System.Net.Security.RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return true; });
}
}
"@
Add-Type -TypeDefinition $sslHandler
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = [SSLHandler]::GetSSLHandler()
#'------------------------------------------------------------------------------
#'Enumerate the Certificates.
#'------------------------------------------------------------------------------
[String]$command = "job show -uuid $JobID -fields id,name"
[String]$uri = "https://$Cluster/api/private/cli/job?uuid=$JobID&fields=id,name"
Write-Host "Executing Command`: $command"
Try{
$response = Invoke-RestMethod -Method Get -Uri $uri -Credential $Credential -ErrorAction Stop
}Catch{
Write-Warning -Message $("Failed Enumerating Job ""$JobID"" on Cluster ""$Cluster"" using URL`: ""$uri"". Error " + $_.Exception.Message)
Exit -1
}
#'------------------------------------------------------------------------------
#'Exit if there were no records returned.
#'------------------------------------------------------------------------------
If($Null -ne $response -And $response.num_records -eq 0){
Write-Host "There are no entries matching your query"
Exit 0
}
#'------------------------------------------------------------------------------
#'Display the Certificates.
#'------------------------------------------------------------------------------
If($Null -ne $response -And $response.num_records -ge 1){
Write-Host "Enumerated Job ""$JobID"" on cluster ""$Cluster"" using URL`: ""$uri"""
}Else{
Write-Warning -Message "Failed Enumerating Job ""$JobID"" on cluster ""$Cluster"" using URL`: ""$uri"""
Exit -1
}
$response.records
#'------------------------------------------------------------------------------
Hope that helps
/Matt
Hi Michael,
Looking at the REST API endpoint "/cluster/jobs" there is no field for "id" or "name" and that would explain why the "Get-NcJob" CmdLet doesn't return a value for these fields. The PSTK will query the ONTAP version and if you are running >= 9.6 the CmdLet's will default to invoking REST API's. Unfortunately the parameter mapping between ZAPI -> REST doesn't always match of is missing functionality. Your options here are to either using the private REST CLI (as provided in the example) or add the "-ZapiCall" to the "Connect-NcController" CmdLet in your script which will force the PSTK to explicitly revert to using ZAPI instead of REST and then the Job ID and Name will be displayed.
Hope this helps
/Matt
Hi Matt,
-ZapiCall was the solution.
THX
Michael