# # Copyright (c) 2001-2010 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary StoragePath ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::StoragePath =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP StoragePath. A related class is L, which represents access to an ONTAP StoragePath. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the StoragePath element are the attributes of the StoragePath ComponentState. =over =item C<< "path_io_kbps" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "path-io-kbps" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "path-io-kbps" in the output of CLI "storage-path-show" =item C<< "target_io_kbps" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "target-io-kbps" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "target-io-kbps" in the output of CLI "storage-path-show" =item C<< "node" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "node" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "node" in the output of CLI "storage-path-show" =item C<< "path_lun_in_use_count" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "path-lun-in-use-count" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "path_lun_in_use_count" in the output of CLI "storage-path-show" =item C<< "target_iops" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "target-iops" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "target-iops" in the output of CLI "storage-path-show" =item C<< "array_name" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "array-name" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "array-name" in the output of CLI "storage-path-show" =item C<< "target_side_switch_port" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "target-side-switch-port" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "target-side-switch-port" in the output of CLI "storage-path-show" =item C<< "port_speed" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "initiator-port-speed" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "initiator-port-speed" in the output of CLI "storage-path-show" =item C<< "initiator_side_switch_port" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "initiator-side-switch-port" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "initiator-side-switch-port" in the output of CLI "storage-path-show" =item C<< "path_iops" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "path_iops" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "path_iops" in the output of CLI "storage-path-show" =item C<< "initiator_lun_in_use_count" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "initiator_lun_in_use_count" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "initiator_lun_in_use_count" in the output of CLI "storage-path-show" =item C<< "path_link_errors" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "path-link-errors" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "path-link-errors" in the output of CLI "storage-path-show" =item C<< "initiator_iops" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "initiator_iops" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "initiator_iops" in the output of CLI "storage-path-show" =item C<< "path_quality" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "path-quality" in the output of ZAPI "storage-initiator-path-list-info" Cmode CLI: Accessible through the field "path-quality" in the output of CLI "storage-path-show" =item C<< "target_wwpn" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "target-wwpn" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "target-wwpn" in the output of CLI "storage-path-show" =item C<< "initiator" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "initiator-port" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "initiator-port" in the output of CLI "storage-path-show" =item C<< "tpgn" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "tpgn" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "tpgn" in the output of CLI "storage-path-show" =item C<< "target_lun_in_use_count" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "target-lun-in-use-count" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "target-lun-in-use-count" in the output of CLI "storage-path-show" =item C<< "initiator_io_kbps" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "initiator_io_kbps" in the output of ZAPI "storage-initiator-path-list-info" CMode CLI: Accessible through the field "initiator_io_kbps" in the output of CLI "storage-path-show" =item C<< vmdisk_device_id >> Virtual disk device id Filled in for CMode CLI. =back =cut package NACL::CS::StoragePath; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw(_dump_one Dumper); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NACL::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'path_io_kbps', scalar => 'target_io_kbps', scalar => 'node', scalar => 'path_lun_in_use_count', scalar => 'target_iops', scalar => 'array_name', scalar => 'target_side_switch_port', scalar => 'port_speed', scalar => 'initiator_side_switch_port', scalar => 'path_iops', scalar => 'initiator_lun_in_use_count', scalar => 'path_link_errors', scalar => 'initiator_iops', scalar => 'path_quality', scalar => 'target_wwpn', scalar => 'initiator', scalar => 'tpgn', scalar => 'target_lun_in_use_count', scalar => 'initiator_io_kbps', scalar => 'lun_number', scalar => 'vmdisk_device_id', ]; =head1 METHODS =head2 fetch my $StoragePath_state = NACL::CS::StoragePath->fetch(command_interface => $ci, ...); my @StoragePath_states = NACL::CS::StoragePath->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. =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', }, ], exception_text => 'No matching storage path(s) found', show_cmd => 'storage path 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 => 'storage_path_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 = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $caught_exception; my $ci_response; my %ci_list_info_args; my %cmd_args; # Displays the antivirus engine and its configuration. if (defined $opts{filter}->{node}) { $cmd_args{node} = $opts{filter}->{node}; } try { $ci_response = $apiset->storage_initiator_path_list_info(%cmd_args); } catch NACL::APISet::Exceptions::ResponseException with { # A caught exception indicates that the storage path being looked for # does not exist. We catch the exception and return immediately. The # 'fetch' frontend decides whether to throw a NoElementsFound # exception based on the value of 'allow_empty' $caught_exception = 1; }; if ($caught_exception) { $Log->exit() if $may_exit; return; } my $ci_output = $ci_response->get_parsed_output(%cmd_args); $Log->debug(Dumper($ci_output)); my @state_objs; my @output = (); if ($opts{command_interface}->version_manager()->is_version_ge(release => '8.3.1')){ @output = @{$ci_output->[0]->{'path-info'}->[0]->{'storage-initiator-path-info'}} if(keys %{$ci_output->[0]}); }else{ @output = @{$ci_output->[0]->{'path-info'}->[0]->{'path-info'}} if(keys %{$ci_output->[0]}); } foreach my $row (@output) { my $state_fields = $pkg->_zapi_hash_copy( source => $row, source_has_extra_arrays => 1, copy => [qw(node)], map => [ "array-name" => "array_name", "initiator-io-kbps" => "initiator-io-kbps", "initiator-iops" => "initiator-iops", "initiator-lun-in-use-count" => "initiator-lun-in-use-count", "initiator-port" => "initiator", "initiator-port-speed" => "port-speed", "initiator-side-switch-port" => "initiator-side-switch-port", "path-io-kbps" => "path-io-kbps", "path-iops" => "path-iops", "path-link-errors" => "path-link-errors", "path-lun-in-use-count" => "path-lun-in-use-count", "path-quality" => "path-quality", "target-io-kbps" => "target-io-kbps", "target-iops" => "target-iops", "target-lun-in-use-count" => "target-lun-in-use-count", "target-side-switch-port" => "target-side-switch-port", "target-wwpn" => "target-wwpn", "tpgn" => "tpgn", ], ); my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => $state_fields); push @state_objs, $obj; } ## end foreach my $row ( @{ $ci_output... $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi 1;