Commit cc41b917 authored by bnachtw's avatar bnachtw
Browse files

added script for putting nodes in collocgroups according to their domain

parent 0216843d
#! /usr/bin/perl
##############################################################################
#
# tsm-group-nodes.pl
#
# script for group former nongroup nodes
# to collocgroupr due to their policy domain
#
#
#
# (C) 2015,2019 GWD Göttingen, Bjørn Nachtwey
# mailto:bjoern.nachtwey@gwdg.de
#
##############################################################################
#
# changelog
# date version remark
# 2015-01-16 0.8 initial coding
# 2015-04-22 0.9 fixes for mon1.tsm.gwdg.de
# 2019-07-31 1.0 switched to common style with account and password given by call
#
##############################################################################
use warnings;
use strict;
use Time::Piece;
##############################################################################
##############################################################################
# F I L L I N Y O U R S E T T I N G S H E R E
##############################################################################
##############################################################################
##############################################################################
# C R E D E N T I A L S
##############################################################################
my $admuser = $ARGV[0]; # or replace by expicit ID
my $admpwd = $ARGV[1]; # or replace by expicit PW
##############################################################################
# # some loop iterators
my $server; # actual server name
my $server_name;
my $node_name;
my $domain_name;
# # some lists to be processed
my @serverlist = qw /tsm110 tsm112 tsm130 tsm131 tsm180 tsm182 tsm230 tsm231 tsm232 tsm233 tsm234 tsm235 tsm236 tsm237 tsm285/; # list of new servers
my @domainlist; # list of domains
my @nodelist; # list of all non-collocated nodes
my $dsmadmc = "/usr/bin/dsmadmc "; # linux servers
my $dsmargs = " -tab -dataonly=yes -id=$admuser -pa=$admpwd -outfile";
my $date = localtime->strftime ('%F');
my $outputpath = "/TSM/log/";
my $outlog = $outputpath . $date . "-grouped-nodes.log";
#
# # new variables
my $command;
my $selectstatement;
open LOGFILE, ">" . $outlog or die "$0: cannot open log file: " . $outlog;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main loop over all servers
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
foreach $server (@serverlist)
{
$server_name = $server;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# get list of domains
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
undef @domainlist;
if ( $server =~ m/-admin$/ )
{
$server_name = $server;
$server_name =~ s/-admin$//;
}
else
{
$server_name = $server;
}
printf LOGFILE "\n ==>\t SERVER: $server_name\n\n";
printf LOGFILE " ====>\t COLLOCGROUPS \n\n";
$selectstatement = "select domain_name from domains minus (select collocgroup_name from collocgroup)";
$command = "$dsmadmc $dsmargs -se=$server \"$selectstatement\" 2>/dev/null";
@domainlist = split '\n' , `$command`;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# define collocgroup for each domain without default-group
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
foreach my $domain (@domainlist)
{
next if ( $domain eq "TPL" );
next if ( $domain =~ m/^GWDG-FS/ );
printf LOGFILE "DEF COLLOCGR $domain\n";
$command = "$dsmadmc $dsmargs -se=$server \"DEF COLLOCGR $domain\" 2>/dev/null";
`$command`;
} # EO foreach domain
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# get all non-collocated nodes
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$selectstatement = "SELECT domain_name, node_name from nodes where (collocgroup_name IS NULL)";
$command = "$dsmadmc $dsmargs -se=$server \"$selectstatement\" 2>/dev/null";
@nodelist = split '\n' , `$command`;
printf LOGFILE "\n ====>\t NODES \n\n";
foreach my $node (@nodelist)
{
if ( ( $node =~ m/^ANR/ ) or ($node =~ m/^ANS/) )
{
last
}
($domain_name, $node_name) = split '\t' , $node;
next if ( $domain_name eq "TPL" );
next if ( $domain_name =~ m/^GWDG-FS/ );
printf LOGFILE "def collocmem $domain_name $node_name\n";
$command = "$dsmadmc $dsmargs -se=$server \"def collocmem $domain_name $node_name\" 2>/dev/null";
`$command`;
}
printf LOGFILE "======================================================================\n";
}
close LOGFILE;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment