# # Copyright (c) 2001-2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary SnapmirrorPolicy ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com, benjaram@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SnapmirrorPolicy =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP SnapmirrorPolicy. A related class is L, which represents access to an ONTAP SnapmirrorPolicy. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the SnapmirrorPolicy element are the attributes of the SnapmirrorPolicy 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<< restart >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< tries >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< total_rules >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< vserver >> Maps to vserver-name for CMode ZAPI. Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< transfer_priority >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< access >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< time_to_complete >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< ignore_atime >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< snapmirror_label >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $snapmirror_label = $obj->snapmirror_label(); # $snapmirror_label contains a reference to the array of values my @snapmirror_label = $obj->snapmirror_label(); # @snapmirror_label contains the array of values Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: @value =item C<< comment >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< keep >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $keep = $obj->keep(); # $keep contains a reference to the array of values my @keep = $obj->keep(); # @keep contains the array of values Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: @value =item C<< warn >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $warn = $obj->warn(); # $warn contains a reference to the array of values my @warn = $obj->warn(); # @warn contains the array of values Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: @value =item C<< policy >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< preserve >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $preserve = $obj->preserve(); # $preserve contains a reference to the array of values my @preserve = $obj->preserve(); # @preserve contains the array of values Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: @value =item C<< owner >> Owner of the Policy Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< total_keep >> Total Retention Count for all Rules in this Policy Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< network_compression_enabled >> Network Compression Enabled possible value(s) are, true,false Filled in for CMode CLI. =item C<< create_snapshot >> Create a New Snapshot Copy possible value(s) are, true,false Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< is_network_compression_enabled >> Is Network Compression Enabled possible value(s) are, true,false Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< replication_mode >> Replication Mode possible value(s) are, sync,semi-sync Filled in for CMode CLI. =item C<< max_client_io_delay >> Maximum Allowed Client I/O Delay (msecs) Filled in for CMode CLI. =item C<< rpo >> Recovery Point Objective (minutes) Filled in for CMode CLI. =item C<< is_domino_mode_enabled >> Is Domino Mode Enabled possible value(s) are, true,false Filled in for CMode CLI. =item C<< type >> Snapmirror Policy Type possible value(s) are, vault,async-mirror,mirror-vault,sync-mirror Filled in for CMode CLI/ZAPI. Filled in for CMode CLI. =item C<< max_io_latency_per_op >> Maximum Allowed I/O Latency Per Operation (msecs) Filled in for CMode CLI. =item C<< window_size_for_tdp_mirror >> Window Size for Transfer Operations for type 'tdp-mirror' Filled in for CMode CLI/ZAPI. =back =cut package NACL::CS::SnapmirrorPolicy; use strict; use warnings; use Params::Validate qw(validate); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); 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 base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'restart', scalar => 'tries', scalar => 'total_rules', scalar => 'vserver', scalar => 'transfer_priority', scalar => 'access', scalar => 'time_to_complete', scalar => 'ignore_atime', array => 'snapmirror_label', scalar => 'comment', array => 'keep', array => 'warn', scalar => 'policy', array => 'preserve', scalar => 'owner', scalar => 'total_keep', scalar => 'network_compression_enabled', scalar => 'create_snapshot', scalar => 'is_network_compression_enabled', scalar => 'replication_mode', scalar => 'max_client_io_delay', scalar => 'rpo', scalar => 'is_domino_mode_enabled', scalar => 'type', scalar => 'max_io_latency_per_op', scalar => 'window_size_for_tdp_mirror' ]; =head1 METHODS =head2 fetch my $SnapmirrorPolicy_state = NACL::CS::SnapmirrorPolicy->fetch(command_interface => $ci, ...); my @SnapmirrorPolicy_states = NACL::CS::SnapmirrorPolicy->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. Supports CMode CLI/ZAPI (iter and non-iter). Invokes "snapmirror-policy-get-iter" API for iter CMode ZAPI. Invokes "snapmirror-policy-get" API for non-iter 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 { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::fetch( @args, show_cmd => 'snapmirror policy show', choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', zapi_type => 'none', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', zapi_type => 'iter', }, { method => '_fetch_cmode_zapi_non_iter', interface => 'ZAPI', set => 'CMode', zapi_type => 'non-iter', check => '_check_non_iter', }, ], exception_text => 'No matching snapmirror policy(s) found' ); $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 => 'snapmirror_policy_show'); $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; my $copy = $pkg->_common_zapi_copy(); my $map = $pkg->_common_zapi_map(); my @state_objs; try { @state_objs = $pkg->SUPER::_fetch_cmode_zapi( %opts, api => 'snapmirror-policy-get-iter', copy => $copy, map => $map, ); } catch NACL::APISet::Exceptions::NoMatchingEntriesException with { $Log->debug('No entries found matching the query'); }; $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi_non_iter { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my $copy = $pkg->_common_zapi_copy(); my $map = $pkg->_common_zapi_map(); my (@state_objs, $vserver); try { @state_objs = $pkg->SUPER::_fetch_cmode_zapi_non_iter( @args, api => 'snapmirror-policy-get', vserver_operated_on => \$vserver, copy => $copy, map => $map, primary_keys => ['policy'], ); } catch NACL::APISet::Exceptions::NoMatchingEntriesException with {}; $Log->exit() if $may_exit; return @state_objs; } sub _common_zapi_copy { my @copy = ( qw(comment ignore-atime restart time-to-complete total-rules transfer-priority tries create-snapshot is-network-compression-enabled owner total-keep type window-size-for-tdp-mirror) ); return wantarray ? @copy : [@copy]; } sub _common_zapi_map { my %map = ( 'keep' => [ make_zapi_array('snapmirror-policy-rules'), make_zapi_skip('snapmirror-policy-rule-info'), 'keep', ], 'preserve' => [ make_zapi_array('snapmirror-policy-rules'), make_zapi_skip('snapmirror-policy-rule-info'), 'preserve', ], 'snapmirror-label' => [ make_zapi_array('snapmirror-policy-rules'), make_zapi_skip('snapmirror-policy-rule-info'), 'snapmirror-label', ], 'warn' => [ make_zapi_array('snapmirror-policy-rules'), make_zapi_skip('snapmirror-policy-rule-info'), 'warn', ], 'access' => 'access-type', 'policy' => 'policy-name', 'vserver' => 'vserver-name', ); return wantarray ? %map : {%map}; } sub _update_state_objs_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; foreach my $state_obj (@{$opts{state_objs}}) { foreach my $field (qw(owner type)) { my $val = $state_obj->$field(); if (defined $val) { $val =~ s/_/-/g; $state_obj->$field($val); } } } $Log->exit() if $may_exit; } sub _check_non_iter { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->_base_check_non_iter( @args, _primary_keys => ['policy'], _vs_context => 1 ); $Log->exit() if $may_exit; } 1;