# # Copyright (c) 2001-2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary VserverServicesLdapClient ComponentState Module ## @author Rupamjyoti.Baruah@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VserverServiceLdapClient =head1 DESCRIPTION C is a derived class of L. It represents the state of a Vserver Service Ldap Client . A related class is L, which represents =head1 ATTRIBUTES The individual pieces of data that are part of the state of the element are the attributes of the ComponentState. =over =item C<< client_config >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< servers >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: @values 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< ad_domain >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value Maps to: 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< preferred_ad_servers >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: @values Maps to: 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< bind_as_cifs_server >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< schema >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< port >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< query_timeout >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value Maps to: 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< min_bind_level >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< bind_dn >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value Maps to: 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< bind_password >> Filled in for CMode CLI, 7Mode CLI. Maps to: 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< base_dn >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< base_scope >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< user_dn >> Filled in for CM de CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< user_scope >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< group_dn >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value Maps to: 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< group_scope >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< netgroup_dn >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value Maps to: 7Mode CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< net grour scout >> Filled in for CMode CLI. =item C<< asymmetric_name_mapping >> Filled in for CMode CLI. = item C<< is_netgroup_byhost_enabled >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value = item C<< 'netgroup_byhost_dn' >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< is_owner >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< vserver >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< use_start_tls >> Use start-tls Over LDAP Connections possible value(s) are, true,false Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =back =cut package NACL::CS::VserverServicesLdapClient; 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 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 [ # These fields are from the C Mode "vserver services ldap client show" scalar => 'client_config', array => 'servers', scalar => 'ad_domain', array => 'preferred_ad_servers', scalar => 'bind_as_cifs_server', scalar => 'schema', scalar => 'port', scalar => 'query_timeout', scalar => 'min_bind_level', scalar => 'bind_dn', scalar => 'bind_password', scalar => 'base_dn', scalar => 'base_scope', scalar => 'user_dn', scalar => 'user_scope', scalar => 'group_dn', scalar => 'group_scope', scalar => 'netgroup_dn', scalar => 'netgroup_scope', scalar => 'asymmetric_name_mapping', scalar => 'is_owner', scalar => 'vserver', scalar => 'use_start_tls', scalar => 'netgroup_byhost_dn', scalar => 'is_netgroup_byhost_enabled', ]; =head1 METHODS =head2 fetch my $node_state = NACL::CS::VserverServicesLdapClient;->fetch(command_interface=>$ci,...); my @node_states = NACL::CS::VserverServicesLdapClient;->fetch(command_interface=>$ci,...); see L Supports CMode CLI/ZAPI, 7Mode CLI. Invokes "ldap-client-get-iter" API for CMode ZAPI. Invokes "options("show-options" => 'ldap')" command 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 = shift; my %opts = @_; 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 => 'vserver services ldap client show', exception_text => 'No matching vserver services ldap client(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, %opts) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(%opts, api => "vserver_services_ldap_client_show"); $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( %opts, api => "ldap-client-get-iter", copy => [ qw(user-scope min-bind-level ad-domain base-dn schema base-scope bind-as-cifs-server bind-dn group-dn group-scope is-owner netgroup-dn netgroup-scope query-timeout use-start-tls user-dn vserver netgroup-byhost-dn is-netgroup-byhost-enabled ) ], map => { "client-config" => 'ldap-client-config', "servers" => [make_zapi_array('servers'), make_zapi_skip('ip-address'),], "port" => 'tcp-port', "preferred-ad-servers" => [ make_zapi_array('preferred-ad-servers'), make_zapi_skip('ip-address'), ] }, ); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi sub _fetch_7mode_cli { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = delete $opts{apiset}; my $filter = delete $opts{filter}; my %cmd_opts; my @state_objs; my $response = $apiset->options("show-options" => 'ldap'); my $output = $response->get_parsed_output(); foreach my $row (@$output) { my $obj = $pkg->new(); my $row_modified; $row_modified = $pkg->_hash_copy( source => $row, map => { 'ldap.ADdomain' => 'ad_domain', 'ldap.name' => 'client_config', 'ldap.servers' => 'servers', 'ldap.servers.preferred' => 'preferred_ad_servers', 'ldap.port' => 'port', 'ldap.timeout' => 'query_timeout', 'ldap.minimum_bind_level' => 'min_bind_level', 'ldap.usermap.base' => 'bind_dn', 'ldap.base.passwd' => 'bind_password', 'ldap.base' => 'base_dn', 'ldap.base.group' => 'group_dn', 'ldap.base.netgroup' => 'netgroup_dn', }, ); $$row_modified{'command_interface'} = $opts{'command_interface'}; $obj->_set_fields(row => $row_modified); push @state_objs, $obj; } ## end foreach my $row (@$output) $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli 1;