Software Development Kit (SDK) and API Discussions

ZAPI Perl for cDOT - snapshot list, create and delete for a list of volumes

Adly
3,195 Views

This is a modified version of the snapman.pl script sample from NMSDK 5.4.
It has been tested on cDOT 8.3.1P1 on data and archivelog volumes of a database when set in backup mode.
You can list the existing snapshots, create a snapshot for each volume in the list with a prefix, delete any snapshot created before a specific elapsed time.
You need NaServer.pm and NaElement.pm present in the same directory as this script.

You may also need the following packages (in Ubuntu) liblwp-useragent-determined-perl libxml-parser-perl perl-doc

 

SYNOPSIS

 

   snapme.pl -h
   snapme.pl -l
   snapme.pl -c
   snapme.pl -d

 

ARGUMENTS

 

   The script has been simplified in command options.
   -h complete help document
   -l to list snapshot info
   -c to create a snapshot
   -d to delete older snapshots

 

VARIABLES

 

   The main variables that need to change to fit your environment:
   $filer cluster management hostname or IP address
   $vserver vserver name
   $user ontapi user with the following privileges in CDOT RBAC section below
   $password password as set for the above user
   @vols array that contains the list of volume names to create the snapshot for, i.e. ("vol1","vol2")
   $snapname global snapshot prefix name as an identifier
   $oldersnap time in minutes used when deleting older snapshots.
   i.e. 60 minutes will delete any snapshots created passed the last hour

 

CDOT RBAC

 

   The following definition of role and user gives the apiuser enough privileges to list, create and delete snapshots for vol1 and vol2.
   login role create -role apirole -vserver Cluster -cmddirname "DEFAULT" -access none
   login role create -role apirole -vserver Cluster -cmddirname "date" -access readonly
   login role create -role apirole -vserver Cluster -cmddirname "volume snapshot show" -query "-vserver vsm -volume vol1|vol2" -access all
   login role create -role apirole -vserver Cluster -cmddirname "volume snapshot delete" -query "-vserver vsm -volume vol1|vol2" -access all
   login create -user-or-group-name apiuser -application ontapi -authmethod password -role apirole -vserver Cluster

1 REPLY 1

jauling_chou
2,740 Views

Sorry for being dense, but where is the Perl code for this?

Public