# $Id$ # # Copyright (c) 2001-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary StorageFirmware Component Module (auto-generated by CGT) ## @author sangavai@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::C::StorageFirmware =head1 DESCRIPTION C is a derived class of L. Unlike other components this package does not model any element/service but is present to provide component-level support for functionality. Since CMode does not model any element/service there is no ComponentState module for this component. For the same reason, 'find' and 'state' will not work for this component. For 7Mode the NACL::CS::StorageDownload is used in this component to find the status of the download. =cut package NACL::C::StorageFirmware; use strict; use warnings; use NACL::ComponentUtils qw (_optional_scalars); use base 'NACL::C::Component::ONTAP'; use Params::Validate qw(validate validate_with SCALAR ARRAYREF); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use Data::Dumper; use NACL::CS::StorageDownload; use NATE::BaseException; use NATE::Exceptions::Argument; =head2 download NACL::C::StorageFirmware->download( command_interface => $ci, ...); (Class method) This method is used to download firmware. CMode CLI downloads the firmware from the server to the filer configuration path. Uses a CMode CLI APIset 'storage_firmware_download'. The package-type can be disk, shelf, acp and all. 7Mode CLI downloads the firmware from the filer configuration path to the respective device( disk, shelf, acp). The 7Mode CLI APIset called are 'storage_download_acp' for package-type acp. 'disk_fw_update' for package-type disk. 'storage_download_shelf' for package-type shelf. =over =item Options =over =item C<< command_interface => $command_interface >> (Required) See L =item C<< apiset_must => $ruleset >> (Optional) See L =item C<< apiset_should => $ruleset >> (Optional) See L =item C<< "sequence" => $string >> (Optional) Applicable only for CMode CLI. =item C<< "node" => $string >> Applicable only for CMode CLI. =item C<< "user" => $user >> (Required for CMode Only) Applicable only for CMode CLI. =item C<< "password" => $pwd >> (Required for CMode only) Applicable only for CMode CLI. =item C<< "package" => $string >> (Optional) Applicable only for CMode CLI. =item C<< 'package-url' => $string >> (Required) Applicable only for CMode CLI. =item C<< 'package-type' => $string >> Applicable for CMode CLI and 7Mode/Nodescope CLI. Note that from SN.1 CMode this option was removed from ONTAP, so if a call is made with this option provided it will be dropped for SN.1 and later releases. See burt 655079. =item C<< 'qual-mode' => $boolean >> (Optional) Starts download qualification test. Firmware will be downloaded continuously to all disk shelves. Applicable only for 7Mode CLI. Maps to: 7M CLI : -Q (Programmatic name: "qual-mode") =item C<< 'stop' => $boolean >> (Optional) Stops download qualification test. Applicable only for 7Mode CLI. Maps to: 7M CLI : -S (Programmatic name: "stop") =item C<< 'revert' => $boolean >> (Optional) Allows the firmware to be reverted to the version shipped with the current Data ONTAP release. Applicable only for 7Mode CLI. Maps to: 7M CLI : -R (Programmatic name: "revert") =item C<< 'jake-reboot' => $boolean >> (Optional) Used only when the package type is shelf Attached shelved will be rebooted continuously. Applicable only for 7Mode CLI. Maps to: 7M CLI : -M (Programmatic name: "jake-reboot") =item C<< 'force-firmware' => $boolean >> (Optional) Force download of specific firmware files to matching modules. Applicable only for 7Mode CLI. Maps to: 7M CLI : -F (Programmatic name: "force-firmware") =item C<< 'file-name' => $string >> (Optional) Firmware filename to be downloaded Used only when the force-firmware is used. Applicable only for 7Mode CLI. Maps to: 7M CLI : file name (Programmatic name: "file name") =item C<< 'shelf-name' => $string >> (Optional) Used only when the package type is shelf Shelf name respresented as .shelf Example : 0a.shelf0 Applicable only for 7Mode CLI. Maps to: 7M CLI : shelf name (Programmatic name: "shelf-name") =item C<< 'channel-name' => $string >> (Optional) Adapter name to which shelves are attached. Example : 0c, 0d Applicable only for 7Mode CLI. Maps to: 7M CLI : -H (Programmatic name: "channel-name") =item C<< 'enclosure-type' => $string >> (Optional) Used only when the package type is shelf Enclosure type like ESAS,IOM3,ESH2 etc. Applicable only for 7Mode CLI. Maps to: 7M CLI : -T (Programmatic name: "enclosure-type") =item C<< 'enclosure-id' => $string >> (Optional) Used only when the package type is shelf Shelf id (numeral) Applicable only for 7Mode CLI. Maps to: 7M CLI : -E (Programmatic name: "enclosure-id") =item C<< 'shelf-module' => $string >> (Optional) Used only when the package type is acpp Specified by triplet .. Applicable only for 7Mode CLI. Maps to: 7M CLI : shelf module (Programmatic name: "shelf-module") =item C<< 'disk-list' => $string >> (Optional) Applicable for 7mode only. Used only when the package type is disk List of disk names. Applicable only for 7Mode CLI. Maps to: 7M CLI : disk list (Programmatic name: "disk-list") =item C<< 'product-id' => $string >> (Optional) Used only when the package type is disk The firmware file name is in the form of product_ID.revision.LOD. The first field in firmware file name is the product id. Applicable only for 7Mode CLI. Maps to: 7M CLI : product id (Programmatic name: "product-id ") =item C<< 'extended_query' => $string >> (Optional) Applicable only for CMode CLI. =item C<< other_options >> This method takes other common options described in L =item C<< '*' >> This method takes all other options supported by "storage firmware download" command in ONTAP. Applicable for CMode CLI. =back =back =over =item Exceptions =over =item C In general, Component methods propagate the exceptions thrown from underlying API layer and the details of those exceptions are described in the L of user guide. =back =back =cut sub download { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->_frontend_log_debug_opts(@args); my %opts = $pkg->_common_validate_with( params => \@args, additional_spec => { _optional_scalars( qw( sequence node package package-url package-type qual-mode stop revert jake-reboot force-firmware file-name shelf-name channel-name enclosure-type enclosure-id shelf-module disk-list product-id user password ) ), }, ignore_primary_keys => 1, api => 'storage_firmware_download', ); my $ret = $pkg->call_on_apiset( %opts, choices => [ { method => "_download_cmode_cli", interface => "CLI", set => "CMode", }, { method => "_download_7mode_cli", interface => "CLI", set => "7Mode|Nodescope", }, ], frontend => 'NACL::C::StorageFirmware::download', ); $Log->exit() if $may_exit; return $ret; } ## end sub download sub _download_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = $pkg->_validate_backend_opts(@args); my $user = $opts{user}; my $pwd = $opts{password}; if (!$user || !$pwd) { $Log->exit() if $may_exit; NATE::Exceptions::Argument->throw("User or Password is null"); } my @prompts_answers = ( 'Enter User:' => $user, 'Enter Password:' => $pwd, ); my %additional_args; $additional_args{'connectrec-match_table'} = \@prompts_answers; # "package-type" was removed in SN.1. See burt 655079. delete $opts{'package-type'}; $pkg->_base_backend_cmode_cli( %opts, api => 'storage_firmware_download', additional_args => \%additional_args ); $Log->exit() if $may_exit; } ## end sub _download_cmode_cli sub _download_7mode_cli { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate_with( params => \@_, spec => $pkg->_backend_validate_spec(), allow_extra => 1 ); my $command_interface = delete $opts{command_interface}; my $apiset = delete $opts{apiset}; my $allowed_7mode_options; if ($opts{'package-type'} =~ /shelf/i) { # Either qual-mode or stop or revert or jake-reboot or file-name can be given. # But the above process can be run one at a time. # If force-firmware is used, then filename should be given # If none of the above operation is given then the basic command will be executed $allowed_7mode_options = [ qw ( qual-mode stop revert jake-reboot force-firmware file-name shelf-name channel-name enclosure-type enclosure-id ) ]; $opts{'force-firmware'} = 1 if ($opts{'file-name'}); } elsif ($opts{'package-type'} =~ /acp/i) { $allowed_7mode_options = [ qw ( revert qual-mode stop force-firmware file-name shelf-module ) ]; $opts{'force-firmware'} = 1 if ($opts{'file-name'}); } elsif ($opts{'package-type'} =~ /disk/i) { $opts{'qual-test'} = delete $opts{'qual-mode'} if ($opts{'qual-mode'}); $opts{'firmware-file'} = delete $opts{'file-name'} if ($opts{'file-name'}); $allowed_7mode_options = [ qw (firmware-file disk-list product-id qual-test revert stop )]; } elsif ($opts{'package-type'} =~ /all/i) { NATE::BaseException->throw( "The package-type all is not supported in 7Mode"); } my $response; if ($opts{'package-type'}) { my %mode_args; $pkg->_hash_copy( source => \%opts, copy => $allowed_7mode_options, target => \%mode_args, ); $mode_args{force} = 1; if ($opts{'package-type'} =~ /shelf/) { if ($opts{'stop'}) { my @prompts_answers = ( '.*Are you sure you want to stop shelf firmware download qualification test*' => 'y',); $response = $apiset->storage_download_shelf( 'stop' => '1', 'connectrec-match_table' => \@prompts_answers, ); } else { $response = $apiset->storage_download_shelf(%mode_args); } } elsif ($opts{'package-type'} =~ /acp/) { delete $mode_args{force}; my @prompts_answers = ( '.*Are you sure you want to continue with ACP processor firmware update*' => 'y',); $mode_args{'connectrec-match_table'} = \@prompts_answers; $response = $apiset->storage_download_acp(%mode_args); } elsif ($opts{'package-type'} =~ /disk/) { $response = $apiset->disk_fw_update(%mode_args); } my $output = $response->get_parsed_output(); my $state = $output->[0]->{status}; if ($state) { my $obj = NACL::CS::StorageDownload->new( command_interface => $command_interface, status => $state, ); return $obj; } } $Log->exit() if $may_exit; } ## end sub _download_7mode_cli __PACKAGE__->_load_event_class(); sub _primary_keys_validate_spec { return (); } 1;