# Copyright (c) 2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # # ## @summary Lsmod ComponentState Module ## @author Vishwanath.Rawat@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here ################################################################################ =head1 NAME NACL::CS::Client::Lsmod =head1 DESCRIPTION C is a derived class of L. It represents the state of Lsmod element. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Lsmod element are the individual attributes of the Lsmod ComponentState =over =item C<< "used_by_modules_count" >> 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<< "used_by_modules" >> 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" >> Linux CLI: Maps to: Linux and Solaris 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<< "module" >> 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::Lsmod; ################### # Everytime use strict; use warnings; ################### # Module includes use Params::Validate qw (validate SCALAR); use NACL::ComponentUtils qw (_optional_scalars); 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::CommandFailedException; use Class::MethodMaker [ # Linux components scalar => "size", scalar => "module", scalar => "used_by_modules_count", array => "used_by_modules", ]; =head1 METHODS =head2 fetch my $iscsi_state = NACL::CS::Client::Lsmod->fetch(command_interface=>$ci); see L Supports Linux CLI. Invokes "lsmod" command for Linux CLI. =back =cut sub fetch { $Log->enter(); my ($pkg, @opts) = @_; my @state_objs = $pkg->SUPER::fetch( @opts, choices => [ { method => "_fetch_linux_cli", interface => "CLI", set => 'Linux' }, ], exception_text => 'No requested modules found', ); $Log->exit(); return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_linux_cli { $Log->enter(); my ($pkg, @opts) = @_; my %opts = validate @opts, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $command_interface = $opts{command_interface}; my ( @state_objs ); my $parsed_output = []; my $resp = $apiset->lsmod(); $parsed_output = $resp->get_parsed_output(); foreach my $row (@$parsed_output) { my $obj = $pkg->new( command_interface => $command_interface ); $obj->_set_fields( row => $row ); push @state_objs, $obj; } $Log->exit(); return @state_objs; } 1;