# $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 VserverCifsDomainPreferredDc ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com , benjaram@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VserverCifsDomainPreferredDc =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP VserverCifsDomainPreferredDc. A related class is L, which represents access to an ONTAP VserverCifsDomainPreferredDc. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the VserverCifsDomainPreferredDc element are the attributes of the VserverCifsDomainPreferredDc ComponentState. =over =item C<< "domain" >> Filled in for CMode CLI/ZAPI,7M CLI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value 7M CLI: For "filter": domain name(Programmatic name: "domain") For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "vserver" >> =item C<< "preferred_dc" >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $preferred_dc = $obj->preferred_dc(); $preferred_dc contains a reference to the array of values my @preferred_dc = $obj->preferred_dc(); @preferred_dc contains the array of values Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: @values 7M 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<< "lif" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< lif_id >> Filled in for CMode CLI / ZAPI. =back =cut package NACL::CS::VserverCifsDomainPreferredDc; 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 Data::Dumper; use NACL::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'domain', scalar => 'vserver', array => 'preferred_dc', scalar => 'lif', scalar => 'lif_id', ]; =head1 METHODS =head2 fetch my $VserverCifsDomainPreferredDc_state = NACL::CS::VserverCifsDomainPreferredDc->fetch(command_interface => $ci, ...); my @VserverCifsDomainPreferredDc_states = NACL::CS::VserverCifsDomainPreferredDc->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. Supports CMode CLI/ZAPI,7Mode CLI. Invokes "cifs-domain-preferred-dc-get-iter" in CMode ZAPI. Invokes "cifs prefdc print" in 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, 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 cifs domain preferred-dc show', exception_text => 'No matching cifs domain preferred dc(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, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@args, api => 'vserver_cifs_domain_preferred_dc_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, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @args, copy => [qw ( domain lif )], map => { 'preferred-dc' => ['preferred-dc', make_zapi_skip('inet-address')] }, api => 'cifs_domain_preferred_dc_get_iter' ); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi sub _fetch_7mode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $apiset = delete $opts{apiset}; my ($prefdc_op, $prefdc_resp); my ($temp_attributes, $final_attributes); my @state_objs; my %cmd_opts; my %copy_filter = %{$opts{filter}}; delete $copy_filter{vserver}; my @copy_requested_fields = @{$opts{requested_fields}}; my $deleted_filter = $pkg->_remove_relational_regex_filters( filter => \%copy_filter, requested_fields => \@copy_requested_fields ); my $filter = \%copy_filter; my $requested_fields = \@copy_requested_fields; if ($filter->{domain}) { $cmd_opts{'domain'} = $filter->{'domain'}; } $prefdc_resp = $apiset->cifs_prefdc_print(%cmd_opts); $prefdc_op = $prefdc_resp->get_parsed_output(); foreach my $row (@$prefdc_op) { my $final_attributes = $pkg->_hash_copy( source => $row, copy => [qw( domain preferred_dc )], ); my $preferred_dc_string = delete $final_attributes->{preferred_dc}; my @pref_dc = split ',', $preferred_dc_string; $final_attributes->{preferred_dc} = \@pref_dc; my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => $final_attributes); push @state_objs, $obj; } ## end foreach my $row (@$prefdc_op) $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli 1;