# $Id: //depot/prod/test/nacldev/lib/NACL/CS/VolumeSnapshotPolicy.pm#10 $ # This is a prototype . It still needs # documentation. # The field representation is incomplete: # The fields considered here are only for C Mode CLI. # Yet to comeup for Zapi fields and CLI 7 Mode # This missing fields are mainly the ones 7Mode and ZAPI represent # rather arbitrarily as "options". Many of the missing fields are # listed commented out in the individual routines for 7Mode CLI # fetch and CMode CLI fetch. # # Copyright (c) 2001-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary Snapshot ComponentState Module ## @author dheeraj.k@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VolumeSnapshotPolicy =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP VolumeSnapshotPolicy. A related class is L, which represents access to an ONTAP VolumeSnapshotPolicy. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the VolumeSnapshotPolicy element are the attributes of the VolumeSnapshotPolicy ComponentState. =over =item C<< policy >> The name of the VolumeSnapshotPolicy element whose state is being represented. Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< enabled >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< comment >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< total_schedules >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< schedules >> (Array) Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< counts >> (Array) Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< prefixes >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $prefixes = $obj->prefixes(); # $prefixes contains a reference to the array of values my @prefixes = $obj->prefixes(); # @prefixes contains the array of values Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< snapmirror_labels >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $snapmirror_labels = $obj->snapmirror_labels(); # $snapmirror_labels contains a reference to the array of values my @snapmirror_labels = $obj->snapmirror_labels(); # @snapmirror_labels contains the array of values Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< vserver >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< policy_owner >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< supported_count >> Supported Number of Snapshots in Revert Version ranges from 0 to 255 Filled in for CMode CLI. =item C<< total_count >> Total Number of Snapshots in This Policy ranges from 0 to 255 Filled in for CMode CLI. =back =cut package NACL::CS::VolumeSnapshotPolicy; use strict; use warnings; use Params::Validate qw(validate); use NACL::Exceptions::NoElementsFound qw(:try); use NACL::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::CS::ComponentState::ZapiArray qw(make_zapi_array); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => "policy", scalar => "enabled", scalar => "comment", scalar => "total_schedules", array => "schedules", array => "counts", array => 'prefixes', array => 'snapmirror_labels', scalar => 'vserver', scalar => 'policy_owner', scalar => 'supported_count', scalar => 'total_count', ]; sub isa { $Log->enter() if $may_enter; my ($pkg_or_obj, $kind) = @_; my $isa = $pkg_or_obj->_build_isa( kind => $kind, alias => 'NACL::CS::SnapshotPolicy' ); $Log->exit() if $may_exit; return $isa; } sub fetch { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], show_cmd => 'volume snapshot policy show', exception_text => 'No matching volume snapshot policy(s) found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch =head1 METHODS =head2 fetch my $snapshotpolicy_state = NACL::CS::VolumeSnapshotPolicy->fetch( command_interface=>$ci,...); my @snapshotpolicy_states = NACL::CS::VolumeSnapshotPolicy->fetch( command_interface=>$ci,...); see L Supports CMode CLI/ZAPI. Invokes "snapshot-policy-get-iter" API for CMode ZAPI. =over =item Exceptions =over =item C When there are no elements matching the query specified or elements of that type doesn't exist, then this exception will be thrown. =back =back =cut sub _fetch_cmode_cli { my $pkg = shift; return $pkg->SUPER::_fetch_cmode_cli(@_, api => "volume_snapshot_policy_show"); } sub _fetch_cmode_zapi { my $pkg = shift; return $pkg->SUPER::_fetch_cmode_zapi( @_, api => "snapshot_policy_get_iter", copy => [qw(total-schedules policy policy-owner enabled comment)], map => { "vserver" => ['vserver-name'], "counts" => [ make_zapi_array('snapshot-policy-schedules'), make_zapi_skip('snapshot-schedule-info'), 'count', ], "prefixes" => [ make_zapi_array('snapshot-policy-schedules'), make_zapi_skip('snapshot-schedule-info'), 'prefix', ], "schedules" => [ make_zapi_array('snapshot-policy-schedules'), make_zapi_skip('snapshot-schedule-info'), 'schedule', ], "snapmirror-labels" => [ make_zapi_array('snapshot-policy-schedules'), make_zapi_skip('snapshot-schedule-info'), 'snapmirror-label', ], }, ); } ## end sub _fetch_cmode_zapi 1;