# $Id$ # # Copyright (c) 2001-2014 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary SnaplockComplianceClock ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SnaplockComplianceClock =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP SnaplockComplianceClock. A related class is L, which represents access to an ONTAP SnaplockComplianceClock. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the SnaplockComplianceClock element are the attributes of the SnaplockComplianceClock ComponentState. Additionally, the command_interface used to obtain the ComponentState object is also an attribute of the object. This makes it easier to obtain the component object corresponding to the CS object, using L. =over =item command_interface The command_interface with which the CS object was obtained. (Available in all CS objects regardless of requested_fields and the mode/interface) =item C<< nodeId >> Node Id of the ComplianceClock Filled in for CMode CLI. =item C<< sccId >> System ComplianceClock Id Filled in for CMode CLI. =item C<< time >> ComplianceClock Time of the Node Filled in for CMode CLI/ZAPI, non-iter. Mapping for CMode ZAPI non-iter: formatted-snaplock-compliance-clock =item C<< node_compliance_clock_secs >> ComplianceClock Time in Seconds Filled in for CMode CLI/ZAPI, non-iter. Mapping for CMode ZAPI non-iter: snaplock-compliance-clock =item C<< compliance_clock_skew >> Skew in ComplianceClock against System Clock Filled in for CMode CLI. =item C<< node >> Node possible value(s) are, ,local Filled in for CMode CLI/ZAPI, non-iter. =back =cut package NACL::CS::SnaplockComplianceClock; use strict; use warnings; use Params::Validate qw(validate); use NATE::Log qw(log_global); use NACL::Exceptions::NoElementsFound qw(:try); use NACL::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::CS::ComponentState::ZapiArray qw(make_zapi_array); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'nodeId', scalar => 'sccId', scalar => 'time', scalar => 'node_compliance_clock_secs', scalar => 'compliance_clock_skew', scalar => 'node', ]; my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); sub _check_non_iter { $Log->enter() if $may_enter; my ($pkg, @opts) = @_; $pkg->_base_check_non_iter(@opts, _primary_keys => [qw(node)],); $Log->exit() if $may_exit; } =head1 METHODS =head2 fetch my $SnaplockComplianceClock_state = NACL::CS::SnaplockComplianceClock->fetch(command_interface => $ci, ...); my @SnaplockComplianceClock_states = NACL::CS::SnaplockComplianceClock->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 CMode CLI/ZAPI, 7Mode-CLI. Invokes snaplock-get-node-compliance-clock API for CMode ZAPI non-iter. Invokes "snaplock clock status" for 7Mode-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, @args) = @_; my @state_objs = $pkg->SUPER::fetch( @args, show_cmd => 'snaplock compliance-clock show', choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', zapi_type => 'none', }, { method => '_fetch_cmode_zapi_non_iter', interface => 'ZAPI', set => 'CMode', zapi_type => 'non-iter', check => '_check_non_iter', }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode', zapi_type => 'none', }, ], exception_text => 'No matching SnaplockComplianceClock(s) found', frontend => 'NACL::CS::SnaplockComplianceClock::fetch', ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@args, api => 'snaplock_compliance_clock_show',); $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi_non_iter { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; my $apiset = $opts{apiset}; my $response = $apiset->snaplock_get_node_compliance_clock( node => $opts{filter}{node}); my $parsed_output = $response->get_parsed_output(); my $time = $parsed_output->[0]{'snaplock-node-compliance-clock'}[0] {'compliance-clock-info'}[0]{'formatted-snaplock-compliance-clock'}; my $cs_obj = $pkg->new(command_interface => $opts{command_interface}); $cs_obj->_set_fields(row => {time => $time, node => $opts{filter}{node}}); $Log->exit() if $may_exit; return $cs_obj; } sub _fetch_7mode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $command_interface = $opts{command_interface}; my $apiset = $opts{apiset}; my $time = $apiset->snaplock_clock_status()->get_parsed_output()->[0]{'system_compliance_clock'}; my $cs = $pkg->new(command_interface => $command_interface); $cs->_set_fields(row => {time => $time, node => $command_interface->node()}); $Log->exit() if $may_exit; return $cs; } 1;