-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmakeRucioRules.py
63 lines (51 loc) · 2.06 KB
/
makeRucioRules.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Script to create standalone Rucio rules for input data, thus
using the wmcore_transferor Rucio account and pointing to Rucio
production instance.
It uses exactly the same parameters as those set by MSTransferor.
NOTE: it depends on the WMAgent environment to load the Rucio wrapper.
"""
import argparse
import logging
import sys
from WMCore.Services.Rucio.Rucio import Rucio
RUCIO_ACCT = "wmcore_transferor"
RUCIO_AUTH_URL = "https://cms-rucio-auth.cern.ch"
RUCIO_URL = "http://cms-rucio.cern.ch"
def parseArgs():
"""
Well, parse the arguments passed in the command line :)
"""
parser = argparse.ArgumentParser(description="Create Rucio container rules with wmcore_transferor acct")
parser.add_argument('-c', '--container', required=True, help='Container name')
parser.add_argument('-r', '--rse', required=True, help='RSE name or expression')
args = parser.parse_args()
return args
def loggerSetup(logLevel=logging.INFO):
"""
Return a logger which writes everything to stdout.
"""
logger = logging.getLogger(__name__)
outHandler = logging.StreamHandler(sys.stdout)
outHandler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(module)s: %(message)s"))
outHandler.setLevel(logLevel)
logger.addHandler(outHandler)
logger.setLevel(logLevel)
return logger
if __name__ == '__main__':
args = parseArgs()
logger = loggerSetup()
rucio = Rucio(acct=RUCIO_ACCT, hostUrl=RUCIO_URL, authUrl=RUCIO_AUTH_URL,
configDict={"logger": logger, "user_agent": "amaltaro/makeRucioRules"})
rule = {'copies': 1,
'activity': 'Production Input',
'lifetime': None,
'account': RUCIO_ACCT,
'grouping': "ALL",
'comment': 'WMCore MSTransferor input data placement'}
logger.info("\nCreating rule for DID: %s, with RSE: %s and other attrs: %s",
args.container, args.rse, rule)
resp = rucio.createReplicationRule(args.container, args.rse, **rule)
logger.info("Response: %s", resp)