# # Copyright (c) 2001-2010 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::StorageAggregate->verify_status() ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::StorageAggregateVerifyStatus =head1 DESCRIPTION C is a derived class of L. Object(s) of this type are returned when NACL::C::StorageAggregate->verify_status() is invoked. (This module does not represent the state of any element, but is an object repesentation of the output obtained when the aggregate verify command is invoked with the action being status.) =head1 ATTRIBUTES The fields of the output are fields of the ComponentState object. =over =item C<< aggregate >> The name of the aggregate. =item C<< is_suspended >> A boolean field (true/false) which represents whether or not mirror verification is suspended for this aggregate. =item C<< percentage_completed >> Mirror verification percentage complete. If verification isn't active, this value won't be returned. =back =cut package NACL::CS::StorageAggregateVerifyStatus; use strict; use warnings; use base 'NACL::CS::ComponentState::ONTAP'; use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use Params::Validate qw(validate); use Class::MethodMaker [ scalar => 'aggregate', scalar => 'is_suspended', scalar => 'percentage_completed', ]; =head1 METHODS =head2 fetch my $aggr_verify_state = NACL::CS::StorageAggregateVerifyStatus->fetch(command_interface => $ci, ...); my @aggr_verify_states = NACL::CS::StorageAggregateVerifyStatus->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 a CMode CLI/ZAPI APISet, 7Mode CLI APISet. Invokes "storage aggregate verify" for CMode CLI. Invokes "aggr-verify-list-info" for CMode/7Mode ZAPI. Invokes "aggr verify status" for 7Mode CLI. =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(); my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::fetch( # For backwards compatibility reasons. The Aggr->verify_status() used # to return an empty array by default. allow_empty => 1, @args, choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_zapi', interface => 'ZAPI', set => 'CMode|7Mode', }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode', }, ], exception_text => 'No matching storage aggregate mirror verification ' . 'operations found' ); $Log->exit(); return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_cmode_cli { $Log->enter(); my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my %cmode_args; my $filter_aggr = $opts{filter}{aggregate}; $cmode_args{aggregate} = $filter_aggr if (defined $filter_aggr); my $response = $apiset->storage_aggregate_verify(%cmode_args, action => 'status'); my $output = $response->get_parsed_output(); my @state_objs; foreach my $parsed (@$output) { unless ($parsed->{is_verify_not_running}) { my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => $parsed); push @state_objs, $obj; } } $Log->exit(); return @state_objs; } sub _fetch_zapi { $Log->enter(); my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my %api_opts; my $filter_aggr = $opts{filter}{aggregate}; if (defined ($filter_aggr) && !$pkg->_check_relational_regex_filter(filter_value => $filter_aggr)) { $api_opts{aggregate} = $filter_aggr; } my $response = $apiset->aggr_verify_list_info(%api_opts); my $parsed = $response->get_parsed_output(); # When no output is returned, parsed output is [ {} ], i.e. an array-ref # with a single entry hash-ref. if (@$parsed == 1 && !keys %{$parsed->[0]}) { $Log->exit(); return; } my @rows = @{$parsed->[0]{'verify-details'}[0]{'verify-detail-info'}}; my @state_objs; foreach my $row (@rows) { my %target; $pkg->_hash_copy( source => $row, target => \%target, map => { 'name' => 'aggregate', 'is-suspended' => 'is_suspended', 'percentage-complete' => 'percentage_completed' } ); # CLI returns the value with a "%", the ZAPI simply returns an integer $target{percentage_completed} .= '%' if (defined $target{percentage_completed}); my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => \%target); push @state_objs, $obj; } $Log->exit(); return @state_objs; } sub _fetch_7mode_cli { $Log->enter(); my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my %api_opts; my $filter_aggr = $opts{filter}{aggregate}; if (defined ($filter_aggr) && !$pkg->_check_relational_regex_filter(filter_value => $filter_aggr)) { $api_opts{aggregate} = $filter_aggr; } my $response = $apiset->aggr_verify_status(%api_opts); my $parsed = $response->get_parsed_output(); my @state_objs; foreach my $aggr (@$parsed) { my %target; $pkg->_hash_copy( source => $aggr, target => \%target, copy => [qw(is_suspended percentage_completed)], map => {'name' => 'aggregate'} ); if (keys %target) { my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => \%target); push @state_objs, $obj; } } $Log->exit(); return @state_objs; } 1;