2012-12-03 06:24 AM
I am trying to create a script that will create numerous qtrees that have spaces in the qtree name. I am importing the qtree names from a CSV file and building an array with the full path of the qtree. Here is a overview of how I am building the qtree path:
$Qtree = [char]34 + "/vol/" + $Volume + "/" + $qtreename + [char]34
Execute the qtree creations:
If I write the command to the screen with the following command I can copy and paste the output and it runs just fine:
write-host "New-NaQtree" $Qtree
When I attempt to loop through the array and execute the qtree creations it fails because it "can't determine volume/qtree names" The quotes in the path seem to be messing with the ability to find the qtree path. I attempted to put the entire command into the array and use the invoke expression to run the command. Here is a sample of what I tried:
$Qtree = "New-NaQtree " + [char]34 + "/vol/" + $Volume + "/" + $qtreename + [char]34
Execute the qtree creations:
($Qtree) | Invoke-Expression
This seems to work but it drops the quotes so all of the qtree names that contain spaces are created incorrectly. Can someone please help me figure out how to get these qtrees created when using quotes??
Solved! SEE THE SOLUTION
2012-12-03 07:51 AM
My guess is this is not possible through the API ( and thus the new-naqtree cmdlet). I don't see a way to get this to work.
However, there is a workaround. Try:
$qtree = "/vol/$volumename`/$qtreename"
Invoke-NaSsh "qtree create `"$qtree`""
One other note, is the storage management guide recommends against using certain characters (namely, spaces and commas) in QTree names for various reasons, including that it breaks SnapMirror:
Qtree name restrictions
Using some special characters in qtree names, such as commas and spaces, can cause problems with
other Data ONTAP capabilities, and should be avoided.
The following characters should be avoided in qtree names:
Spaces in qtree names can prevent SnapMirror updates from working correctly.
Commas in qtree names can prevent quotas from working correctly for that qtree, unless the name
is enclosed in double quotation marks.
2012-12-03 08:33 AM
Thank you for the reply. The issue is that we are moving from a legacy Celerra to the Netapp and all of the tree quotas on the Celerra were created with the spaces in the names. In order to not break everything we had to leave the spaces in place.
2012-12-03 08:59 AM
Looks like a problem with the way the toolkit handles QTree paths with spaces. Until that's resolved, you can invoke the API directly like this:
Invoke-NaSystemApi "<qtree-create> <volume>$Volume</volume> <qtree>$qtreename</qtree> </qtree-create>"
Not real pretty, but it should do what you want...
2012-12-03 09:41 AM
Thanks so much that works like a champ!! Now I am also having an issue with setting quotas on the qtree when there are space is the name.
I believe I can use the same invoke-NaSystemApi "<quota-add-entry> "?? But I am unsure on the rest of the syntax. My command would have been Add-naquota tree "/vol/office01/A B" -Threshold 100g. This of course is having the same issue as the earlier qtree create command.