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

Add a way to restrict specific nodes from being available for use.

In the node_attributes table, add an "allowed_projects" entry with
the value a comma separated list of project names that may use
this node.

I hope we don't have another way to do this; could not remember if we
did already!
parent 4ea58ac7
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2000-2012 University of Utah and the Flux Group. # Copyright (c) 2000-2013 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -550,6 +550,7 @@ while (my ($node_id, $feature, $weight) = $result->fetchrow()) { ...@@ -550,6 +550,7 @@ while (my ($node_id, $feature, $weight) = $result->fetchrow()) {
push @{$features{$node_id}}, "$feature:$weight"; push @{$features{$node_id}}, "$feature:$weight";
} }
} }
# #
# Read in the node_auxtypes table for each node. # Read in the node_auxtypes table for each node.
# #
...@@ -844,7 +845,8 @@ $result = ...@@ -844,7 +845,8 @@ $result =
" np.battery_percentage,np.uuid,b.sharing_mode, ". " np.battery_percentage,np.uuid,b.sharing_mode, ".
" ru.load_1min, ru.load_5min, ru.status_timestamp, ". " ru.load_1min, ru.load_5min, ru.status_timestamp, ".
" a.def_boot_osid, nat2.attrvalue, wn.country, " . " a.def_boot_osid, nat2.attrvalue, wn.country, " .
" wn.latitude, wn.longitude, t.isremotenode, b.erole ". " wn.latitude, wn.longitude, t.isremotenode, b.erole, ".
" nat3.attrvalue ".
"from nodes as a ". "from nodes as a ".
"left join reserved as b on a.node_id=b.node_id ". "left join reserved as b on a.node_id=b.node_id ".
"left join reserved as m on a.phys_nodeid=m.node_id ". "left join reserved as m on a.phys_nodeid=m.node_id ".
...@@ -856,6 +858,9 @@ $result = ...@@ -856,6 +858,9 @@ $result =
"left join node_attributes as nat2 on ". "left join node_attributes as nat2 on ".
" nat2.node_id=a.node_id and ". " nat2.node_id=a.node_id and ".
" nat2.attrkey='shared_weight' ". " nat2.attrkey='shared_weight' ".
"left join node_attributes as nat3 on ".
" nat3.node_id=a.node_id and ".
" nat3.attrkey='allowed_projects' ".
"left join node_rusage as ru on ru.node_id=a.node_id ". "left join node_rusage as ru on ru.node_id=a.node_id ".
"left outer join ". "left outer join ".
" (select type,attrvalue ". " (select type,attrvalue ".
...@@ -865,7 +870,6 @@ $result = ...@@ -865,7 +870,6 @@ $result =
" on t.type=dedicated_wa_types.type ". " on t.type=dedicated_wa_types.type ".
"left join widearea_nodeinfo as wn on a.node_id=wn.node_id ". "left join widearea_nodeinfo as wn on a.node_id=wn.node_id ".
"where $free_condition and ". "where $free_condition and ".
# " a.role='testnode'"
" (a.role='testnode' and (t.isremotenode=0 or ". " (a.role='testnode' and (t.isremotenode=0 or ".
" dedicated_wa_types.attrvalue=1))"); " dedicated_wa_types.attrvalue=1))");
...@@ -880,13 +884,21 @@ $result = ...@@ -880,13 +884,21 @@ $result =
while (($node,$type,$physnode,$class,$issubnode,$def_boot_osid,$reserved, while (($node,$type,$physnode,$class,$issubnode,$def_boot_osid,$reserved,
$prereserved,$eventstate,$battery_perc,$uuid,$sharing_mode, $prereserved,$eventstate,$battery_perc,$uuid,$sharing_mode,
$load_1min,$load_5min,$load_tstamp,$osid,$weight,$country,$latitude, $load_1min,$load_5min,$load_tstamp,$osid,$weight,$country,$latitude,
$longitude,$isremote,$erole) = $result->fetchrow_array) { $longitude,$isremote,$erole,
$allowed_projects) = $result->fetchrow_array) {
my $current = $top->CreateNode($node); my $current = $top->CreateNode($node);
$current->SetSubnode($physnode, $issubnode); $current->SetSubnode($physnode, $issubnode);
$current->SetRemote($isremote); $current->SetRemote($isremote);
# next #
# if ($isremote); # Look for a specific node restriction. Easier to to do here
# then trying to do this up above in the already bizarre query.
#
if (defined($pid) && defined($allowed_projects)) {
my @allowed = split(",", $allowed_projects);
next
if (! grep {$_ eq $pid} @allowed);
}
$nodes{$node} = $type $nodes{$node} = $type
if (!defined($pid) || if (!defined($pid) ||
......
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