Commit 4c8a4cde authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

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"; } ...@@ -217,6 +217,7 @@ sub TBADMINCTRL_POLICY_NODES() { "nodes"; }
sub TBADMINCTRL_POLICY_TYPE() { "type"; } sub TBADMINCTRL_POLICY_TYPE() { "type"; }
sub TBADMINCTRL_POLICY_CLASS() { "class"; } sub TBADMINCTRL_POLICY_CLASS() { "class"; }
sub TBADMINCTRL_POLICY_ATTR() { "attribute"; } sub TBADMINCTRL_POLICY_ATTR() { "attribute"; }
sub TBADMINCTRL_POLICY_MEMBERSHIP() { "membership"; }
# #
# The current usage data structure, filled in below. # The current usage data structure, filled in below.
...@@ -238,7 +239,7 @@ sub Declare($) ...@@ -238,7 +239,7 @@ sub Declare($)
{ {
my ($msg) = @_; my ($msg) = @_;
print "*** Admission Control: $msg\n"; print STDERR "*** Admission Control: $msg\n";
} }
# Debug stuff # Debug stuff
...@@ -516,12 +517,32 @@ sub TestGroupPolicy($$$$$$) ...@@ -516,12 +517,32 @@ sub TestGroupPolicy($$$$$$)
# #
# Test a Global policy. # Test a Global policy.
# #
sub TestGlobalPolicy($$$$) sub TestGlobalPolicy($$$$$)
{ {
my ($policy, $test, $count, $auxdata) = @_; my ($policy, $test, $count, $auxdata, $uid) = @_;
my $current = 0; 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. # Simple check first.
# #
...@@ -747,8 +768,8 @@ sub TestPolicies($$$$) ...@@ -747,8 +768,8 @@ sub TestPolicies($$$$)
} }
$query_result = $query_result =
DBQueryWarn("select * from group_policies ". DBQueryWarn("select distinct * from group_policies ".
"where (pid='$pid' and gid='$gid') or ". "where (pid='$pid' and (pid=gid or gid='$gid')) or ".
" pid='+' or pid='-' ". " pid='+' or pid='-' ".
"order by pid,gid desc"); "order by pid,gid desc");
return -1 return -1
...@@ -788,7 +809,7 @@ sub TestPolicies($$$$) ...@@ -788,7 +809,7 @@ sub TestPolicies($$$$)
my $count = $pref->{'count'}; my $count = $pref->{'count'};
my $auxdata = $pref->{'auxdata'}; my $auxdata = $pref->{'auxdata'};
my $result = TestGlobalPolicy($policy, $test, $count, $auxdata); my $result = TestGlobalPolicy($policy, $test, $count, $auxdata, $uid);
$failcount++ $failcount++
if (!$result); if (!$result);
......
Supports Markdown
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