Commit c4ae0f7c authored by David Johnson's avatar David Johnson
Browse files

Fix a case where exptidx wasn't being initialized in Slice._load. More

importantly, fix several places where inserts were using %d as argument
placeholders in queries.  When using the MySQLdb module in python, you
can only use %s as a placeholder in "prepared" queries---the module looks
at the types of the values to see how to format them in the query.  This
behavior is insidious and contrary to the python standard DB interface
documentation, but that's how it is.
parent b2dc315f
......@@ -687,7 +687,7 @@ class Plab:
DBQueryFatal("replace into reserved"
" (node_id, exptidx, pid, eid, rsrv_time, vname)"
" values (%s, %d, %s, %s, now(), %s)",
" values (%s, %s, %s, %s, now(), %s)",
(nodeid, res_exptidx,
......@@ -787,7 +787,7 @@ class Plab:
# Put the last vnode created into the special monitoring expt.
DBQueryFatal("insert into reserved"
" (node_id, exptidx, pid, eid, rsrv_time, vname)"
" values (%s, %d, %s, %s, now(), %s)",
" values (%s, %s, %s, %s, now(), %s)",
(vnodeid, mon_exptidx,
......@@ -1100,7 +1100,7 @@ class Slice:
DBQueryFatal("insert into plab_slices "
" values (%d, %s, %s, %s, %s, %s, %s)",
" values (%s, %s, %s, %s, %s, %s, %s)",
(self.exptidx,, self.eid, self.slicename,
time.strftime("%Y-%m-%d %H:%M:%S",
......@@ -1158,6 +1158,26 @@ class Slice:
if verbose:
print "Loading slice for pid/eid %s/%s" % (, self.eid)
# grab our exptidx
res = DBQueryFatal("select idx, expt_name from experiments "
"where pid=%s "
"and eid=%s",
(, self.eid))
if not len(res):
raise RuntimeError, \
"Didn't get any results while looking up info on " \
"experiment %s/%s" % (, self.eid)
(eindex, descr) = res[0]
if not self.slicename:
self.slicename = "%s_%s" % (SLICEPREFIX, eindex)
self.description = descr
self.exptidx = eindex
res = DBQueryFatal("select slicename, slicemeta, leaseend "
" from plab_slices "
" where pid = %s and eid = %s",
......@@ -1416,7 +1436,7 @@ class Node:
DBQueryFatal("replace into plab_slice_nodes"
" (exptidx, pid, eid, slicename, node_id,"
" nodemeta, leaseend)"
" values (%d, %s, %s, %s, %s, %s, %s)",
" values (%s, %s, %s, %s, %s, %s, %s)",
(self.slice.exptidx,, self.slice.eid,
self.slice.slicename, self.nodeid,
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