msmonitor 2.3.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Utils/CPMetrics.py +270 -0
- Utils/CertTools.py +62 -0
- Utils/EmailAlert.py +50 -0
- Utils/ExtendedUnitTestCase.py +62 -0
- Utils/FileTools.py +182 -0
- Utils/IteratorTools.py +80 -0
- Utils/MathUtils.py +31 -0
- Utils/MemoryCache.py +119 -0
- Utils/Patterns.py +24 -0
- Utils/Pipeline.py +137 -0
- Utils/PortForward.py +97 -0
- Utils/ProcessStats.py +103 -0
- Utils/PythonVersion.py +17 -0
- Utils/Signals.py +36 -0
- Utils/TemporaryEnvironment.py +27 -0
- Utils/Throttled.py +227 -0
- Utils/Timers.py +130 -0
- Utils/Timestamps.py +86 -0
- Utils/TokenManager.py +143 -0
- Utils/Tracing.py +60 -0
- Utils/TwPrint.py +98 -0
- Utils/Utilities.py +308 -0
- Utils/__init__.py +11 -0
- WMCore/Algorithms/Alarm.py +39 -0
- WMCore/Algorithms/MathAlgos.py +274 -0
- WMCore/Algorithms/MiscAlgos.py +67 -0
- WMCore/Algorithms/ParseXMLFile.py +115 -0
- WMCore/Algorithms/Permissions.py +27 -0
- WMCore/Algorithms/Singleton.py +58 -0
- WMCore/Algorithms/SubprocessAlgos.py +129 -0
- WMCore/Algorithms/__init__.py +7 -0
- WMCore/Cache/GenericDataCache.py +98 -0
- WMCore/Cache/WMConfigCache.py +572 -0
- WMCore/Cache/__init__.py +0 -0
- WMCore/Configuration.py +651 -0
- WMCore/DAOFactory.py +47 -0
- WMCore/DataStructs/File.py +177 -0
- WMCore/DataStructs/Fileset.py +140 -0
- WMCore/DataStructs/Job.py +182 -0
- WMCore/DataStructs/JobGroup.py +142 -0
- WMCore/DataStructs/JobPackage.py +49 -0
- WMCore/DataStructs/LumiList.py +734 -0
- WMCore/DataStructs/Mask.py +219 -0
- WMCore/DataStructs/MathStructs/ContinuousSummaryHistogram.py +197 -0
- WMCore/DataStructs/MathStructs/DiscreteSummaryHistogram.py +92 -0
- WMCore/DataStructs/MathStructs/SummaryHistogram.py +117 -0
- WMCore/DataStructs/MathStructs/__init__.py +0 -0
- WMCore/DataStructs/Pickleable.py +24 -0
- WMCore/DataStructs/Run.py +256 -0
- WMCore/DataStructs/Subscription.py +175 -0
- WMCore/DataStructs/WMObject.py +47 -0
- WMCore/DataStructs/WorkUnit.py +112 -0
- WMCore/DataStructs/Workflow.py +60 -0
- WMCore/DataStructs/__init__.py +8 -0
- WMCore/Database/CMSCouch.py +1349 -0
- WMCore/Database/ConfigDBMap.py +29 -0
- WMCore/Database/CouchUtils.py +118 -0
- WMCore/Database/DBCore.py +198 -0
- WMCore/Database/DBCreator.py +113 -0
- WMCore/Database/DBExceptionHandler.py +57 -0
- WMCore/Database/DBFactory.py +110 -0
- WMCore/Database/DBFormatter.py +177 -0
- WMCore/Database/Dialects.py +13 -0
- WMCore/Database/ExecuteDAO.py +327 -0
- WMCore/Database/MongoDB.py +241 -0
- WMCore/Database/MySQL/Destroy.py +42 -0
- WMCore/Database/MySQL/ListUserContent.py +20 -0
- WMCore/Database/MySQL/__init__.py +9 -0
- WMCore/Database/MySQLCore.py +132 -0
- WMCore/Database/Oracle/Destroy.py +56 -0
- WMCore/Database/Oracle/ListUserContent.py +19 -0
- WMCore/Database/Oracle/__init__.py +9 -0
- WMCore/Database/ResultSet.py +44 -0
- WMCore/Database/Transaction.py +91 -0
- WMCore/Database/__init__.py +9 -0
- WMCore/Database/ipy_profile_couch.py +438 -0
- WMCore/GroupUser/CouchObject.py +127 -0
- WMCore/GroupUser/Decorators.py +51 -0
- WMCore/GroupUser/Group.py +33 -0
- WMCore/GroupUser/Interface.py +73 -0
- WMCore/GroupUser/User.py +96 -0
- WMCore/GroupUser/__init__.py +11 -0
- WMCore/Lexicon.py +836 -0
- WMCore/MicroService/CherryPyThreads/HeartbeatMonitor.py +6 -0
- WMCore/MicroService/CherryPyThreads/__init__.py +0 -0
- WMCore/MicroService/DataStructs/DefaultStructs.py +101 -0
- WMCore/MicroService/DataStructs/__init__.py +0 -0
- WMCore/MicroService/MSCore/MSAuth.py +153 -0
- WMCore/MicroService/MSCore/MSCore.py +113 -0
- WMCore/MicroService/MSCore/MSManager.py +484 -0
- WMCore/MicroService/MSCore/TaskManager.py +218 -0
- WMCore/MicroService/MSCore/__init__.py +0 -0
- WMCore/MicroService/MSMonitor/MSMonitor.py +270 -0
- WMCore/MicroService/MSMonitor/__init__.py +0 -0
- WMCore/MicroService/Service/Data.py +225 -0
- WMCore/MicroService/Service/RestApiHub.py +46 -0
- WMCore/MicroService/Service/__init__.py +0 -0
- WMCore/MicroService/Tools/Common.py +579 -0
- WMCore/MicroService/Tools/PycurlRucio.py +419 -0
- WMCore/MicroService/Tools/__init__.py +0 -0
- WMCore/MicroService/WebGui/FrontPage.py +56 -0
- WMCore/MicroService/WebGui/__init__.py +0 -0
- WMCore/REST/Auth.py +202 -0
- WMCore/REST/CherryPyPeriodicTask.py +166 -0
- WMCore/REST/Error.py +333 -0
- WMCore/REST/Format.py +642 -0
- WMCore/REST/HeartbeatMonitorBase.py +90 -0
- WMCore/REST/Main.py +623 -0
- WMCore/REST/Server.py +2435 -0
- WMCore/REST/Services.py +24 -0
- WMCore/REST/Test.py +120 -0
- WMCore/REST/Tools.py +38 -0
- WMCore/REST/Validation.py +250 -0
- WMCore/REST/__init__.py +1 -0
- WMCore/ReqMgr/DataStructs/RequestStatus.py +209 -0
- WMCore/ReqMgr/DataStructs/RequestType.py +13 -0
- WMCore/ReqMgr/DataStructs/__init__.py +0 -0
- WMCore/ReqMgr/__init__.py +1 -0
- WMCore/Services/AlertManager/AlertManagerAPI.py +111 -0
- WMCore/Services/AlertManager/__init__.py +0 -0
- WMCore/Services/CRIC/CRIC.py +238 -0
- WMCore/Services/CRIC/__init__.py +0 -0
- WMCore/Services/DBS/DBS3Reader.py +1044 -0
- WMCore/Services/DBS/DBSConcurrency.py +44 -0
- WMCore/Services/DBS/DBSErrors.py +113 -0
- WMCore/Services/DBS/DBSReader.py +23 -0
- WMCore/Services/DBS/DBSUtils.py +139 -0
- WMCore/Services/DBS/DBSWriterObjects.py +381 -0
- WMCore/Services/DBS/ProdException.py +133 -0
- WMCore/Services/DBS/__init__.py +8 -0
- WMCore/Services/FWJRDB/FWJRDBAPI.py +118 -0
- WMCore/Services/FWJRDB/__init__.py +0 -0
- WMCore/Services/HTTPS/HTTPSAuthHandler.py +66 -0
- WMCore/Services/HTTPS/__init__.py +0 -0
- WMCore/Services/LogDB/LogDB.py +201 -0
- WMCore/Services/LogDB/LogDBBackend.py +191 -0
- WMCore/Services/LogDB/LogDBExceptions.py +11 -0
- WMCore/Services/LogDB/LogDBReport.py +85 -0
- WMCore/Services/LogDB/__init__.py +0 -0
- WMCore/Services/MSPileup/__init__.py +0 -0
- WMCore/Services/MSUtils/MSUtils.py +54 -0
- WMCore/Services/MSUtils/__init__.py +0 -0
- WMCore/Services/McM/McM.py +173 -0
- WMCore/Services/McM/__init__.py +8 -0
- WMCore/Services/MonIT/Grafana.py +133 -0
- WMCore/Services/MonIT/__init__.py +0 -0
- WMCore/Services/PyCondor/PyCondorAPI.py +154 -0
- WMCore/Services/PyCondor/PyCondorUtils.py +105 -0
- WMCore/Services/PyCondor/__init__.py +0 -0
- WMCore/Services/ReqMgr/ReqMgr.py +261 -0
- WMCore/Services/ReqMgr/__init__.py +0 -0
- WMCore/Services/ReqMgrAux/ReqMgrAux.py +419 -0
- WMCore/Services/ReqMgrAux/__init__.py +0 -0
- WMCore/Services/RequestDB/RequestDBReader.py +267 -0
- WMCore/Services/RequestDB/RequestDBWriter.py +39 -0
- WMCore/Services/RequestDB/__init__.py +0 -0
- WMCore/Services/Requests.py +624 -0
- WMCore/Services/Rucio/Rucio.py +1287 -0
- WMCore/Services/Rucio/RucioUtils.py +74 -0
- WMCore/Services/Rucio/__init__.py +0 -0
- WMCore/Services/RucioConMon/RucioConMon.py +128 -0
- WMCore/Services/RucioConMon/__init__.py +0 -0
- WMCore/Services/Service.py +400 -0
- WMCore/Services/StompAMQ/__init__.py +0 -0
- WMCore/Services/TagCollector/TagCollector.py +155 -0
- WMCore/Services/TagCollector/XMLUtils.py +98 -0
- WMCore/Services/TagCollector/__init__.py +0 -0
- WMCore/Services/UUIDLib.py +13 -0
- WMCore/Services/UserFileCache/UserFileCache.py +160 -0
- WMCore/Services/UserFileCache/__init__.py +8 -0
- WMCore/Services/WMAgent/WMAgent.py +63 -0
- WMCore/Services/WMAgent/__init__.py +0 -0
- WMCore/Services/WMArchive/CMSSWMetrics.py +526 -0
- WMCore/Services/WMArchive/DataMap.py +463 -0
- WMCore/Services/WMArchive/WMArchive.py +33 -0
- WMCore/Services/WMArchive/__init__.py +0 -0
- WMCore/Services/WMBS/WMBS.py +97 -0
- WMCore/Services/WMBS/__init__.py +0 -0
- WMCore/Services/WMStats/DataStruct/RequestInfoCollection.py +300 -0
- WMCore/Services/WMStats/DataStruct/__init__.py +0 -0
- WMCore/Services/WMStats/WMStatsPycurl.py +145 -0
- WMCore/Services/WMStats/WMStatsReader.py +445 -0
- WMCore/Services/WMStats/WMStatsWriter.py +273 -0
- WMCore/Services/WMStats/__init__.py +0 -0
- WMCore/Services/WMStatsServer/WMStatsServer.py +134 -0
- WMCore/Services/WMStatsServer/__init__.py +0 -0
- WMCore/Services/WorkQueue/WorkQueue.py +492 -0
- WMCore/Services/WorkQueue/__init__.py +0 -0
- WMCore/Services/__init__.py +8 -0
- WMCore/Services/pycurl_manager.py +574 -0
- WMCore/WMBase.py +50 -0
- WMCore/WMConnectionBase.py +164 -0
- WMCore/WMException.py +183 -0
- WMCore/WMExceptions.py +269 -0
- WMCore/WMFactory.py +76 -0
- WMCore/WMInit.py +228 -0
- WMCore/WMLogging.py +108 -0
- WMCore/Wrappers/JsonWrapper/JSONThunker.py +342 -0
- WMCore/Wrappers/JsonWrapper/__init__.py +7 -0
- WMCore/Wrappers/__init__.py +6 -0
- WMCore/__init__.py +10 -0
- msmonitor-2.3.10.data/data/bin/wmc-dist-patch +15 -0
- msmonitor-2.3.10.data/data/bin/wmc-dist-unpatch +8 -0
- msmonitor-2.3.10.data/data/bin/wmc-httpd +3 -0
- msmonitor-2.3.10.dist-info/LICENSE +202 -0
- msmonitor-2.3.10.dist-info/METADATA +21 -0
- msmonitor-2.3.10.dist-info/NOTICE +16 -0
- msmonitor-2.3.10.dist-info/RECORD +210 -0
- msmonitor-2.3.10.dist-info/WHEEL +5 -0
- msmonitor-2.3.10.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# pylint: disable=E0239
|
|
2
|
+
# E0239: inherit-non-class
|
|
3
|
+
"""
|
|
4
|
+
File : Data.py
|
|
5
|
+
Author : Valentin Kuznetsov <vkuznet AT gmail dot com>
|
|
6
|
+
Description: This module consists of all REST APIs required by MicroService
|
|
7
|
+
|
|
8
|
+
Client may invoke GET/POST calls to MicroService, e.g.
|
|
9
|
+
# return status of the MicroService
|
|
10
|
+
curl http://localhost:8822/microservice/data/status
|
|
11
|
+
# ping MicroService, i.e. return its default message
|
|
12
|
+
curl http://localhost:8822/microservice/data
|
|
13
|
+
# post data to MicroService
|
|
14
|
+
curl -X POST -H "Content-type: application/json" -d '{"request":{"spec":"spec"}}' http://localhost:8822/microservice/data
|
|
15
|
+
|
|
16
|
+
# MSPileup get APIs
|
|
17
|
+
# spec.json will contains spec query to delete MSPileup document, e.g.
|
|
18
|
+
# {"query": {"pileupName": "bla-bla-bla"}}
|
|
19
|
+
curl -X POST -H "Content-type: application/json" -d@./spec.json http://lhost:port/ms-pileup/data
|
|
20
|
+
|
|
21
|
+
or we will use dedicated end-point, e.g. data
|
|
22
|
+
curl -X GET http://lhost:port/ms-pileup/data/pileup?pileupName=bla
|
|
23
|
+
curl -X GET http://lhost:port/ms-pileup/data/pileup?campaign=campaign
|
|
24
|
+
|
|
25
|
+
# MSPileup create APIs
|
|
26
|
+
# doc.json contains new MSPileup document
|
|
27
|
+
curl -X POST -H "Content-type: application/json" -d@./doc.json http://lhost:port/ms-pileup/data
|
|
28
|
+
|
|
29
|
+
# MSPileup update API
|
|
30
|
+
curl -X PUT -H "Content-type: application/json" -d '{"pileupName":"bla"}' http://localhost:8822/microservice/data
|
|
31
|
+
|
|
32
|
+
# MSPileup delete API
|
|
33
|
+
curl -X DELETE -H "Content-type: application/json" -d '{"pileupName":"bla"}' http://localhost:8822/microservice/data
|
|
34
|
+
"""
|
|
35
|
+
# futures
|
|
36
|
+
from __future__ import print_function, division
|
|
37
|
+
|
|
38
|
+
# system modules
|
|
39
|
+
import json
|
|
40
|
+
import traceback
|
|
41
|
+
import importlib
|
|
42
|
+
from future.utils import with_metaclass
|
|
43
|
+
# from types import GeneratorType
|
|
44
|
+
|
|
45
|
+
# 3d party modules
|
|
46
|
+
import cherrypy
|
|
47
|
+
|
|
48
|
+
# WMCore modules
|
|
49
|
+
import WMCore
|
|
50
|
+
from Utils.Patterns import Singleton
|
|
51
|
+
from WMCore.REST.Server import RESTEntity, restcall
|
|
52
|
+
from WMCore.REST.Tools import tools
|
|
53
|
+
# from WMCore.REST.Validation import validate_rx, validate_str
|
|
54
|
+
from WMCore.REST.Format import JSONFormat, PrettyJSONFormat
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def results(res):
|
|
58
|
+
"Return results in a list format suitable by REST server"
|
|
59
|
+
if not isinstance(res, list):
|
|
60
|
+
return [res]
|
|
61
|
+
return res
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def mspileupError(doc):
|
|
65
|
+
"""
|
|
66
|
+
Check MSPileup record for error
|
|
67
|
+
:return: None or raise cherrypy.HTTPError
|
|
68
|
+
"""
|
|
69
|
+
if 'error' in doc:
|
|
70
|
+
msg = doc['message']
|
|
71
|
+
code = doc['code']
|
|
72
|
+
msg = f'MSPileupError: {msg}, code: {code}'
|
|
73
|
+
raise cherrypy.HTTPError(400, msg) from None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class Data(with_metaclass(Singleton, RESTEntity, object)):
|
|
77
|
+
"""
|
|
78
|
+
This class is responsbiel for both the REST interface
|
|
79
|
+
and the application/service itself, thus make it a
|
|
80
|
+
Singleton to guarantee that only one instance will be
|
|
81
|
+
executing
|
|
82
|
+
"""
|
|
83
|
+
def __init__(self, app, api, config, mount):
|
|
84
|
+
RESTEntity.__init__(self, app, api, config, mount)
|
|
85
|
+
self.config = config
|
|
86
|
+
arr = config.manager.split('.')
|
|
87
|
+
self.mount = mount
|
|
88
|
+
try:
|
|
89
|
+
cname = arr[-1]
|
|
90
|
+
module = importlib.import_module('.'.join(arr[:-1]))
|
|
91
|
+
self.mgr = getattr(module, cname)(config)
|
|
92
|
+
except ImportError:
|
|
93
|
+
print("ERROR initializing MicroService REST module.")
|
|
94
|
+
traceback.print_exc()
|
|
95
|
+
|
|
96
|
+
def validate(self, apiobj, method, api, param, safe):
|
|
97
|
+
"""
|
|
98
|
+
Validate request input data.
|
|
99
|
+
Has to be implemented, otherwise the service fails to start.
|
|
100
|
+
If it's not implemented correctly (e.g. just pass), the arguments
|
|
101
|
+
are not passed in the method at all.
|
|
102
|
+
|
|
103
|
+
"""
|
|
104
|
+
if method == 'GET':
|
|
105
|
+
for prop in list(param.kwargs):
|
|
106
|
+
safe.kwargs[prop] = param.kwargs.pop(prop)
|
|
107
|
+
safe.kwargs['API'] = api
|
|
108
|
+
if param.args:
|
|
109
|
+
return False
|
|
110
|
+
elif method == 'POST':
|
|
111
|
+
if not param.args or not param.kwargs:
|
|
112
|
+
return False
|
|
113
|
+
return True
|
|
114
|
+
|
|
115
|
+
@restcall(formats=[('text/plain', PrettyJSONFormat()), ('application/json', JSONFormat())])
|
|
116
|
+
@tools.expires(secs=-1)
|
|
117
|
+
def get(self, **kwds):
|
|
118
|
+
"""
|
|
119
|
+
Implement GET request with given uid or set of parameters
|
|
120
|
+
"""
|
|
121
|
+
res = {'wmcore_version': WMCore.__version__,
|
|
122
|
+
'microservice_version': WMCore.__version__, # FIXME: extract it from another place
|
|
123
|
+
'microservice': self.mgr.__class__.__name__}
|
|
124
|
+
|
|
125
|
+
api = kwds.get('API')
|
|
126
|
+
|
|
127
|
+
if api == "status":
|
|
128
|
+
detail = True if kwds.pop("detail", True) in (True, "true", "True", "TRUE") else False
|
|
129
|
+
res.update(self.mgr.status(detail, **kwds))
|
|
130
|
+
yield res
|
|
131
|
+
elif api == "info":
|
|
132
|
+
res.update(self.mgr.info(kwds.pop("request", None), **kwds))
|
|
133
|
+
yield res
|
|
134
|
+
elif 'ms-pileup' in self.mount:
|
|
135
|
+
# this section of the GET API is only relevant for MSPileup service
|
|
136
|
+
# the self.mount point should match service configuration, e.g. in MSPileup we define
|
|
137
|
+
# mount point as /ms-pileup/data, e.g. http://.../ms-pileup/data
|
|
138
|
+
try:
|
|
139
|
+
for doc in self.mgr.get(**kwds):
|
|
140
|
+
mspileupError(doc)
|
|
141
|
+
yield doc
|
|
142
|
+
except cherrypy.HTTPError:
|
|
143
|
+
raise
|
|
144
|
+
except:
|
|
145
|
+
msg = 'Unable to GET request, error=%s' % traceback.format_exc()
|
|
146
|
+
raise cherrypy.HTTPError(status=500, message=msg) from None
|
|
147
|
+
|
|
148
|
+
@restcall(formats=[('application/json', JSONFormat())])
|
|
149
|
+
@tools.expires(secs=-1)
|
|
150
|
+
def post(self):
|
|
151
|
+
"""
|
|
152
|
+
Implement POST request API.
|
|
153
|
+
The input HTTP request should be in the following form
|
|
154
|
+
{"request":some_data} for posting the data into the service.
|
|
155
|
+
|
|
156
|
+
NOTE: the usage of this method requires further thought
|
|
157
|
+
"""
|
|
158
|
+
try:
|
|
159
|
+
data = json.load(cherrypy.request.body)
|
|
160
|
+
if 'ms-pileup' in self.mount:
|
|
161
|
+
# this section of POST API is only relevant for MSPileup service
|
|
162
|
+
for doc in self.mgr.post(data):
|
|
163
|
+
mspileupError(doc)
|
|
164
|
+
yield doc
|
|
165
|
+
elif 'ms-transferor' in self.mount:
|
|
166
|
+
for doc in self.mgr.post(data):
|
|
167
|
+
yield doc
|
|
168
|
+
else:
|
|
169
|
+
msg = f"End point {self.mount} does not support POST request JSON payload"
|
|
170
|
+
raise cherrypy.HTTPError(status=400, message=msg) from None
|
|
171
|
+
except cherrypy.HTTPError:
|
|
172
|
+
raise
|
|
173
|
+
except:
|
|
174
|
+
msg = 'Unable to POST request, error=%s' % traceback.format_exc()
|
|
175
|
+
raise cherrypy.HTTPError(status=500, message=msg) from None
|
|
176
|
+
|
|
177
|
+
@restcall(formats=[('application/json', JSONFormat())])
|
|
178
|
+
@tools.expires(secs=-1)
|
|
179
|
+
def put(self):
|
|
180
|
+
"""
|
|
181
|
+
Implement PUT HTTP method of MicroService API.
|
|
182
|
+
"""
|
|
183
|
+
try:
|
|
184
|
+
if 'ms-pileup' in self.mount:
|
|
185
|
+
# this section of PUT API is only relevant for MSPileup service
|
|
186
|
+
data = json.load(cherrypy.request.body)
|
|
187
|
+
for doc in self.mgr.update(data):
|
|
188
|
+
mspileupError(doc)
|
|
189
|
+
yield doc
|
|
190
|
+
except cherrypy.HTTPError:
|
|
191
|
+
raise
|
|
192
|
+
except:
|
|
193
|
+
msg = 'Unable to PUT request, error=%s' % traceback.format_exc()
|
|
194
|
+
raise cherrypy.HTTPError(status=500, message=msg) from None
|
|
195
|
+
|
|
196
|
+
@restcall(formats=[('application/json', JSONFormat())])
|
|
197
|
+
@tools.expires(secs=-1)
|
|
198
|
+
def delete(self):
|
|
199
|
+
"""
|
|
200
|
+
Implement DELETE HTTP method of MicroService API.
|
|
201
|
+
"""
|
|
202
|
+
if 'ms-pileup' not in self.mount:
|
|
203
|
+
return # not implemented for other MS services
|
|
204
|
+
|
|
205
|
+
# DELETE API is only relevant for MSPileup service
|
|
206
|
+
spec = {}
|
|
207
|
+
try:
|
|
208
|
+
spec = json.load(cherrypy.request.body)
|
|
209
|
+
except:
|
|
210
|
+
msg = 'Unable to DELETE request, error=%s' % traceback.format_exc()
|
|
211
|
+
raise cherrypy.HTTPError(status=400, message=msg) from None
|
|
212
|
+
# so far allow only pileupName in input spec
|
|
213
|
+
if 'pileupName' not in spec:
|
|
214
|
+
msg = "wrong spec, please provide pileupName"
|
|
215
|
+
raise cherrypy.HTTPError(status=400, message=msg) from None
|
|
216
|
+
try:
|
|
217
|
+
if 'pileupName' in spec and len(spec.keys()) == 1:
|
|
218
|
+
for doc in self.mgr.delete(spec):
|
|
219
|
+
mspileupError(doc)
|
|
220
|
+
yield doc
|
|
221
|
+
except cherrypy.HTTPError:
|
|
222
|
+
raise
|
|
223
|
+
except:
|
|
224
|
+
msg = 'Unable to DELETE request, error=%s' % traceback.format_exc()
|
|
225
|
+
raise cherrypy.HTTPError(status=500, message=msg) from None
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
File : RestApiHub.py
|
|
3
|
+
Author : Valentin Kuznetsov <vkuznet AT gmail dot com>
|
|
4
|
+
Description: REST API module for MicroService class.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
# futures
|
|
8
|
+
from __future__ import print_function, division
|
|
9
|
+
|
|
10
|
+
# cherrypy modules
|
|
11
|
+
import cherrypy
|
|
12
|
+
|
|
13
|
+
# WMCore modules
|
|
14
|
+
from WMCore.Configuration import Configuration
|
|
15
|
+
from WMCore.REST.Server import RESTApi
|
|
16
|
+
from WMCore.MicroService.Service.Data import Data
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class RestApiHub(RESTApi):
|
|
20
|
+
"""
|
|
21
|
+
RestInterface defines REST APIs for MicroService.
|
|
22
|
+
They are mounted to entry point defined in _add method.
|
|
23
|
+
"""
|
|
24
|
+
def __init__(self, app, config, mount):
|
|
25
|
+
"""
|
|
26
|
+
:arg app: reference to application object; passed to all entities.
|
|
27
|
+
:arg config: reference to configuration; passed to all entities.
|
|
28
|
+
:arg str mount: is definition coming from configuration file to mount the app in REST server
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
RESTApi.__init__(self, app, config, mount)
|
|
32
|
+
|
|
33
|
+
cherrypy.log("MicroService entire configuration:\n%s" % Configuration.getInstance())
|
|
34
|
+
cherrypy.log("MicroService REST configuration subset:\n%s" % config)
|
|
35
|
+
|
|
36
|
+
self._add({"status": Data(app, self, config, mount),
|
|
37
|
+
"info": Data(app, self, config, mount)})
|
|
38
|
+
|
|
39
|
+
# the mount point should match service configuration, e.g. in MSPileup we define
|
|
40
|
+
# mount point as /ms-pileup/data, e.g. http://.../ms-pileup/data
|
|
41
|
+
if 'ms-pileup' in mount:
|
|
42
|
+
# add new API "pileup" and it will be accessible as /ms-pileup/data/pileup
|
|
43
|
+
self._add({"pileup": Data(app, self, config, mount)})
|
|
44
|
+
elif 'ms-transferor' in mount:
|
|
45
|
+
# add new API "transferor" and it will be accessible as /ms-transferor/data/transferor
|
|
46
|
+
self._add({"transferor": Data(app, self, config, mount)})
|
|
File without changes
|