X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FGetBootMedium.py;h=7225b126c1ca38100b1f9ff64acce80315d65712;hb=05cc869ac1b972416a371d02ded9f47bcaab8067;hp=53f68a1e5f693c6736d5f0d19b7126ac05ed7598;hpb=5d8a25ab329d0c44d34645b0ddeacba2f02331eb;p=plcapi.git diff --git a/PLC/Methods/GetBootMedium.py b/PLC/Methods/GetBootMedium.py index 53f68a1..7225b12 100644 --- a/PLC/Methods/GetBootMedium.py +++ b/PLC/Methods/GetBootMedium.py @@ -1,5 +1,3 @@ -# $Id$ -# $URL$ import random import base64 import os @@ -264,13 +262,13 @@ class GetBootMedium(Method): node_id=node['node_id'] # no support for deployment-based BootCD's, use kvariants instead - node_pldistro = GetNodePldistro (self.api).call(auth, node_id) + node_pldistro = GetNodePldistro (self.api,self.caller).call(auth, node_id) if node_pldistro: pldistro = node_pldistro - node_fcdistro = GetNodeFcdistro (self.api).call(auth, node_id) + node_fcdistro = GetNodeFcdistro (self.api,self.caller).call(auth, node_id) if node_fcdistro: fcdistro = node_fcdistro - node_arch = GetNodeArch (self.api).call(auth,node_id) + node_arch = GetNodeArch (self.api,self.caller).call(auth,node_id) if node_arch: arch = node_arch return (pldistro,fcdistro,arch) @@ -314,8 +312,16 @@ class GetBootMedium(Method): raise PLCInvalidArgument, "File %s not under %s"%(filename,self.WORKDIR) ### output should not exist (concurrent runs ..) + # numerous reports of issues with this policy + # looks like people sometime suspend/cancel their download + # and this leads to the old file sitting in there forever + # so, if the file is older than 5 minutes, we just trash + grace=5 + if os.path.exists(filename) and (time.time()-os.path.getmtime(filename)) >= (grace*60): + os.unlink(filename) if os.path.exists(filename): - raise PLCInvalidArgument, "Resulting file %s already exists"%filename + raise PLCInvalidArgument, "Resulting file %s already exists - please try again in %d minutes"%\ + (filename,grace) ### we can now safely create the file, ### either we are admin or under a controlled location