Hi Scott,
I've created a CLI parser a few days ago.
I needed to rename a qtree and recreate a corresponding cifs share & NFS exports.
I bumped into this burt and wrote this CLI parser. It still needs some testing, but it comes pretty close.
# container for the ACL result
$global:aclList = @()
##################################################################
# THIS Function IS PURELY FOR A BURT IN DATAONTAP 8.0 and 8.1
# It is fixed in 8.2
# The API calls fail for the cmdlet Get-NaCifsShareAcl within vfiler context
# This way we detect the version and use a CLI parser instead
# Creation : mirko@netap.com
##################################################################
# This function parses the output of CLI "vfiler run cifs shares"
function parseCifsSharesOutput($output){
# get the list of the shares (this command is not affected by the burt)
$shares = Get-NaCifsShare
$acls = @()
$tempshare = ""
$shareObj = New-Object DataONTAP.Types.Cifs.AccessRightsInfo
# parse the lines
$lines = $output -split "`n"
foreach($line in $lines){
# if were are past the "----" lines, we can can start parsing
if($infostarted){
# it the line is start with a "tab", it's an acl
if($line.StartsWith("`t")){
# ACL found
$line = $line.Trim()
$acl = $line.Split("/")
if($acl.Count -eq 2){
$newacl = New-Object DataONTAP.Types.Cifs.AccessRightsInfo
$newacl.UserName = $acl[0].Trim()
$newacl.AccessRights = $acl[1].Trim()
$acls[$acls.Length-1].UserAclInfo += $newacl
}
# if the line does not start with "tab", it is a new share entry
}else{
# new share found
$line = $line.Trim()
# ignore blank lines (normally at the end)
if($line -ne ""){
$share = $line -split "\s+/"
$tempshare = $shares | where{$_.ShareName -eq $share[0].Trim()}
if($tempshare){
$shareObj = New-Object DataONTAP.Types.Cifs.CifsShareAclInfo
$shareObj.ShareName = $tempshare.ShareName
$acls += $shareObj
}
}
}
}
# we ignore all lines until we come accross "----"
if($line.StartsWith("----")){
$infostarted = $true
}
}
# we must use a global variabel to get this out of the function scope
$global:aclList = $acls
}
# this is a replacement for get-nacifsshareacl
function getNaCifsShareAcl($vfiler){
# Get the version
$version = Get-NaSystemVersion
if ($version.Contains("8.0") -or $version.Contains("8.1"))
{
$useCli = $true
}
else
{
$useCli = $false
}
if($useCli){
# because of the burt, we get the ACL info through CLI instead
$command = "vfiler run $vfiler cifs shares"
Invoke-NaSsh -Command $command -WarningVariable warningMsg -OutVariable outMsg -ErrorVariable errorMsg 2>&1 | Out-Null
# if the command was errorless
if(-not $warningMsg -and -not $errorMsg){
parseCifsSharesOutput $outMsg
}else{
Throw "Warning : $warningMsg`nError : $errorMsg"
}
}else{
$global:aclList = Get-NaCifsShareAcl
}
$global:aclList | ft
}