# $Id$ # # Copyright (c) 2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary SystemNodeCoredumpSegment ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com , gupendra@netapp.com, raghaveb@netapp.com, benjaram@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SystemNodeCoredumpSegment =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP SystemNodeCoredumpSegment. A related class is L, which represents access to an ONTAP SystemNodeCoredumpSegment. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the SystemNodeCoredumpSegment element are the attributes of the SystemNodeCoredumpSegment ComponentState. Additionally, the command_interface used to obtain the ComponentState object is also an attribute of the object. This makes it easier to obtain the component object corresponding to the CS object, using L. =over =item command_interface The command_interface with which the CS object was obtained. (Available in all CS objects regardless of requested_fields and the mode/interface) =item C<< segment >> Filled in for CMode CLI/ZAPI and 7Mode CLI/ZAPI. =item C<< node >> Filled in for CMode CLI/ZAPI and 7Mode CLI/ZAPI. =item C<< owner_node >> Filled in for CMode CLI/ZAPI and 7Mode CLI/ZAPI. =item C<< panic_system_id >> Filled in for CMode CLI/ZAPI and 7Mode CLI/ZAPI. =item C<< segment_directory >> Filled in for CMode CLI/ZAPI and 7Mode CLI/ZAPI. =item C<< total_segment_count >> Filled in for CMode CLI/ZAPI and 7Mode CLI/ZAPI. =item C<< segment_name >> Filled in for CMode CLI/ZAPI and 7Mode CLI/ZAPI. =item C<< panic_time >> Filled in for CMode CLI/ZAPI and 7Mode CLI/ZAPI. =item C<< md5_data_chksum >> Filled in for CMode CLI/ZAPI and 7Mode CLI/ZAPI. =back =cut package NACL::CS::SystemNodeCoredumpSegment; use strict; use warnings; use Params::Validate qw(validate validate_pos HASHREF); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NATE::BaseException qw(:try); use NACL::Exceptions::NoElementsFound qw(:try); use NACL::C::Exceptions::SystemNodeCoredumpSegment::NotSupportedForThisPlatform ( ); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'segment', scalar => 'node', scalar => 'owner_node', scalar => 'panic_system_id', scalar => 'segment_directory', scalar => 'total_segment_count', scalar => 'segment_name', scalar => 'panic_time', scalar => 'md5_data_chksum', ]; =head1 METHODS =head2 fetch my $SystemNodeCoredumpSegment_state = NACL::CS::SystemNodeCoredumpSegment->fetch(command_interface => $ci, ...); my @SystemNodeCoredumpSegment_states = NACL::CS::SystemNodeCoredumpSegment->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, 7Mode CLI/ZAPI APISet. This method executes core-segment-config-get for 7Mode ZAPI This method executes core-segment-get-iter for CMode ZAPI =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, @args) = @_; my @state_objs = $pkg->SUPER::fetch( @args, 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' }, { method => '_fetch_7mode_zapi', interface => 'ZAPI', set => '7Mode' }, ], exception_text => 'No matching system node coredump segment(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, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@args, api => 'system_node_coredump_segment_show',); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @args, api => 'core-segment-get-iter', copy => [ qw( segment total-segment-count segment-name panic-time panic-system-id owner-node node md5-data-chksum ) ] ); } ## 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 $apiset = $opts{apiset}; my $command_interface = $opts{command_interface}; my %filter = %{$opts{filter}}; my $node; my $delete_cmode_only_options = sub { # Not applicable for 7Mode my ($hashref) = validate_pos(@_, {type => HASHREF}); $node = delete $hashref->{node}; delete $hashref->{'owner-node'}; }; $delete_cmode_only_options->(\%filter); my %api_args; while (my ($key, $value) = each %filter) { $api_args{$key} = $value; } my %requested_fields; map { $requested_fields{$_} = 1 } @{$opts{requested_fields}}; $delete_cmode_only_options->(\%requested_fields); my @final_req_field = keys %requested_fields; if (@final_req_field) { $api_args{fields} = join ',', @final_req_field; } my ($response, $caught_exception); try { $response = $apiset->coredump_segment_show(%api_args); } catch NACL::APISet::Exceptions::CommandFailedException with { my $exception = $_[0]; if (NACL::C::Exceptions::SystemNodeCoredumpSegment::NotSupportedForThisPlatform ->detect( exception => $exception ) ) { $Log->exit() if $may_exit; NACL::C::Exceptions::SystemNodeCoredumpSegment::NotSupportedForThisPlatform ->convert_and_throw(exception => $exception); } elsif ( $exception->isa( 'NACL::APISet::Exceptions::NoMatchingEntriesException') ) { $caught_exception = 1; } }; if ($caught_exception) { $Log->exit() if $may_exit; return; } my $output = $response->get_parsed_output(); my @state_objs; foreach my $row (@$output) { my $obj = $pkg->new( command_interface => $command_interface, node => $node ); $obj->_set_fields(row => $row); push @state_objs, $obj; } ## end foreach my $list_output (@$output) $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli sub _fetch_7mode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my @state_objs; my $apiset = $opts{apiset}; my $command_interface = $opts{command_interface}; my @copy_requested_fields = @{$opts{requested_fields}}; my (%desired_attributes_hash, %core_options); foreach (@copy_requested_fields) { $desired_attributes_hash{$_} = 1; } if (keys %desired_attributes_hash) { $core_options{'desired-attributes'} = {%desired_attributes_hash}; } my $response = $apiset->core_segment_get_iter(%core_options); my $output = $response->get_parsed_output(); foreach my $list_output ( @{$output->[0]{'attributes-list'}[0]{'core-segment-info'}}) { my $target = $pkg->_hash_copy( source => $list_output, copy => [ qw(segment node owner-node panic-system-id total-segment-count segment-name panic-time md5-data-chksum) ], ); my $obj = $pkg->new(command_interface => $command_interface,); $obj->_set_fields(row => $target); push @state_objs, $obj; } ## end foreach my $list_output (@$output) $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_zapi 1;