Software Development Kit (SDK) and API Discussions
Software Development Kit (SDK) and API Discussions
Current open case: https://smartsolve.netapp.com/case?case_id=2006143948
Normally we refer the customer to the Community forums when it involves Powershell and SDK. Bbut since the case has been open for 2 weeks without progress, I decided to work with the customer to find a solution.
Summary:
Is something wrong with the commands I am sending, considering the differences from test to production, since these same commands work in test.
The API/Powershell is a new tool for us and we might be doing something as simple as leaving off a switch or maybe there are syntax differences we would need because of differences in our Test and Prod environments. Test and prod differences as I see it are the following.
In test, the files are directly on the controller, pjaxfas0102 /vol/pi_tm_test/piroot/…..
I make my connection to pjaxfas0102 and I can see anything in the directories and files that are on the controller.
In Prod, the files are on a vfiler (jaxfas5113), attached to the controller (pjaxfas0101) /vol/PIShare1/piroot7/…..
I make my connection to pjaxfas0101 and I can see only the level below /vol like PIShare1.
PS C:\Users\s701717> Get-Nafile /vol/pi_tm_test_5113/piroot
Name Type Size Created Modified Owner Group Perm Empty
---- ---- ---- ------- -------- ----- ----- ---- -----
/vol/pi_tm_test_5113/piroot directory 4 KB 10/14/2015 10/14/2015 0 0 777
PS C:\Users\s701717> Get-Nafile /vol/pi_tm_test_5113/piroot/powerimage
Name Type Size Created Modified Owner Group Perm Empty
---- ---- ---- ------- -------- ----- ----- ---- -----
/vol/pi_tm_test_5113/piroot/powerimage directory 4 KB 10/14/2015 10/28/2015 0 0 777
PS C:\Users\s701717> get-nafile /vol/PIShare1/piroot7
get-nafile : Unable to stat /vol/PIShare1/piroot7: No such file or directory
At line:1 char:1
+ get-nafile /vol/PIShare1/piroot7
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (pjaxfas0101.dsglobal.org:NaController) [Get-NaFile], EONTAPI_ENOENT
+ FullyQualifiedErrorId : ApiException,DataONTAP.PowerShell.SDK.Cmdlets.File.GetNaFile
PS C:\Users\s701717> get-nafile /vol/PIShare1
Name Type Size Created Modified Owner Group Perm Empty
---- ---- ---- ------- -------- ----- ----- ---- -----
/vol/PIShare1 directory 4 KB 5/13/2010 5/13/2010 0 0 777
PS C:\Users\s701717> get-nafile /vol/PIShare1/piroot7
get-nafile : Unable to stat /vol/PIShare1/piroot7: No such file or directory
At line:1 char:1
+ get-nafile /vol/PIShare1/piroot7
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (pjaxfas0101.dsglobal.org:NaController) [Get-NaFile], EONTAPI_ENOENT
+ FullyQualifiedErrorId : ApiException,DataONTAP.PowerShell.SDK.Cmdlets.File.GetNaFile
Quesitons:
1. if WORM is enabled on the file, then will this not work. Will a read-nafile work instead? (i will have the customer try this)
thank you
Hi,
Could you please post the rest of your code\commands? When you connect to your production controller that is hosting the files within the vfiler context did you specify the -Vfiler parameter to the "Connect-NaController" CmdLet? If not then the global nacontroller object will be set to the context of the physical controller (not to the vfiler) and the "Get-NaFile" CmdLet does not accept a -Vfiler parameter so when connecting to your controller in production you would need to set the -Vfiler parameter on the "Connect-NaController" CmdLet. The Syntax is:
Syntax: Connect-NaController [-Name] <String> [-Port <UInt16>] [-Credential <PSCredential>] [-HTTPS] [-HTTP] [-RPC] [-Transient] [-Vfiler <String>] [-Tim eout <Int32>] [<CommonParameters>] Get-NaFile [-Path] <String> [-Controller <NaController>] [<CommonParameters>]
Can you please try the following code:
[String]$controller = "pjaxfas0101"
[String]$vFiler = "jaxfas5113"
[String]$mountPoint = "/vol/PIShare1/piroot7"
$credentials = $host.ui.PromptForCredential("Connect to vfiler ""$vFiler"" on controller ""$controller""", "Please enter the user name and password", "", "")
#'------------------------------------------------------------------------------
#'Connect to the vfiler on the controller.
#'------------------------------------------------------------------------------
Import-Module DataONTAP
Try{
Connect-NaController -Name $controller -HTTPS -Vfiler $vFiler -Credential $credentials -ErrorAction Stop | Out-Null
Write-Host "Connected to vfiler ""$vFiler"" on controller ""$controller"""
}Catch{
Write-Warning -Message $("Failed Connecting to vfiler ""$vfiler"" on controller ""$controller"". Error " + $_.Exception.Message)
Exit -1
}
#'------------------------------------------------------------------------------
#'List the file and directory information in the mount point.
#'------------------------------------------------------------------------------
Try{
Get-NaFile -Path $mountPoint -ErrorAction Stop
}Catch{
Write-Warning -Message $("Failed listing files in ""$mountPoint"" on vfiler ""$vfiler"" controller ""$controller"". Error " + $_.Exception.Message)
Exit -1
}
#'------------------------------------------------------------------------------
Please post any error messages and let me know if you have any questions. Hope this helps
/matt
I added the -vFiler parameter, and also added the -https parameter
I got the following return from the script
WARNING: Failed Connecting to vfiler "jaxfas5113.corp.citistreet.org" on controller "pjaxfas0101.dsglobal.org". Error Unknown vfiler name in API request.
When I just run the connect string by itself, i get the following error
Connect-NaController : Unknown vfiler name in API request
At line:3 char:1
+ Connect-NaController -Name pjaxfas0101.dsglobal.org -Vfiler jaxfas5113.corp.citi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (pjaxfas0101.dsglobal.org:NaController) [Connect-NaController], EVFILER
NOTFOUND
+ FullyQualifiedErrorId : HttpConnectionFailed,DataONTAP.PowerShell.SDK.ConnectNaController
I was able to get past the Vfiler not found by removing the FQN from the script, I am still however getting the File Not Found Error.
Connected to vfiler "jaxfas5113" on controller "pjaxfas0101.dsglobal.org"
WARNING: Failed listing files in mount point "/vol/PIShare1/piroot7" on vfiler "jaxfas5113" controller "pjaxfas0101.dsglobal.org". Err
or Unable to stat /vol/PIShare1/piroot7: No such file or directory
Hi,
Try using the "Read-NaDirectory" CmdLet to list the files and directories within the volume. You then need to check the objects type to determine if it is a file or a directory and if it is a file you can then use the "Get-NaFile" CmdLet to list the file. EG:
[String]$controllerName = "testns01.testlab.local" [String]$vfilerName = "testnv01" [String]$volumeName = "volume_01" $credentials = Get-Credential #'------------------------------------------------------------------------------ #'Connect to the vfiler on the controller. #'------------------------------------------------------------------------------ Try{ Connect-NaController -Name $controllerName -Vfiler $vfilerName -HTTPS -Credential $credentials -ErrorAction Stop | Out-Null Write-Host "Connected to vfiler ""$vfilerName"" on controller ""$controllerName""" }Catch{ Write-Warning -Message $("Failed connecting to vfiler ""$vFilerName"" on controller ""$controllerName"". Error " + $_.Exception.Message) Exit -1 } #'------------------------------------------------------------------------------ #'List the files and directories in the volume. #'------------------------------------------------------------------------------ Try{ $results = read-nadirectory "/vol/$volumeName" Write-Host "Enumerated files and directories in ""/vol/$volumeName""" }Catch{ Write-Warning -Message $("Failed listing files and directories in ""/vol/$volumeName"". Error " + $_.Exception.Message) Exit -1 } #'------------------------------------------------------------------------------ #'list any files in the volume. #'------------------------------------------------------------------------------ ForEach($result In $results){ If($result.Type -eq "file"){ [String]$filePath = $("/vol/$volumeName/" + $result.Name) Try{ $file = Get-NaFile "$filePath" -ErrorAction Stop $file | Format-List }Catch{ Write-Warning -Message $("Failed listing file ""$filePath"". Error " + $_.Exception.Message) } } } #'------------------------------------------------------------------------------
Example output:
cmdlet Get-Credential at command pipeline position 1 Supply values for the following parameters: Connected to vfiler "testnv01" on controller "testns01.testlab.local" Enumerated files and directories in "/vol/volume_01" Name : /vol/volume_01/readme.txt FileType : file FileSize : 15 CreationTimestampDT : 9/03/2016 11:28:14 AM ChangedTimestampDT : 9/03/2016 11:28:29 AM ModifiedTimestampDT : 9/03/2016 11:28:29 AM AccessedTimestampDT : 9/03/2016 11:28:29 AM AclType : nt_acl OwnerId : 0 GroupId : 0 Perm : 777 HardLinksCount : 1 InodeNumber : 32361 IsEmpty :
Hope this helps. Please let me know if you have any questions.
/matt
Thank you for reviewing this issue.
I tried the Read-NaDirectory, using your modified script and I still am not finding the files and folders under the volume level.
I then reran the Read-NaDirectory lines specifically. And noticed something in result from the volume level read
read-nadirectory /vol/PIShare1
read-nadirectory /vol/PIShare1
Name Type Size Created Modified Owner Group Perm Empty
---- ---- ---- ------- -------- ----- ----- ---- -----
. directory 4 KB 5/13/2010 5/13/2010 0 0 777 False
.. directory 12 KB 5/13/2010 3/11/2016 0 0 777 False
.bplusvtoc_internal directory 4 KB 6/8/2014 6/8/2014 0 0 0 True
.vtoc_internal directory 4 KB 6/8/2014 6/8/2014 0 0 0 True
PIShare1 directory 20 KB 5/13/2010 3/3/2016 0 0 777 False
It seems as if the command doesn't see any of the contents of the PIShare1 folder, there are at least 6 different directories directly in the PIShare1 Volume as you can see from the command belows result.
read-nadirectory /vol/PIShare1/piroot7
read-nadirectory : Unable to open directory /vol/PIShare1/piroot7: No such file or directory
At line:1 char:1
+ read-nadirectory /vol/PIShare1/piroot7
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (pjaxfas0101.dsglobal.org:NaController) [Read-NaDirectory], EONTAPI_ENOENT
+ FullyQualifiedErrorId : ApiException,DataONTAP.PowerShell.SDK.Cmdlets.File.ReadNaDirectory
To give some further background:
Ultimately what I am trying to accomplish using the PS scripts and API code is to reset file retention dates further into the future since files that were previously snaplocked and set to a WORM state now are exceeding the initial default retention period and the files need to be retained longer in an unmodifiable state. To accomplish this I coded a Vb.net application using a combination of standard .Net file system calls to recursively scan all directories and files to determine if the Date Modified file attribute was set into the future. Using the .net file system calls I build a list of files which need to have there retention date reset. I then run the list through a Netapp API call to 'file-set-snaplock-retention-time' with the file path and new retention date. This code worked fine in our test environment. Once I moved to our production environment I was getting file not found on all path/file combinations that I was passing to the file-set-snaplock-retention-time API Call. In order to try to determine the issue I started investigating other commands that I could test with that didn't do anything destructive sense the data in production is live data. My theory being that If I can't find the file with a simple read like Get-NAFile, then I surely wouldn't be able to run something like a set-NasnaplockRetentionTime or the VB.Net call of file-set-snaplock-retention-time. Hope this helps
Thanks again in advance
Mike
Hi,
Just to close out this thread the solution was to ensure the CIFS Share's mount point is valid. EG
$controllerName = "pjaxfas0101.dsglobal.org" $vfilerName = "jaxfas5113" $shareName = "PIShare1" $credentials = Get-Credential Import-Module DataONTAP Connect-NaController -Name $controllerName -Vfiler $vfilerName -HTTPS -Credential $credentials $share = Get-NaCifsShare -Share $shareName Write-Host $("listing directories and files within CIFS share ""$shareName"" in mount point """ + $share.MountPoint + """ on vFiler ""$vfilerName""") $share | Format-List Read-NaDirectory -Path $share.MountPoint
/matt