2012-11-29 07:17 AM
I am writing a "decommission" workflow i.e. to remove volumes.
One of the requirements is to ensure that the volume only contains a single qtree and that there is no non-qtree data.
I've tried a couple of ways to do this but with no success for various reasons...
Firstly I tried using PowerShell by calling the Invoke-NaSSh cmdlet to perform an "ls" of the volume. I tried passing "priv set advanced;ls /vol/vol0" as parameters. This works if it is run on the command line as a standard powershell script but it fails when ran within WFA. For some reason the ls command produces no output - no error messages logged just no output.
I then moved on to try Perl using the "file-list-directory-iter-*" ZAPI calls. I successfully scripted this from the command line but again struggled to get this to execute from within WFA. This time I unserstand the reason though. ZAPI requires a user name and password to be passed to it. It uses "getCredentials()" within WFAUtil.pm to pass the credentials that are stored in WFA when establishing the connection to the filer. The problem is that we are not using the WFA credential cache, we are running the WFA service using a Windows Domain account which is in the administrators group on the filers. There are over 800 filers in the estate which is the reason why we are running in this mode. If I populate the WFA credentials cache the workflow succeeds, but this isnt really a scalable option....
If anyone has any suggestions as to how I meet this requirement, or if they know why the PowerShell cmdlet might be failing I would really appreciate it:-)
Solved! SEE THE SOLUTION
2012-11-29 09:01 AM
1. Doesn't On Tap have ls built into it now? You have to run it from priv mode.
priv set advanced
2. Have you tried the secret java script built into the filer?
You can use ls after launching that script.
Not sure how this would return values to WFA, but at least it might be a start.
2012-11-29 09:13 AM
Thanks for the response.
You are correct, ls has been built in for several years.
The problem is I need to call it from WFA so PowerShell is the best bet. But for some reason the Invoke-NaSsh powershell cmdlet called from WFA (whilst in priv set advanced mode) returns nothing. All other non-priveleged commands run fine,
I wasnt aware of the hidden java shell. I tried calling this from PoSH as below but no luck:
Invoke-NaSsh -Controller $dst_filer -Command "java netapp.cmds.jsh;ls /vol/vol0" -Credential $cred
It just returns jsh> waits a few seconds and then ls returns nothing.
Any other ideas welcome:-)
2012-11-29 09:14 PM
I tried something like this and that did give the output for me:
Connect-WfaController -Array $Array
Get-WFALogger -Info -message $("Listing vol0 volume contents")
$inputRequestXML = "<system-cli><priv>advanced</priv><args><arg>ls</a
$OutputXML = Invoke-NaSystemApi $inputRequestXML
Get-WfaLogger -Info -message "vol0 ls output"
Get-WfaLogger -Info -message $OutputXML.results."cli-output"
Listing vol0 volume contents
vol0 ls output:
When this experiment was done, the credentials were configured in WFA i.e I used the credential cache.
Did not try with your deployment mode of using Windows domain service. (I dont have that setup right now)
Hopefully, it works for you too.
By the way, 2 queries:
- So, if you do find non-qtree data, are you erroring out and stopping the decommissioning workflow ?
Was that the requirement?
- Are you cross-checking the contents of ls to check whether there is a single qtree with that name using
2012-11-29 09:49 PM
Adding on top of Shailja's comment. ONTAP also provides power shell command 'Read-NaDirectory' which is equivalent to 'file-list-directory-iter-*'.
List the contents of the root directory in volume 'vol2'.
Name Modified Owner Group Perm Empty Type Size Created
---- -------- ----- ----- ---- ----- ---- ---- -------
8/27/2010 0 0 1077 False directory 4 KB 11/6/2008
8/27/2010 0 0 2077 False directory 16 KB 11/6/2008
lun1 file 20 GB 3/19/2009
8/22/2010 0 0 1077
lun2 file 20 GB 2/10/2010
8/22/2010 0 0 1077
quorum file 1 GB 2/12/2009
2012-11-30 03:02 AM
Hello shailaja and girirp,
Thanks you both for your responses.
Both methods work and I decided to go with the Read-NaDirectory simply becuase it is easier to read.