# $Id$ # # Copyright (c) 2001-2011 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary VfilerDr ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VfilerDr =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP Vfiler Dr. A related class is L, which represents access to an ONTAP Vfiler. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Vfiler dr element are the elements of the Vfiler ComponentState. =over =item C<< storage-path >> =item C<< status >> =back =cut package NACL::CS::VfilerDr; use strict; use warnings; use base 'NACL::CS::ComponentState::ONTAP'; use NACL::ComponentUtils qw(Dumper); use Params::Validate qw(validate SCALAR); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use Class::MethodMaker [ scalar => 'storage_path', scalar => 'status', ]; =head1 METHODS =head2 fetch my $vfiler_state = NACL::CS::VfilerDr->fetch(command_interface => $ci, ...); my @vfiler_states = NACL::CS::VfilerDr->fetch(command_interface => $ci, ...); =item Options =over =item C<< remote-vfiler=>$remote_vfiler_name >> (Mandatory) =item C<< remote-filer=>$remote_filer >> (Mandatory) =item C<< 'filter'=>{status => "idle"} >> (Optional) =item C<< 'requested_fields'=>["status"} >> (Optional) =item C<< 'command_interface'=> $ci >> (Mandatory) =back See L. =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', }, ], exception_text => 'No matching vfiler dr(s) found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_7mode_cli { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $command_interface = $opts{command_interface}; my %cmd_input; $cmd_input{'remote-filer'} = $opts{'remote-filer'}; $cmd_input{'remote-vfiler'} = $opts{'remote-vfiler'}; my $response = $apiset->vfiler_dr_status(%cmd_input); my $output = $response->get_parsed_output(); my @state_objs; foreach my $row (@$output) { my $obj = $pkg->new( command_interface => $command_interface ); $obj->_set_fields( row => $row ); push @state_objs, $obj; } ## end foreach my $row (@$output) $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli sub _fetch_validate_spec { my $pkg = shift; my $validate_spec = $pkg->SUPER::_fetch_validate_spec(); $validate_spec->{'remote-vfiler'} = { type => SCALAR }; $validate_spec->{'remote-filer'} = { type => SCALAR }; return $validate_spec; } ## end sub _fetch_validate_spec sub _fetch_backend_validate_spec { my $pkg = shift; my $validate_spec = $pkg->SUPER::_fetch_backend_validate_spec; $validate_spec->{'remote-vfiler'} = { type => SCALAR }; $validate_spec->{'remote-filer'} = { type => SCALAR }; return $validate_spec; } ## end sub _fetch_backend_validate_spec 1;