Commit bc307111 authored by David Johnson's avatar David Johnson

Fix up the renew code. Also add support for marking plab nodes as

"deleted" -- it's been hanging out in my dev tree and I forgot about
it.
parent 5929e134
This diff is collapsed.
......@@ -854,6 +854,10 @@ class mod_PLC4:
pass
def renewSlice(self, slice, force = False):
"""
Returns -1 if did not need to renew; 0 if renew succeeded;
1 if renew failed.
"""
agent = self.__getAgent(slice.slicename)
ret = 0
now = int(time.time()) # seconds since the epoch (UTC)
......@@ -897,7 +901,7 @@ class mod_PLC4:
if leaseend - now > MIN_LEASE_WINDOW and not force:
print "Slice %s (%s/%s) doesn't need to be renewed" % \
(slice.slicename, slice.pid, slice.eid)
return 1
return -1
# Max out leaseend as far as (politically) possible
newleaseend = now + MAX_PLC_LEASELEN
......@@ -917,7 +921,7 @@ class mod_PLC4:
slice.slicemeta = self.getSliceMeta(slice)
slice.slicemeta_legacy = None
ret = 1
ret = 0
if debug:
print "SliceRenew returns: %s" % res
pass
......@@ -925,7 +929,7 @@ class mod_PLC4:
except:
print "Failed to renew lease for slice %s" % slice.slicename
traceback.print_exc()
ret = 0
ret = 1
pass
else:
slice.leaseend = newleaseend
......
......@@ -11,49 +11,41 @@ sys.path.append("@prefix@/lib")
import libplab
from libtestbed import *
usage = "\t%prog [-vd] [-p plcname] pid eid [slicename]"
usage = "\t%prog [-vd] [-p plcname] [-e pid/eid] [-s slicename]"
def main(args):
me = args[0]
parser = TBParser(usage)
parser.add_option("-p","--plc",dest="plc",action="store",
help="PLC Name",default=None)
help="PLC name",default=None)
parser.add_option("-e","--expt",dest="expt",action="store",
help="pid/eid",default=None)
parser.add_option("-s","--slicename",dest="slicename",action="store",
help="slice name",default=None)
slicename = None
pid,eid = None,None
expt = None
(opts,args) = parser.parse_args()
libplab.debug = opts.debug
libplab.verbose = opts.verbose
if len(args) == 2:
pid,eid = args
if not pid or not eid:
print "Must supply both pid and eid!"
sys.exit(1)
pass
pass
elif len(args) == 3:
pid,eid,slicename = args
if not pid or not eid or not slicename:
print "Must supply both pid and eid!"
sys.exit(1)
pass
pass
else:
parser.error("Incorrect number of arguments")
if expt:
try:
pid,eid = expt.split('/')
except:
parser.error("Improper pid/eid")
pass
if not slicename and opts.plc:
print "Ignoring '-p' PLC option, since you did not specify" \
"a slicename!"
opts.plc = None
if len(args) > 0:
parser.error("Incorrect number of arguments")
pass
plab = libplab.Plab()
plab.renew(pid,eid,opts.plc,slicename)
plab.renew(opts.plc,pid,eid,slicename)
return
if __name__ == "__main__":
......
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