# $Id: //depot/prod/test/nacldev/lib/NACL/CS/SystemNodeServiceProcessorImage.pm# $ # # Copyright (c) 2001-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary SystemNodeServiceProcessorImage ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com,skotagir@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SystemNodeServiceProcessorImage =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP SystemNodeServiceProcessorImage. A related class is L, which represents access to an ONTAP SystemNodeServiceProcessorImage. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the SystemNodeServiceProcessorImage element are the attributes of the SystemNodeServiceProcessorImage 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<< status >> Image Status, possible value(s) are Installed,Corrupt,Updating,Auto-Updating,None Filled in for CMode CLI/ZAPI,7Mode CLI Maps to: 7M CLI : status CM ZAPI: $status =item C<< version >> Firmware Version Filled in for CMode CLI/ZAPI Maps to: CM ZAPI: $version =item C<< name >> Installed Firmware Filled in for CMode CLI/ZAPI Maps to: CM ZAPI: $name =item C<< node >> Node Filled in for CMode CLI/ZAPI, 7Mode CLI For CMode ZAPI , If node name is not specified, then it will be picked up from AA the hostname attribute of hostrec object present in the command_interface passed. Maps to: 7M CLI : -node (Programmatic name: 'nodename') CM ZAPI: $node =item C<< autoupdate >> Firmware Autoupdate, possible value(s) are true,false Filled in for CMode CLI/ZAPI, 7Mode CLI Maps to: 7M CLI : autoupdate CM ZAPI: $autoupdate =item C<< image >> Image, possible value(s) are primary,backup Filled in for CMode CLI/ZAPI, 7Mode CLI Maps to: 7M CLI : image CM ZAPI: $image =item C<< type >> Type, possible value(s) are BMC,RLM,SP Filled in for CMode CLI/ZAPI, 7Mode CLi Maps to: 7M CLI : type CM ZAPI: $type =item C<< is_current >> Is Image Current, possible value(s) are true,false Filled in for CMode CLI/ZAPI,7Mode CLI Maps to: 7M CLI : is_current CM ZAPI: $is_current =item C<< last_update_status >> Last Update Status, possible value(s) are Failed,Passed Filled in for CMode CLI/ZAPI,7Mode CLI. Maps to: 7M CLI : last_update_status CM ZAPI: $last_update_status =item C<< last_installed_version >> Last Installed Firmware Version Filled in for CMode CLI/ZAPI,7Mode CLI. Maps to: 7M CLI : last_installed_version CM ZAPI: $last_installed_version =item C<< running_version >> Running Firmware Version Filled in for CMode CLI/ZAPI,7Moce CLI. Maps to: 7M CLI : running_version CM ZAPI: $running_version =back =cut package NACL::CS::SystemNodeServiceProcessorImage; 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::_Mixins::SystemNodeServiceProcessor qw(:all); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'status', scalar => 'version', scalar => 'name', scalar => 'node', scalar => 'autoupdate', scalar => 'image', scalar => 'type', scalar => 'is_current', scalar => 'last_update_status', scalar => 'last_installed_version', scalar => 'running_version', ]; =head1 METHODS =head2 fetch my $SystemNodeServiceProcessorImage_state = NACL::CS::SystemNodeServiceProcessorImage->fetch(command_interface => $ci, ...); my @SystemNodeServiceProcessorImage_states = NACL::CS::SystemNodeServiceProcessorImage->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 APISet. Invokes "system node service-processor image show" command for 7Mode CLI Invokes "service-processor-firmware-get" api 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. =item C When apiset_must choice for interface is provided as 'ZAPI' and if the method is invoked without specifying 'node' in the 'filter' or if the method is invoked with special query characters in the filter, 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_7mode_cli', interface => 'CLI', set => '7Mode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', check => '_fetch_zapi_check', } ], exception_text => 'No matching system node service-processor image(s) found', show_cmd => 'system node service-processor image show', ); $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 => 'system_node_service_processor_image_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, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $command_interface = delete $opts{command_interface}; my $apiset = delete $opts{apiset}; my %copy_filter = %{$opts{filter}}; my @copy_requested_fields = @{$opts{requested_fields}}; $pkg->_remove_relational_regex_filters( filter => \%copy_filter, requested_fields => \@copy_requested_fields ); my %apiset_opts = (); if (scalar(keys %copy_filter)) { %apiset_opts = %copy_filter; } if (scalar(@copy_requested_fields)) { $apiset_opts{fields} = join(',', @copy_requested_fields); } else { # APISets returns parsed output when -instance is specified, # hence adding that option by default. $apiset_opts{'instance'} = 1 } if (exists $apiset_opts{'node'}) { $apiset_opts{'nodename'} = delete $apiset_opts{'node'}; } my @state_objs; my $response = $apiset->system_node_service_processor_image_show(%apiset_opts); my $list_output = $response->get_parsed_output(); foreach my $output (@{$list_output}) { my $target = $pkg->_hash_copy( source => $output, copy => [ qw(node type image last_update_status last_installed_version is_current running_version status autoupdate ) ], map => { 'image_status' => 'status', 'is_image_current' => 'is_current', 'running_firmware_image' => 'running_version', 'firmware_autoupdate' => 'autoupdate', 'last_installed_firmware_version' => 'last_installed_version', }, ); my $obj = $pkg->new(command_interface => $command_interface,); $obj->_set_fields(row => $target); push @state_objs, $obj; } ## end foreach my $output (@$list_output) $Log->exit() if $may_exit; return @state_objs; } ## 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 $apiset = $opts{apiset}; my @state_objs; my @requested_fields = @{$opts{requested_fields}}; my (%desired_attributes_hash, %sp_options); foreach (@requested_fields) { $desired_attributes_hash{$_} = 1; } if (keys %desired_attributes_hash) { $sp_options{'desired-attributes'} = {%desired_attributes_hash}; } my $args = $pkg->_hash_copy( source => $opts{filter}, copy => [qw(node)], ); my $image_response = $apiset->service_processor_image_get(%$args, %sp_options); my $image_output = $image_response->get_parsed_output(); foreach my $row ( @{$image_output->[0]{'attributes'}[0]{'service-processor-image'}}) { my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => $row); push @state_objs, $obj; } ## end foreach my $row ( @{ $gpo_output... $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi 1;