# $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 VolumeFlexcacheCachePolicy Component Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::C::VolumeFlexcacheCachePolicy =head1 DESCRIPTION C is a derived class of L. It represents access to an ONTAP VolumeFlexcacheCachePolicy. A related class is L, which represents the past state of an ONTAP VolumeFlexcacheCachePolicy. =head1 ATTRIBUTES =head2 command_interface See L =head2 vserver =head2 policy =cut package NACL::C::VolumeFlexcacheCachePolicy; use strict; use warnings; use NACL::CS::VolumeFlexcacheCachePolicy; use NACL::ComponentUtils qw (_optional_scalars Dumper); use base 'NACL::C::Component::ONTAP'; use Params::Validate qw(validate validate_with SCALAR ARRAYREF); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NACL::C::_Mixins::VolumeFlexcacheCachePolicy qw(:all); =head1 METHODS =head2 new my $VolumeFlexcacheCachePolicy = NACL::C::VolumeFlexcacheCachePolicy->new(command_interface=>$ci, vserver =>$vserver, policy =>$policy, ); Return a new VolumeFlexcacheCachePolicy component object with the given attributes. =cut use Class::MethodMaker [ scalar => 'vserver', scalar => 'policy', ]; sub init { $Log->enter() if $may_enter; my ($self, @args) = @_; $self->SUPER::init(@args); $self->_vserver_context_init(@args); $Log->exit() if $may_exit; } ## end sub init =head2 find my $VolumeFlexcacheCachePolicy = NACL::C::VolumeFlexcacheCachePolicy->find(command_interface => $ci, ...); my @VolumeFlexcacheCachePolicys = NACL::C::VolumeFlexcacheCachePolicy->find(command_interface => $ci, ...); (Class method) A constructor of sorts, which discovers which elements are present (by interacting with the given command interface). In an array context it creates a component object for each present element and returns them. In a scalar context it creates a component object for just one element. This method is generally not implemented in individual components. The base class (L provides an implementation. See for a more detailed description along with explanation of all the options accepted. =head2 state my $VolumeFlexcacheCachePolicy_state = $NACL::C::VolumeFlexcacheCachePolicy->state(); (Instance method) Fetch the current state of the element associated with this component, and return a Component State object corresponding to this component (calling this on NACL::C::VolumeFlexcacheCachePolicy would return a NACL::CS::VolumeFlexcacheCachePolicy object) This method is generally not implemented in individual components. The base class (L provides an implementation. See for a more detailed description along with explanation of all the options accepted. =cut =head2 modify NACL::C::VolumeFlexcacheCachePolicy->modify( command_interface => $ci, vserver => $vserver, policy => $policy, ...); or $VolumeFlexcacheCachePolicy_object->modify(...); (Class or instance method) This method is used to modify a cache policy. Uses a CMode CLI/ZAPI APISet. Invokes "flexcache-cache-policy-modify" API for CMode ZAPI. =over =item Options =over =item C<< command_interface => $command_interface >> (Required for class method, Not Applicable for instance method) See L =item C<< apiset_must => $ruleset >> (Optional) See L =item C<< apiset_should => $ruleset >> (Optional) See L =item C<< "vserver" => $vserver >> (Required for class method, Not Applicable for instance method) Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: ZAPI will be invoked in the context of the vserver specified to this option. =item C<< "policy" => $policy >> (Required for class method, Not Applicable for instance method) Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: cache-policy-name =item C<< "reg-ttl" => $string >> Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: time-to-live-files =item C<< "dir-ttl" => $string >> Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: time-to-live-directories =item C<< "id" => $string >> Applicable for CMode CLI. =item C<< 'meta-ttl' => $string >> *ONTAP Metafile TTL in Seconds Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: time-to-live-metafiles =item C<< 'deleg-lru-timeout' => $string >> *Delegation LRU Timeout in Seconds Applicable for CMode CLI/ZAPI. =item C<< 'other-ttl' => $string >> *Other File TTL in Seconds Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: time-to-live-other =item C<< 'sym-ttl' => $string >> *Symbolic Link TTL in Seconds Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: time-to-live-symbolic =item C<< 'prefer-local-cache' => $string >> *Local Cache Preferred over Local Origin, possible value(s) are true,false Applicable for CMode CLI/ZAPI. =item C<< "extended_query" => $string >> (Optional) Applicable for CMode CLI. =item C<< '*' >> This method takes all other options supported by "volume flexcache cache-policy modify" command in ONTAP. Applicable for CMode CLI/ZAPI. =back =back =over =item Exceptions =over =item C In general, Component methods propagate the exceptions thrown from underlying API layer and the details of those exceptions are described in the L of user guide. =back =back =cut sub modify { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; $pkg_or_obj->_frontend_log_debug_opts(@args); my %opts = $pkg_or_obj->_common_validate_with( params => \@args, additional_spec => { _optional_scalars( qw( reg-ttl dir-ttl id meta-ttl deleg-lru-timeout other-ttl sym-ttl prefer-local-cache ) ), }, cli_cmd => 'volume flexcache cache-policy modify', ); my $ret = $pkg_or_obj->call_on_apiset( %opts, choices => [ { method => '_modify_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_modify_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], frontend => 'NACL::C::VolumeFlexcacheCachePolicy::modify', ); $Log->exit() if $may_exit; } ## end sub modify sub _modify_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->_base_backend_cmode_cli(@args, api => 'volume_flexcache_cache_policy_modify'); $Log->exit() if $may_exit; } ## end sub _modify_cmode_cli sub _modify_cmode_zapi { $Log->enter() if $may_enter; my ($pkg_or_obj, %opts) = @_; my $common_copy = $pkg_or_obj->_common_zapi_copy(); my $common_map = $pkg_or_obj->_common_zapi_map(); $pkg_or_obj->_base_backend_cmode_zapi( %opts, api => 'flexcache-cache-policy-modify', copy => $common_copy, map => $common_map, ); $Log->exit() if $may_exit; } ## end sub _modify_cmode_zapi =head2 delete NACL::C::VolumeFlexcacheCachePolicy->delete( command_interface => $ci, vserver => $vserver, policy => $policy, ...); or $VolumeFlexcacheCachePolicy_object->delete(...); (Class or instance method) This method is used to delete a cache policy. Uses a CMode CLI/ZAPI APISet. Invokes "flexcache-cache-policy-destroy" API for CMode ZAPI. =over =item Options =over =item C<< command_interface => $command_interface >> (Required for class method, Not Applicable for instance method) See L =item C<< apiset_must => $ruleset >> (Optional) See L =item C<< apiset_should => $ruleset >> (Optional) See L =item C<< "vserver" => $vserver >> (Required for class method, Not Applicable for instance method) Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: ZAPI will be invoked in the context of the vserver specified to this option. =item C<< "policy" => $policy >> (Required for class method, Not Applicable for instance method) Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: cache-policy-name =item C<< "extended_query" => $string >> (Optional) Applicable for CMode CLI. =item C<< '*' >> This method takes all other options supported by "volume flexcache cache-policy delete" command in ONTAP. Applicable for CMode CLI. =back =back =over =item Exceptions =over =item C In general, Component methods propagate the exceptions thrown from underlying API layer and the details of those exceptions are described in the L of user guide. =back =back =cut sub delete { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; $pkg_or_obj->_frontend_log_debug_opts(@args); my %opts = $pkg_or_obj->_common_validate_with( params => \@args, cli_cmd => 'volume flexcache cache-policy delete', ); my $ret = $pkg_or_obj->call_on_apiset( %opts, choices => [ { method => '_delete_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_delete_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], frontend => 'NACL::C::VolumeFlexcacheCachePolicy::delete', ); $Log->exit() if $may_exit; return $ret; } ## end sub delete sub _delete_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->_base_backend_cmode_cli(@args, api => 'volume_flexcache_cache_policy_delete'); $Log->exit() if $may_exit; } ## end sub _delete_cmode_cli sub _delete_cmode_zapi { $Log->enter() if $may_enter; my ($pkg_or_obj, %opts) = @_; my $map = {'policy' => 'cache-policy-name'}; my $copy = [qw (vserver )]; $pkg_or_obj->_base_backend_cmode_zapi( %opts, api => 'flexcache-cache-policy-destroy', copy => $copy, map => $map, ); $Log->exit() if $may_exit; } ## end sub _delete_cmode_zapi =head2 create my $VolumeFlexcacheCachePolicy_object = NACL::C::VolumeFlexcacheCachePolicy->create( command_interface => $ci, vserver => $vserver, policy => $policy, ...); (Class method) This method is used to add a new cache policy. Uses a CMode CLI/ZAPI APISet. Invokes "flexcache-cache-policy-create" API for CMode ZAPI. =over =item Options =over =item C<< command_interface => $command_interface >> (Required) See L =item C<< apiset_must => $ruleset >> (Optional) See L =item C<< apiset_should => $ruleset >> (Optional) See L =item C<< "vserver" => $vserver >> (Required) Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: ZAPI will be invoked in the context of the vserver specified to this option. =item C<< "policy" => $policy >> (Required) Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: cache-policy-name =item C<< "reg-ttl" => $string >> Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: time-to-live-files =item C<< "dir-ttl" => $string >> Applicable for CMode CLI/ZAPI. Maps to: CM ZAPI: time-to-live-directories =item C<< "id" => $string >> Applicable for CMode CLI. =item C<< 'meta-ttl' => $string >> *ONTAP Metafile TTL in Seconds Applicable for CMode CLI. =item C<< 'deleg-lru-timeout' => $string >> *Delegation LRU Timeout in Seconds Applicable for CMode CLI. =item C<< 'other-ttl' => $string >> *Other File TTL in Seconds Applicable for CMode CLI. =item C<< 'sym-ttl' => $string >> *Symbolic Link TTL in Seconds Applicable for CMode CLI. =item C<< 'prefer-local-cache' => $string >> *Local Cache Preferred over Local Origin, possible value(s) are true,false Applicable for CMode CLI. =item C<< "extended_query" => $string >> (Optional) Applicable for CMode CLI. =item C<< '*' >> This method takes all other options supported by "volume flexcache cache-policy create" command in ONTAP. Applicable for CMode CLI. =back =back =over =item Exceptions =over =item C In general, Component methods propagate the exceptions thrown from underlying API layer and the details of those exceptions are described in the L of user guide. =back =back =cut sub create { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->_frontend_log_debug_opts(@args); my %opts = $pkg->_common_validate_with( only_static_method => 1, params => \@args, additional_spec => { _optional_scalars( qw( reg-ttl dir-ttl id meta-ttl deleg-lru-timeout other-ttl sym-ttl prefer-local-cache ) ), }, cli_cmd => 'volume flexcache cache-policy create', ); my $ret = $pkg->call_on_apiset( %opts, choices => [ { method => '_create_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_create_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], frontend => 'NACL::C::VolumeFlexcacheCachePolicy::create', ); my $obj = $pkg->new( command_interface => $opts{'command_interface'}, vserver => $opts{'vserver'}, policy => $opts{'policy'}, ); $Log->exit() if $may_exit; return $obj; } ## end sub create sub _create_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->_base_backend_cmode_cli(@args, api => 'volume_flexcache_cache_policy_create'); $Log->exit() if $may_exit; } ## end sub _create_cmode_cli sub _create_cmode_zapi { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; my %opts = validate_with( params => \@args, spec => { %{$pkg_or_obj->_backend_validate_spec()}, 'reg-ttl' => {default => 0}, 'dir-ttl' => {default => 0}, 'meta-ttl' => {default => 15}, 'sym-ttl' => {default => 0}, 'other-ttl' => {default => 0}, 'deleg-lru-timeout' => {default => 3600}, 'prefer-local-cache' => {default => "false"}, }, allow_extra => 1 ); my $common_copy = $pkg_or_obj->_common_zapi_copy(); my $common_map = $pkg_or_obj->_common_zapi_map(); $pkg_or_obj->_base_backend_cmode_zapi( %opts, api => 'flexcache-cache-policy-create', copy => $common_copy, map => $common_map, ); $Log->exit() if $may_exit; } ## end sub _create_cmode_zapi __PACKAGE__->_load_event_class(); sub _primary_keys_validate_spec { return ( 'vserver' => {type => SCALAR}, 'policy' => {type => SCALAR}, ); } ## end sub _primary_keys_validate_spec 1;