# $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 VserverCifsGroupPolicy ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::VserverCifsGroupPolicy =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP VserverCifsGroupPolicy. A related class is L, which represents access to an ONTAP VserverCifsGroupPolicy. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the VserverCifsGroupPolicy element are the attributes of the VserverCifsGroupPolicy ComponentState. =over =item C<< "vserver" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: "For "filter":Invoked in the context of the specified vserver For requested_fields: Not applicable but the field will be populated in the CS object For Output mapping: The vserver in whose context, the ZAPI was invoked, will be returned =item C<< "status" >> Filled in for CMode CLI/ZAPI and 7M CLI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value 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<< "gpo_status_zapi" >> =back =cut package NACL::CS::VserverCifsGroupPolicy; 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::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'vserver', scalar => 'status', scalar => 'gpo_status_zapi', ]; =head1 METHODS =head2 fetch my $VserverCifsGroupPolicy_state = NACL::CS::VserverCifsGroupPolicy->fetch(command_interface => $ci, ...); my @VserverCifsGroupPolicy_states = NACL::CS::VserverCifsGroupPolicy->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 CM CLI/ZAPI and 7M CLI. Invokes "gpo-get-iter" API for CMode ZAPI. Invokes "options cifs.gpo.enable" 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 cifs group-policy show', 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', }, ], exception_text => 'No matching vserver cifs group policy(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 = shift; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@_, api => 'vserver_cifs_group_policy_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, %opts) = @_; if (exists $opts{filter}->{status}) { my %filter = %{$opts{filter}}; if ($filter{status} eq 'enabled') { $filter{status} = 'true'; } elsif ($filter{status} eq 'disabled') { $filter{status} = 'false'; } $opts{filter} = \%filter; } my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( %opts, copy =>[qw(vserver)], map => { 'status' => 'is-gpo-enabled'}, api =>'gpo-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 @state_objs; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = delete $opts{apiset}; delete $opts{filter}; my (%temp_attributes, %final_attributes); my $response = $apiset->options('cifs.gpo.enable'); my $output = $response->get_parsed_output(); $temp_attributes{'gpo_status'} = $output->[0]->{'cifs.gpo.enable'}; $pkg->_hash_copy( source => \%temp_attributes, map => {'gpo_status' => "status",}, target => \%final_attributes ); my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => \%final_attributes); push @state_objs, $obj; return @state_objs; } ## end sub _fetch_7mode_cli sub _update_state_objs_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->SUPER::_update_state_objs_cmode_zapi( @args, zapi_field_translations => {enable_disable => [qw(status)]}, ); $Log->exit() if $may_exit; } 1;