# $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 LunMapped ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com , benjaram@netapp.com ## @status shared ## @pod here # =head1 NAME NACL::CS::LunMapped =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP LunMapped. A related class is L, which represents access to an ONTAP LunMapped. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the LunMapped element are the attributes of the LunMapped 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 >> Filled in for 7Mode CLI. Maps to: 7M 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<< lunMapRefId >> Filled in for CMode CLI. =item C<< initiator-group-vsa-enabled >> Filled in for CMode CLI. =item C<< 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 Filled in for CMode CLI. =item C<< state >> Filled in for CMode CLI. =item C<< lun >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. Output mapping, This would be obtained from the value of 'path' attribute. 7M 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<< igroup >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value 7M 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<< ostype >> Filled in for CMode CLI. =item C<< qtree >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. Output mapping, This would be obtained from the value of 'path' attribute. 7M 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<< volume >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. Output mapping, This would be obtained from the value of 'path' attribute. 7M 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<< vserver >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< initiator-group-uuid >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< path >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. Output mapping, This would be obtained from the value of 'path' attribute. 7M 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<< portset >> Filled in for CMode CLI. =item C<< alua >> Filled in for CMode CLI. =item C<< lun_uuid >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =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 >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value 7M 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<< initiator-group-use-partner >> Filled in for CMode CLI. =item C<< mapped >> Filled in for CMode CLI. =item C<< os >> Filled in for CMode CLI. =item C<< luno >> Filled in for CMode CLI. =item C<< type >> Filled in for CMode CLI. =back =cut package NACL::CS::LunMapped; 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 NATE::Exceptions::Argument; use base 'NACL::CS::ComponentState::ONTAP'; use NACL::C::_Mixins::Lun qw(_construct_path _extract_volume_qtree_lun_from_path); use NACL::Exceptions::InvalidChoice; use Class::MethodMaker [ scalar => 'protocol', scalar => 'lunMapRefId', scalar => 'initiator_group_vsa_enabled', array => 'initiators', scalar => 'state', scalar => 'lun', scalar => 'igroup', scalar => 'ostype', scalar => 'qtree', scalar => 'volume', scalar => 'vserver', scalar => 'initiator_group_uuid', scalar => 'path', scalar => 'portset', scalar => 'alua', scalar => 'lun_uuid', scalar => 'initiator_group_throttle_borrow', scalar => 'initiator_group_throttle_reserve', scalar => 'lun_id', scalar => 'initiator_group_use_partner', scalar => 'mapped', scalar => 'os', scalar => 'luno', scalar => 'type', ]; =head1 METHODS =head2 fetch my $LunMapped_state = NACL::CS::LunMapped->fetch(command_interface => $ci, ...); my @LunMapped_states = NACL::CS::LunMapped->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. Supports CMode CLI/ZAPI, 7Mode CLI. Invokes "lun-map-get-iter" API for CMode ZAPI. Invokes "lun show" command for 7Mode CLI. =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, choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode' }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', check => '_check_cmode_zapi', }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode' }, ], exception_text => 'No matching lun mapped(s) found', show_cmd => 'lun mapped 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 => 'lun_mapped_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, %opts) = @_; my %filter_copy = %{$opts{filter}}; if (exists $filter_copy{volume} && exists $filter_copy{lun} && exists $filter_copy{qtree}) { $pkg->_construct_path(params => \%filter_copy); } my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( %opts, filter => \%filter_copy, api => 'lun_map_get_iter', map => {'igroup' => 'initiator-group',}, copy => [qw ( initiator-group-uuid lun-id lun-uuid path vserver)], ); # _apply_filter is set so that additional filtering needs to be # done. ${$opts{_apply_filter}} = 1; foreach my $state_obj (@state_objs) { my ($vol, $qtree, $lun) = $pkg->_extract_volume_qtree_lun_from_path( path => $state_obj->path()); $state_obj->volume($vol); $state_obj->qtree($qtree); $state_obj->lun($lun); } $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi sub _check_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; my $filter = $opts{filter}; my @requested = $opts{requested_fields}; if ('initiators' ~~ @requested || defined $filter->{'initiators'}) { $Log->exit() if $may_exit; NACL::Exceptions::InvalidChoice->throw("'initiators' is not supported " . " by the ZAPI in the call to NACL::CS::LunMapped, hence ZAPI cannot be used. "); } } sub _fetch_7mode_cli { my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my @state_objs; my $response = $apiset->lun_show('mapping' => "1"); my $output = $response->get_parsed_output(); foreach my $row (@$output) { my $row_modified = $pkg->_hash_copy( source => $row, copy => [qw(protocol igroup lun_id)], map => {'lun_path' => 'path',}, ); my $obj = $pkg->new(command_interface => $opts{'command_interface'}); $obj->_set_fields(row => $row_modified); my $path = $obj->path(); my @path_fields = split("\/", $path); $obj->volume($path_fields[2]); if (scalar @path_fields == 4) { $obj->qtree('""'); $obj->lun($path_fields[3]); } else { $obj->qtree($path_fields[3]); $obj->lun($path_fields[4]); } push @state_objs, $obj; } ## end foreach my $row (@$output) return @state_objs; } ## end sub _fetch_7mode_cli 1;