# $Id: //depot/prod/test/nacldev/lib/NACL/CS/StorageAggregateWafliron.pm#20 $ # # Copyright (c) 2001-2010 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary StorageAggregateWafliron ComponentState Module ## @author Sumit.Mittal@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::StorageAggregateWafliron =head1 DESCRIPTION C is a derived class of L. It represents the state of a StorageAggregateWafliron. A related class is L, which represents access to an ONTAP StorageAggregateWafliron. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the element are the attributes of the ComponentState. =over =item C<< aggregate >> =item C<< state >> =item C<< iron_status >> =item C<< iron_scan_percentage >> =item C<< iron_last_start_errno >> =item C<< iron_last_start_error_info >> =item C<< mount_phase_snap_inofiles >> (7Mode) =item C<< mount_phase_activemap >> (7Mode) =item C<< mount_phase_snapmaps >> (7Mode) =item C<< mount_phase_snapdir >> (7Mode) =item C<< mount_phase_metadir >> (7Mode) =item C<< mount_phase_flex_vols >> (7Mode) =item C<< mount_phase_rootdir_for_iron >> (7Mode) =item C<< mount_phase_refcnt >> (7Mode) =item C<< mount_phase_rootdir >> (7Mode) =item C<< mount_phase_summary_map >> (7Mode) =item C<< mount_phase_snap_selfcover >> (7Mode) =item C<< mount_phase_status_of_previous_attempt >> (7Mode) =item C<< status_file_blks_total >> (7Mode) =item C<< status_file_volume >> (7Mode) =item C<< status_file_files >> (7Mode) =item C<< status_file_blks_used >> (7Mode) =item C<< iron_summary_scan_percentage >> Filled in for CMode CLI. =item C<< mnt_flexvols >> Flex Vols Mount Phase Filled in for CMode CLI. =item C<< blocks >> Blocks Scanned Filled in for CMode CLI. =item C<< files >> Files Scanned Filled in for CMode CLI. =item C<< mnt_metadir >> Metadir Mount Phase Filled in for CMode CLI. =item C<< mount_summary >> Total Mount Phase Filled in for CMode CLI. =item C<< opt_commit_option >> Optional Commit Mode Filled in for CMode CLI. =item C<< isf_total_blks_reserve >> (Status Files) Total Blocks Reserved Filled in for CMode CLI. =item C<< mnt_snapinofiles >> Snap Inofiles Mount Phase Filled in for CMode CLI. =item C<< mnt_snapdir >> Snapdir Mount Phase Filled in for CMode CLI. =item C<< mnt_rootdir_for_iron >> Rootdir for Iron Mount Phase Filled in for CMode CLI. =item C<< isf_total_blks_use >> (Status Files) Used Blocks Filled in for CMode CLI. =item C<< mnt_rootdir >> Rootdir Mount Phase Filled in for CMode CLI. =item C<< mnt_snapself >> Snap Selfcover Mount Phase Filled in for CMode CLI. =item C<< mnt_snapmap >> Snapmaps Mount Phase Filled in for CMode CLI. =item C<< luns >> LUNs Scanned Filled in for CMode CLI. =item C<< mnt_activemap >> Activemap Mount Phase Filled in for CMode CLI. =item C<< directories >> Directories Scanned Filled in for CMode CLI. =item C<< private_inodes >> Private Inodes Scanned Filled in for CMode CLI. =item C<< mnt_summarymap >> Summary Map Mount Phase Filled in for CMode CLI. =item C<< opt_commit_msg >> Optional Commit Mode Message Filled in for CMode CLI. =item C<< prev_cp_option >> Prev-cp Query Mode Filled in for CMode CLI. =item C<< mnt_fpametafile >> Flash Pool Aggregate Metafile Mount Phase Filled in for CMode CLI. =item C<< volume >> Volume Filled in for CMode CLI. =item C<< public_inodes >> Public Inodes Scanned Filled in for CMode CLI. =item C<< isf_total_files >> (Status Files) Files Filled in for CMode CLI. =item C<< vserver >> Vserver Filled in for CMode CLI. =item C<< host_volname >> Status Files Redirected to Volume Filled in for CMode CLI. =item C<< mnt_refcount >> Refcnt Mount Phase Filled in for CMode CLI. =back =cut package NACL::CS::StorageAggregateWafliron; 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::APISet::Exceptions::InvalidParamValueException qw(:try); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'aggregate', scalar => 'state', scalar => 'iron_status', scalar => 'iron_scan_percentage', scalar => 'iron_last_start_errno', scalar => 'iron_last_start_error_info', # 7Mode CLI scalar => 'mount_phase_snap_inofiles', scalar => 'mount_phase_activemap', scalar => 'mount_phase_snapmaps', scalar => 'mount_phase_snapdir', scalar => 'mount_phase_metadir', scalar => 'mount_phase_flex_vols', scalar => 'mount_phase_rootdir_for_iron', scalar => 'mount_phase_refcnt', scalar => 'mount_phase_rootdir', scalar => 'mount_phase_summary_map', scalar => 'mount_phase_snap_selfcover', scalar => 'mount_phase_status_of_previous_attempt', scalar => 'status_file_blks_total', scalar => 'status_file_volume', scalar => 'status_file_files', scalar => 'status_file_blks_used', scalar => 'iron_summary_scan_percentage', scalar => 'mnt_flexvols', scalar => 'blocks', scalar => 'files', scalar => 'mnt_metadir', scalar => 'mount_summary', scalar => 'opt_commit_option', scalar => 'isf_total_blks_reserve', scalar => 'mnt_snapinofiles', scalar => 'mnt_snapdir', scalar => 'mnt_rootdir_for_iron', scalar => 'isf_total_blks_use', scalar => 'mnt_rootdir', scalar => 'mnt_snapself', scalar => 'mnt_snapmap', scalar => 'luns', scalar => 'mnt_activemap', scalar => 'directories', scalar => 'private_inodes', scalar => 'mnt_summarymap', scalar => 'opt_commit_msg', scalar => 'prev_cp_option', scalar => 'mnt_fpametafile', scalar => 'volume', scalar => 'public_inodes', scalar => 'isf_total_files', scalar => 'vserver', scalar => 'host_volname', scalar => 'mnt_refcount', ]; sub isa { $Log->enter() if $may_enter; my ($pkg_or_obj, $kind) = @_; my $isa = $pkg_or_obj->_build_isa( kind => $kind, alias => 'NACL::CS::AggregateWafliron' ); $Log->exit() if $may_exit; return $isa; } =head1 METHODS =head2 fetch my $node_state = NACL::CS::StorageAggregateWafliron->fetch(command_interface=>$ci,...); my @node_states = NACL::CS::StorageAggregateWafliron->fetch(command_interface=>$ci,...); see L. Uses a CMode CLI or a 7Mode CLI or a Nodescope 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 = shift; my @state_objs = $pkg->SUPER::fetch( @_, show_cmd => 'storage aggregate wafliron show', choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode|Nodescope', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', check => "_check_cmode_zapi", }, ], exception_text => 'No matching wafliron 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 => 'storage_aggregate_wafliron_show'); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _fetch_7mode_cli { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = delete $opts{apiset}; my $requested_fields = delete $opts{requested_fields}; my $filter = delete $opts{filter}; my $aggr_args = $pkg->_hash_copy( source => $filter, copy => [qw(aggregate)], ); my ($response, $caught_exception); try { $response = $apiset->aggr_wafliron_status(%$aggr_args); } catch NACL::APISet::Exceptions::InvalidParamValueException with { $caught_exception = 1; }; if ($caught_exception) { $Log->exit() if $may_exit; return; } my $wafl_output = $response->get_parsed_output(); my @states; foreach my $row (@{$wafl_output}) { my $state_fields = $pkg->_zapi_hash_copy( source => $row, source_has_extra_arrays => 1, copy => [qw(aggregate status_of_previous_attempt)], map => [ "status" => "iron_status", ['mount_phase_info', 'snap_inofiles'] => "mount_phase_snap_inofiles", ['mount_phase_info', 'activemap'] => "mount_phase_activemap", ['mount_phase_info', 'snapmaps'] => "mount_phase_snapmaps", ['mount_phase_info', 'snapdir'] => "mount_phase_snapdir", ['mount_phase_info', 'metadir'] => "mount_phase_metadir", ['mount_phase_info', 'flex_vols'] => "mount_phase_flex_vols", ['mount_phase_info', 'rootdir_for_iron'] => "mount_phase_rootdir_for_iron", ['mount_phase_info', 'refcnt'] => "mount_phase_refcnt", ['mount_phase_info', 'rootdir'] => "mount_phase_rootdir", ['mount_phase_info', 'summary_map'] => "mount_phase_summary_map", ['mount_phase_info', 'snap_selfcover'] => "mount_phase_snap_selfcover", ['status_file_info', 'blks_total'] => "status_file_blks_total", ['status_file_info', 'volume'] => "status_file_volume", ['status_file_info', 'files'] => "status_file_files", ['status_file_info', 'blks_used'] => "status_file_blks_used", ['scan_stats_info', 'scanning'] => 'iron_scan_percentage' ], ); # Map to what CMode returns if (defined $state_fields->{iron_status} && ( $state_fields->{iron_status} =~ /not currently active/ || $state_fields->{iron_status} =~ /optional\s+commit\s+mode\s+has\s+completed/) ) { $state_fields->{iron_status} = 'not_running'; } ## end if ( defined $state_fields... if (defined $state_fields->{status_of_previous_attempt}) { $state_fields->{'iron-last-start-error-info'} = $state_fields->{status_of_previous_attempt}; if ($state_fields->{'iron-last-start-error-info'} =~ /Successful/i) { $state_fields->{'iron-last-start-errno'} = 0; } } else { $state_fields->{'iron-last-start-error-info'} = '-'; $state_fields->{'iron-last-start-errno'} = '-'; } my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => $state_fields); push @states, $obj; } ## end foreach my $row ( @{$wafl_output... $Log->exit() if $may_exit; return @states; } ## end sub _fetch_7mode_cli sub _fetch_cmode_zapi{ $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $map = { "iron-last-start-errno" => [ 'aggr-wafliron-attributes', 'last-start-errno' ], "iron-last-start-error-info" => [ 'aggr-wafliron-attributes', 'last-start-error-info' ], "iron-scan-percentage" => [ 'aggr-wafliron-attributes', 'scan-percentage' ], "iron-status" => [ 'aggr-wafliron-attributes', 'state' ], "iron-summary-scan-percentage" => [ 'aggr-wafliron-attributes', 'summary-scan-percentage' ], "aggregate" => 'aggregate-name' }; my @states; try { @states = $pkg->SUPER::_fetch_cmode_zapi( %opts, api => 'aggr-get-iter', map => $map, ); } catch NACL::APISet::Exceptions::ResponseException with { my $exception = shift; my $response_obj = $exception->get_response_object(); # The fix for burt 569514 made aggr-get-iter fail when searching # for a non-existant aggregate. In this case it fails with # # We catch this and suppress it (the front-end should decide whether # to turn this into a NoElementsFound or not) if ($response_obj->get_error_number() ne '13040') { $Log->exit() if $may_exit; $exception->throw(); } }; # when wafliron state is not_running # zapi call to aggr-get-iter do not # return any entry for wafliron-attributes # so in such a case making default value to # iron-status value as not_running unless (@states) { $Log->exit() if $may_exit; return $pkg->new( command_interface => $opts{command_interface}, iron_status => 'not_running' ); } $Log->exit() if $may_exit; return @states; } sub _check_cmode_zapi { $Log->enter() if $may_enter; my ( $pkg, %opts ) = @_; my $filter = $opts{filter}; my @requested = @{$opts{requested_fields}}; my @valid_field_zapi = (qw(iron-status iron-scan-percentage iron-last-start-errno iron-last-start-error-info)) ; my (@unmatched_filter_arr, @unmatched_request_arr ) ; map{ my $val = $_; push @unmatched_filter_arr , $val if(! grep( /$val/, @valid_field_zapi)) ; } keys %{$filter} ; map{ my $val = $_ ; push @unmatched_request_arr , $val if(! grep( /$val/, @valid_field_zapi)); } @requested ; my $unsupported_fields = join (',', @unmatched_filter_arr); $unsupported_fields .= join (',', @unmatched_request_arr); if(@unmatched_filter_arr || @unmatched_request_arr){ $Log->exit() if $may_exit; NACL::Exceptions::InvalidChoice->throw("$unsupported_fields is not supported " . "by 'aggr-get-iter' ZAPI in NACL::CS::StorageAggregate, hence ZAPI cannot be used. "); } $Log->exit() if $may_exit; } 1;