This example uses MVEL array types to avoid doing a splitByDelimiter inside the iteration, which is pretty costly with the regex compile and match going on each time, and multiple times for nested splitByDelimiter calls. Rather than return a single value, I created a new function, split, which returns an array. You can then index the array in each iteration.
The user enters the controller, vFiler, optional volume (one is created if an existing one isn't chosen), the number of qtrees to create, and a CSV list of qtree sizes. If the number of sizes provided is less than the number of qtrees requested, the last size value is used for all remaining qtrees. Thus, to create 5 qtrees if the same size, you only need enter one size value.
For existing volumes, the find chart verifies that the containing aggregate contains enough space to accommodate the qtrees without exceeding a maximum utilization percentage (a unique requirement of this particular customer). If no volume is specified, the most utilized aggregate that can accommodate the request, again without exceeding the maximum utilization, is chosen. Volume and qtree names follow a simple naming standard. Finally, this customer wanted to specify the NFS export security for the qtrees as a copy/pasted string containing all the options, which is why the export creation and security setting commands are separated.
One problem I found with the existing Create QTree command is that it attempts to initialize quotas each time the QTree is created. First, there is a potential problem with using the quota resize command, rather than reinitializing the quotas, because resize won't pick up the quotas correctly of no existing quota already exists (which would happen if the volume is newly created). Second, once the quota resize (or reinitialization) starts, it runs for some time, causing subsequent Create QTree attempts to fail. So, I moved the quota initialization code out of Create QTree (my Create Qtree 2, clever naming, huh?), and created a new command to reinitialize the quotas (turn them off then on again), which is called at the very end of the flow. This also speeds up qtree creation considerably, since there are several fewer PS toolkit calls and no wait loop.
I'm still testing this, so if you see anything fishy, let me know and I'll either explain it or fix it