# # Copyright (c) 2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # # ## @summary Multipath ComponentState Module ## @author sshaik@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here ################################################################################ =head1 NAME NACL::CS::Client::Multipath =head1 DESCRIPTION C is a derived class of L. It represents the state of Multipath element. A related class is L, which represents access to a Multipath element. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Multipath element are the individual attributes of the Multipath ComponentState =over =item C<< "wwid" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "status" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "device" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "devnode" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "priority" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "path_selector" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "chk_st" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "dev_t">> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "device_status">> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "dm_st" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "hcil" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "features" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "size" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<<"hardware_handler" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "wp" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "vend" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "product" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =item C<< "paths" >> Filled in for Linux CLI. Maps to: Linux CLI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =back =cut ################### # Package package NACL::CS::Client::Multipath; ################### # Everytime use strict; use warnings; ################### # Module includes use Params::Validate qw (validate validate_with HASHREF ARRAYREF OBJECT); use NACL::ComponentUtils qw (_optional_scalars Dumper); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use base 'NACL::CS::ComponentState::Client'; use NACL::Exceptions::NoElementsFound qw(:try); use NACL::APISet::Exceptions::InvalidParamValueException qw(:try); use Class::MethodMaker [ scalar => "priority", scalar => "device", scalar => "status", scalar => "path_selector", scalar => "chk_st", scalar => "dev_t", scalar => "device_status", scalar => "dm_st", scalar => "hcil", scalar => "features", scalar => "size", scalar => "wwid", scalar => "devnode", scalar => "hardware_handler", scalar => "wp", scalar => "vend", scalar => "product", array => "paths", ]; =head1 METHODS =head2 fetch my $lun_state = NACL::CS::Client::Multipath->fetch(command_interface=>$ci,...); my @lun_states = NACL::CS::Client::Multipath->fetch(command_interface=>$ci,...); see L Supports Linux. Invokes "multipath" command for Linux CLI. =cut sub fetch { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => "_fetch_linux_cli", interface => "CLI", set => 'Linux' }, ], exception_text => 'No multipath found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_linux_cli { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $filter = delete $opts{filter}; my ( @state_objs, $output); my %api_args; $output = $apiset->multipath('all-topology-info' => 1, 'privilege-level' => 'root', %$filter)->get_parsed_output(); foreach my $row (@$output) { my ($obj,@path_info); foreach my $path (@{$row->{paths}}) { my $device = '/dev/'. delete $path->{dev}; $obj = $pkg->new( command_interface => $opts{command_interface}, device => $device ); $obj->_set_fields( row => $path ); push @path_info,$obj; } delete $row->{paths}; foreach my $info (@path_info) { $info->_set_fields( row => $row ); } push @state_objs, @path_info; } ## end foreach my $row (@$output) $Log->exit() if $may_exit; return @state_objs; } 1;