# $Id: //depot/prod/test/nacldev/lib/NACL/CS/DFM/Ldap.pm#1 $ # # Copyright (c) 2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary Ldap ComponentState Module (auto-generated by CGT) ## @author dl-mpo-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::DFM::Ldap =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP Ldap. A related class is L, which represents access to an ONTAP Ldap. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Ldap element are the attributes of the Ldap ComponentState. =over =item C<< ldap_server_addr >> =item C<< ldap_server_port >> =back =cut package NACL::CS::DFM::Ldap; use strict; use warnings; use Params::Validate qw(validate validate_with SCALAR ARRAYREF HASHREF); use NACL::ComponentUtils qw(Dumper); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use base 'NACL::CS::ComponentState::DFM'; use Class::MethodMaker [ new => [ '-hash', 'new' ], scalar => 'ldap_server_addr', scalar => 'ldap_server_port', scalar => 'ldap_server', ]; =head1 METHODS =head2 fetch my $Ldap_state = NACL::CS::DFM::Ldap->fetch(command_interface => $ci, ...); my @Ldap_states = NACL::CS::DFM::Ldap->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. =cut sub fetch { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => '_fetch_zapi', interface => 'ZAPI', set => 'DFM', }, ], exception_text => 'No matching Ldap(s) found.', ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_zapi { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $command_interface = delete $opts{command_interface}; my $apiset = delete $opts{apiset}; my $allowed_options = [ qw( ldap-server ) ]; my %args; $pkg->_hash_copy( source => $opts{filter}, copy => $allowed_options, target => \%args, ); my $response = $apiset->ldap_server_list_info(%args); my $parsed_output = $response->get_parsed_output(); my @state_objs; # Go one level down to 'ldap-server' which will have all the fields my $output = $parsed_output->[0]->{'ldap-servers'}->[0]->{'ldap-server'}; foreach my $row ( @{$output} ) { my $obj = $pkg->new(command_interface => $command_interface); $obj->_set_fields( row => $row ); $obj->{'ldap_server'} = { 'ldap-server-addr' => $row->{'ldap-server-addr'}, 'ldap-server-port' => $row->{'ldap-server-port'} }; push( @state_objs, $obj ); } # Return the state objects return @state_objs; } sub _extra_filter_fields { $Log->enter() if $may_enter; $Log->exit() if $may_exit; return [ qw(ldap-server) ]; } 1;