# # Copyright (c) 2001-2012 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->show_resync_status() (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::StorageAggregateShowResyncStatus =head1 DESCRIPTION C is a derived class of L. Object(s) of this type are returned when NACL::C::StorageAggregate->show_resync_status() is invoked. ((This module does not represent the state of any element, but is an object repesentation of the output obtained when NACL::C::StorageAggregate->show_resync_status() is invoked.) =head1 ATTRIBUTES The fields of the output are fields of the ComponentState object. =over =item C<< plex >> Filled in for CMode CLI, 7Mode CLI. =item C<< is_online >> Filled in for CMode CLI/ZAPI, 7Mode CLI. =item C<< is_resyncing >> Filled in for CMode CLI/ZAPI, 7Mode CLI. =item C<< in_progress >> Filled in for CMode CLI, 7Mode CLI. =item C<< aggregate >> Filled in for CMode CLI/ZAPI, 7Mode CLI. =item C<< resyncing_percent >> Filled in for CMode CLI/ZAPI, 7Mode CLI. =item C<< pool >> Filled in for CMode CLI/ZAPI, 7Mode CLI. =item C<< status >> Filled in for CMode CLI, 7Mode CLI. Maps to: CMode ZAPI: plex-status =item C<< resync_level >> Filled in for CMode CLI/ZAPI, 7Mode CLI. =item C<< plex_path >> Filled in for CMode CLI, 7Mode CLI. =back =cut package NACL::CS::StorageAggregateShowResyncStatus; 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::CS::StorageAggregatePlex; use NACL::Exceptions::NoElementsFound qw(:try); use NACL::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::CS::ComponentState::ZapiArray qw(make_zapi_array); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'plex', scalar => 'is_online', scalar => 'is_resyncing', scalar => 'in_progress', scalar => 'aggregate', scalar => 'resyncing_percent', scalar => 'pool', scalar => 'status', scalar => 'resync_level', scalar => 'plex_path', ]; =head1 METHODS =head2 fetch my $StorageAggregateShowResyncStatus_state = NACL::CS::StorageAggregateShowResyncStatus->fetch(command_interface => $ci, ...); my @StorageAggregateShowResyncStatus_states = NACL::CS::StorageAggregateShowResyncStatus->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 "aggr-get-iter" API for CMode ZAPI. Invokes "raid_config info listplex" command 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() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, 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' } ], show_cmd => 'storage aggregate show-resync-status', exception_text => 'No matching storage aggregate(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 => 'storage_aggregate_show_resync_status',); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg,%opts) = @_; my @state_objs; try{ @state_objs = $pkg->SUPER::_fetch_cmode_zapi( %opts, api => "aggr_get_iter", suppress_type_warning => 1, requested_fields => [qw(plex is-resyncing resyncing-percent is-online pool resync-level status)], map => { "aggregate" => 'aggregate-name', "plex" => [ 'aggr-raid-attributes', make_zapi_array('plexes'), make_zapi_skip('plex-attributes'), 'plex-name', ], "is-resyncing" => [ 'aggr-raid-attributes', make_zapi_array('plexes'), make_zapi_skip('plex-attributes'), 'is-resyncing', ], "resyncing-percent" => [ 'aggr-raid-attributes', make_zapi_array('plexes'), make_zapi_skip('plex-attributes'), 'resyncing-percentage', ], "status" => [ 'aggr-raid-attributes', make_zapi_array('plexes'), make_zapi_skip('plex-attributes'), 'plex-status', ], "is-online" => [ 'aggr-raid-attributes', make_zapi_array('plexes'), make_zapi_skip('plex-attributes'), 'is-online', ], "pool" => [ 'aggr-raid-attributes', make_zapi_array('plexes'), make_zapi_skip('plex-attributes'), 'pool', ], "resync-level" => [ 'aggr-raid-attributes', make_zapi_array('plexes'), make_zapi_skip('plex-attributes'), 'resync-level', ], }, ); } catch NACL::APISet::Exceptions::ResponseException with { my $exception = shift; my $response_obj = $exception->get_response_object(); if ($response_obj->get_error_number() ne '13040') { $Log->exit() if $may_exit; $exception->throw(); } }; #ZAPI returns the fields in a typedef array, while CLI returns these # fields as scalar. Hence converting each of these fields into scalars # for a particular aggregate my @modified_obj; foreach my $state_obj_mod (@state_objs) { my $aggregate = $state_obj_mod->aggregate(); my $no_of_elements = 0; $no_of_elements = scalar @{$state_obj_mod->plex()} if(!($state_obj_mod->plex() =~ /[-]/)); while ($no_of_elements) { my $new_obj = $pkg->new(command_interface => $opts{'command_interface'}); $new_obj->{aggregate} = $aggregate; foreach my $option ('plex', 'resyncing_percent','is_resyncing', 'is_online', 'pool', 'resync_level','status') { if (defined $state_obj_mod->{$option}) { if (ref($state_obj_mod->{$option}) !~ /ARRAY/i) { $new_obj->{$option} = $state_obj_mod->{$option}; } else { my $value = shift $state_obj_mod->{$option}; $new_obj->{$option} = $value; } } } $no_of_elements--; push(@modified_obj, $new_obj); } } $Log->exit() if $may_exit; return @modified_obj; } ## end sub _fetch_cmode_zapi sub _fetch_7mode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my @state_objs; my $filter = $opts{filter}; my $requested_fields = $opts{requested_fields}; my $cmode_options = [ qw( plex plex_path is_online is_resyncing in_progress status pool aggregate resyncing_percent resync_level ) ], my @plex_objs = NACL::CS::StorageAggregatePlex->fetch( command_interface => $opts{command_interface}, apiset_should => {interface => 'CLI'}, filter => $filter, requested_fields => $requested_fields, ); my $state_fields; foreach my $obj (@plex_objs) { foreach my $attr (@$cmode_options) { my $attr_isset = $attr . '_isset'; if ($obj->$attr_isset) { $state_fields->{$attr} = $obj->$attr; } } my $obj = $pkg->new(command_interface => $opts{command_interface},); $obj->_set_fields(row => $state_fields); push @state_objs, $obj; } ## end foreach $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli 1;