Change approve script to use schema function
authorTodd Lyons <tlyons@exim.org>
Tue, 22 Oct 2013 14:19:34 +0000 (07:19 -0700)
committerTodd Lyons <tlyons@exim.org>
Tue, 22 Oct 2013 14:19:34 +0000 (07:19 -0700)
scripts/approve_system.pl [new file with mode: 0755]
scripts/delete_unlisted_branches.pl
scripts/set_system_status.pl [deleted file]

diff --git a/scripts/approve_system.pl b/scripts/approve_system.pl
new file mode 100755 (executable)
index 0000000..7a36db7
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use DBI;
+use Data::Dumper;
+
+die "Must pass current sysname and new sysname\n" unless scalar @ARGV == 2;
+
+use vars qw($dbhost $dbname $dbuser $dbpass $dbport
+);
+require "$ENV{BFConfDir}/BuildFarmWeb.pl";
+
+die "no dbname" unless $dbname;
+die "no dbuser" unless $dbuser;
+
+my $dsn="dbi:Pg:dbname=$dbname";
+$dsn .= ";host=$dbhost" if $dbhost;
+$dsn .= ";port=$dbport" if $dbport;
+
+my $db = DBI->connect($dsn,$dbuser,$dbpass);
+
+die $DBI::errstr unless $db;
+
+#my $sth_up = $db->prepare(q[
+#       SELECT approve(?, ?)
+#      ]);
+#$sth_up->execute(@ARGV);
+$db->do('SELECT approve(?, ?)', undef, @ARGV);
+
+my $sth = $db->prepare(q[ 
+       SELECT name, status, operating_system, os_version, sys_owner, owner_email
+       FROM buildsystems AS b
+       ORDER BY name ASC
+      ]);
+$sth->execute();
+
+my $format = "%-10s %-10s %-18s %-20s %-18s %-s\n";
+printf $format, "SysName", "Status", "Owner", "Email", "Distro", "Version";
+while (my $row = $sth->fetchrow_hashref)
+{
+  printf $format, $row->{name}, $row->{status}, $row->{sys_owner},
+                  $row->{owner_email}, $row->{operating_system},
+                  $row->{os_version};
+}
+$db->disconnect();
index 03df7969f15dceaaa1302b3fda19e389fe8b1566..fd37fd2337a8781d2c4256202b1a1525c7392c83 100755 (executable)
@@ -47,7 +47,11 @@ my $del_dash_sth = $db->prepare(q[
        WHERE sysname = ?
        AND branch = ?
       ]);
-
+my $del_snap_sth = $db->prepare(q[
+       DELETE FROM latest_snapshot
+       WHERE sysname = ?
+       AND branch = ?
+      ]);
 while (my $row = $sth->fetchrow_hashref)
 {
   my $sysname = $row->{sysname};
@@ -58,6 +62,7 @@ while (my $row = $sth->fetchrow_hashref)
     print "** Delete branch $branch\n";
     $del_sth->execute($sysname,$branch);
     $del_dash_sth->execute($sysname,$branch);
+    $del_snap_sth->execute($sysname,$branch);
   }
 }
 $db->disconnect();
diff --git a/scripts/set_system_status.pl b/scripts/set_system_status.pl
deleted file mode 100755 (executable)
index 7912135..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use DBI;
-use Data::Dumper;
-
-die "Must pass sysname and status\n" unless scalar @ARGV == 2;
-
-use vars qw($dbhost $dbname $dbuser $dbpass $dbport
-);
-require "$ENV{BFConfDir}/BuildFarmWeb.pl";
-
-die "no dbname" unless $dbname;
-die "no dbuser" unless $dbuser;
-
-my $dsn="dbi:Pg:dbname=$dbname";
-$dsn .= ";host=$dbhost" if $dbhost;
-$dsn .= ";port=$dbport" if $dbport;
-
-my $db = DBI->connect($dsn,$dbuser,$dbpass);
-
-die $DBI::errstr unless $db;
-
-my $sth_up = $db->prepare(q[
-       UPDATE buildsystems AS b
-       SET status = ?
-       WHERE name = ?
-      ]);
-$sth_up->execute($ARGV[1],$ARGV[0]);
-
-my $sth = $db->prepare(q[ 
-       SELECT name, status, operating_system, os_version, sys_owner, owner_email
-       FROM buildsystems AS b
-       ORDER BY name ASC
-      ]);
-$sth->execute();
-
-my $format = "%-10s %-10s %-18s %-20s %-18s %-s\n";
-printf $format, "SysName", "Status", "Owner", "Email", "Distro", "Version";
-while (my $row = $sth->fetchrow_hashref)
-{
-  printf $format, $row->{name}, $row->{status}, $row->{sys_owner},
-                  $row->{owner_email}, $row->{operating_system},
-                  $row->{os_version};
-}
-$db->disconnect();