#**************************************************************************** # # (C) Copyright 2003 Novell, Inc. # All Rights Reserved. # # This program is an unpublished copyrighted work which is proprietary # to Novell, Inc. and contains confidential information that is not # to be reproduced or disclosed to any other person or entity without # prior written consent from Novell, Inc. in each and every instance. # # WARNING: Unauthorized reproduction of this program as well as # unauthorized preparation of derivative works based upon the # program or distribution of copies by sale, rental, lease or # lending are violations of federal copyright laws and state trade # secret laws, punishable by civil and criminal penalties. # # Author: Brad Rupp # Workfile: ClusterCliSnapin_View.pm # Contents: Handler for the "Cluster View" command # #**************************************************************************** # The package name must be the same as the file name (including case) package ClusterCliSnapin_View; #********************************************************************** # Use Statements #********************************************************************** use strict; use warnings; use diagnostics; use ClusterCliUtils; require ClusterCliSnapinInterface; our @ISA = ("ClusterCliSnapinInterface"); #********************************************************************** # Functions #********************************************************************** #********************************************************************** # Name: Param # Description: Returns the name of the parameter this class handles # Parameters: None. # Return: Paramter string # Notes: #********************************************************************** sub Param() { return("view"); } # Param #********************************************************************** # Name: Execute # Description: Executes the command handler # Parameters: List of parameters for the command. # Return: true on success. false otherwise. # Notes: #********************************************************************** sub Execute(@) { my $self = shift; my $fh; my $host; my $xml; my $cluster; my $current; my $epoch; my $master; my @templist; my $temp; my $vfsfile = "/Novell/Cluster/NodeState.xml"; # Output the standard NCS information $host = $self->GetHost(); $fh = $self->OpenVfsFile($host, $vfsfile); $self->ReadVfsFile($fh, $xml); $self->CloseVfsFile($fh); # The grouping must be a minimal match because sometimes sysread returns # the XML twice. Don't ask me why... $xml =~ /[\s]*(.*?)<\/cluster>[\s]*<\/ncsReply>/s; $xml = $1; if ($xml =~ /(.*?)<\/name>/s) { $cluster = $1; } else { $cluster = ""; } if ($xml =~ /(.*?)<\/thisNode>/s) { $current = $1; } else { $current = ""; } if ($xml =~ /(.*?)<\/epoch>/s) { $epoch = $1; } else { $epoch = ""; } if ($xml =~ /(.*?)<\/masterNode>/s) { $master = $1; } else { $master = ""; } $xml =~ /(.*?)<\/nodes>/s; $xml = $1; @templist = $xml =~ /(.*?)<\/node>/gs; ClusterCliUtils::PrintToCliScreen("\n\tCluster $cluster\n"); ClusterCliUtils::PrintToCliScreen("\tThis node $current [ epoch $epoch master node $master ]\n"); ClusterCliUtils::PrintToCliScreen("\tCluster nodes [ "); for (my $idx = 0; $idx < @templist; $idx++) { if ($idx != 0) { $temp = ", $templist[$idx]"; } else { $temp = $templist[$idx]; } # if ($idx != 0) ClusterCliUtils::PrintToCliScreen($temp); } # for (my $idx = 0; $idx < @templist; $idx++) ClusterCliUtils::PrintToCliScreen(" ]\n\t"); # Output the BCC peer information $self->ShowBccPeers($host); return(1); } # Execute #********************************************************************** # Name: Help # Description: Prints help for the command handler # Parameters: List of parameters passed in to the help command # Return: true on success. false otherwise. # Notes: #********************************************************************** sub Help(@) { ClusterCliUtils::PrintToCliScreen("\nCLUSTER VIEW\n"); ClusterCliUtils::PrintToCliScreen(" Used to view the current cluster membership.\n"); ClusterCliUtils::PrintToCliScreen(" Will display this node's number, cluster epoch number,\n"); ClusterCliUtils::PrintToCliScreen(" master node number, a list of the nodes that are currently\n"); ClusterCliUtils::PrintToCliScreen(" members of the cluster, and peer clusters if this cluster\n"); ClusterCliUtils::PrintToCliScreen(" is a member of a Business Continuance Cluster\n"); ClusterCliUtils::PrintToCliScreen("Example: cluster view\n"); return(1); } # Help 1;