package RDA::Remote; # $Id: Remote.pm,v 1.21 2008/02/25 14:55:25 mschenke Exp $ # ARCS: $Header: /home/cvs/repository/RDA_4/src/scripting/lib/RDA/Remote.pm,v 1.21 2008/02/25 14:55:25 mschenke Exp $ # # Change History # 20080225 MSC Change the copyright notice. =head1 NAME RDA::Remote - Package Used to Manage Remote Data Collections. =head1 SYNOPSIS require RDA::Remote; =head1 DESCRIPTION The following methods are available: =cut use strict; BEGIN { use Exporter; } # Define the global public variables use vars qw($VERSION); $VERSION = sprintf("%d.%02d", q$Revision: 1.21 $ =~ /(\d+)\.(\d+)/); # Report the module version number sub Version { $VERSION; } =head2 S This method disables the remote collection on nodes that are still executing a step before the post treatment or the report package transfer. When you specify the force option without any node, then all nodes are considered. =cut sub disable { my $agt = shift; # Perform the action and indicate if the setup must be saved _exec_code($agt, 'RACsetup', 'S900REXE', 'disable', @_) ? 0 : 1; } =head2 S This method edits one or more remote node initial settings. The modifications are provided as a comma separated list of C pairs. No settings are created. When you specify the force option without any node, then all nodes are considered. =cut sub edit { my $agt = shift; my $edt = shift; # Perform the action and indicate if the setup must be saved return 0 unless $edt; $agt->set_temp_setting('EXT_EDIT', $edt); _exec_code($agt, 'RACsetup', 'S900REXE', 'edit', @_) ? 0 : 1; } =head2 S This method lists the nodes. =cut sub list { my $agt = shift; # Perform the action and indicate that there are no setup changes _exec_code($agt, 'RACsetup', 'S900REXE', 'list', @_); 0; } =head2 S This method restarts the remote node collection from the beginning. This only occurs when the node step is defined already. When you specify the force option without any node, then all nodes are restarted. =cut sub restart { my $agt = shift; # Perform the action and indicate if the setup must be saved _exec_code($agt, 'RACsetup', 'S900REXE', 'restart', @_) ? 0 : 1; } =head2 S This method attempts to execute the last step of remote data collections again. This is only performed for nodes with errors. When you specify the force option without any node, then all nodes are restarted. =cut sub retry { my $agt = shift; # Perform the action and indicate if the setup must be saved _exec_code($agt, 'RACsetup', 'S900REXE', 'retry', @_) ? 0 : 1; } =head2 S This method specifies the commands that should be used for remote operations on the specified nodes. When you specify the force option without any node, then all nodes are considered. Valid types are as follows: =over 10 =item B< dft > Restores the default settings. =item B< remsh > Uses C/C. =item B< rsh > Uses C/C. =item B< ssh > Uses C/C. =item B< ssh0 > Uses C/C without connection timeout. =back =cut sub set { my $agt = shift; my $typ = shift; # Validate the type return 0 unless $typ && $typ =~ m/^(dft|remsh|rsh|ssh0?)$/; # Perform the action and indicate if the setup must be saved _exec_code($agt, 'RACsetup', 'S900REXE', "set_$typ", @_) ? 0 : 1; } =head2 S This method sets up the remote data collection for a cluster. You can specify a user as an argument to get the cluster nodes from the database. The following user formats are supported: =over 16 =item B< user > To connect with the user in the database referenced by the ORACLE_SID environment variable. =item B< user@SID > To connect with the user in the specified database. =item B< / > To connect as C to the database referenced by the ORACLE_SID environment variable. =item B< /@SID > To connect as C to the specified database. =back Using C requires appropriate privileges. If the user is not specified, the method uses an operating system command (C or C) to get the cluster nodes. In that case, the RDA collection must be initiated from one of the cluster nodes. =cut sub setup_cluster { my $agt = shift; my $flg = $agt->is_configured('S919LOAD'); my $trc = $agt->get_setting('RDA_TRACE'); # Execute the RACsetup script return 0 if _exec_code($agt, 'RACsetup', 'S900REXE', 'setup', @_); # Setup the remote data collection module $agt->set_temp_setting('REMOTE_COLLECTION',1); $agt->setup('S909RDSP',$trc); $agt->set_info('yes', 1); $agt->set_temp_setting('REMOTE_DEFINITION',1); $agt->setup('S900REXE',$trc); $agt->setup('S919LOAD',$trc) if $flg; # Indicate that the setup must be saved 1; } =head2 S This method suspends remote collection by putting the current step in error. This is only performed for nodes where the collection is not completed. When you specify the force option without any node, then all nodes are considered. =cut sub suspend { my $agt = shift; # Perform the action and indicate if the setup must be saved _exec_code($agt, 'RACsetup', 'S900REXE', 'suspend', @_) ? 0 : 1; } =head1 REMOTE DAEMON MANAGEMENT =head2 S This method starts a background collection on the specified nodes. When you specify the force option without any node, then all nodes are considered. =cut sub start_daemon { my $agt = shift; # Perform the action and indicate that there are no setup changes _exec_code($agt, 'RACsetup', 'S900REXE', 'start_daemon', @_); 0; } =head2 S This method stops the background collection on the specified nodes. When you specify the force option without any node, then all nodes are considered. =cut sub stop_daemon { my $agt = shift; # Perform the action and indicate that there are no setup changes _exec_code($agt, 'RACsetup', 'S900REXE', 'stop_daemon', @_); 0; } # --- Internal functions ------------------------------------------------------ # Execute the sub module sub _exec_code { my $agt = shift; my $nam = shift; my $mod = shift; my $act = shift; my ($obj, $ret); # Execute the RAC setup script require RDA::Block; $obj = RDA::Block->new($nam, $agt->get_info('dir'), $agt); unless ($ret = $obj->load) { $agt->set_current($mod); $agt->init; $agt->set_temp_setting('EXT_CMD', $act) if $act; $agt->set_temp_setting('EXT_ARGS', join('|', @_)) if scalar(@_); eval { local $SIG{'INT'} = sub { local $SIG{'__WARN__'} = sub {}; die ("RDA-00206: RDA data collection interrupted\n"); }; $ret = $obj->collect($agt->get_setting('RDA_DEBUG'), $agt->get_setting('RDA_TRACE')); }; $agt->set_current; } $ret; } 1; __END__ =head1 SEE ALSO See also L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L. =head1 COPYRIGHT NOTICE Copyright (c) 2002-2008, Oracle. All rights reserved. =head1 TRADEMARK NOTICE Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. =cut