Skip to content

Commit

Permalink
write installVdiSchema logs to STDOUT; debug bulkInstallVdiSchema; ad…
Browse files Browse the repository at this point in the history
…d .gitignore
  • Loading branch information
steve-fischer-200 committed Dec 13, 2023
1 parent 980ff2a commit 379f626
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib/perl/SchemaInstallUtils.pm

15 changes: 11 additions & 4 deletions bin/bulkInstallVdiSchema
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,20 @@ foreach my $d (@dbDescriptors) {

my $flag = $create? '--create' : '--drop';

if ($drop) {
print "\nYou are about to UNINSTALL the VDI_DATASETS and VDI_CONTROL schemas on database:\n $dbDescriptorsStr\nType 'I am not afraid' to proceed: ";
my $confirm = <STDIN>;
chomp $confirm;
die "You did not correctly confirm the db instance\n" unless 'I am not afraid' eq $confirm;
}

foreach my $d (@dbDescrips) {
foreach my $lifecycle (@lifecycles) {
foreach my $campus (@campuses) {
my $cmd = cwd() . "/installVdiSchema --dbName $d->{name} --dbHost $d->{host}.penn.apidb.org $flag --lifecycle $lifecycle --campus $campus";
$cmd = "$cmd 2>> $logFile";
print STDERR "Running cmd: $cmd\n";
# system("$cmd 2> $logFile") && print STDERR "Failed: $!\n";
my $cmd = cwd() . "/installVdiSchema --dbName $d->{name} --dbHost $d->{host}.penn.apidb.org $flag --lifecycle $lifecycle --campus $campus --dontAsk";
$cmd = "$cmd >> $logFile";
print STDERR "\nRunning cmd: $cmd\n";
system($cmd) && print STDERR "Failed: $!\n";
}
}
}
Expand Down
21 changes: 11 additions & 10 deletions bin/installVdiSchema
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ $| = 1; # flush each line on output

my @envVars = ('DB_PLATFORM', 'DB_USER', 'DB_PASS');
my $envStr = '$' . join(", \$", @envVars);
my ($dbName, $dbHost, $drop, $create, $lifecycle, $campus, $allowFailures);
my ($dbName, $dbHost, $drop, $create, $lifecycle, $campus, $allowFailures, $dontAsk);

&GetOptions("dbName=s" => \$dbName,
"dbHost=s" => \$dbHost,
"allowFailures!" => \$allowFailures,
"create!" => \$create,
"drop!" => \$drop,
"lifecycle=s" => \$lifecycle,
"campus=s" => \$campus);
"campus=s" => \$campus,
"dontAsk!" => \$dontAsk);

my @lifecycle = ('dev', 'qa', 'feat', 'beta', 'prod');
my $lcStr = join(", ", @lifecycle);
Expand All @@ -47,7 +48,7 @@ Caution: only use --allowFailures if you know what you are doing
Required environment variables: $envStr
Log is printed to STDERR
Log is printed to STDOUT
Include the following in your bash environment or on the command line preceding the command below:
export DB_PLATFORM=Oracle; export DB_USER=MY-LOGIN; export DB_PASS=MY-PASSWORD;
Expand All @@ -66,7 +67,7 @@ die "DB Platform must be either 'Oracle' or 'Postgres'\n" unless ($dbVendor eq '
my $dbh = getDbh($dbName, $dbHost, $dbVendor, $login, $password);

my $schemaSuffix = uc("${lifecycle}_${campus}");
if ($drop) {
if ($drop && !$dontAsk) {
print "\nYou are about to UNINSTALL the VDI_DATASETS_$schemaSuffix and VDI_CONTROL_$schemaSuffix schemas on database:\n $dbName\nType the name of the database to confirm: ";
my $confirm = <STDIN>;
chomp $confirm;
Expand All @@ -81,9 +82,9 @@ my @create = qw(

if ($create) {
for my $sqlFile (@create) {
print STDERR "\n==============================================================\n";
print STDERR "running $sqlFile for $schemaSuffix\n";
print STDERR "==============================================================\n";
print STDOUT "\n==============================================================\n";
print STDOUT "running $sqlFile for $schemaSuffix\n";
print STDOUT "==============================================================\n";
my @sqlplusParamValues = ($schemaSuffix);
my $filePath = cwd() . "/../lib/sql/$dbVendor/$sqlFile";
runSql($login, $password, $dbh, $dbVendor, $filePath, $allowFailures, @sqlplusParamValues);
Expand All @@ -93,11 +94,11 @@ if ($create) {
if ($dbVendor eq 'Oracle') {
my $schemaSetStr = join ', ', map "'$_'", @schemas;
my $count = dropSchemaSetTables($dbh, $schemaSetStr);
print STDERR "Dropped $count objects\n";
print STDOUT "Dropped $count objects\n";
} else {
my $count = dropSchemaSetPostgres($dbh, @schemas);
print STDERR "Dropped $count schemas\n";
print STDOUT "Dropped $count schemas\n";
}
}

print STDERR "\nDone.\n";
print STDOUT "\nDone.\n";

0 comments on commit 379f626

Please sign in to comment.