# # 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::Volume->show_space() (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VolumeShowSpace =head1 DESCRIPTION C is a derived class of L. Object(s) of this type are returned when NACL::C::Volume->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::Volume->show_space() is invoked.) =head1 ATTRIBUTES The fields of the output are fields of the ComponentState object. =over =item C<< snapshot_space_used >> Snapshot Reserve Used Filled in for CMode CLI. =item C<< user_data_percent >> User Data Percent Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode 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<< quota_metafiles >> Quota Metadata, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< volume_size >> Total User-Visible Size, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI. Maps to: CMode 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. =item C<< snapshot_spill >> Snapshot Spill, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode 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. =item C<< dedupe_metafiles_tmp >> Temporary Deduplication Metadata, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI. =item C<< used_percent >> Used Including Snaphot Reserve Percent Filled in for CMode CLI. =item C<< aggregate >> Aggregate Name Filled in for CMode CLI. =item C<< filesystem_metadata_percent >> Filesystem Metadata Percent Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode 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<< snapshot_spill_percent >> Snapshot Spill Percent Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< dedupe_metafiles_tmp_percent >> Temporary Deduplication Metadata Percent Filled in for CMode CLI. =item C<< volume >> Volume Name Filled in for CMode CLI/ZAPI, 7Mode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI/ZAPI: For "Filter" : volume For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< snapshot_reserve >> Snapshot Reserve Size, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI/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. =item C<< vserver >> Vserver Name Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< inodes >> Inode Metadata, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode CLI/ZAPI. Maps to: CMode ZAPI/ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode 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<< dedupe_metafiles >> Deduplication Metadata, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode 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. =item C<< user_data >> User Data, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI/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. =item C<< inodes_percent >> Inode Metadata Percent Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode 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<< filesystem_metadata >> Filesystem Metadata, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI/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. =item C<< dedupe_metafiles_percent >> Deduplication Metadata Percent Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< used >> Used Including Snapshot Reserve, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI. =item C<< snapshot_reserve_percent >> Space Reserved for Snapshots Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode 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<< quota_metafiles_percent >> Quota Metadata Percent Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< snapmirror_metadata_percent >> SnapMirror Metadata Percent Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< snapmirror_metadata >> SnapMirror Metadata, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode 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. =item C<< total_used >> Used Including Snapshot Reserve, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI/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. =item C<< hostname >> Hostname Filled in for CMode CLI. =item C<< volume_dsid >> Volume DSID Filled in for CMode CLI. =item C<< total_used_percent >> Used Including Snapshot Reserve Percent Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode 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_uuid >> Vserver UUID Filled in for CMode CLI. =item C<< dedupe_metafiles_temporary_percent >> Temporary Deduplication Metadata Percent Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< dedupe_metafiles_temporary >> Temporary Deduplication Metadata, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI, 7Mode ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode 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. =item C<< aggregate_uuid >> Aggregate UUID Filled in for CMode CLI. =item C<< volume_msid >> Volume MSID Filled in for CMode CLI. =item C<< percent_inodes_used >> Filled in for CMode CLI. =item C<< dsid >> 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_used >> 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<< mounted_on >> Filled in for CMode CLI. =item C<< percent_compression_saved >> Filled in for CMode CLI. =item C<< vbn_zero_saved >> Filled in for CMode CLI. =item C<< volume_style >> 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<< compression_saved >> Filled in for CMode CLI. =item C<< skip_snapshot_lines >> 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<< node >> Filled in for CMode CLI. =item C<< inodes_free >> Filled in for CMode CLI. =item C<< percent_vbn_zero_saved >> Filled in for CMode CLI. =item C<< percent_used_space >> Filled in for CMode CLI. =item C<< tape_backup_metadata >> Tape Backup Metadata, possible value(s) are [KB,MB,GB,TB,PB] Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< tape_backup_metadata_percent >> Tape Backup Metadata Percent Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< performance_metadata_percent >> Performance Metadata Percent Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< performance_metadata >> Performance Metadata Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< physical_used_percent >> Total Physical Used Percent Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< snapshot_reserve_unusable >> Snapshot Reserve Unusable Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< snapshot_reserve_unusable_percent >> Snapshot Reserve Unusable Percent Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< physical_used >> Total Physical Used Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =back =cut package NACL::CS::VolumeShowSpace; 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 => 'snapshot_space_used', scalar => 'user_data_percent', scalar => 'quota_metafiles', scalar => 'volume_size', scalar => 'snapshot_spill', scalar => 'dedupe_metafiles_tmp', scalar => 'used_percent', scalar => 'aggregate', scalar => 'filesystem_metadata_percent', scalar => 'snapshot_spill_percent', scalar => 'dedupe_metafiles_tmp_percent', scalar => 'volume', scalar => 'snapshot_reserve', scalar => 'vserver', scalar => 'inodes', scalar => 'dedupe_metafiles', scalar => 'user_data', scalar => 'inodes_percent', scalar => 'filesystem_metadata', scalar => 'dedupe_metafiles_percent', scalar => 'used', scalar => 'snapshot_reserve_percent', scalar => 'quota_metafiles_percent', scalar => 'snapmirror_metadata_percent', scalar => 'snapmirror_metadata', scalar => 'total_used', scalar => 'hostname', scalar => 'volume_dsid', scalar => 'total_used_percent', scalar => 'vserver_uuid', scalar => 'dedupe_metafiles_temporary_percent', scalar => 'dedupe_metafiles_temporary', scalar => 'aggregate_uuid', scalar => 'volume_msid', scalar => 'percent_inodes_used', scalar => 'dsid', scalar => 'filesys_name', scalar => 'uuid', scalar => 'inodes_used', scalar => 'total_space', scalar => 'used_space', scalar => 'total_saved', scalar => 'mounted_on', scalar => 'percent_compression_saved', scalar => 'vbn_zero_saved', scalar => 'volume_style', scalar => 'reserved_space', scalar => 'available_space', scalar => 'percent_dedupe_saved', scalar => 'compression_saved', scalar => 'skip_snapshot_lines', scalar => 'dedupe_saved', scalar => 'percent_total_saved', scalar => 'node', scalar => 'inodes_free', scalar => 'percent_vbn_zero_saved', scalar => 'percent_used_space', scalar => 'tape_backup_metadata', scalar => 'tape_backup_metadata_percent', scalar => 'performance_metadata_percent', scalar => 'performance_metadata', scalar => 'physical_used_percent', scalar => 'snapshot_reserve_unusable', scalar => 'snapshot_reserve_unusable_percent', scalar => 'physical_used', ]; =head1 METHODS =head2 fetch my $VolumeShowSpace_state = NACL::CS::VolumeShowSpace->fetch(command_interface => $ci, ...); my @VolumeShowSpace_states = NACL::CS::VolumeShowSpace->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/ZAPI. Invokes "volume-space-get-iter" API for CMode ZAPI. Invokes "vol status('show-space' => 1)" command for 7Mode/Nodescope CLI. Invokes "volume-space-list-info" API for 7Mode 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, @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' }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode|Nodescope' }, { method => '_fetch_7mode_zapi', interface => 'ZAPI', set => '7Mode' } ], show_cmd => 'volume show-space', exception_text => 'No matching volume(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 => 'volume_show_space',); $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @args, api => 'volume_space_get_iter', copy => [ qw ( dedupe-metafiles dedupe-metafiles-temporary dedupe-metafiles-percent dedupe-metafiles-temporary-percent filesystem-metadata inodes-percent inodes quota-metafiles quota-metafiles-percent snapmirror-metadata-percent snapmirror-metadata snapshot-spill-percent snapshot-spill snapshot-reserve-percent snapshot-reserve tape-backup-metadata-percent tape-backup-metadata user-data-percent total-used-percent total-used filesystem-metadata-percent user-data volume vserver performance-metadata performance-metadata-percent physical-used physical-used-percent snapshot-reserve-unusable snapshot-reserve-unusable-percent ) ], ); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi 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, volume copy => ['volume'], ); try { $response = $apiset->vol_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 # to map them but we need to use the underscore here, not hyphen copy => [ qw( volume inodes inodes_percent snapshot_reserve snapshot_reserve_percent user_data user_data_percent filesystem_metadata filesystem_metadata_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' => 'total_used', 'total_percent' => 'total_used_percent', }, ); 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_7mode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; 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, copy => [qw (volume)], ); my $response = $apiset->volume_space_list_info(%$cmd_args); my $output = $response->get_parsed_output(); my @state_objs; my $space_info = defined($output->[0]->{'space-infos'}->[0]->{'space-info'}) ? $output->[0]->{'space-infos'}->[0]->{'space-info'} : $output->[0]->{'vol-space-infos'}->[0]->{'vol-space-info'}; foreach my $row (@$space_info) { my $final_attributes = $pkg->_hash_copy( source => $row, copy => [ qw( volume snapshot-reserve inodes total-used dedupe-metafiles dedupe-metafiles dedupe-metafiles-temporary user-data filesystem-metadata snapmirror-metadata snapshot-spill volume-size ) ], ); 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_zapi 1;