ADSM-L

Re: cancel process automation

1999-02-01 17:36:03
Subject: Re: cancel process automation
From: Russell Street <russells AT AUCKLAND.AC DOT NZ>
Date: Tue, 2 Feb 1999 11:36:03 +1300
> has anyone automate (script or sql) the [ cancel process xxxx ] command
> yet, I need to cancel my space reclamation processes prior to my backup
> stgpool & DRM processes.

Here is a perl script does vaguely that.

It uses a "select .. from processes" to find the processes to cancel.

This is a hacked up and untested version of the real thing, so it may
not be quite right ;)



Russell
============================================================
#!/usr/local/bin/perl5 -w
#!/usr/local/bin/perl5 -w
## =================================================================
## File: adsm-cancel-expire
##
## Cancel a running expire process
##
## Author:  Russell Street <r.street AT auckland.ac DOT nz>
##          ITSS, University of Auckland
##
## =================================================================

use English;
use strict;

my $adsm::admin = "-id=XXX -pass=YYY";
my $adsm::DSMADMC = "dsmadmc";


## -----------------------------------------------------------------
## Look for any process called "Expiration"
## -----------------------------------------------------------------

{
    my %lines = ();
    my $result = "";

    my $cmd = "select process_num from processes where process = 
\\'Expiration\\'";

    adsm_execute_macro(user => $adsm::admin,
                       command => $cmd,
                       result => \%lines,
                       error => \$result);

    my @t = grep /^select process/, keys %lines;
    exit if !defined @t || (scalar @t == 0);

    my $sel_lines = $lines{$t[0]};
    exit if !defined $sel_lines;

    foreach (@{$sel_lines}) {
        adsm_execute_macro(user => $adsm::admin,
                           command => "cancel process $_",
                           result => \%lines,
                           error => \$result);
    }
}


## -----------------------------------------------------------------
## adsm_execute_macro --- execute ADSM commands and return the
## output as a Perl datastructure...
##
## Parameters (as a hash ref)
##    user    => username/password   (scalar)      input
##    command => command to execute  (scalar)      input
##    result  => hash of results     (hash ref)    returned
##    error   => error string        (scalar ref)  returned
## -----------------------------------------------------------------

sub adsm_execute_macro {
    my %params = @_;


    my $command = "$adsm::DSMADMC < /dev/null -commadelimited " . $params{user} 
. " " . $params{command};

    my $command_output = `$command`;
    my $command_status = $CHILD_ERROR >> 8;

    if ($command_status != 0) {
        ${$params{'error'}} = "ADSM command '" . $params{command} . "' . 
failed...\n" . $command_output;
    return;
}
<Prev in Thread] Current Thread [Next in Thread>