# # Copyright (c) 2001-2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary LunMapping ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::LunMapping =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP LunMapping. A related class is L, which represents access to an ONTAP LunMapping. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the LunMapping element are the attributes of the LunMapping 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<< protocol >> Igroup Protocol Type Filled in for CMode CLI. =item C<< initiators >> Initiators (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $initiators = $obj->initiators(); # $initiators contains a reference to the array of values my @initiators = $obj->initiators(); # @initiators contains the array of values If this field needs to be passed to the filter hash, the value for this field should be passed in as an arrayref # filter => { initiators = [ value1, value2...] } Filled in for CMode CLI. =item C<< initiator_group_vsa_enabled >> Filled in for CMode CLI. =item C<< node >> LUN Node Filled in for CMode CLI/ZAPI. =item C<< state >> LUN State Filled in for CMode CLI. =item C<< ostype >> Igroup OS Type possible value(s) are, solaris,windows,hpux,aix,linux,netware,vmware,openvms,xen,hyper_v Filled in for CMode CLI. =item C<< igroup >> Igroup Name Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: $value =item C<< lun >> LUN Name Filled in for CMode CLI. =item C<< qtree >> Qtree Name Filled in for CMode CLI. =item C<< vdisk_id >> Vdisk ID Filled in for CMode CLI. =item C<< vserver_uuid >> Vserver UUID Filled in for CMode CLI. =item C<< igroup_uuid >> Igroup UUID Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: $value =item C<< volume >> Volume Name Filled in for CMode CLI. =item C<< vserver >> Vserver Name Filled in for CMode CLI/ZAPI. =item C<< reporting_nodes >> Reporting Nodes (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $reporting_nodes = $obj->reporting_nodes(); # $reporting_nodes contains a reference to the array of values my @reporting_nodes = $obj->reporting_nodes(); # @reporting_nodes contains the array of values If this field needs to be passed to the filter hash, the value for this field should be passed in as an arrayref # filter => { reporting_nodes = [ value1, value2...] } Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: @values =item C<< portset_uuid >> Portset UUID Filled in for CMode CLI. =item C<< path >> LUN Path Filled in for CMode CLI/ZAPI. =item C<< portset >> Portset Binding Igroup Filled in for CMode CLI. =item C<< lun_uuid >> LUN UUID Filled in for CMode CLI/ZAPI. =item C<< alua >> ALUA possible value(s) are, true,false Filled in for CMode CLI. =item C<< initiator_group_throttle_borrow >> Filled in for CMode CLI. =item C<< initiator_group_throttle_reserve >> Filled in for CMode CLI. =item C<< lun_id >> LUN ID ranges from 0 to 4095 Filled in for CMode CLI/ZAPI. =item C<< initiator_group_use_partner >> Filled in for CMode CLI. =item C<< volume_msid >> Volume MSID Filled in for CMode CLI. =item C<< mapped >> Mapped Filled in for CMode CLI. =back =cut package NACL::CS::LunMapping; 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::Exceptions::NoElementsFound qw(:try); use NACL::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::CS::ComponentState::ZapiArray qw(make_zapi_array); use NACL::C::_Mixins::Lun qw(:all); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'protocol', array => 'initiators', scalar => 'initiator_group_vsa_enabled', scalar => 'node', scalar => 'state', scalar => 'ostype', scalar => 'igroup', scalar => 'lun', scalar => 'qtree', scalar => 'vdisk_id', scalar => 'vserver_uuid', scalar => 'igroup_uuid', scalar => 'volume', scalar => 'vserver', array => 'reporting_nodes', scalar => 'portset_uuid', scalar => 'path', scalar => 'portset', scalar => 'lun_uuid', scalar => 'alua', scalar => 'initiator_group_throttle_borrow', scalar => 'initiator_group_throttle_reserve', scalar => 'lun_id', scalar => 'initiator_group_use_partner', scalar => 'volume_msid', scalar => 'mapped', ]; =head1 METHODS =head2 fetch my $LunMapping_state = NACL::CS::LunMapping->fetch(command_interface => $ci, ...); my @LunMapping_states = NACL::CS::LunMapping->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 CMode CLI/ZAPI. Invokes lun-map-get-iter 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. =back =back =cut sub fetch { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::fetch( @args, show_cmd => 'lun mapping show', choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode' }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode' }, ], exception_text => 'No matching lun mapping(s) found', frontend => 'NACL::CS::LunMapping::fetch', ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@args, api => 'lun_mapping_show',); $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $need_to_apply_filter; if (!defined $opts{filter}->{path}) { my %filter = %{$opts{filter}}; try { $pkg->_construct_path(params => \%filter); $opts{filter} = \%filter; } otherwise { # All of the necessary inputs to construct the path were # not provided. # Check if some of them were provided, in which case we need # the base class to filter. if ( defined $filter{volume} || defined $filter{qtree} || defined $filter{lun}) { $need_to_apply_filter = 1; } }; } my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @args, copy => [qw(node vserver path lun-uuid lun-id)], map => { 'igroup' => 'initiator-group', 'igroup-uuid' => 'initiator-group-uuid', 'reporting-nodes' => [ make_zapi_array('reporting-nodes'), make_zapi_skip('node-name'), ], }, api => "lun-map-get-iter", ); foreach my $state_obj (@state_objs) { # Update each object with the value of volume, qtree, lun my ($volume, $qtree, $lun) = $pkg->_extract_volume_qtree_lun_from_path( path => $state_obj->path()); # Default qtree to being the empty qtree $qtree ||= '""'; $state_obj->volume($volume); $state_obj->qtree($qtree); $state_obj->lun($lun); } ${$opts{_apply_filter}} = 1 if $need_to_apply_filter; $Log->exit() if $may_exit; return @state_objs; } 1;