Monday Dec 06, 2010

Scripting with the Sun ZFS Storage 7000 Appliance

The Sun ZFS Storage 7000 appliance has a user friendly and easy to understand graphical web based interface we call the "BUI" or "Browser User Interface".

This interface is very useful for many tasks, but in some cases a script (or workflow) may be more appropriate, such as:
    • Repetitive tasks
    • Tasks which work on (or obtain information about) a large number of shares or users
    • Tasks which are triggered by an alert threshold (workflows)
    • Tasks where you want a only very basic input, but a consistent output (workflows)
The appliance scripting language is based on ECMAscript 3 (close to javascript). I'm not going to cover ECMAscript 3 in great depth (I'm far from an expert here), but I would like to show you some neat things you can do with the appliance, to get you started based on what I have found from my own playing around.

I'm making the assumption you have some sort of programming background, and understand variables, arrays, functions to some extent - but of course if something is not clear, please let me know so I can fix it up or clarify it.

NOTE: You should *ALWAYS* test your scripts on test/development hosts, with a similar amount of users and shares configured, before running in production. With scripting comes great power, and as such great responsibility! Without proper testing in an environment that accurately represents your production environment, you may run into issues, which no doubt should be avoided in a production environment.

If you do not have access to physical test hosts, you can use the Sun ZFS Storage 7000 Simulator, found at:
Now, on with the show!

Variable Declarations and Arrays
Variables
ECMAScript is a dynamically and weakly typed language. If you don't know what that means, google is your friend - but at a high level it means we declare variables with no specific type, we can "just use" variables that have previously not been declared, and we can convert between types easily.

For example, I can create and use a variable straight away in the middle of my code, without any previous declaration:

projects=list();

Which makes projects an array of values that are returned from the list(); method (which is usable in most contexts). With this type of variable, I can do things like get a property of this array, such as:

projects.length

which tells us how many objects are in the array (covered later). I could then say:

projects=3;

and now projects is just a simple number - we have changed the type on the fly.

Should we declare variables like this and change their types randomly? In my opinion, the answer is no - I feel it is a better practice to declare variables you are going to use, before you use them - and keep them as the same type to avoid both errors and confusion. You can declare variables up front as follows:

var myVariable=0;

To demonstrate the ability to just randomly assign and change the type of variables, you can create a simple script at the cli as follows (bold for input):

fishy10:> script
("." to run)> run("cd /");
("." to run)> run ("shares");
("." to run)> var projects;
("." to run)> projects=list();
("." to run)> printf("Number of projects is: %d\n",projects.length);
("." to run)> projects=152;
("." to run)> printf("Value of the projects variable as an integer is now: %d\n",projects);
("." to run)> .
Number of projects is: 7
Value of the projects variable as an integer is now: 152

You can also confirm this behaviour by checking the typeof variable we are dealing with:

fishy10:> script
("." to run)> run("cd /");
("." to run)> run ("shares");
("." to run)> var projects;
("." to run)> projects=list();
("." to run)> printf("var projects is of type %s\n",typeof(projects));
("." to run)> projects=152;
("." to run)> printf("var projects is of type %s\n",typeof(projects));
("." to run)> .
var projects is of type object
var projects is of type number


Arrays
So you likely noticed that we have already touched on arrays, as the list() method (in the shares context) stored an array into the 'projects' variable.

But what if you want to declare your own array? Easy! This is very similar to Java and other languages, we just instantiate a brand new "Array" object using the keyword new:

var myArray = new Array();

will create an array called "myArray".

A quick example:

fishy10:> script
("." to run)> testArray = new Array();
("." to run)> testArray[0]="This";
("." to run)> testArray[1]="is";
("." to run)> testArray[2]="just";
("." to run)> testArray[3]="a";
("." to run)> testArray[4]="test";
("." to run)> for (i=0; i < testArray.length; i++)
("." to run)> {
("." to run)>    printf("Array element %d is %s\n",i,testArray[i]);
("." to run)> }
("." to run)> .
Array element 0 is This
Array element 1 is is
Array element 2 is just
Array element 3 is a
Array element 4 is test


Working With Loops
For Loop
For loops are very similar to those you will see in C, java and several other languages. One of the key differences here is, as you were made aware earlier, we can be a bit more sloppy with our variable declarations.

The general way you would likely use a for loop is as follows:

for (variable; test-case; modifier for variable)
{

}

For example, you may wish to declare a variable i as 0; and a MAX_ITERATIONS variable to determine how many times this loop should repeat:

