ZFS Tricks: Blinking The Lights

matthew's picture

I've created a new blog with my work at https://blogs.oracle.com/storageops . The first entry is copied below.


I've had an account on blogs.oracle.com  for several years now, but never really used it. Decided it was about time. Without further ado, let's dive in!

One of the most powerful facilities of the Oracle ZFS Storage Appliance is "workflows". You can find these in the BUI or the CLI under "maintenance":

ZFS Maintenance Workflows BUI image

For most people, Workflows are kind of a mystery. If you've been on a call with Support, you've probably been asked to use them, but they seemed like this arcane thing that was only for Support.

In reality, Workflows are for YOU!  So to get you started playing in the land of workflows, here's a sample script. What this does it turn off all the hard drive lights on your ZFS appliance. This is a useful little utility I wrote; with thousands of ZFS appliances in our domains and dozens of storage admins working with several on-site remote hands, often the blinking locator lights get left on after repairs are complete.  Wouldn't it be nice to have a way to clear them? Now you have one!

For now, don't worry about some of the comments. I'll go into jslint/jshint in a later blog entry. Just save this BlinkenLightsOff.akwf to your computer somewhere handy, then upload it by clicking the plus sign in the "Maintenance Workflows" section of your BUI:

Save the code below as "BlinkenLightsOff.akwf" on your hard drive somewhere memorable.

/*globals run, continue, list, printf, print, get, set, choices, akshDump, nas, audit, shell*/
/*jslint maxerr: 50, indent: 4, plusplus: true, forin: true */

//A workflow to cause your drive locator lights to turn off.
//Author: Matthew P. Barnson <matthew.spam.barnson@oracle.com>
//Last updated: 2014-10-06

var workflow = {
    name: 'BlinkenLightsOff',
    origin: 'Oracle PDIT mbarnson',
    description: 'Disk Lights Off',
    version: '1.2',
    hidden: false,
    alert: false,
    setid: true,
    execute: function (params) {
        "use strict";
        var myBlinkyBlinkBlink = function (params) {
            run('maintenance hardware');
            var myHardware = list(),
                hardware = 0,
                myComponents = [],
                component = 0,
                disk = 0,
                myLightStatus = false,
                lightStatus = "Blinkenlights Output:\n";
            for (hardware = 0; hardware < myHardware.length; hardware++) {
                run('select ' + myHardware[hardware]);
                myComponents = list();
                //lightStatus = lightStatus + 'Checking ' + myComponents + '\n';
                for (component = 0; component < myComponents.length; component++) {
                    lightStatus = lightStatus + 'Checking component ' + myComponents[component] + '\n';
                    if (myComponents[component].match(/disk/)) {
                        run('select ' + myComponents[component]);
                        myDisks = list();
                        for (disk = 0; disk < myDisks.length; disk++) {
                            run('select ' + myDisks[disk]);
                            myLightStatus = get('locate');
                            if (!myLightStatus) {
                                lightStatus = lightStatus + myHardware[hardware] + ':' +
                                    myComponents[component] + ':' +
                                    myDisks[disk] + ':' +
                                    " is already dark.\n";
                            } else {
                                lightStatus = lightStatus + 'Darkening ' +
                                       myHardware[hardware] + ":" +
                                       myComponents[component] + ":" +
                                       myDisks[disk] + "\n";
                                set('locate', false);
                //printf('%s\n', myComponents);
            audit('Turning off all blinking disk lights.\n');
            return (lightStatus + '\n');
        return (myBlinkyBlinkBlink());

You can run this workflow either by clicking on it and executing via the BUI, or executing it from the CLI with this command:

maintenance workflows select name="BlinkenLightsOff" execute

Enjoy! Next week, just in time for the holidays, I'll post a way to make all your hard drive lights turn on; you can enjoy blinking Yule lights in your data center. Those of you with a modest amount of appliance experience will be able to easily figure it out from the above code; it's very similar code.