# $Id$ # # Copyright (c) 2001-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary Cluster ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::Cluster =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP Cluster. A related class is L, which represents access to an ONTAP Cluster. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Cluster element are the attributes of the Cluster ComponentState. =over =item C<< node >> The name of the node in the cluster element whose state is being represented. Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< health >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< eligibility >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< uuid >> Filled in for CMode CLI. =item C<< epsilon >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< "uuid_str" >> Filled in for CMode CLI. =item C<< node_uuid >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =back =cut package NACL::CS::Cluster; use strict; use warnings; use Params::Validate qw(validate); use NACL::Exceptions::NoElementsFound qw(:try); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use base qw(NACL::CS::ComponentState::ONTAP); use NACL::ComponentUtils qw(_dump_one); use Class::MethodMaker [ scalar => 'node', scalar => 'health', scalar => 'eligibility', scalar => 'uuid', scalar => 'epsilon', scalar => 'uuid_str', scalar => 'node_uuid', ]; =head1 METHODS =head2 fetch my $cluster_state = NACL::CS::Cluster->fetch(command_interface=>$ci,...); my @cluster_states = NACL::CS::Cluster->fetch(command_interface=>$ci,...); see L Supports CMode CLI. =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_cmode_zapi", interface => "ZAPI", set => "CMode", }, ], exception_text => 'No matching cluster(s) found', show_cmd => 'cluster show', ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_cmode_cli { my ($pkg, @args) = @_; my @state_objs; try { @state_objs = $pkg->SUPER::_fetch_cmode_cli(@args, api => "cluster_show"); } catch NACL::APISet::Exceptions::CommandNotFoundException with { my $exception = $_[0]; $Log->exit() if $may_exit; NACL::C::Exceptions::Cluster::PreClusterMode->convert_and_throw( exception => $exception); }; $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs; try { @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @args, copy => [qw (node-uuid)], map => { 'epsilon' => 'is-node-epsilon', 'eligibility' => 'is-node-eligible', 'health' => 'is-node-healthy', 'node' => 'node-name' }, api => "cluster-node-get-iter" ); } catch NACL::APISet::Exceptions::ResponseException with { my $exception = $_[0]; if ($exception->text() =~ /ZAPI is not enabled in pre-cluster mode/) { $Log->exit() if $may_exit; NACL::C::Exceptions::Cluster::PreClusterMode->convert_and_throw( exception => $exception); } else { $Log->exit() if $may_exit; $exception->throw(); } }; $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi 1;