def web_requestNew(self): # validate # * dataset # * srcse # * dstse # * protocol self.log.debug(self.request.arguments) valid_list = ["dataset", "srcse", "dstse", "protocol"] build_input_param = {} for k in valid_list: if not self.request.arguments.has_key(k): raise WErr( 400, "Missing %s" % k ) build_input_param[k] = self.request.arguments[k][0] self.log.debug(build_input_param) # check the data ## SE if build_input_param["dstse"] == build_input_param["srcse"]: raise WErr( 400, "dstse and srcse are same" ) ## protocol if build_input_param["protocol"] not in ["DIRACDMS", "DIRACFTS"]: raise WErr( 400, "protocol %s is wrong"%build_input_param["protocol"] ) # create RPC = RPCClient("Transfer/TransferRequest") res = RPC.create(build_input_param["dataset"], build_input_param["srcse"], build_input_param["dstse"], build_input_param["protocol"]) # TODO how to return error to the user? if not res["OK"]: self.log.error(res) self.set_status(200) self.finish() self.log.debug("finish")
def web_requestNew(self): # validate # * dataset # * srcse # * dstse # * protocol self.log.debug(self.request.arguments) valid_list = ["dataset", "srcse", "dstse", "protocol"] build_input_param = {} for k in valid_list: if not self.request.arguments.has_key(k): raise WErr(400, "Missing %s" % k) build_input_param[k] = self.request.arguments[k][0] self.log.debug(build_input_param) # check the data ## SE if build_input_param["dstse"] == build_input_param["srcse"]: raise WErr(400, "dstse and srcse are same") ## protocol if build_input_param["protocol"] not in ["DIRACDMS", "DIRACFTS"]: raise WErr(400, "protocol %s is wrong" % build_input_param["protocol"]) # create RPC = RPCClient("Transfer/TransferRequest") res = RPC.create(build_input_param["dataset"], build_input_param["srcse"], build_input_param["dstse"], build_input_param["protocol"]) # TODO how to return error to the user? if not res["OK"]: self.log.error(res) self.set_status(200) self.finish() self.log.debug("finish")
# -*- coding: utf-8 -*- import DIRAC from DIRAC import gLogger from DIRAC.Core.Base import Script Script.setUsageMessage(""" Create a data transfer request. Usage: %s <dataset name> <src SE> <dst SE> """ % Script.scriptName) Script.parseCommandLine( ignoreErrors = True ) args = Script.getPositionalArgs() if (len(args) != 3): gLogger.error("Please support dataset name, src SE, dst SE.") DIRAC.exit(-1) from DIRAC.Core.DISET.RPCClient import RPCClient transferRequest = RPCClient("Transfer/TransferRequest") dataset = args[0] ep_from = args[1] ep_to = args[2] print transferRequest.create(dataset, ep_from, ep_to)
# -*- coding: utf-8 -*- import DIRAC from DIRAC.Core.Base import Script Script.setUsageMessage(""" Create a data transfer request. Usage: %s <dataset name> <src SE> <dst SE> """ % Script.scriptName) Script.parseCommandLine(ignoreErrors=True) args = Script.getPositionalArgs() if (len(args) != 3): gLogger.error("Please support dataset name, src SE, dst SE.") DIRAC.exit(-1) from DIRAC.Core.DISET.RPCClient import RPCClient transferRequest = RPCClient("Transfer/TransferRequest") dataset = args[0] ep_from = args[1] ep_to = args[2] print transferRequest.create(dataset, ep_from, ep_to)
Script.setUsageMessage(""" Create a data transfer request. Usage: %s <dataset name> <src SE> <dst SE> -p <Protocol> """ % Script.scriptName) Script.registerSwitch("p:", "protocol=", "Transfer Protocol") Script.parseCommandLine( ignoreErrors = True ) args = Script.getPositionalArgs() if (len(args) != 3): gLogger.error("Please support dataset name, src SE, dst SE.") DIRAC.exit(-1) protocol = "DIRACDMS" # default for k, v in Script.getUnprocessedSwitches(): if k in ('p', 'protocol'): protocol = v from DIRAC.Core.DISET.RPCClient import RPCClient transferRequest = RPCClient("Transfer/TransferRequest") dataset = args[0] ep_from = args[1] ep_to = args[2] print transferRequest.create(dataset, ep_from, ep_to, protocol)
""" % Script.scriptName) Script.registerSwitch("f:", "file=", "file contains LFN") Script.parseCommandLine( ignoreErrors = True ) filelist = [] for k,v in Script.getUnprocessedSwitches(): if k.lower() in ["f", "file"]: with open(v) as f: for line in f: filelist.append(line) args = Script.getPositionalArgs() if ( len(args) == 0 or (len(filelist)+len(args) < 2) ): gLogger.error("Please support dataset name and LFNs") DIRAC.exit(-1) dataset = args[0] filelist.extend(args[1:]) gLogger.info("Dataset is ", dataset) gLogger.info("FileList is ", filelist) from DIRAC.Core.DISET.RPCClient import RPCClient transferRequest = RPCClient("Transfer/Dataset") print transferRequest.create(dataset, filelist)
from DIRAC.Core.Base import Script Script.setUsageMessage(""" Create a data transfer request. Usage: %s <dataset name> <src SE> <dst SE> -p <Protocol> """ % Script.scriptName) Script.registerSwitch("p:", "protocol=", "Transfer Protocol") Script.parseCommandLine(ignoreErrors=True) args = Script.getPositionalArgs() if (len(args) != 3): gLogger.error("Please support dataset name, src SE, dst SE.") DIRAC.exit(-1) protocol = "DIRACDMS" # default for k, v in Script.getUnprocessedSwitches(): if k in ('p', 'protocol'): protocol = v from DIRAC.Core.DISET.RPCClient import RPCClient transferRequest = RPCClient("Transfer/TransferRequest") dataset = args[0] ep_from = args[1] ep_to = args[2] print transferRequest.create(dataset, ep_from, ep_to, protocol)