forked from irods/irods_rule_engine_plugin_python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.py.template
330 lines (230 loc) · 8.41 KB
/
core.py.template
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
import datetime
import json
def writeStringToCharArray(s, char_array):
for i in range(0, len(s)):
char_array[i] = s[i]
def pythonRuleEnginePluginTest(rule_args, callback, rei):
with open('/tmp/from_core_py.txt', 'a') as f:
f.write(str(datetime.datetime.now()))
f.write('\n')
c = 0
for arg in rule_args:
f.write('\t')
f.write(str(c))
f.write(' : ')
f.write(str(arg))
f.write('\n')
c = c +1
callback.writeLine('serverLog', 'Printed to server log from python rule engine')
def acPreConnect(rule_args, callback, rei):
rule_args[0] = 'CS_NEG_DONT_CARE'
def acCreateUser(rule_args, callback, rei):
ret = callback.msiCreateUser()
if not ret['status']:
callback.msiRollback()
return ret
ret = acCreateDefaultCollections(rule_args, callback, rei)
if not ret['status']:
callback.msiRollback()
return ret
ret = callback.msiAddUserToGroup('public')
if not ret['status']:
callback.msiRollback()
return ret
callback.msiCommit()
def acCreateDefaultCollections(rule_args, callback, rei):
ret = acCreateUserZoneCollections(rule_args, callback, rei)
return ret
def acCreateUserZoneCollections(rule_args, callback, rei):
rodsZoneProxy = str(rei.uoip.rodsZone)
otherUserName = str(rei.uoio.userName)
homeStr = '/'.join(['', rodsZoneProxy, 'home'])
trashStr = '/'.join(['', rodsZoneProxy, 'trash', 'home'])
homeDict = [homeStr, otherUserName]
trashDict = [trashStr, otherUserName]
ret = acCreateCollByAdmin(homeDict, callback, rei)
ret = acCreateCollByAdmin(trashDict, callback, rei)
return ret
def acCreateCollByAdmin(rule_args, callback, rei):
ret = callback.msiCreateCollByAdmin(rule_args[0], rule_args[1])
return ret
def acDeleteUser(rule_args, callback, rei):
ret = callback.acDeleteDefaultCollections()
if not ret['status']:
callback.msiRollback()
return ret
ret = callback.msiDeleteUser()
if not ret['status']:
callback.msiRollback()
return ret
callback.msiCommit()
def acDeleteDefaultCollections(rule_args, callback, rei):
return acDeleteUserZoneCollections(rule_args, callback, rei)
def acDeleteUserZoneCollections(rule_args, callback, rei):
rodsZoneProxy = str(rei.uoip.rodsZone)
otherUserName = str(rei.uoio.userName)
homeStr = '/'.join(['', rodsZoneProxy, 'home'])
trashStr = '/'.join(['', rodsZoneProxy, 'trash', 'home'])
homeDict = [homeStr, otherUserName]
trashDict = [trashStr, otherUserName]
ret = acDeleteCollByAdminIfPresent(homeDict, callback, rei)
ret = acDeleteCollByAdminIfPresent(trashDict, callback, rei)
return ret
def acDeleteCollByAdminIfPresent(rule_args, callback, rei):
ret = callback.msiDeleteCollByAdmin(rule_args[0], rule_args[1])
if not ret['status']:
if not ret['code'] == -808000:
callback.failmsg(ret['code'], 'error deleting collection')
return ret
def acDeleteCollByAdmin(rule_args, callback, rei):
callback.msiDeleteCollByAdmin(rule_args[0], rule_args[1])
def acRenameLocalZone(rule_args, callback, rei):
coll_name = '/' + rule_args[0]
ret = callback.msiRenameCollection(coll_name, rule_args[1])
if not ret['status']:
callback.msiRollback()
return ret
ret = callback.msiRenameLocalZone(rule_args[0], rule_args[1])
if not ret['status']:
callback.msiRollback()
return ret
callback.msiCommit()
def acGetUserByDN(rule_args, callback, rei):
pass
def acAclPolicy(rule_args, callback, rei):
callback.msiAclPolicy('STRICT')
def acTicketPolicy(rule_args, callback, rei):
pass
def acCheckPasswordStrength(rule_args, callback, rei):
pass
def acSetRescSchemeForCreate(rule_args, callback, rei):
with open('../../etc/irods/server_config.json') as f:
server_config_dict = json.load(f)
callback.msiSetDefaultResc(server_config_dict.get('default_resource_name', 'demoResc'), 'null')
def acSetRescSchemeForRepl(rule_args, callback, rei):
with open('../../etc/irods/server_config.json') as f:
server_config_dict = json.load(f)
callback.msiSetDefaultResc(server_config_dict.get('default_resource_name', 'demoResc'), 'null')
def acPreprocForDataObjOpen(rule_args, callback, rei):
pass
def acSetMultiReplPerResc(rule_args, callback, rei):
pass
def acPostProcForPut(rule_args, callback, rei):
#pythonRuleEnginePluginTest(rule_args, callback, rei)
pass
def acPostProcForCopy(rule_args, callback, rei):
pass
def acPostProcForFilePathReg(rule_args, callback, rei):
pass
def acPostProcForCreate(rule_args, callback, rei):
pass
def acPostProcForOpen(rule_args, callback, rei):
pass
def acPostProcForPhymv(rule_args, callback, rei):
pass
def acPostProcForRepl(rule_args, callback, rei):
pass
def acSetNumThreads(rule_args, callback, rei):
callback.msiSetNumThreads('default', 'default', 'default')
def acDataDeletePolicy(rule_args, callback, rei):
pass
def acPostProcForDelete(rule_args, callback, rei):
pass
def acSetChkFilePathPerm(rule_args, callback, rei):
callback.msiSetChkFilePathPerm('disallowPathReg')
def acTrashPolicy(rule_args, callback, rei):
pass
def acSetPublicUserPolicy(rule_args, callback, rei):
pass
def acChkHostAccessControl(rule_args, callback, rei):
pass
def acSetVaultPathPolicy(rule_args, callback, rei):
callback.msiSetGraftPathScheme('no', '1')
def acSetReServerNumProc(rule_args, callback, rei):
callback.msiSetReServerNumProc('default')
def acPreprocForCollCreate(rule_args, callback, rei):
pass
def acPostProcForCollCreate(rule_args, callback, rei):
pass
def acPreprocForRmColl(rule_args, callback, rei):
pass
def acPostProcForRmColl(rule_args, callback, rei):
pass
def acPreProcForModifyUser(rule_args, callback, rei):
pass
def acPostProcForModifyUser(rule_args, callback, rei):
pass
def acPreProcForModifyAVUMetadata(rule_args, callback, rei):
pass
def acPostProcForModifyAVUMetadata(rule_args, callback, rei):
pass
def acPreProcForCreateUser(rule_args, callback, rei):
pass
def acPostProcForCreateUser(rule_args, callback, rei):
pass
def acPreProcForDeleteUser(rule_args, callback, rei):
pass
def acPostProcForDeleteUser(rule_args, callback, rei):
pass
def acPreProcForCreateResource(rule_args, callback, rei):
pass
def acPostProcForCreateResource(rule_args, callback, rei):
pass
def acPreProcForCreateToken(rule_args, callback, rei):
pass
def acPostProcForCreateToken(rule_args, callback, rei):
pass
def acPreProcForModifyUserGroup(rule_args, callback, rei):
pass
def acPostProcForModifyUserGroup(rule_args, callback, rei):
pass
def acPreProcForDeleteResource(rule_args, callback, rei):
pass
def acPostProcForDeleteResource(rule_args, callback, rei):
pass
def acPreProcForDeleteToken(rule_args, callback, rei):
pass
def acPostProcForDeleteToken(rule_args, callback, rei):
pass
def acPreProcForModifyResource(rule_args, callback, rei):
pass
def acPostProcForModifyResource(rule_args, callback, rei):
pass
def acPreProcForModifyCollMeta(rule_args, callback, rei):
pass
def acPostProcForModifyCollMeta(rule_args, callback, rei):
pass
def acPreProcForModifyDataObjMeta(rule_args, callback, rei):
pass
def acPostProcForModifyDataObjMeta(rule_args, callback, rei):
pass
def acPreProcForModifyAccessControl(rule_args, callback, rei):
pass
def acPostProcForModifyAccessControl(rule_args, callback, rei):
pass
def acPreProcForObjRename(rule_args, callback, rei):
pass
def acPostProcForObjRename(rule_args, callback, rei):
pass
def acPreProcForGenQuery(rule_args, callback, rei):
pass
def acPostProcForGenQuery(rule_args, callback, rei):
pass
def acRescQuotaPolicy(rule_args, callback, rei):
callback.msiSetRescQuotaPolicy('off')
def acBulkPutPostProcPolicy(rule_args, callback, rei):
callback.msiSetBulkPutPostProcPolicy('off')
def acPostProcForTarFileReg(rule_args, callback, rei):
pass
def acPostProcForDataObjWrite(rule_args, callback, rei):
pass
def acPostProcForDataObjRead(rule_args, callback, rei):
pass
def acPreProcForExecCmd(rule_args, callback, rei):
pass
def acPreProcForServerPortal(rule_args, callback, rei):
pass
def acPostProcForServerPortal(rule_args, callback, rei):
pass
def acPostProcForDataCopyReceived(rule_args, callback, rei):
pass