# # Copyright (c) 2001-2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary ComponentState Module for the method NACL::C::StorageAggregate->show_space() (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::StorageAggregateShowSpace =head1 DESCRIPTION C is a derived class of L. Object(s) of this type are returned when NACL::C::StorageAggregate->show_space() is invoked. ((This module does not represent the state of any element, but is an object repesentation of the output obtained when NACL::C::StorageAggregate->show_space() is invoked.) =head1 ATTRIBUTES The fields of the output are fields of the ComponentState object. =over =item C<< aggregate_metadata_percent >> Aggregate Metadata Percent Filled in for CMode CLI/ZAPI, 7Mode/Nodescope CLI =item C<< snap_size_total >> Total space for Snapshot Copies in bytes Filled in for CMode CLI/ZAPI, 7Mode/Nodescope CLI =item C<< aggregate_metadata >> Aggregate Metadata, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode/Nodescope CLI =item C<< used_including_snapshot_reserve_percent >> Used Percent Including Snapshot Reserve Filled in for CMode CLI/ZAPI, 7Mode/Nodescope CLI =item C<< used_including_snapshot_reserve >> Used Including Snapshot Reserve, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode/Nodescope CLI =item C<< volume_footprints_percent >> Volume Data and Metadata Footprint Percent Filled in for CMode CLI/ZAPI, 7Mode/Nodescope CLI =item C<< percent_snapshot_space >> Space Reserved for Snapshot Copies Filled in for CMode CLI/ZAPI, 7Mode/Nodescope CLI =item C<< aggregate >> Aggregate Filled in for CMode CLI/ZAPI, 7Mode/Nodescope CLI Maps to: 7M/Nodescope CLI: aggregate * For filter: aggregate name (Programmatic option: 'aggregate') =item C<< volume_footprints >> Volume Data and Metadata Footprint, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode/Nodescope CLI =item C<< skip_snapshot_lines >> Filled in for CMode CLI. =item C<< percent_inodes_used >> Filled in for CMode CLI. =item C<< dedupe_saved >> Filled in for CMode CLI. =item C<< percent_total_saved >> Filled in for CMode CLI. =item C<< filesys_name >> Filled in for CMode CLI. =item C<< uuid >> Filled in for CMode CLI. =item C<< inodes_free >> Filled in for CMode CLI. =item C<< inodes_used >> Filled in for CMode CLI. =item C<< total_hybrid_cache_size >> Filled in for CMode CLI. =item C<< percent_vbn_zero_saved >> Filled in for CMode CLI. =item C<< total_space >> Filled in for CMode CLI. =item C<< used_space >> Filled in for CMode CLI. =item C<< total_saved >> Filled in for CMode CLI. =item C<< percent_compression_saved >> Filled in for CMode CLI. =item C<< percent_used_space >> Filled in for CMode CLI. =item C<< vbn_zero_saved >> Filled in for CMode CLI. =item C<< hya >> Filled in for CMode CLI. =item C<< reserved_space >> Filled in for CMode CLI. =item C<< available_space >> Filled in for CMode CLI. =item C<< percent_dedupe_saved >> Filled in for CMode CLI. =item C<< type >> Filled in for CMode CLI. =item C<< compression_saved >> Filled in for CMode CLI. =item C<< snapshot_reserve_unusable >> Snapshot Reserve Unusable Filled in for CMode CLI/ZAPI. =item C<< snapshot_reserve_unusable_percent >> Snapshot Reserve Unusable Percent Filled in for CMode CLI/ZAPI. =item C<< physical_used >> Physical Used Filled in for CMode CLI/ZAPI. =item C<< aggregate_size >> Size Filled in for CMode CLI/ZAPI. =item C<< physical_used_percent >> Physical Used Percent Filled in for CMode CLI/ZAPI. =back =cut package NACL::CS::StorageAggregateShowSpace; 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 base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'aggregate_metadata_percent', scalar => 'snap_size_total', scalar => 'aggregate_metadata', scalar => 'used_including_snapshot_reserve_percent', scalar => 'used_including_snapshot_reserve', scalar => 'volume_footprints_percent', scalar => 'percent_snapshot_space', scalar => 'aggregate', scalar => 'volume_footprints', scalar => 'skip_snapshot_lines', scalar => 'percent_inodes_used', scalar => 'dedupe_saved', scalar => 'percent_total_saved', scalar => 'filesys_name', scalar => 'uuid', scalar => 'inodes_free', scalar => 'inodes_used', scalar => 'total_hybrid_cache_size', scalar => 'percent_vbn_zero_saved', scalar => 'total_space', scalar => 'used_space', scalar => 'total_saved', scalar => 'percent_compression_saved', scalar => 'percent_used_space', scalar => 'vbn_zero_saved', scalar => 'hya', scalar => 'reserved_space', scalar => 'available_space', scalar => 'percent_dedupe_saved', scalar => 'type', scalar => 'compression_saved', scalar => 'snapshot_reserve_unusable', scalar => 'snapshot_reserve_unusable_percent', scalar => 'physical_used', scalar => 'aggregate_size', scalar => 'physical_used_percent', ]; =head1 METHODS =head2 fetch my $StorageAggregateShowSpace_state = NACL::CS::StorageAggregateShowSpace->fetch(command_interface => $ci, ...); my @StorageAggregateShowSpace_states = NACL::CS::StorageAggregateShowSpace->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 a CMode or 7Mode/Nodescope CLI APISet. Invokes 'aggr status -S' command for 7Mode CLI. Invokes 'aggr-space-get-iter' 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 = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode' }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode|Nodescope' }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode' } ], show_cmd => 'storage aggregate show-space', exception_text => 'No matching storage aggregate(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 @state_objs = $pkg->SUPER::_fetch_cmode_cli(@_, api => 'storage_aggregate_show_space',); $Log->exit() if $may_exit; return @state_objs; } sub _fetch_7mode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my ($response, $caught_exception); # We should not be modifying the original reference passed in # Make a local copy and then modify that my %copy_filter = %{$opts{filter}}; my @copy_requested_fields = @{$opts{requested_fields}}; $pkg->_remove_relational_regex_filters( filter => \%copy_filter, requested_fields => \@copy_requested_fields ); my $cmd_args = $pkg->_hash_copy( source => \%copy_filter, # There is only one filter field, aggregate copy => ['aggregate'], ); try { $response = $apiset->aggr_status( 'show-space' => 1, %$cmd_args ); } ## end try catch NACL::APISet::Exceptions::InvalidParamValueException with { # A caught exception indicates that the volume being looked for # does not exist. We catch the exception and return immediately. The # 'fetch' frontend decides whether to throw a NoElementsFound # exception based on the value of 'allow_empty' $caught_exception = 1; }; if ($caught_exception) { $Log->exit() if $may_exit; return; } my $output = $response->get_parsed_output(); my @state_objs; foreach my $row (@$output) { # Due to loss of precision, we are not converting the values to bytes my $final_attributes = $pkg->_hash_copy( source => $row, # Note: Hyphen and underscore are equivalent, so we don't need copy => [ qw( aggregate aggregate_metadata aggregate_metadata_percent volume_footprints volume_footprints_percent ) ], # If we find more fields need to be added to the 7Mode APIset, we # can add them to copy or map later map => { 'total' => 'used_including_snapshot_reserve', 'total_percent' => 'used_including_snapshot_reserve_percent', 'snapshot_reserve' => 'snap_size_total', 'snapshot_reserve_percent' => 'percent_snapshot_space', }, ); my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => $final_attributes); push @state_objs, $obj; } ## end foreach my $row (@$output) $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @args, api => 'aggr-space-get-iter', copy => [ qw (aggregate volume-footprints volume-footprints-percent snap-size-total percent-snapshot-space aggregate-metadata aggregate-metadata-percent used-including-snapshot-reserve used-including-snapshot-reserve-percent aggregate-size snapshot-reserve-unusable snapshot-reserve-unusable-percent physical-used physical-used-percent) ], ); $Log->exit() if $may_exit; return @state_objs; } 1;