#!/usr/bin/perl use warnings; use strict; # Author: David Morris # Version: $Id: dg2fs,v 1.4 2004/11/05 21:05:40 davey Exp $ # Purpose: Create volumes and file systems on Veritas Diskgroups # License: Released under the GNU Public Licence (GPL) # The terms of the GPL are available at: # http://www.gnu.org/licenses/gpl.html use diagnostics; use Data::Dumper; use Getopt::Long; GetOptions( "host=s"=> \ (my $hostname) , "cbs=s" => \ (my $cbs), "help" => \ (my $help), "<>" => sub {print "Error\n"}, ) or die Usage(); if (defined $help || ! defined @ARGV) { Usage(); } sub Usage { print <<"EOF"; Usage: $0 --host=hostname --cbs=cbsname $0 --host=rhine-f --cbs=routpw01 Examples: Options: --host the hostname where the diskgroups will be created, e.g. ward-0 --cbs call by service name, e.g. routpw01 --help Print this help message EOF exit } if ( -x "${cbs}.fs" ) { do "${cbs}.fs"; } my ($group, $hashref, $disk, $dg, @filesystems, @mountpoints, @vxcommands, $diskgroup); my %veritasgroups = createveritasgroups($cbs); sub DgName { my $dg = shift; if ( $dg eq "apps" ) { my $diskgroup ='dg_'.${dg}.'_'.${hostname}; return $diskgroup; } else { my $diskgroup ='dg_'.${dg}.'_'.${cbs}; return $diskgroup; } } foreach $dg (sort keys %veritasgroups) { my ($mp, $sz, $vn, $al, $vxcmd, $mkfscmd); $hashref = \%{$veritasgroups{$dg}}; my $diskgroup = DgName($dg); while (my ($k, $v) = each %$hashref ) { $mp = ${$v}[0]; $sz = ${$v}[1]; $vn = ${$v}[2]; $al = (${$v}[3]) || ""; $vxcmd = " vxassist -g $diskgroup make $vn $sz $al\n"; $mkfscmd = " mkfs -F vxfs -o largefiles /dev/vx/rdsk/$diskgroup/$vn\n"; push @vxcommands, $vxcmd; push @filesystems, $mkfscmd; push @mountpoints, " mkdir -p $mp\n"; } } sub PrintCommands { print "# Volumes\n"; print sort(@vxcommands); print "# Filesystems\n"; print sort(@filesystems); print "# Mountpoints\n"; print sort(@mountpoints); } PrintCommands();