# $Id$ # This is a prototype.It needs documentation. # # Copyright (c) 2001-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary VserverServicesNisDomain ComponentState Module ## @author Rupamjyoti.Baruah@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VserverServicesNisDomain =head1 DESCRIPTION C is a derived class of L. It represents the state of a Vserver Services Nis Domain. A related class is L, which represents access to ONTAP Vserver Services Nis Domain. =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<< vserver >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< domain >> 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<< active >> 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<< ipdetails >> Filled in for CMode/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<< bound_servers >> Bound NIS Servers (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $bound_servers = $obj->bound_servers(); # $bound_servers contains a reference to the array of values my @bound_servers = $obj->bound_servers(); # @bound_servers contains the array of values If this field needs to be passed to the filter hash, the value for this field should be passed in as an arrayref # filter => { bound_servers = [ value1, value2...] } Filled in for CMode CLI. =back =cut package NACL::CS::VserverServicesNisDomain; use strict; use warnings; use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use Params::Validate qw(validate); use NACL::ComponentUtils qw(_dump_one); use NACL::C::Component; 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 nis-domain show" scalar => 'vserver', scalar => 'domain', scalar => 'active', array => 'servers', array => 'ipdetails', array => 'bound_servers', ]; =head1 METHODS =head2 fetch my $node_state = NACL::CS::VserverServicesNisDomain->fetch(command_interface=>$ci,...); my @node_states = NACL::CS::VserverServicesNisDomain->fetch(command_interface=>$ci,...); see L Supports CMode CLI/ZAPI, 7Mode CLI. Invokes "nis-get-iter" API for CMode ZAPI. Invokes "nis info" 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 @state_objs = $pkg->SUPER::fetch( @_, show_cmd => 'vserver services nis-domain show', choices => [ { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode', }, { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], exception_text => 'No matching vserver services nis domain(s) found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_cmode_cli { my $pkg = shift; return $pkg->SUPER::_fetch_cmode_cli(@_, api => "vserver_services_nis_domain_show"); } sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @_, api => "nis_get_iter", map => { "vserver" => ['vserver'], "active" => ['is-active'], "servers" => [ make_zapi_array('nis-servers'), make_zapi_skip('ip-address'), ], "domain" => ['nis-domain'], }, ); $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 $state_settings; my $command_interface = delete $opts{command_interface}; my $response = $apiset->nis_info(%cmd_opts); my $output = $response->get_parsed_output(); foreach my $list_output (@$output) { my $target = $pkg->_hash_copy( source => $list_output, copy => [qw(domain ipdetails)] ); my $state_info = $target->{'ipdetails'}->[0]; if ($state_info->{'bound'} eq "NO") { $state_info->{'bound'} = "FALSE"; } $state_settings = $pkg->_hash_copy( source => $state_info, map => { 'bound' => 'active', 'ip_address' => 'servers', }, ); my %final_attributes = (%$target, %$state_settings); my $obj = $pkg->new(command_interface => $command_interface); $obj->_set_fields(row => \%final_attributes); push @state_objs, $obj; } ## end foreach my $list_output (@$output) $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli 1;