# $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 SystemHealthPolicyDefinition ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SystemHealthPolicyDefinition =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP SystemHealthPolicyDefinition. A related class is L, which represents access to an ONTAP SystemHealthPolicyDefinition. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the SystemHealthPolicyDefinition element are the attributes of the SystemHealthPolicyDefinition ComponentState. =over =item C<< "rule_expression" >> =item C<< "alert_id" >> =item C<< "enable" >> =item C<< "responsible_resource_info" >> =item C<< "monitor" >> =item C<< "alert_count" >> =item C<< "node" >> =item C<< "where" >> =item C<< "prev_alert_creation_time" >> =item C<< "policy_id" >> =item C<< process >> Filled in for CMode CLI. =item C<< asup_enable >> Enable ASUP for this alert, possible value(s) are true,false Filled in for CMode CLI. =back =cut package NACL::CS::SystemHealthPolicyDefinition; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw(_dump_one); 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 => 'rule_expression', scalar => 'alert_id', scalar => 'enable', scalar => 'responsible_resource_info', scalar => 'monitor', scalar => 'alert_count', scalar => 'node', scalar => 'where', scalar => 'prev_alert_creation_time', scalar => 'policy_id', scalar => 'process', scalar => 'asup_enable', ]; =head1 METHODS =head2 fetch my $SystemHealthPolicyDefinition_state = NACL::CS::SystemHealthPolicyDefinition->fetch(command_interface => $ci, ...); my @SystemHealthPolicyDefinition_states = NACL::CS::SystemHealthPolicyDefinition->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. =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', }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode', }, ], show_cmd => 'system health policy definition show', exception_text => 'No matching system health policy definition(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 => 'system_health_policy_definition_show'); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my $pkg = shift; my %opts = @_; my $copy = [ qw(alert-id rule-expression enable responsible-resource-info monitor alert-count node where policy-id) ]; my $map = {"prev_alert_creation_time" => ['creation-time'],}; $Log->exit() if $may_exit; return $pkg->SUPER::_fetch_cmode_zapi( %opts, api => "diagnosis-policy-definition-get-iter", copy => $copy, map => $map, ); } ## end sub _fetch_cmode_zapi sub _fetch_7mode_cli { $Log->enter() if $may_enter; my $pkg_or_obj = shift; my %opts = validate @_, $pkg_or_obj->_fetch_backend_validate_spec(); my $command_interface = $opts{command_interface}; my $apiset = $opts{apiset}; my $filter = delete $opts{filter}; my %final_attributes; my @state_objs; my $response = $apiset->system_health_policy_definition_show(); my $output = $response->get_parsed_output(); pop @{$output}; foreach my $row (@{$output}) { $pkg_or_obj->_hash_copy( source => $row, copy => [qw( node monitor where enable )], map => { policy => "policy-id", 'number_of_alerts' => "alert-count", 'previous_alert_time' => "prev-alert-creation-time", 'responsible_resource' => "responsible-resource-info", 'policy_rule_expression' => "rule-expression", 'alert_id' => "alert-id" }, target => \%final_attributes ); my $obj = $pkg_or_obj->new(command_interface => $command_interface,); $obj->_set_fields(row => \%final_attributes); push @state_objs, $obj; } $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli 1;