# $Id$ # # Copyright (c) 2001-2010 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::StorageDisk->ddr_label_print() (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::StorageDiskDdrLabelPrint =head1 DESCRIPTION C is a derived class of L. Object(s) of this type are returned when NACL::C::StorageDisk->ddr_label_print() is invoked. (This module does not represent the state of any element, but is an object repesentation of the output obtained when NACL::C::StorageDisk->ddr_label_print() is invoked.) =head1 ATTRIBUTES The fields of the output are fields of the ComponentState object. =over =item C<< "datecode" >> Filled in ddr_label command in 7Mode CLI. =item C<< "alias_product_id" >> Filled in ddr_label command in 7Mode CLI. =item C<< "fake_ssd" >> Filled in ddr_label command in 7Mode CLI. =item C<< "product_id" >> Filled in ddr_label command in 7Mode CLI. =item C<< "qual_flags" >> Filled in ddr_label command in 7Mode CLI. =item C<< "last_block" >> Filled in ddr_label command in 7Mode CLI. =item C<< "fastzero" >> Filled in ddr_label command in 7Mode CLI. =item C<< "qual_flag_index" >> Filled in ddr_label command in 7Mode CLI. =item C<< "checkrev" >> Filled in ddr_label command in 7Mode CLI. =item C<< "verify_size" >> Filled in ddr_label command in 7Mode CLI. =item C<< "last_block_azcs" >> Filled in ddr_label command in 7Mode CLI. =item C<< "zcs_flag" >> Filled in ddr_label command in 7Mode CLI. =item C<< "firmware" >> Filled in ddr_label command in 7Mode CLI. =item C<< "mini_disk_header_present" >> Filled in ddr_label command in 7Mode CLI. =item C<< "vendor_id" >> Filled in ddr_label command in 7Mode CLI. =back =cut package NACL::CS::StorageDiskDdrLabelPrint; use strict; use warnings; use Params::Validate qw(validate validate_with SCALAR ARRAYREF HASHREF); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NACL::APISet::Exceptions::ResponseException qw(:try); use NACL::ComponentUtils qw(Dumper); use base qw(NACL::CS::ComponentState::ONTAP); use Class::MethodMaker [ scalar => 'disk', scalar => 'rpm', scalar => 'bps', scalar => 'firmware', scalar => 'checkrev', scalar => 'fake_ssd', scalar => 'product_id', scalar => 'datecode', scalar => 'last_block', scalar => 'qual_flags', scalar => 'vendor_id', scalar => 'fastzero', scalar => 'qual_flag_index', scalar => 'alias_vendor_id', scalar => 'verify_size', scalar => 'zcs_flag', scalar => 'last_block_azcs', scalar => 'native_product_id', scalar => 'alias_product_id', scalar => 'native_vendor_id', scalar => 'mini_disk_header_present', ]; =head1 METHODS =head2 fetch my $StorageDiskDdrLabelPrint_state= NACL::CS::StorageDiskDdrLablPrint->fetch(command_interface => $ci, ...); my @StorageDiskDdrLabelPrint_state= NACL::CS::StorageDiskDdrLablPrint->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 7Mode CLI and Nodescope =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_7mode_cli', interface => 'CLI', set => '7Mode|Nodescope', }, ], exception_text => 'No matching disk(s) found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch 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 @orig_requested_fields = @{ $opts{requested_fields} }; my %orig_filter = %{ $opts{filter} }; $pkg->_remove_relational_regex_filters( filter => \%orig_filter, requested_fields => \@orig_requested_fields ); if ( $opts{command_interface}->is_cmode() ) { if ( $orig_filter{disk} ) { $orig_filter{disk} = _get_disk($orig_filter{disk},1); } } my $requested_fields = \@orig_requested_fields; my $filter = \%orig_filter; my %api_args; if (defined $filter->{disk}) { $api_args{disks} = $filter->{disk}; } else { $api_args{disks} = 'all'; } my ($response, $caught_exception); try { $response = $apiset->disk_ddr_label_print(%api_args); } catch NACL::APISet::Exceptions::InvalidParamValueException with { # Indicates disk doesn't exist $caught_exception = 1; }; if ($caught_exception) { $Log->exit() if $may_exit; return; } my @state_objs; my $output = $response->get_parsed_output(); foreach my $row (@$output) { my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => $row); push @state_objs, $obj; } $Log->exit() if $may_exit; return @state_objs; } sub _apply_filter { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = validate_with( params => \@args, spec => { filter => { type => HASHREF }, state_objs => { type => ARRAYREF }, }, allow_extra => 1 ); my %filter = %{$opts{filter}}; if (defined $filter{disk}) { my @disks_with_node = split '\|', $filter{disk}; delete $filter{disk}; my @disks; foreach my $disk_with_node (@disks_with_node) { push @disks, _get_disk($disk_with_node, 'last'); } my @new_state_objs; foreach my $state_obj (@{$opts{state_objs}}) { my $disk_in_obj = $state_obj->disk(); if (defined $disk_in_obj) { if ( grep(/^$disk_in_obj$/, @disks) ) { push @new_state_objs, $state_obj; } } } @{$opts{state_objs}} = @new_state_objs; } $pkg->SUPER::_apply_filter( %opts, filter => \%filter ); $Log->exit() if $may_exit; } ## end of _apply_filter sub _get_disk { my ($disk, $index) = @_; my @disks = split ':', $disk; if ($index eq 'last') { return $disks[-1]; } elsif ($index eq 'first') { return $disks[0]; } elsif($index =~/^\d+$/) { return $disks[$index]; } return; } 1;