All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

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