# $Id: //depot/prod/test/nacldev/lib/NACL/CS/VolumeFileShowDiskUsage.pm#7 $ # # Copyright (c) 2001-2010 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary VolumeFileShowDiskUsage ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VolumeFileShowDiskUsage =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP VolumeFileShowDiskUsage. A related class is L, which represents access to an ONTAP VolumeFileShowDiskUsage. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the VolumeFileShowDiskUsage element are the attributes of the VolumeFileShowDiskUsage ComponentState. =over =item C<< "accessed_timestamp" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "accessed-timestamp" in the output of ZAPI "file-get-file-info" =item C<< "acl_type" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "acl-type" in the output of ZAPI "file-get-file-info" =item C<< "total" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "bytes-used" in the output of ZAPI "file-get-file-info" =item C<< "path" >> =item C<< "changed_timestamp" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "changed-timestamp" in the output of ZAPI "file-get-file-info" =item C<< "creation_timestamp" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "creation-timestamp" in the output of ZAPI "file-get-file-info" =item C<< "dsid" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "dsid" in the output of ZAPI "file-get-file-info" =item C<< "vserver" >> =item C<< "file_size" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "file-size" in the output of ZAPI "file-get-file-info" item C<< "file_type" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "file-type" in the output of ZAPI "file-get-file-info" =item C<< "group_id" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "group-id" in the output of ZAPI "file-get-file-info" =item C<< "hard_links_count" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "hard-links-count" in the output of ZAPI "file-get-file-info" item C<< "inode_gen_number" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "inode-gen-number" in the output of ZAPI "file-get-file-info" =item C<< "inode_number" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "inode-number" in the output of ZAPI "file-get-file-info" =item C<< "is_empty" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "is-empty" in the output of ZAPI "file-get-file-info" =item C<< "modified_timestamp" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "modified-timestamp" in the output of ZAPI "file-get-file-info" =item C<< "msid" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "msid" in the output of ZAPI "file-get-file-info" =item C<< "name" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "name" in the output of ZAPI "file-get-file-info" =item C<< "perm" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "perm" in the output of ZAPI "file-get-file-info" =item C<< "owner_id" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "owner-id" in the output of ZAPI "file-get-file-info" =item C<< range >> Filled in for CMode CLI. =item C<< unique_h >> Filled in for CMode CLI. =item C<< total_m >> Filled in for CMode CLI. =item C<< total_bytes >> Filled in for CMode CLI. =item C<< unique_m >> Filled in for CMode CLI. =item C<< total_h >> Filled in for CMode CLI. =item C<< unique_bytes >> Filled in for CMode CLI. =back =cut package NACL::CS::VolumeFileShowDiskUsage; use strict; use warnings; use Params::Validate qw(validate_with SCALAR); use NACL::ComponentUtils qw(_dump_one Dumper); 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 base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'accessed_timestamp', scalar => 'acl_type', scalar => 'total', scalar => 'changed_timestamp', scalar => 'creation_timestamp', scalar => 'dsid', scalar => 'path', scalar => 'file_size', scalar => 'file_type', scalar => 'group_id', scalar => 'hard_links_count', scalar => 'inode_gen_number', scalar => 'inode_number', scalar => 'is_empty', scalar => 'modified_timestamp', scalar => 'msid', scalar => 'name', scalar => 'perm', scalar => 'owner_id', scalar => 'vserver', scalar => 'range', scalar => 'unique_h', scalar => 'total_m', scalar => 'total_bytes', scalar => 'unique_m', scalar => 'total_h', scalar => 'unique_bytes', ]; =head1 METHODS =head2 fetch my $VolumeFileShowDiskUsage_state = NACL::CS::VolumeFileShowDiskUsage->fetch(command_interface => $ci, ...); my @VolumeFileShowDiskUsage_states = NACL::CS::VolumeFileShowDiskUsage->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_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], exception_text => 'No matching volume file show disk usage(s) found' ); $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 %opts = @_; validate_with( params => $opts{filter}, spec => $pkg->_show_set_validate_spec_cli(), ); my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@_, api => 'volume_file_show_disk_usage',); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my $pkg = shift; my %opts = @_; my $apiset = $opts{apiset}; my $caught_exception; my $status_response; validate_with( params => $opts{filter}, spec => $pkg->_show_set_validate_spec_zapi(), allow_extra => 1 ); my %cmd_opts; $cmd_opts{'path'} = $opts{filter}->{'path'}; $pkg->_handle_zapi_vserver_context( api_opts => \%cmd_opts, vserver => $opts{filter}{vserver}, command_interface => $opts{command_interface}, frontend_method => 'fetch' ); try { $status_response = $apiset->file_get_file_info(%cmd_opts); } catch NACL::APISet::Exceptions::ResponseException with { #Path is a required input parameter, hence should be passed #through the Unittest scripts. $caught_exception = 1; }; return if ($caught_exception); my $status_output = $status_response->get_parsed_output(); $Log->debug(Dumper($status_output)); my @state_objs; my $state_fields = $pkg->_zapi_hash_copy( source => $status_output->[0]->{'file-info'}->[0], copy => [ qw(perm name msid dsid accessed-timestamp acl-type changed-timestamp creation-timestamp file-size file-type group-id hard-links-count inode-gen-number inode-number is-empty modified-timestamp owner-id ) ], map => ["bytes-used" => ['total'],], ); my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => $state_fields); push @state_objs, $obj; $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi sub _show_set_validate_spec_cli { return { 'range' => {type => SCALAR, optional => 1}, 'vserver' => {type => SCALAR}, 'path' => {type => SCALAR} }; } ## end sub _show_set_validate_spec_cli sub _show_set_validate_spec_zapi { return {'path' => {type => SCALAR},}; } 1;