Commit 4931fecf authored by Leigh Stoller's avatar Leigh Stoller

Move setting the node permission table for a project from the web

interface to the backend. mkproj now looks at the pcremote_ok set
and makes the proper calls to grantnodetype. This reduces the amount
of hardwired goo in the web interface.

Still, there is a bit of hardwired stuff in mkproj. At present we do
not form a relationship between a phys node type and the types we
assign to the virtual nodes. Thats is, nothing says that a pcplabphys
implies the right to use pcplabinet, etc. With only 3 remote phys
types, I just hardwired it into mkproj calling grantnodetype with type
pcplab (the class for the virtnodes) for pcplabphys. Same for pcron
and pcwa, (both get pcvwa). Ultimately we need a better type system.
In general the type system is pretty screwy.
parent a6b65ad7
......@@ -24,6 +24,7 @@ my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
my $MKGROUP = "$TB/sbin/mkgroup";
my $MKACCT = "$TB/sbin/tbacct add";
my $GRANTTYPE= "$TB/sbin/grantnodetype -d";
my $PROJROOT = "/proj";
my $GRPROOT = "/groups";
......@@ -226,6 +227,45 @@ if (! -e $workdir) {
}
}
#
# If approved to use remote nodes, then grant permission to use the
# specific types of virtual nodes on those remote physical nodes.
# Unfortunately, the node_types table does not store a relationship
# between the phys type and the virtual types that are hosted on them.
# Need to add that I guess, but in the meantime we have just 3 remote
# phys types to worry about.
#
my $query_result =
DBQueryFatal("select pcremote_ok from projects where pid='$pid'");
if ($query_result->num_rows) {
my ($pcremote) = $query_result->fetchrow_array();
if (defined($pcremote)) {
print "$pcremote\n";
foreach my $type (split(",", $pcremote)) {
print "$type\n";
if ($type eq "pcplabphys") {
$type = "pcplab";
}
elsif ($type eq "pcron") {
$type = "pcvwa";
}
elsif ($type eq "pcwa") {
$type = "pcvwa";
}
else {
fatal("Unknown remote type $type!");
}
print "$type\n";
system("$GRANTTYPE -p $pid $type") == 0 or
fatal("Could not grant permission to use type $type!");
}
}
}
print "Project Creation Completed!\n";
exit(0);
......
......@@ -131,7 +131,7 @@ while (my ($nodetype,$nodeclass) = $query_result->fetchrow_array()) {
my $aux_result =
DBQueryFatal("select auxtype from node_types_auxtypes ".
"where type='$type'");
"where type='$nodetype' or type='$nodeclass'");
while (my ($auxtype) = $aux_result->fetchrow_array()) {
$newtypes{$auxtype} = 1
......
......@@ -198,44 +198,21 @@ elseif (strcmp($approval, "approve") == 0) {
# Temporary Plab hack.
#
$pcremote_ok = array();
$auxtypes = array();
if (isset($pcplab_okay) &&
!strcmp($pcplab_okay, "Yep")) {
$pcremote_ok[] = "pcplabphys";
$auxtypes[] = "pcplab";
$auxtypes[] = "pcplabinet";
$auxtypes[] = "pcplabinet2";
$auxtypes[] = "pcplabintl";
$auxtypes[] = "pcplabdsl";
}
# RON implies pcwa too.
if (isset($ron_okay) &&
!strcmp($ron_okay, "Yep")) {
$pcremote_ok[] = "pcron";
$pcremote_ok[] = "pcwa";
$auxtypes[] = "pcvron";
$auxtypes[] = "pcvroninet";
$auxtypes[] = "pcvroninet2";
$auxtypes[] = "pcvronintl";
$auxtypes[] = "pcvrondsl";
$auxtypes[] = "pcvwa";
$auxtypes[] = "pcvwainet";
$auxtypes[] = "pcvwainet2";
$auxtypes[] = "pcvwaintl";
$auxtypes[] = "pcvwadsl";
}
if (count($pcremote_ok)) {
$foo = implode(",", $pcremote_ok);
DBQueryFatal("UPDATE projects set pcremote_ok='$foo' ".
"WHERE pid='$pid'");
}
if (count($auxtypes)) {
while (list ($idx, $type) = each ($auxtypes)) {
DBQueryFatal("insert into nodetypeXpid_permissions ".
"(pid, type) ".
"values ('$pid', '$type')");
}
}
TBMAIL("$headname '$headuid' <$headuid_email>",
"Project '$pid' Approval",
......
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