Commit 4c8a4cde authored by Leigh Stoller's avatar Leigh Stoller

Add very hacky global_policies test to use for NSDI deadline. To

support NSDI06 easily, we want to create a project called NSDI06, have
anyone who has an NSDI deadline join that project, and use that
membership to allow them to swapin experiments in their real projects.
So, new global_policies entry format:

	insert into global_policies
	     values ('membership', 'emulab-ops,testbed,NSDI06', 'eq', 0);

When this policy is inserted, only members of the comma separated list
of projects names can swap in *any* experiments.

Just remove the table entry to remove the retriction.
parent 2588d99d
......@@ -217,6 +217,7 @@ sub TBADMINCTRL_POLICY_NODES() { "nodes"; }
sub TBADMINCTRL_POLICY_TYPE() { "type"; }
sub TBADMINCTRL_POLICY_CLASS() { "class"; }
sub TBADMINCTRL_POLICY_ATTR() { "attribute"; }
sub TBADMINCTRL_POLICY_MEMBERSHIP() { "membership"; }
#
# The current usage data structure, filled in below.
......@@ -238,7 +239,7 @@ sub Declare($)
{
my ($msg) = @_;
print "*** Admission Control: $msg\n";
print STDERR "*** Admission Control: $msg\n";
}
# Debug stuff
......@@ -516,12 +517,32 @@ sub TestGroupPolicy($$$$$$)
#
# Test a Global policy.
#
sub TestGlobalPolicy($$$$)
sub TestGlobalPolicy($$$$$)
{
my ($policy, $test, $count, $auxdata) = @_;
my ($policy, $test, $count, $auxdata, $uid) = @_;
my $current = 0;
if ($policy eq TBADMINCTRL_POLICY_EXPT()) {
if ($policy eq TBADMINCTRL_POLICY_MEMBERSHIP()) {
#
# HACK! $uid must be a member of the comma separated list of projects.
#
my @pidlist = split(",", $auxdata);
my $query_result =
DBQueryWarn("select uid from group_membership ".
"where uid='$uid' and (".
join(" or ", map("pid='$_'", @pidlist)) . ")");
return -1
if (!$query_result);
if (! $query_result->numrows) {
Declare("You must be a member of these projects to swapin any ".
"experiments: $auxdata");
return 0;
}
}
elsif ($policy eq TBADMINCTRL_POLICY_EXPT()) {
#
# Simple check first.
#
......@@ -747,8 +768,8 @@ sub TestPolicies($$$$)
}
$query_result =
DBQueryWarn("select * from group_policies ".
"where (pid='$pid' and gid='$gid') or ".
DBQueryWarn("select distinct * from group_policies ".
"where (pid='$pid' and (pid=gid or gid='$gid')) or ".
" pid='+' or pid='-' ".
"order by pid,gid desc");
return -1
......@@ -788,7 +809,7 @@ sub TestPolicies($$$$)
my $count = $pref->{'count'};
my $auxdata = $pref->{'auxdata'};
my $result = TestGlobalPolicy($policy, $test, $count, $auxdata);
my $result = TestGlobalPolicy($policy, $test, $count, $auxdata, $uid);
$failcount++
if (!$result);
......
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