# $Id: //depot/prod/test/main/lib/NACL/CS/SystemServicesNdmp.pm#1 $ # # Copyright (c) 2010 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary SystemServicesNdmp ComponentState Module ## @author dl-dpg-nb-automation; dl-nacl-dev ## @status public ## @pod here =head1 NAME NACL::CS::SystemServicesNdmp =head1 DESCRIPTION C is a derived class of L. It represents the state of an NDMP session. A related class is L, which represents access to the NDMP service configuration and individual NDMP sessions. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the SystemServicesNdmp element are the attributes of the SystemServicesNdmp ComponentState. =over =item C<< ndmp_version >> NDMP Version =item C<< effHost >> Effective host =item C<< session_authorized >> Is session authorized? Possible values: true; false =item C<< client_addr >> NDMP client address =item C<< spt_device_id >> Scsi device ID =item C<< spt_ha >> Scsi host adapter =item C<< spt_scsi_id >> Scsi target ID =item C<< spt_scsi_lun >> Scsi lun ID =item C<< tape_device >> Tape device =item C<< tape_mode >> Tape mode =item C<< mover_state >> Mover state =item C<< mover_mode >> Mover mode =item C<< mover_pausereason >> Mover pause reason =item C<< mover_halt_reason >> Mover halt reason =item C<< mover_record_size >> Mover record size =item C<< mover_record_num >> Mover record num =item C<< mover_bytes_moved >> Mover bytes moved =item C<< mover_seek_position >> Mover seek position =item C<< mover_bytes_left_to_read >> Mover bytes left to read =item C<< mover_window_offset >> Mover window offset =item C<< mover_window_length >> Mover window length =item C<< mover_position >> Mover position =item C<< mover_setrecordsize_flag >> Mover SetRecordSize flag =item C<< mover_setwindow_flag >> Mover SetWindow flag =item C<< mover_con_adr_type >> Mover connect type =item C<< mover_con_adr >> Mover connect address =item C<< mover_con_adr_port >> Mover connect port =item C<< data_operation >> Data operation =item C<< data_state >> Data state =item C<< data_halt_reason >> Data Halt Reason =item C<< data_con_adr_typee >> Data server connect type =item C<< data_bytes_processed >> Data bytes processed =item C<< operating >> =item C<< session_id >> Session identifier =item C<< enable >> Filled in for CMode CLI. =item C<< password >> Filled in for CMode CLI. =item C<< user_id >> Filled in for CMode CLI. =item C<< clear_text >> Filled in for CMode CLI. =item C<< node >> Filled in for CMode CLI. =item C<< common_sessions >> NDMP Common Sessions Filled in for CMode CLI. =back =cut package NACL::CS::SystemServicesNdmp; use strict; use warnings; use Params::Validate qw(validate); use Data::Dumper; use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NACL::ComponentUtils qw(_dump_one); use NACL::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'ndmp_version', scalar => 'effHost', scalar => 'session_authorized', scalar => 'client_addr', scalar => 'spt_device_id', scalar => 'spt_ha', scalar => 'spt_scsi_id', scalar => 'spt_scsi_lun', scalar => 'tape_device', scalar => 'tape_mode', scalar => 'mover_state', scalar => 'mover_mode', scalar => 'mover_pausereason', scalar => 'mover_halt_reason', scalar => 'mover_record_size', scalar => 'mover_record_num', scalar => 'mover_bytes_moved', scalar => 'mover_seek_position', scalar => 'mover_bytes_left_to_read', scalar => 'mover_window_offset', scalar => 'mover_window_length', scalar => 'mover_position', scalar => 'mover_setrecordsize_flag', scalar => 'mover_setwindow_flag', scalar => 'mover_con_adr_type', scalar => 'mover_con_adr_', scalar => 'mover_con_adr_port', scalar => 'data_operation', scalar => 'data_state', scalar => 'data_halt_reason', scalar => 'data_con_adr_type', scalar => 'data_bytes_processed', scalar => 'operating', scalar => 'session_id', scalar => 'enable', scalar => 'password', scalar => 'user_id', scalar => 'clear_text', scalar => 'node', scalar => 'common_sessions', ]; =head1 METHODS =head2 fetch my $SystemServicesNdmp_state = NACL::CS::SystemServicesNdmp->fetch(command_interface => $ci, ...); my @SystemServicesNdmp_states = NACL::CS::SystemServicesNdmp->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 status', choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode|Nodescope', }, ], exception_text => 'No matching system services ndmp(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 => 'system_services_ndmp_status',); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _fetch_7mode_cli { $Log->enter() if $may_enter; my $pkg = shift; my ($status_output, $probe_output, $caught_exception, $key, %api_args, %operating_keyed_by_session_id); my ($status_session_info, $probe_session_info); my ($status_response, $probe_response, $probe_session); my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; # applying filter so that we can retrieve probe status for a # particular session my $filter = $opts{filter}; if (exists $filter->{'session-id'}) { $api_args{'session-id'} = $filter->{'session-id'}; } try { #invoking appropiate API $status_response = $apiset->ndmpd_status(); $probe_response = $apiset->ndmpd_probe(%api_args); } ## end try catch NACL::APISet::Exceptions::InvalidParamValueException with { $caught_exception = 1; }; if ($caught_exception) { $Log->exit() if $may_exit; return; } my @state_objs; #retrieve the parsed output $status_output = $status_response->get_parsed_output(); $probe_output = $probe_response->get_parsed_output(); #Parsed output is array of hash.ndmpd_session_info is a key having value # again array of hash. Reading the ndmpd_session_info in a variable $status_session_info = $status_output->[0]{ndmpd_session_info}; $probe_session_info = $probe_output->[0]{ndmpd_session_info}; my ($status_session_id, $probe_session_id); # creating a hash, Session id as Key and respective operating value # will be value for it from ndmpd status output # operating is the only field is only given by ndmpd status command # as this field is very much required, we will copy the operating # field value to ndmpd probe status. foreach my $status_session (@{$status_session_info}) { $operating_keyed_by_session_id{$status_session->{session}} = $status_session->{operating}; } #reading ndmpd probe parsed output foreach $probe_session (@{$probe_session_info}) { my $obj = $pkg->new(command_interface => $opts{command_interface}); my $current_session_id = $probe_session->{session}; # keys in the parsed output contains dot character.Beacuse of # method maker classs, we cant use dot character hence we are replacing # all dot character to underscore foreach my $key (keys %{$probe_session}) { if ($key =~ /\./) { my $new_key = $key; $new_key =~ s/\./_/g; $probe_session->{$new_key} = delete $probe_session->{$key}; } } ## end foreach my $key ( keys %{$probe_session... #translating 7mode output to C-Mode equivalent $obj->_hash_move( source => $probe_session, map => { 'session' => 'session_id', 'effhost' => 'effHost', 'mover_connect_addr_type' => 'mover_con_adr_type', 'mover_setwindowflag' => 'mover_setwindow_flag', 'mover_setrecordsizeflag' => 'mover_setrecordsize_flag', 'mover_windowlength' => 'mover_window_length', 'mover_windowoffset' => 'mover_window_offset', 'mover_byteslefttoread' => 'mover_bytes_left_to_read', 'mover_seekposition' => 'mover_seek_position', 'mover_bytesmoved' => 'mover_bytes_moved', 'mover_recordnum' => 'mover_record_num', 'mover_recordsize' => 'mover_record_size', 'mover_haltreason' => 'mover_halt_reason', 'data_bytesprocessed' => 'data_bytes_processed', 'data_connect_addr_type' => 'data_con_adr_type', 'data_haltreason' => 'data_halt_reason', 'authorized' => 'session_authorized', 'protocol_version' => 'ndmp_version', # data_haltreason field is not present in C-Mode but in order # to maintain consistency across fields 'data_haltreason' => 'data_halt_reason' }, target => $probe_session ); #creating a new key as 'operating' whose value will be fetched #from operating_keyed_by_session_id hash by passing current session-id $probe_session->{operating} = $operating_keyed_by_session_id{$current_session_id}; #creating a object $obj->_set_fields(row => $probe_session); # push the above created object to an array push @state_objs, $obj; } ## end foreach $probe_session ( @{... $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli 1;