Fix typos, index creation.
authorjelmer <jelmer@1e5ffdc8-eadd-0310-9daa-9cb4117fe24b>
Mon, 21 Apr 2008 12:04:09 +0000 (12:04 +0000)
committerjelmer <jelmer@1e5ffdc8-eadd-0310-9daa-9cb4117fe24b>
Mon, 21 Apr 2008 12:04:09 +0000 (12:04 +0000)
git-svn-id: file:///home/svn/build-farm/trunk@789 1e5ffdc8-eadd-0310-9daa-9cb4117fe24b

admin.pl
hostdb.pm

index c3fc0e1c3ab10f1344e727c8312e8d6cad2bddeb..95e802c796899736ee3854a2b961d3c3427b98ac 100755 (executable)
--- a/admin.pl
+++ b/admin.pl
@@ -25,8 +25,8 @@ use Mail::Send;
 my $db = new hostdb("$RealBin/hostdb.sqlite") or die("Unable to connect to host database: $!");
 my $dry_run = true;
 
-print "Samba Build farm managment tool\n";
-print "===============================\n";
+print "Samba Build farm management tool\n";
+print "================================\n";
 
 my $op;
 
@@ -52,7 +52,7 @@ if ($op eq "remove") {
        print "Please enter hostname to delete: ";
        my $hostname = <>;
        chomp($hostname);
-       $db->deletehost($hostname) or die("Unable to create host $hostname");
+       $db->deletehost($hostname) or die("Unable to delete host $hostname");
 } elsif ($op eq "modify") {
        print "Please enter hostname to modify: ";
        my $hostname = <>;
@@ -167,6 +167,7 @@ __EOF__
        my $hostname = <>;
        chomp($hostname);
        my $host = $db->host($hostname);
+       die ("No such host $host") unless ($host);
        print "Host: $host->{name}";
        if ($host->{fqdn}) { print " ($host->{fqdn})"; }
        print "\n";
index 16a01072afc9e2d137fab94588674870428d94e4..a0f072b4c75510bf730b61a74b8639dccac91183 100644 (file)
--- a/hostdb.pm
+++ b/hostdb.pm
@@ -38,6 +38,8 @@ sub provision($)
        my ($self) = @_;
        
        $self->{dbh}->do("CREATE TABLE host ( name text, owner text, owner_email text, password text, ssh_access int, fqdn text, platform text, permission text );");
+       
+       $self->{dbh}->do("CREATE UNIQUE INDEX unique_hostname ON host (name);");
 }
 
 sub createhost($$$$$$)
@@ -46,8 +48,6 @@ sub createhost($$$$$$)
        my $sth = $self->{dbh}->prepare("INSERT INTO host (name, platform, owner, owner_email, password, permission) VALUES (?,?,?,?,?,?)");
        
        $sth->execute($name, $platform, $owner, $owner_email, $password, $permission);
-       
-       $self->{dbh}->do("CREATE UNIQUE INDEX unique_hostname ON host (name);");
 }
 
 sub deletehost($$)