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

Minor bug fix to statewait.

Add waitforactive() to avoid waiting for state='active' on the client.
parent 297994eb
......@@ -1233,7 +1233,7 @@ class experiment:
argdict["state"] = [argdict["state"],]
pass
res = DBQueryFatal("select state,gid from experiments "
res = DBQueryFatal("select state from experiments "
"where pid=%s and eid=%s",
(argdict["proj"], argdict["exp"]))
......@@ -1252,6 +1252,7 @@ class experiment:
#
# First, see if the experiment is already in the desired state,
#
state = res[0][0]
if (state in argdict["state"]):
return EmulabResponse(RESPONSE_SUCCESS, value=state, output=state)
......@@ -1330,6 +1331,14 @@ class experiment:
del(mc)
return EmulabResponse(RESPONSE_SUCCESS, value=retval, output=retval)
#
# Wrap up above for a simple "waitforactive" to avoid leaking more
# goo out then needed (eventstates).
#
def waitforactive(self, version, argdict):
argdict["state"] = "active";
return self.statewait(version, argdict);
#
# Return the node/link mappings for an experiment.
......
......@@ -722,7 +722,48 @@ experiments.
<td>The Emulab ID of the experiment</td>
</tr>
</table>
<br>
<li><tt><b>waitforactive</b></tt>: Wait for an experiment to reach
the <em>active</em> state. Typically, you would use this if you
launched a swapin asynchronously, and then wanted to wait later for
the swapin to complete.
<table cellpadding=2>
<tr>
<th>Name</th><th>Type</th><th>Description</th>
</tr>
<tr></tr>
<tr>
<td><tt>proj</tt></td>
<td>string</td>
<td>The Emulab project ID in which the experiment was created</td>
</tr>
<tr>
<td><tt>exp</tt></td>
<td>string</td>
<td>The Emulab ID of the experiment</td>
</tr>
</table>
<br>
The optional arguments are:<br><br>
<table cellpadding=2>
<tr>
<th>Name</th><th>Type</th><th>Default</th><th>Description</th>
</tr>
<tr></tr>
<tr>
<td><tt>timeout</tt></td>
<td>integer</td>
<td><i>forever</i></td>
<td>Timeout after this many <b>seconds</b>. The return code is
is <tt>RESPONSE_SUCCESS</tt> if experiment reaches the active state or
<tt>RESPONSE_TIMEDOUT</tt> if the timer expires.
</td>
</tr>
</table>
<br>
<li><tt><b>statewait</b></tt>: Wait for an experiment to reach a particular
state. State is one of swapped, active, swapping, activating, etc. If the
......
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