# $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 VfilerMigrate ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VfilerMigrate =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP Vfiler. 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 element are the elements of the Vfiler ComponentState. =over =item Options =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'=>$node >> (Mandatory) =over =item C<< storage-path >> =item C<< status >> =back =cut package NACL::CS::VfilerMigrate; use strict; use warnings; use base 'NACL::CS::ComponentState::ONTAP'; use NACL::ComponentUtils qw(_dump_one Dumper); use Params::Validate qw(validate); use NACL::Exceptions::InvalidFilterField qw(:try); use NACL::Exceptions::NoElementsFound qw(:try); use Params::Validate qw(SCALAR ARRAYREF UNDEF HASHREF); 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::VfilerMigrate->fetch(command_interface => $ci, ...); my @vfiler_states = NACL::CS::VfilerMigrate->fetch(command_interface => $ci, ...); 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 migrate(s) found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_7mode_cli { my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = delete $opts{apiset}; delete $opts{command_interface}; delete $opts{requested_fields}; delete $opts{filter}; my $response = $apiset->vfiler_migrate_status(%opts); my $output = $response->get_parsed_output(); my @state_objs; foreach my $row (@$output) { my $obj = $pkg->new(); while ( my ( $key, $value ) = each %$row ) { $obj->$key($value); } push @state_objs, $obj; } ## end foreach my $row (@$output) 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;