Commit c7861021 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Change naming for per-experiment DB user, since the max name is 16 chars.

Now named by "E${exptidx" which sorta sucks but not much to do.
parent 2396b44d
......@@ -1471,6 +1471,7 @@ sub InitializeEnvVariables($)
if ($self->dpdb() && $self->dpdbname() && $self->dpdbname() ne "") {
my $dpdbname = $self->dpdbname();
my $dpdbpassword = $self->dpdbpassword();
my $dpdbuser = "E" . $self->idx();
$self->AddEnvVariable("DP_DBNAME", $dpdbname) == 0
or return -1;
......@@ -1478,7 +1479,7 @@ sub InitializeEnvVariables($)
$self->AddEnvVariable("DP_HOST", $CONTROL) == 0
or return -1;
$self->AddEnvVariable("DP_USER", $dpdbname) == 0
$self->AddEnvVariable("DP_USER", $dpdbuser) == 0
or return -1;
$self->AddEnvVariable("DP_PASSWORD", $dpdbpassword) == 0
......
......@@ -521,12 +521,14 @@ sub AddExpDB(@)
# Add a user that is named by this DB, with the password from above.
# Basically, a per-experiment DB user for the DB.
#
print "Adding user '$dbname' to mysql database on $CONTROL.\n";
$retval = DoOpsStuff("adduser $dbname", $dpdbpassword);
my $dbuser = "E${exptidx}";
print "Adding user '$dbuser' to mysql database on $CONTROL.\n";
$retval = DoOpsStuff("adduser $dbuser", $dpdbpassword);
if ($retval && $retval != EEXIST()) {
fatal("$OPSDBPROXY failed on $CONTROL!");
}
$retval = DoOpsStuff("setdbs", "$dbname $dbname");
$retval = DoOpsStuff("setdbs", "$dbuser $dbname");
if ($retval) {
fatal("$OPSDBPROXY failed on $CONTROL!");
}
......@@ -578,12 +580,12 @@ sub DelExpDB(@)
# Always do a DB removal if the experiment has a dbname set.
#
my $query_result =
DBQueryFatal("select dpdbname from experiments ".
DBQueryFatal("select dpdbname,idx from experiments ".
"where pid='$pid' and eid='$eid'");
return 0
if (!$query_result->numrows);
my ($dbname) = $query_result->fetchrow_array();
my ($dbname,$exptidx) = $query_result->fetchrow_array();
return -1
if (!defined($dbname));
......@@ -591,8 +593,10 @@ sub DelExpDB(@)
#
# Delete the per-experiment DB user for the DB.
#
print "Deleting user '$dbname' from mysql database on $CONTROL.\n";
my $retval = DoOpsStuff("deluser $dbname");
my $dbuser = "E${exptidx}";
print "Deleting user '$dbuser' from mysql database on $CONTROL.\n";
my $retval = DoOpsStuff("deluser $dbuser");
if ($retval) {
fatal("$OPSDBPROXY failed on $CONTROL!");
}
......
......@@ -1077,6 +1077,11 @@ function SHOWEXP($pid, $eid, $short = 0, $sortby = "") {
<td class=\"left\">$dpdbname</td>
</tr>\n";
echo "<tr>
<td>DataBase User: </td>
<td class=\"left\">E${exptidx}</td>
</tr>\n";
echo "<tr>
<td>DataBase Password: </td>
<td class=\"left\">$dpdbpassword</td>
......
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