Commit a027c882 authored by Leigh B Stoller's avatar Leigh B Stoller

Small rework of how we map remote pid/uid to local users/projects, it

was not quite right and the graphs were messed up.
parent 5ceb698a
......@@ -2087,22 +2087,25 @@ sub DoMaxExtensionInternal($$)
# Map project/user to local users (if appropriate).
foreach my $res (values(%{$reslist})) {
if (exists($res->{'project'}) && $res->{'project'} &&
GeniHRN::IsValid($res->{'project'})) {
my $project = APT_Utility::MapProjectURN($res->{'project'});
if (defined($project)) {
$res->{'pid'} = $project->pid();
$res->{'pid_idx'} = $project->pid_idx();
}
my $project = APT_Utility::MapProjectURN($res->{'project'});
if (defined($project)) {
$res->{'remote_pid'} = $res->{'pid'};
$res->{'pid'} = $project->pid();
$res->{'pid_idx'} = $project->pid_idx();
}
if (exists($res->{'user'}) && $res->{'user'} &&
GeniHRN::IsValid($res->{'user'})) {
my $geniuser = APT_Utility::MapUserURN($res->{'user'});
if (defined($geniuser)) {
$res->{'uid'} = $geniuser->uid();
$res->{'uid_idx'} = $geniuser->uid_idx();
}
else {
$res->{'remote_pid'} = $res->{'pid'};
}
my $geniuser = APT_Utility::MapUserURN($res->{'user'});
if (defined($geniuser)) {
$res->{'remote_uid'} = $res->{'uid'};
$res->{'uid'} = $geniuser->uid();
$res->{'uid_idx'} = $geniuser->uid_idx();
}
else {
$res->{'remote_uid'} = $res->{'uid'};
}
#
# Add these for the web interface since we are already messing
# with the results.
......
......@@ -489,25 +489,24 @@ sub DoList()
#
foreach my $details (values(%$list)) {
my $userhrn = GeniHRN->new($details->{'user'});
my $geniuser = GeniUser->Lookup($details->{'user'}, 1);
if (defined($geniuser) && $geniuser->IsLocal()) {
#print Dumper($geniuser);
$details->{'uid'} = $geniuser->uid();
$details->{'uid_idx'} = $geniuser->idx();
my $geniuser = MapUserURN($userhrn);
if (defined($geniuser)) {
$details->{'remote_uid'} = $details->{'uid'};
$details->{'uid'} = $geniuser->uid();
$details->{'uid_idx'} = $geniuser->idx();
}
else {
$details->{'uid'} = $userhrn->id();
$details->{'remote_uid'} = $details->{'uid'};
}
my $projhrn = GeniHRN->new($details->{'project'});
if ($projhrn->domain() eq $OURDOMAIN && defined($projhrn->project())) {
my $project = Project->Lookup($projhrn->project());
if (defined(($project))) {
$details->{'pid'} = $project->pid();
$details->{'pid_idx'} = $project->pid_idx();
}
my $project = APT_Utility::MapProjectURN($projhrn);
if (defined($project)) {
$details->{'remote_pid'} = $details->{'pid'};
$details->{'pid'} = $project->pid();
$details->{'pid_idx'} = $project->pid_idx();
}
else {
$details->{'pid'} = $projhrn->id();
$details->{'remote_pid'} = $details->{'pid'};
}
#
......@@ -1121,17 +1120,18 @@ sub DoHistory()
my $userhrn = GeniHRN->new($res->{'user'});
if ($userhrn->domain() eq $OURDOMAIN &&
$userhrn->id eq $geniuser->uid()) {
$res->{'uid'} = $geniuser->uid();
$res->{'uid_idx'} = $geniuser->idx();
$res->{'remote_uid'} = $res->{'uid'};
$res->{'uid'} = $geniuser->uid();
$res->{'uid_idx'} = $geniuser->idx();
}
my $project = APT_Utility::MapProjectURN($res->{'project'});
if (defined($project)) {
$res->{'pid'} = $project->pid();
$res->{'pid_idx'} = $project->pid_idx();
$res->{'remote_pid'} = $res->{'pid'};
$res->{'pid'} = $project->pid();
$res->{'pid_idx'} = $project->pid_idx();
}
else {
my $projhrn = GeniHRN->new($res->{'project'});
$res->{'pid'} = $projhrn->id();
$res->{'remote_pid'} = $res->{'pid'};
}
#
......
......@@ -764,7 +764,9 @@ sub SliceMaxExtension($)
my $blob = {};
$blob->{"uuid"} = $res->uuid();
$blob->{"project"} = $project->nonlocalurn();
$blob->{"pid"} = $project->pid();
$blob->{"user"} = $user->nonlocalurn();
$blob->{"uid"} = $user->uid();
$blob->{"nodes"} = $res->nodes();
$blob->{"using"} = $using;
$blob->{"type"} = $res->type();
......@@ -1232,7 +1234,9 @@ sub Reservations($)
$blob->{"idx"} = $idx;
$blob->{"uuid"} = $uuid;
$blob->{"project"} = $projurn;
$blob->{"pid"} = $pid;
$blob->{"user"} = $user->nonlocalurn();
$blob->{"uid"} = $user->uid();
$blob->{"nodes"} = $row->{'nodes'};
$blob->{"type"} = $type;
$blob->{"using"} = $using;
......@@ -1709,7 +1713,9 @@ sub ReservationHistory($)
$blob->{"idx"} = "";
$blob->{"uuid"} = $res->uuid() || "";
$blob->{"project"} = $projurn;
$blob->{"pid"} = $pid;
$blob->{"user"} = $geniuser->emulab_user()->nonlocalurn();
$blob->{"uid"} = $geniuser->emulab_user()->uid();
$blob->{"nodes"} = $res->nodes();
$blob->{"type"} = $res->type();
$blob->{"created"} = TBDateStringGMT($res->created());
......
......@@ -422,11 +422,11 @@ window.DrawResHistoryGraph = (function ()
if (Array.isArray(reserved)) {
continue;
}
var pcount = allocated[details.pid][details.type];
var pcount = allocated[details.remote_pid][details.type];
// Watch for nothing allocated by the user at this time stamp
var ucount = 0;
if (_.has(allocated, details.uid)) {
ucount = allocated[details.uid][details.type];
if (_.has(allocated, details.remote_uid)) {
ucount = allocated[details.remote_uid][details.type];
}
uvalues.push({"x" : stamp, "y" : parseInt(ucount)});
pvalues.push({"x" : stamp, "y" : parseInt(pcount)});
......
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