Commit 229fb701 authored by Leigh Stoller's avatar Leigh Stoller

Add TBNodeUpdateAccountsByUID() function to mark nodes as needing

account updates for a particular user. The set of nodes is based on
local project membership (local nodes and widearea nodes via
pcremote_ok), and also checks the new widearea_accounts table.
parent 6dcfa9f3
......@@ -107,6 +107,7 @@ use Exporter;
TBIsNodeVirtual TBControlNetIP TBPhysNodeID
TBExptOpenLogFile TBExptCloseLogFile TBExptCreateLogFile
TBNodeUpdateAccountsByPid TBNodeUpdateAccountsByType
TBNodeUpdateAccountsByUID
TBSaveExpLogFiles TBExptWorkDir TBExptUserDir TBExptLogDir
TBExptDestroy TBIPtoNodeID
......@@ -2183,6 +2184,61 @@ sub TBNodeUpdateAccountsByPid($)
return 1;
}
#
# Schedule account updates on all the nodes that this person has
# an account on.
#
# There are two sets of nodes. The first is all of the local nodes in
# all of projects the user is a member of. The second is all of the
# widearea nodes that the project has access to. Rather than operate
# on a per node basis. grab the project names (for the reserved
# table) and the remote types to match against the node types. Of
# course, the pcremote_ok slot is a set, so need to parse that.
#
# usage TBNodeUpdateAccountsByPid(char pid)
# Returns 1 all the time.
#
sub TBNodeUpdateAccountsByUID($)
{
my ($uid) = @_;
my $query_result =
DBQueryFatal("select p.pid,pcremote_ok from users as u ".
"left join group_membership as g on ".
" u.uid=g.uid and g.pid=g.gid ".
"left join projects as p on p.pid=g.pid ".
"where u.uid='$uid'");
while (my %row = $query_result->fetchhash()) {
my $pid = $row{'pid'};
my $pcremote = $row{'pcremote_ok'};
if (defined($pcremote)) {
my @typelist = split(',', $pcremote);
foreach my $nodetype (@typelist) {
TBNodeUpdateAccountsByType($nodetype);
}
}
TBNodeUpdateAccountsByPid($pid);
}
#
# Also update on widearea nodes if entries in widearea_accounts
#
$query_result =
DBQueryFatal("select node_id from widearea_accounts ".
"where uid='$uid' and trust!='none'");
while (my %row = $query_result->fetchhash()) {
my $node_id = $row{'node_id'};
DBQueryFatal("update nodes set update_accounts=update_accounts+1 ".
"where node_id='$node_id' and update_accounts<2");
}
return 1;
}
#
# Issue a DB query. Argument is a string. Returns the actual query object, so
# it is up to the caller to test it. I would not for one moment view this
......
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