# # Copyright (c) 2001-2010 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary ComponentState Module for the method NACL::C::SystemServicesNdmp->show() ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SystemServicesNdmpShow =head1 DESCRIPTION C is a derived class of L. Object(s) of this type are returned when NACL::C::SystemServicesNdmp->show() is invoked. (This command shows the NDMP service configuration for all the nodes in the cluster) (This module does not represent the state of any element, but is an object repesentation of the output obtained when the "system services ndmp show" is run. =head1 ATTRIBUTES The fields of the output are fields of the ComponentState object. =over =item C<< node >> The node for which the NDMP service configurations are being displated. =item C<< enable >> NDMP service enabled? Possible values: true; false =item C<< clear_text >> Allow clear text password? Possible values: true; false =item C<< user_id >> NDMP User ID =back =cut package NACL::CS::SystemServicesNdmpShow; 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 => 'node', scalar => 'enable', scalar => 'clear_text', scalar => 'user_id', ]; =head1 METHODS =head2 fetch my $SystemServicesNdmpShow_obj = NACL::CS::SystemServicesNdmpShow->fetch(command_interface => $ci, ...); my @SystemServicesNdmpShow_objs = NACL::CS::SystemServicesNdmpShow->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. =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 => 'system services ndmp show', choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', zapi_type => 'iter' }, ], exception_text => 'No matching system services ndmp show(s) found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_cmode_cli { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::_fetch_cmode_cli( @_, api => 'system_services_ndmp_show' ); $Log->exit() if $may_exit; return @state_objs; } # The only field we can fill in in 7Mode/Nodescope is whether the service # is enabled or not. We do this by running "ndmpd status". sub _fetch_7mode_cli { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; my $apiset = $opts{apiset}; my $response = $apiset->ndmpd_status(); my $output = $response->get_parsed_output(); my $status = $output->[0]{ndmpd_status}; # The NDMP status as returned by "ndmpd status" is either "ON" or "OFF". # CMode CLI has a field "enable" which is either of true or false. # We perform to ON -> true; OFF -> false mapping here my $enable; if ($status =~ /on/i) { $enable = 'true'; } else { $enable = 'false'; } my @state_objs; my $state_obj = $pkg->new(enable => $enable); push @state_objs, $state_obj; $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @args, copy => [ qw(enable user-id clear-text ) ], map => {'node' => 'node-name',}, api => "ndmp-node-attributes-get-iter", ); $Log->exit() if $may_exit; return @state_objs; } 1;