#!/usr/bin/perl # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # bos720 src/bos/usr/lib/nim/perl/NIM.pm 1.3 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2005 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)89 1.3 src/bos/usr/lib/nim/perl/NIM.pm, cmdnim, bos720 9/26/05 16:09:23 package NIM; use base DSHContext; # Put any initialization code here. # # Ex. Constants, command paths, global variables for caching etc. sub valid_context { # Return 1 if the context is valid (i.e. licensed software? # node resolution commands work?) undef if not; return (-f '/etc/niminfo') && (-f '/usr/sbin/nim'); } sub context_properties { # Return a hash table of properties and values that are relevant # in the context's environment. Any environment variables? Any # settings in the software that may be relevant to a dsh utility? # (ex. remote shell settings) return undef } sub all_nodes { # Return a list of all nodes in the NIM context # # This is typically done by running a command in backticks # and then adding each node into an array or hash table # In the case of a hash table, only the keys need to be returned. my @output = `/usr/sbin/lsnim -t standalone`; foreach my $line (@output) { my ($nim_client, $class, $type) = split(/\s+/, $line); push(@nim_node_list, $nim_client); } return @nim_node_list; } sub all_nodegroups { # Return a list of all nodegroups in the NIM context # # This is typically done by running a command in backticks # and then adding each nodegroup into an array or hash table # In the case of a hash table, only the keys need to be returned. my @output = `/usr/sbin/lsnim -t mac_group`; foreach my $line (@output) { my ($group, $class, $type) = split(/\s+/, $line); push(@nim_nodegroup_list, $group); } return @nim_nodegroup_list; } sub nodegroup_members { # Return a list of members for all nodegroups specified in the # array @nodegroup_list # # This is typically done by iterating over each nodegroup in the # list and running a command in backticks to expand the nodegroup # nodegroup membership my ($class, $nodegroup) = @_; my @members = (); my @output = `/usr/sbin/lsnim -m $nodegroup`; if ( $? == 0 ) { foreach my $line (@output) { my ($nim_client, $class, $type) = split(/\s+/, $line); push(@members, $nim_client); } } return \@members; } # Other subroutines can be added as needed. These subroutines listed # here are required for the context to support nodes and nodegroups # The full interface is listed in /opt/csm/pm/dsh/DSHContext.pm 1;