# $Id$ # # Copyright (c) 2001-2011 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary VolumeCopy Component Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VolumeCopy =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP Volume copy. A related class is L, which represents access to an ONTAP Volume copy. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Volume Copy element are the attributes of the VolumeCopy ComponentState. =over =item C<< status >> The status of Volume Copy operation. (7Mode Only) =item C<< operation_number >> The operation no of current Volume Copy operation. (7Mode Only) =back =cut package NACL::CS::VolumeCopy; use strict; use warnings; use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NACL::ComponentUtils qw (Dumper); use Params::Validate qw(validate); use NATE::BaseException qw(:try); use NATE::Exceptions::Argument (); use NACL::APISet::Exceptions::ResponseException (); use base 'NACL::CS::ComponentState::ONTAP'; use NACL::Exceptions::NoElementsFound qw(:try); use Class::MethodMaker [ scalar => 'status', scalar => 'operation_number', ]; =head1 METHODS =head2 fetch my $volcopy_state = NACL::CS::VolumeCopy->fetch(command_interface=>$ci,...); my @volcopy_states = NACL::CS::VolumeCopy->fetch(command_interface=>$ci,...); see L Uses a 7Mode CLI APISet. =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,%opts) = @_; my @state_objs; @state_objs = $pkg->SUPER::fetch( %opts, choices => [ { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode', }, ], exception_text => 'No matching volume copy(s) found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_7mode_cli { $Log->enter() if $may_enter; my $pkg = shift; my $obj; my @state_objs; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my (%api_opts,$response); my $flag = 0; my $command_interface = delete $opts{command_interface}; my $apiset = delete $opts{apiset}; my $filter = delete $opts{filter}; if ( defined $filter->{'operation-number'} ) { $api_opts{'operation-number'} = $filter->{'operation-number'}; } try { $response = $apiset->vol_copy_status(%api_opts); } catch NACL::APISet::Exceptions::ResponseException with { my $exception_obj = $_[0]; if ($exception_obj->text() =~/No operations in progress/i) { $flag = 1; } else { $Log->exit() if $may_exit; $exception_obj->throw(); } }; if ($flag){ $Log->exit() if $may_exit; return; } my $output = $response->get_parsed_output(); foreach my $row (@$output) { $obj = $pkg->new(); $obj->operation_number( $row->{operation_no} ); $obj->status( $row->{status} ); push( @state_objs, $obj ); } $Log->exit() if $may_exit; return @state_objs; } # Overriding because "destination-volume" is not an attribute of the # object but this field will be present in the filter when state() is # invoked on a component object sub _extra_filter_fields { $Log->enter() if $may_enter; $Log->exit() if $may_exit; return [ 'destination-volume' ]; } 1;