var i=0;
var MAX_ITERATIONS=10;

And then, use this variable to be tested against some case existing (has i reached MAX_ITERATIONS? - if not, increment i using i++);

for (i=0; i < MAX_ITERATIONS; i++)
{
 // some work to do
}

So lets run something like this on the appliance:

fishy10:> script
("." to run)> var i=0;
("." to run)> var MAX_ITERATIONS=10;
("." to run)> for (i=0; i < MAX_ITERATIONS; i++)
("." to run)> {
("." to run)>    printf("The number is %d\n",i);
("." to run)> }
("." to run)> .
The number is 0
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9


While Loop
While loops again are very similar to other languages, we loop "while" a condition is met. 

For example:

fishy10:> script
("." to run)> var isTen=false;
("." to run)> var counter=0;
("." to run)> while(isTen==false)
("." to run)> {
("." to run)>    if (counter==10) 
("." to run)>    
("." to run)>            isTen=true;   
("." to run)>    
("." to run)>    printf("Counter is %d\n",counter);
("." to run)>    counter++;    
("." to run)> }
("." to run)> printf("Loop has ended and Counter is %d\n",counter);
("." to run)> .
Counter is 0
Counter is 1
Counter is 2
Counter is 3
Counter is 4
Counter is 5
Counter is 6
Counter is 7
Counter is 8
Counter is 9
Counter is 10
Loop has ended and Counter is 11

So what do we notice here? Something has actually gone wrong - counter will technically be 11 once the loop completes... Why is this?

Well, if we have a loop like this, where the 'while' condition that will end the loop may be set based on some other condition(s) existing (such as the counter has reached 10) - we must ensure that we  terminate this iteration of the loop when the condition is met - otherwise the rest of the code will be followed which may not be desirable. 

In other words, like in other languages, we will only ever check the loop condition once we are ready to perform the next iteration, so any other code after we set "isTen" to be true, will still be executed as we can see it was above.

We can avoid this by adding a break into our loop once we know we have set the condition - this will stop the rest of the logic being processed in this iteration (and as such, counter will not be incremented). So lets try that again:

fishy10:> script
("." to run)> var isTen=false;
("." to run)> var counter=0;
("." to run)> while(isTen==false)
("." to run)> {
("." to run)>    if (counter==10) 
("." to run)>    { 
("." to run)>            isTen=true;   
("." to run)>            break;
("." to run)>    } 
("." to run)>    printf("Counter is %d\n",counter);
("." to run)>    counter++;    
("." to run)> }
("." to run)> printf("Loop has ended and Counter is %d\n", counter);
("." to run)> .
Counter is 0
Counter is 1
Counter is 2
Counter is 3
Counter is 4
Counter is 5
Counter is 6
Counter is 7
Counter is 8
Counter is 9
Loop has ended and Counter is 10

Much better!

Methods to Obtain and Manipulate Data
Get Method
The get method allows you to get simple properties from an object, for example a quota from a user. The syntax is fairly simple:

var myVariable=get('property');

You can discover the properties in different contexts, within the CLI. Just go to the context you want (for example, shares select default - for selecting the default project), and then run  ls or list, and you will get (amongst other things):

Properties:
                    aclinherit = restricted
                       aclmode = groupmask
                         atime = true
                      checksum = fletcher4
                   compression = off
                         dedup = false
                 compressratio = 100
                        copies = 1
.
.
.


An example of where you may wish to use this, is when you are getting a bunch of information about a user (such as quota information when in a shares context):

