# # Copyright (c) 2001-2010 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary SisLs ComponentState Module ## @author anbumozh@netapp.com dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SisLs =head1 DESCRIPTION C is a derived class of L. A related class is L, which represents the output of sis ls in 7Mode =head1 ATTRIBUTES This module does not represent the state of any element, but is an object repesentation of the output obtained when the sis ls is executed =over =item C<< "volume" >> =item C<< "file_info" >> =item C<< "aggregate" >> =item C<< "total_files_in_aggr" >> =item C<< "total_blocks_used_in_volume" >> =back =cut package NACL::CS::SisLs; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw(_dump_one); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use Data::Dumper; use NACL::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'volume', array => 'file_info', scalar => 'aggregate', scalar => 'total_files_in_aggr', scalar => 'total_blocks_used_in_volume' ]; =head1 METHODS =head2 fetch my $SisLs_state = NACL::CS::SisLs->fetch(command_interface => $ci, ...); my @SisLs_states = NACL::CS::SisLs->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_7mode_cli', interface => 'CLI', set => '7Mode|Nodescope', }, ], exception_text => 'No matching sis ls(s) found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_7mode_cli { $Log->enter() if $may_enter; my @state_objs; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $filter = $opts{filter}; delete $opts{command_interface}; my $apiset = delete $opts{apiset}; if (exists($filter->{path})) { $opts{path} = $filter->{path}; } elsif (exists($filter->{volume})) { $opts{path} = "/vol/$filter->{volume}"; } else { # API layer maps this to -a option $opts{all} = 1; } my $allowed_7mode_options = [qw(all path)]; my $args = $pkg->_hash_copy( source => \%opts, copy => $allowed_7mode_options, ); %opts = %$args; my $response = $apiset->sis_ls(%opts); my $output = $response->get_parsed_output(); foreach my $row ( @$output ) { my $obj = $pkg->new(); $obj->_set_fields(row => $row); push(@state_objs,$obj); } $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli 1;