# # Copyright (c) 2001-2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary ComponentState Module for the method NACL::C::Snapmirror->list_destinations() (auto-generated by CGT) ## @author benjaram@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SnapmirrorListDestinations =head1 DESCRIPTION C is a derived class of L. Object(s) of this type are returned when NACL::C::Snapmirror->list_destinations() is invoked. ((This module does not represent the state of any element, but is an object repesentation of the output obtained when NACL::C::Snapmirror->list_destinations() is invoked.) =head1 ATTRIBUTES The fields of the output are fields of the ComponentState object. =over =item C<< destination_volume >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< source_volume >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< destination_vserver >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< rel_status >> Filled in for CMode CLI. =item C<< status >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< source_vserver >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< transfer_progress >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< dest_volume_msid >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< relationship_id >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< destination_path >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< progress_last_updated >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< type >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< source_path >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< rel_type >> Filled in for CMode CLI. =item C<< dstVsUuid >> Filled in for CMode CLI. =item C<< hidden_rel_id >> Filled in for CMode CLI. =item C<< is_constituent >> Constituent Relationship, possible value(s) are true,false Filled in for CMode CLI/ZAPI. =item C<< source_volume_node >> Source Volume Node Name Filled in for CMode CLI/ZAPI. =item C<< policy_type >> SnapMirror Policy Type possible value(s) are, vault,async-mirror,mirror-vault,sync-mirror Filled in for CMode CLI. =item C<< group_type >> Relationship Group Type possible value(s) are, None,Vserver,InfiniteVol Filled in for CMode CLI. =back =cut package NACL::CS::SnapmirrorListDestinations; use strict; use warnings; use feature 'state'; use Params::Validate qw(validate validate_with HASHREF ARRAYREF); 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); # _zapi_fields_underscored_value, _lc_fields_zapi should not be used from the mix-in use NACL::C::_Mixins::Snapmirror qw(:all !_zapi_fields_underscored_value !_lc_fields_zapi); use NACL::CS::_Mixins::Snapmirror qw(:all); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'destination_volume', scalar => 'source_volume', scalar => 'destination_vserver', scalar => 'rel_status', scalar => 'status', scalar => 'source_vserver', scalar => 'transfer_progress', scalar => 'dest_volume_msid', scalar => 'relationship_id', scalar => 'destination_path', scalar => 'progress_last_updated', scalar => 'type', scalar => 'source_path', scalar => 'rel_type', scalar => 'dstVsUuid', scalar => 'hidden_rel_id', scalar => 'is_constituent', scalar => 'source_volume_node', scalar => 'policy_type', scalar => 'group_type', ]; =head1 METHODS =head2 fetch my $SnapmirrorListDestinations_state = NACL::CS::SnapmirrorListDestinations->fetch(command_interface => $ci, ...); my @SnapmirrorListDestinations_states = NACL::CS::SnapmirrorListDestinations->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 (both iter and non-iter) APISet. Invokes 'snapmirror-get-destination-iter' API for iter CMode ZAPI; invokes 'snapmirror-get-destination' 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 list-destinations', 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 => '_non_iter_check_cs', }, ], exception_text => 'No matching snapmirror(s) found', show_cmd => 'snapmirror list-destinations', ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@args, api => 'snapmirror_list_destinations',); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _local_common_zapi_copy { my @copy = ( qw( destination-volume destination-vserver progress-last-updated relationship-id source-volume source-vserver transfer-progress is-constituent source-volume-node) ); return wantarray ? @copy : [@copy]; } sub _local_common_zapi_map { my %map = ( 'destination-path' => 'destination-location', 'dest-volume-msid' => 'destination-volume-msid', 'status' => 'relationship-status', 'type' => 'relationship-type', 'source-path' => 'source-location', 'group-type' => 'relationship-group-type', ); return wantarray ? %map : {%map}; } sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; $pkg->_update_filter_cmode_zapi(all_opts => \%opts); my $copy = $pkg->_destination_common_zapi_copy(); my $map = $pkg->_destination_common_zapi_map(); my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( %opts, api => 'snapmirror-get-destination-iter', copy => $copy, map => $map, ); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi sub _fetch_cmode_zapi_non_iter { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; my $copy = $pkg->_destination_common_zapi_copy(); my $map = $pkg->_destination_common_zapi_map(); # The keys that are accepted are # (source|destination)-(path|vserver|volume) my @primary_keys; foreach my $src_or_dst (qw(source destination)) { foreach my $elem (qw(volume vserver path)) { push @primary_keys, "$src_or_dst-$elem"; } } my @state_objs = $pkg->SUPER::_fetch_cmode_zapi_non_iter( %opts, api => 'snapmirror-get-destination', copy => $copy, map => $map, primary_keys => \@primary_keys, ); $Log->exit() if $may_exit; return @state_objs; } # Perform the various mappings/translations needed to make the values in # the filter look like the CLI equivalent sub _update_filter_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; state $spec = {all_opts => {type => HASHREF}}; my %opts = validate(@args, $spec); my $all_opts = $opts{all_opts}; if ($all_opts->{filter}) { my %filter = %{$all_opts->{filter}}; my %args = (opts_ptr => \%filter); $pkg->_update_type_for_zapi(%args); $pkg->_update_lc_fields_for_zapi(%args); $pkg->_update_underscore_value_for_zapi(%args); $all_opts->{filter} = \%filter; } $Log->exit() if $may_exit; } # Perform the various mappings/translations needed to make the values in # the CS object look like the CLI equivalent sub _update_state_objs_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->SUPER::_update_state_objs_cmode_zapi( @args, zapi_field_translations => { hyphenate_value => [$pkg->_zapi_fields_underscored_value()], }, hash_map_translations => { $pkg->_hash_map_translations_status(), $pkg->_hash_map_translations_type(), $pkg->_hash_map_translations_group_type(), }, ); $Log->exit() if $may_exit; } sub _zapi_fields_underscored_value { return (qw(policy-type)); } sub _lc_fields_zapi { return (qw(status)); } sub _super_apply_filter { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; $pkg->SUPER::_apply_filter(%opts); $Log->exit() if $may_exit; } sub _extra_filter_fields { return ['expand','relationship-group-type'] } 1;