# # Copyright (c) 2001-2010 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary VolumeMoveTargetAggr ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VolumeMoveTargetAggr =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP VolumeMoveTargetAggr. A related class is L, which represents access to an ONTAP VolumeMoveTargetAggr. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the VolumeMoveTargetAggr element are the attributes of the VolumeMoveTargetAggr ComponentState. =over =item C<< "storagetype" >> Filled in for CMode CLI/ZAPI Maps to: CM ZAPI: $value =item C<< "volume" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. =item C<< "vserver" >> Filled in for CMode CLI/ZAPI. =item C<< "aggregate" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: $value =item C<< "availsize" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: 256413696 =back =cut package NACL::CS::VolumeMoveTargetAggr; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw(_dump_one); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use Data::Dumper; use NACL::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'storagetype', scalar => 'volume', scalar => 'vserver', scalar => 'aggregate', scalar => 'availsize', ]; =head1 METHODS =head2 fetch my $VolumeMoveTargetAggr_state = NACL::CS::VolumeMoveTargetAggr->fetch(command_interface => $ci, ...); my @VolumeMoveTargetAggr_states = NACL::CS::VolumeMoveTargetAggr->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. =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 = shift; my @state_objs = $pkg->SUPER::fetch( @_, show_cmd => 'volume move target-aggr show', choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode', }, ], exception_text => 'No matching volume move target aggr(s) found' ); $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 = shift; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@_, api => 'volume_move_target_aggr_show'); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _fetch_cmode_zapi { my $pkg = shift; my %opts = @_; my $pass_through_opts = {}; my %filter_opts = %{$opts{'filter'}}; $pkg->_hash_move( source => \%filter_opts, move => ['vserver'], map => {'volume' => 'volume-name'}, target => $pass_through_opts, ); my $map = { 'aggregate' => 'aggr-name', 'availsize' => 'available-size', 'storagetype' => 'storage-type', }; my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( %opts, api => "volume-move-target-aggr-get-iter", map => $map, pass_through_opts => $pass_through_opts, # Not present in copy/map since they are not present in the typedef inapplicable_for_help_xml => [qw(volume vserver)], ); foreach my $state_obj (@state_objs) { $state_obj->volume($$pass_through_opts{'volume-name'}); $state_obj->vserver($$pass_through_opts{vserver}); } return @state_objs; } ## end sub _fetch_cmode_zapi sub _fetch_7mode_cli { my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $command_interface = $opts{command_interface}; my $volume = $opts{filter}{volume}; my $vol_obj = NACL::CS::Volume->fetch( command_interface => $command_interface, apiset_should => {interface => 'CLI'}, filter => {volume => $volume}, requested_fields => [qw(size aggregate)], ); # Find size of volume my $vol_size = $vol_obj->size(); my $aggr_name = $vol_obj->aggregate(); # Find matching aggregates my @aggr_cs = NACL::CS::Aggregate->fetch( command_interface => $command_interface, filter => { state => 'online', availsize => ">$vol_size", aggregate => "!$aggr_name", }, allow_empty => 1, requested_fields => ['availsize'] ); my @state_objs; foreach my $cs (@aggr_cs) { my $obj = $pkg->new(command_interface => $command_interface); $obj->volume($volume); $obj->aggregate($cs->aggregate()); $obj->availsize($cs->availsize()); push @state_objs, $obj; } return @state_objs; } ## end sub _fetch_7mode_cli 1;