# # Copyright (c) 2001-2014 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary VolumeSnaplock ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VolumeSnaplock =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP VolumeSnaplock. A related class is L, which represents access to an ONTAP VolumeSnaplock. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the VolumeSnaplock element are the attributes of the VolumeSnaplock ComponentState. Additionally, the command_interface used to obtain the ComponentState object is also an attribute of the object. This makes it easier to obtain the component object corresponding to the CS object, using L. =over =item command_interface The command_interface with which the CS object was obtained. (Available in all CS objects regardless of requested_fields and the mode/interface) =item C<< volume >> Volume Name Filled in for CMode CLI/ZAPI, non-iter. =item C<< vserver >> Vserver Name Filled in for CMode CLI/ZAPI, non-iter. =item C<< default_retention_period >> Default Retention Period possible value(s) are, { seconds,minutes,hours,days,months,years} , min , max , infinite Filled in for CMode CLI/ZAPI, non-iter. =item C<< volume_compliance_clock >> Volume Compliance Clock Filled in for CMode CLI/ZAPI, non-iter. =item C<< maximum_retention_period >> Maximum Retention Period possible value(s) are, { seconds,minutes,hours,days,months,years} , infinite Filled in for CMode CLI/ZAPI, non-iter. =item C<< expiry_time >> Volume Expiry Time Filled in for CMode CLI/ZAPI, non-iter. =item C<< type >> SnapLock Type of Volume possible value(s) are, non-snaplock,compliance,enterprise Filled in for CMode CLI/ZAPI, non-iter. =item C<< minimum_retention_period >> Minimum Retention Period possible value(s) are, { seconds,minutes,hours,days,months,years} , infinite Filled in for CMode CLI/ZAPI, non-iter. =item C<< compliance_clock_time >> ComplianceClock Filled in for CMode CLI/ZAPI, non-iter. =item C<< autocommit_period >> Autocommit Period Filled in for CMode CLI/ZAPI, non-iter. =item C<< allow_privileged_delete >> Privileged-delete Filled in for CMode CLI/ZAPI, non-iter. =back =cut package NACL::CS::VolumeSnaplock; use strict; use warnings; use Params::Validate qw(validate); use NATE::Log qw(log_global); use NACL::Exceptions::NoElementsFound qw(:try); use NACL::APISet::Exceptions::NoMatchingEntriesException; use NACL::APISet::Exceptions::ResponseException; use NACL::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::CS::ComponentState::ZapiArray qw(make_zapi_array); use base 'NACL::CS::ComponentState::ONTAP'; use NATE::Exceptions::Argument qw(:try); use Class::MethodMaker [ scalar => 'volume', scalar => 'vserver', scalar => 'default_retention_period', scalar => 'volume_compliance_clock', scalar => 'maximum_retention_period', scalar => 'expiry_time', scalar => 'type', scalar => 'minimum_retention_period', scalar => 'compliance_clock_time', scalar => 'autocommit_period', scalar => 'allow_privileged_delete', scalar => 'privileged_delete', ]; my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); sub _check_non_iter { $Log->enter() if $may_enter; my ($pkg, @opts) = @_; $pkg->_base_check_non_iter( @opts, _primary_keys => [qw(volume vserver)], _vs_context => 1 ); $Log->exit() if $may_exit; } =head1 METHODS =head2 fetch my $VolumeSnaplock_state = NACL::CS::VolumeSnaplock->fetch(command_interface => $ci, ...); my @VolumeSnaplock_states = NACL::CS::VolumeSnaplock->fetch(command_interface => $ci, ...); (Class method) Discovers which elements are present and returns their state in ComponentState objects. Called in scalar context it returns only one state object, in list context it returns all state objects. See L for a more detailed description along with a complete explanation of the options it accepts. Uses CMode CLI/ZAPI. Invokes volume-get-snaplock-attrs API for CMode ZAPI non-iter. =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 { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs ; try{ @state_objs = $pkg->SUPER::fetch( @args, show_cmd => 'volume snaplock show', choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', zapi_type => 'none', }, { method => '_fetch_cmode_zapi_non_iter', interface => 'ZAPI', set => 'CMode', zapi_type => 'non-iter', check => '_check_non_iter', }, ], exception_text => 'No matching VolumeSnaplock(s) found', frontend => 'NACL::CS::VolumeSnaplock::fetch', ); } catch NACL::APISet::Exceptions::ResponseException with{ my $exception_object = shift; my $text = $exception_object->text(); if($text =~/Operation is not supported on volumes of SnapLock type.*/){ NACL::Exceptions::NoElementsFound->throw($text); } else{ $exception_object->throw(); } }; $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@args, api => 'volume_snaplock_show',); $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi_non_iter { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; my ($only_row, $caught_exception); my $filter = $opts{filter}; my %api_opts = (volume => $filter->{volume}, 'vserver-override-name' => $filter->{vserver}); try { my $response = $opts{apiset}->volume_get_snaplock_attrs(%api_opts); my $output = $response->get_parsed_output(); $only_row = $output->[0]{'snaplock-attrs'}[0]{'snaplock-attrs-info'}[0]; } catch NACL::APISet::Exceptions::NoMatchingEntriesException with { $caught_exception = 1; }; if ($caught_exception) { $Log->exit() if $may_exit; return; } # CLI has vserver, volume in output, but ZAPI does not, so populate it # from the filter. my %cs_row = (volume => $filter->{volume}, vserver => $filter->{vserver}); $pkg->_zapi_hash_copy( source => $only_row, target => \%cs_row, copy => [ qw(autocommit-period default-retention-period maximum-retention-period type minimum-retention-period volume vserver) ], map => [ 'privileged-delete-state' => 'privileged-delete', 'volume-expiry-time' => 'expiry-time', [ 'volume-compliance-clock', 'compliance-clock-info', 'formatted-snaplock-compliance-clock' ] => 'compliance-clock-time', ], source_has_extra_arrays => 1, ); my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => \%cs_row); $Log->exit() if $may_exit; return $obj; } 1;