var users=list();
for(k=0; k < users.length; k++)
{
     user=users[k];
     run('select ' + user);
     var username=get('name');
     var usage=get('usage');
     var quota=get('quota');
.
.
.

Which you can then use to your advantage - to print or manipulate infomation (you could change a user's information with a set method, based on the information returned from the get method). The set method is explained next.

Set Method
The set method can be used in a simple manner, similar to get. The syntax for set is:

set('property','value'); // where value is a string, if it was a number, you don't need quotes

For example, we could set the quota on a share as follows (first observing the initial value):

fishy10:shares default/test-geoff> script
("." to run)> var currentQuota=get('quota');
("." to run)> printf("Current Quota is: %s\n",currentQuota);
("." to run)> set('quota','30G');
("." to run)> run('commit');
("." to run)> currentQuota=get('quota');
("." to run)> printf("Current Quota is: %s\n",currentQuota);
("." to run)> .
Current Quota is: 0
Current Quota is: 32212254720

This shows us using both the get and set methods as can be used in scripts, of course when only setting an individual share, the above is overkill - it would be much easier to set it manually at the cli using 'set quota=3G' and then 'commit'.

List Method
The list method can be very powerful, especially in more complex scripts which iterate over large amounts of data and manipulate it if so desired. The general way you will use list is as follows:

var myVar=list();

Which will make "myVar" an array, containing all the objects in the relevant context (this could be a list of users, shares, projects, etc). You can then gather or manipulate data very easily.

We could list all the shares and mountpoints in a given project for example:

fishy10:shares another-project> script
("." to run)> var shares=list();
("." to run)> for (i=0; i < shares.length; i++)
("." to run)> {
("." to run)>    run('select ' + shares[i]);
("." to run)>    var mountpoint=get('mountpoint');
("." to run)>    printf("Share %s discovered, has mountpoint %s\n",shares[i],mountpoint);
("." to run)>    run('done');
("." to run)> }
("." to run)> .
Share and-another discovered, has mountpoint /export/another-project/and-another
Share another-share discovered, has mountpoint /export/another-project/another-share
Share bob discovered, has mountpoint /export/another-project
Share more-shares-for-all discovered, has mountpoint /export/another-project/more-shares-for-all
Share yep discovered, has mountpoint /export/another-project/yep


Writing More Complex and Re-Usable Code
Functions
The best way to be able to write more complex code is to use functions to split up repeatable or reusable sections of your code. This also makes your more complex code easier to read and understand for other programmers.

We write functions as follows:

function functionName(variable1,variable2,...,variableN)
{

}

For example, we could have a function that takes a project name as input, and lists shares for that project (assuming we're already in the 'project' context - context is important!):

function getShares(proj)
{
        run('select ' + proj);
        shares=list();
        printf("Project: %s\n", proj);

        for(j=0; j < shares.length; j++)
        {
                printf("Discovered share: %s\n",shares[i]);
        }
        run('done'); // exit selected project
}

Commenting your Code
Like any other language, a large part of making it readable and understandable is to comment it. You can use the same comment style as in C and Java amongst other languages.

In other words, sngle line comments use:
//
at the beginning of the comment.

Multi line comments use:
/*
at the beginning, and:
*/ 
at the end.

For example, here we will use both:

fishy10:> script
("." to run)> // This is a test comment
("." to run)> printf("doing some work...\n");
("." to run)> /* This is a multi-line
("." to run)> comment which I will span across
("." to run)> three lines in total */
("." to run)> printf("doing some more work...\n");
("." to run)> .
doing some work...
doing some more work...

Your comments do not have to be on their own, they can begin (particularly with single line comments this is handy) at the end of a statement, for example

var projects=list(); // The variable projects is an array containing all projects on the system.

Try and Catch Statements
You may be used to using try and catch statements in other languages, and they can (and should) be utilised in your code to catch expected or unexpected error conditions, that you do NOT wish to stop your code from executing (if you do not catch these errors, your script will exit!):

try
{
  // do some work
}
catch(err) // Catch any error that could occur
{
 // do something here under the error condition
}

For example, you may wish to only execute some code if a context can be reached. If you can't perform certain actions under certain circumstances, that may be perfectly acceptable.

For example if you want to test a condition that only makes sense when looking at a SMB/NFS share, but does not make sense when you hit an iscsi or FC LUN, you don't want to stop all processing of other shares you may not have covered yet.

For example we may wish to obtain quota information on all shares for all users on a share (but this makes no sense for a LUN):

function getShareQuota(shar) // Get quota for each user of this share
{
        run('select ' + shar);
        printf("  SHARE: %s\n", shar);
        try
        {
                run('users');
                printf("    %20s        %11s    %11s   %3s\n","Username","Usage(G)","Quota(G)","Quota(%)");
                printf("    %20s        %11s    %11s    %4s\n","--------","--------","--------","----");
                users=list();
                for(k=0; k < users.length; k++)
                {
                        user=users[k];
                        getUserQuota(user);
                }
                run('done'); // exit user context
        }
        catch(err)
        {
                printf("    SKIPPING %s - This is NOT a NFS or CIFs share, not looking for users\n", shar);
        }
        run('done'); // done with this share
}


Running Scripts Remotely over SSH
As you have likely noticed, writing and running scripts for all but the simplest jobs directly on the appliance is not going to be a lot of fun.

There's a couple of choices on what you can do here:
  1. Create scripts on a remote system and run them over ssh
  2. Create scripts, wrapping them in workflow code, so they are stored on the appliance and can be triggered under certain circumstances (like a threshold being reached)
We'll cover the first one here, and then cover workflows later on (as these are for the most part just scripts with some wrapper information around them).

Creating a SSH Public/Private SSH Key Pair
Log on to your handy Solaris box (You wouldn't be using any other OS, right? :P) and use ssh-keygen to create a pair of ssh keys. I'm storing this separate to my normal key:

[geoff@lightning ~] ssh-keygen -t rsa -b 1024
Generating public/private rsa key pair.
Enter file in which to save the key (/export/home/geoff/.ssh/id_rsa): /export/home/geoff/.ssh/nas_key_rsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /export/home/geoff/.ssh/nas_key_rsa.
Your public key has been saved in /export/home/geoff/.ssh/nas_key_rsa.pub.
The key fingerprint is:
7f:3d:53:f0:2a:5e:8b:2d:94:2a:55:77:66:5c:9b:14 geoff@lightning

Installing the Public Key on the Appliance
On your Solaris host, observe the public key:

[geoff@lightning ~] cat .ssh/nas_key_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAvYfK3RIaAYmMHBOvyhKM41NaSmcgUMC3ig
PN5gUKJQvSnYmjuWG6CBr1CkF5UcDji7v19jG3qAD5lAMFn+L0CxgRr8TNaAU+hA4/
tpAGkjm+dKYSyJgEdMIURweyyfUFXoerweR8AWW5xlovGKEWZTAfvJX9Zqvh8oMQ
5UJLUUc= geoff@lightning


Now, copy and paste everything after "ssh-rsa" and before "user@hostname" - in this case, geoff@lightning. That is, this bit:

AAAAB3NzaC1yc2EAAAABIwAAAIEAvYfK3RIaAYmMHBOvyhKM41NaSmcgUMC3ig
PN5gUKJQvSnYmjuWG6CBr1CkF5UcDji7v19jG3qAD5lAMFn+L0CxgRr8TNaAU+hA4/
tpAGkjm+dKYSyJgEdMIURweyyfUFXoerweR8AWW5xlovGKEWZTAfvJX9Zqvh8oMQ
5UJLUUc=

Logon to your appliance and get into the preferences -> keys area for this user (root):

[geoff@lightning ~] ssh root@fishy10.priv
Password: 
Last login: Mon Dec  6 17:13:28 2010 from 192.168.0.2
fishy10:> configuration users
fishy10:configuration users> select root
fishy10:configuration users root> preferences 
fishy10:configuration users root preferences> keys

OR do it all in one hit:

fishy10:> configuration users select root preferences keys

Now, we create a new public key that will be accepted for this user and set the type to RSA:

fishy10:configuration users root preferences keys> create
fishy10:configuration users root preferences key (uncommitted)> set type=RSA


Set the key itself using the string copied previously (between ssh-rsa and user@host), and set the key ensuring you put double quotes around it (eg. set key="<key>"):

fishy10:configuration users root preferences key (uncommitted)> set key="AAAAB3NzaC1yc2EAAAABIwAAAIEAvYfK3RIaAYmMHBOvyhKM41NaSmcg
UMC3igPN5gUKJQvSnYmjuWG6CBr1CkF5UcDji7v19jG3qAD5lAMFn+L0CxgRr8TN
aAU+hA4/tpAGkjm+dKYSyJgEdMIURweyyfUFXoerweR8AWW5xlovGKEWZTAfvJX
9Zqvh8oMQ5UJLUUc="

Now set the comment for this key (do not use spaces):

fishy10:configuration users root preferences key (uncommitted)> set comment="LightningRSAKey"
Commit the new key:

fishy10:configuration users root preferences key (uncommitted)> commit

Verify the key is there:

fishy10:configuration users root preferences keys> ls
Keys:

NAME     MODIFIED              TYPE   COMMENT                                  
key-000  2010-10-25 20:56:42   RSA    cycloneRSAKey                           
key-001  2010-12-6 17:44:53    RSA    LightningRSAKey                         


As you can see, we now have my new key, and a previous key I have created on this appliance.

Running your Script over SSH from a Remote System
Here I have created a basic test script, and saved it as test.ecma3:

[geoff@lightning ~] cat test.ecma3 
script
// This is a test script, By Geoff Ongley 2010.
printf("Testing script remotely over ssh\n");
.

Now, we can run this script remotely with our keyless login:

[geoff@lightning ~] ssh -i .ssh/nas_key_rsa root@fishy10 < test.ecma3
Pseudo-terminal will not be allocated because stdin is not a terminal.
Testing script remotely over ssh


Putting it Together - An Example Completed Quota Gathering Script
So now we have a lot of the basics to creating a script, let us do something useful, like, find out how much every user is using, on every share on the system (you will recognise some of the code from my previous examples):

script
/*************************************
* Quick and Dirty Quota Check script *
* Written By Geoff Ongley            *
* 25 October 2010                    *
*************************************/
function getUserQuota(usr)
{
        run('select ' + usr);
        var username=get('name');
        var usage=get('usage');
        var quota=get('quota');
        var usage_g=usage / 1073741824; // convert bytes to gigabytes
        var quota_g=quota / 1073741824; // as above
        var quota_percent=0
        if (quota > 0)
        {
                quota_percent=(usage / quota)*(100/1);
        }
        printf("    %20s        %8.2f           %8.2f
          %d%%\n",username,usage_g,quota_g,quota_percent);
        run('done'); // done with this selected user
}
function getShareQuota(shar)
{
        //printf("DEBUG: selecting share %s\n", shar);
        run('select ' + shar);
        printf("  SHARE: %s\n", shar);
        try
        {
                run('users');
                printf("    %20s        %11s    %11s
   %3s\n","Username","Usage(G)","Quota(G)","Quota(%)");
                printf("    %20s        %11s    %11s
   %4s\n","--------","--------","--------","--------");
                
                users=list();
                for(k=0; k < users.length; k++)
                {
                        user=users[k];
                        getUserQuota(user);
                }
                run('done'); // exit user context
        }
        catch(err)
        {
                printf("    SKIPPING %s - This is NOT a NFS or
CIFs share, not looking for users\n", shar);
        }
        run('done'); // done with this share
}
function getShares(proj)
{
        //printf("DEBUG: selecting project %s\n",proj);
        run('select ' + proj);
        shares=list();
        printf("Project: %s\n", proj);
        for(j=0; j < shares.length; j++)
        {
                share=shares[j];
                getShareQuota(share);
        }
        run('done'); // exit selected project
}
function getProjects()
{
        run('cd /');
        run('shares');
        projects=list();
        
        for (i=0; i < projects.length; i++)
        {
                var project=projects[i];
                getShares(project);
        }
        run('done'); // exit context for all projects
}
getProjects();
.

Which can be run as follows, and will print information like this:

[geoff@lightning ~/FISHWORKS_SCRIPTS] ssh -i ~/.ssh/nas_key_rsa root@fishy10 < get_quota_utilisation.ecma3
Pseudo-terminal will not be allocated because stdin is not a terminal.
Project: another-project
  SHARE: and-another
                Username           Usage(G)       Quota(G)    Quota(%)
                --------           --------       --------    --------
                  nobody            0.00            0.00        0%
                 geoffro            0.05            0.00        0%
                   Billy            0.10            0.00        0%
                    root            0.00            0.00        0%
            testing-user            0.05            0.00        0%
  SHARE: another-share
                Username           Usage(G)       Quota(G)    Quota(%)
                --------           --------       --------    --------
                    root            0.00            0.00        0%
                  nobody            0.00            0.00        0%
                 geoffro            0.05            0.49        9%
            testing-user            0.05            0.02        249%
                   Billy            0.10            0.29        33%
  SHARE: bob
                Username           Usage(G)       Quota(G)    Quota(%)
                --------           --------       --------    --------
                  nobody            0.00            0.00        0%
                    root            0.00            0.00        0%
  SHARE: more-shares-for-all
                Username           Usage(G)       Quota(G)    Quota(%)
                --------           --------       --------    --------
                   Billy            0.10            0.00        0%
            testing-user            0.05            0.00        0%
                  nobody            0.00            0.00        0%
                    root            0.00            0.00        0%
                 geoffro            0.05            0.00        0%
  SHARE: yep
                Username           Usage(G)       Quota(G)    Quota(%)
                --------           --------       --------    --------
                    root            0.00            0.00        0%
                  nobody            0.00            0.00        0%
                   Billy            0.10            0.01        999%
            testing-user            0.05            0.49        9%
                 geoffro            0.05            0.00        0%
Project: default
  SHARE: Test-LUN
    SKIPPING Test-LUN - This is NOT a NFS or CIFs share, not looking for users
  SHARE: test-geoff
                Username           Usage(G)       Quota(G)    Quota(%)
                --------           --------       --------    --------
                 geoffro            0.05            0.00        0%
                    root            3.18           10.00        31%
                    uucp            0.00            0.00        0%
                  nobody            0.59            0.49        119%
^CKilled by signal 2.

Creating a Workflow
Workflows are scripts that we store on the appliance, and can have the script execute either on request (even from the BUI), or on an event such as a threshold being met.

Workflow Basics
A workflow allows you to create a simple process that can be executed either via the BUI interface interactively, or by an alert being raised (for some threshold being reached, for example).

The basics parameters you will have to set for your "workflow object" (notice you're creating a variable, that embodies ECMAScript) are as follows (parameters is optional):

name: A name for this workflow
description: A Description for the workflow
parameters: A set of input parameters (useful when you need user input to execute the workflow)
execute: The code, the script itself to execute, which will be function (parameters)

With parameters, you can specify things like this (slightly modified sample taken from the System Administration Guide):

 ...
parameters:
        variableParam1: 
        {
                             label: 'Name of Share',
                             type: 'String'
                  },
                  variableParam2
                  {
                             label: 'Share Size',
                             type: 'size'
                  },
execute: ....
};
Note the commas separating the sections of name, parameters, execute, and so on. This is important!

Also - there is plenty of properties you can set on the parameters for your workflow, these are described in the Sun ZFS Storage System Administration Guide.

Creating a Basic Workflow from a Basic Script
To make a basic script into a basic workflow, you need to wrap the following around your script to create a 'workflow' object:

var workflow = {
name: 'Get User Quotas',
description: 'Displays Quota Utilisation for each user on each share',
execute: function() 
{

// (basic script goes here, minus the "script" at the beginning, and "." at the end)

}
};

However, it appears (at least in my experience to date) that the workflow object may only be happy with one function in the execute parameter - either that or I'm doing something wrong. As far as I can tell, after execute: you should only have a basic one function context like so:

execute: function(param1,param2,...,paramN) // Parameters from workflow object
{

}

To deal with this, and to give an example similar to our script earlier, I have created another simple quota check, to show the same basic functionality, but in a workflow format:

var workflow = {
name: 'Get User Quotas',
description: 'Displays Quota Utilisation for each user on each share',
execute: function () {
        run('cd /');
        run('shares');
        projects=list();
        for (i=0; i < projects.length; i++)
        {
                run('select ' + projects[i]);
                shares=list('filesystem');
                printf("Project: %s\n", projects[i]);

                for(j=0; j < shares.length; j++)
                {
                        run('select ' +shares[j]);
                        try
                        {
                                run('users');
                                printf("  SHARE: %s\n", shares[j]);
                                printf("    %20s        %11s    %11s    %3s\n","Username","Usage(G)","Quota(G)","Quota(%)");
                                printf("    %20s        %11s    %11s    %4s\n","--------","--------","--------","-------");

                                users=list();
                                for(k=0; k < users.length; k++)
                                {
                                        run('select ' + users[k]);
                                        username=get('name');
                                        usage=get('usage');
                                        quota=get('quota');
                                        usage_g=usage / 1073741824; // convert bytes to gigabytes
                                        quota_g=quota / 1073741824; // as above
                                        quota_percent=0
                                        if (quota > 0)
                                        {
                                                quota_percent=(usage / quota)*(100/1);
                                        }
                                        printf("    %20s        %8.2f   %8.2f %d%%\n",username,usage_g,quota_g,quota_percent);
                                        run('done');
                                }
                                run('done'); // exit user context
                        }
                        catch(err)
                        {
                        //      printf("    %s is a LUN, Not looking for users\n", shares[j]);
                        }
                        run('done'); // exit selected share context
                }
                run('done'); // exit project context
        }
        }
};


Summary
The Sun ZFS Storage 7000 Appliance offers lots of different and interesting features to Sun/Oracle customers, including the world renowned Analytics. Hopefully the above will help you to think of new creative things you could be doing by taking advantage of one of the other neat features, the internal scripting engine!

Some references are below to help you continue learning more, I'll update this post as I do the same! Enjoy...


More information on ECMAScript 3
A complete reference to ECMAScript 3 which will help you learn more of the details you may be interested in, can be found here:



More Information on Administering the Sun ZFS Storage 7000
The Sun ZFS Storage 7000 System Administration guide can be a useful reference point, and can be found here:



About

Solaris, Storage 7000 and anything else that I happen to find interesting :)

Search

Categories
Archives
December 2010
SunMonTueWedThuFriSat
   
1
2
3
4
5
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
       
Today