-
Notifications
You must be signed in to change notification settings - Fork 0
/
policy.da
595 lines (503 loc) · 24.7 KB
/
policy.da
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
import sys
import time
import random
import logging
import configparser
import xml.etree.ElementTree as ET
# Data Structure for Request
class Request:
def __init__(self, sub_id, res_id, h, sub_attrs=None, res_attrs = None, action=None):
self.app_id = None
self.sub_id = sub_id
self.res_id = res_id
self.attrs_read_from_tent = {}
self.attrs_read_from_cache = {}
self.timestamp = time.time()
self.sub_attrs = sub_attrs
self.res_attrs = res_attrs
self.sub_attrs_to_update = []
self.res_attrs_to_update = []
self.sub_attrs_for_policy_eval = {}
self.hashMap = h
self.action = action
self.dbEmulator = None
# Data Structure for Rules
class Rule:
def __init__(self, rulename, sub_id, res_id, action, sub_attrs, res_attrs, sub_attrs_to_update, res_attrs_to_update):
self.rulename = rulename
self.dbEmulator = None
self.sub_id = sub_id
self.res_id = res_id
self.sub_attrs = sub_attrs
self.res_attrs = res_attrs
self.action = action
self.sub_attrs_to_update = sub_attrs_to_update
self.res_attrs_to_update = res_attrs_to_update
#Process Application
class Application(process):
def setup(hashMap:dict, sub_co:set, res_co:set, master_id: Master, dbEmulator:DB_Emulator, req:Request):
pass
def run():
req.dbEmulator = dbEmulator
output("Application sending Req to Sub_Co " + str(req.hashMap[req.sub_id]))
send(("evalRequestFromApp", req), to=req.hashMap[req.sub_id])
await(len(listof(p,received(('done',), from_=p))) == 1) # wait till master asks to shutdown
def receive(msg=('done',), from_=p) :
output(str(self.id)+" shutting Down")
def receive(msg=('policyDecisionFromSub_Co', decision), from_= sub_coord_id):
output("Received Policy decision from Sub_Co at App-> " + str(self.id))
if decision== "Success":
output("Policy Evaluated")
send(('okay',), to=master_id)
class Sub_Co(process):
def setup():
self.procs = dict()
self.app_id = None
self.updated_cache = dict()
self.has_read_from_tent = []
self.tent_updated_attrs = {} # dict of str and dict
# 'Attr1':{'Val':value, 'Time':timestamp}
def run():
await(len(listof(p,received(('done',), from_=p))) == 1)
def receive(msg=('done',), from_=p) :
output(str(self.id)+" shutting Down")
def receive(msg=('evalRequestFromApp', req), from_= app_id):
# Mark yourself as running. So as it is easy to check whether you were restarted later.
output("Received Eval Req from App at Sub_Co-> " + str(self.id))
if req.app_id is None:
req.app_id = app_id
self.procs[req] = "Running"
# Get the Attributes needed (Only reqd ones, not all of them) from the config file.
# req.sub_attrs = {"history":"empty"}
# req.res_attrs = {}
# check if those attributes in recent and then tent
# update the request accordingly
output("reading tent"+ str(tent_updated_attrs))
for attr in req.sub_attrs:
if attr in tent_updated_attrs:
# First Pref to Tent
req.attrs_read_from_tent[attr] = tent_updated_attrs[attr]['value']
elif attr in updated_cache:
# Then Cache
req.attrs_read_from_cache[attr] = updated_cache[attr]
# At this point, the sub_attr has latest value of all the subject Attributes
# Find the resource Coordinator from config file or hash
output("Request Updated with Tent and Cache")
output("Final Req Object is-> " + str(req))
output("Sub_Co Sending Eval Request to Res_Co-> " + str(req.hashMap[req.res_id]))
send(('evalRequestFromSub_Co', req), to=req.hashMap[req.res_id])
# When the decision arrives
def performCleanup(req):
req.attrs_read_from_tent = {}
req.attrs_read_from_cache = {}
req.timestamp = time.time()
req.sub_attrs_to_update = []
req.res_attrs_to_update = []
req.sub_attrs_for_policy_eval = {}
return req
def receive(msg=('decisionFromWorker', req), from_= w_id):
output("Decision from Worker Recvd at-> " + str(self.id))
output("Sub obligations-> " + str(req.sub_attrs_to_update))
output("Res obligations-> " + str(req.res_attrs_to_update))
# Check Subject Conflict here
conflict = None
output("Tent_attr BEFORE-> " + str(tent_updated_attrs))
output("My Time Stamp - " + str(req.timestamp))
if req.sub_attrs_for_policy_eval:
for attr in req.sub_attrs_for_policy_eval:
if attr in tent_updated_attrs:
if req.sub_attrs_for_policy_eval[attr] != tent_updated_attrs[attr]['value']:
# If someone has updated tent after you read from it
# Conflict
conflict = "Present"
# Cleanup and Restart
procs[self.id] = "Restarted"
# Restart Code
output("Subject Conflict Found. Restart-> " + str(req.app_id))
req = performCleanup(req)
send(('evalRequestFromApp', req), to = self.id)
break
if conflict != "Present":
output("Subject Conflict-> Absent.")
if req.sub_attrs_to_update:
for attr in req.sub_attrs_to_update:
# If you are here, No subject Conflict. Add to tent. (Step 9)
if attr in tent_updated_attrs:
tent_updated_attrs[attr]['value'] = req.sub_attrs_to_update[attr]
tent_updated_attrs[attr]['timestamp'] = req.timestamp
else:
# New Entry
val = req.sub_attrs_to_update[attr]
ts = req.timestamp
tent_updated_attrs[attr] = dict()
tent_updated_attrs[attr]['value'] = val
tent_updated_attrs[attr]['timestamp'] = ts
output("Updated the tent_attr-> " + str(tent_updated_attrs))
output("Sending Req for Res Conflict eval to Res_Co-> " + str(req.hashMap[req.res_id]))
# Check for Res Conflict
send(('conflictEvalRequestFromSub_Co', req), to=req.hashMap[req.res_id])
def receive(msg=('conflictEvalReplyFromRes_Co', conflict_decision, req), from_= res_coord_id):
output("Received Conflict eval reply from Res_Co at-> " + str(self.id))
if conflict_decision == "Present":
# Resource Conflict
output("Resource Conflict was found at Res_Co.")
for r in has_read_from_tent:
if r.timestamp > req.timestamp:
# Cleanup
# Check if any the tent_updated_attrs was updated by
# Any of these. If yes, revert back.
output("Clearing Adminstration for request-> " + str(r))
for attr in r.sub_attrs:
if attr in tent_updated_attrs:
if tent_updated_attrs[attr]['timestamp'] == r.timestamp:
del tent_updated_attrs[attr]
output("Restarting request " + str(r))
send(('evalRequestFromApp', r), to=self.id)
# Restart yourself
output("Clearing Adminstration for request-> " + str(req))
for attr in req.sub_attrs:
if attr in tent_updated_attrs:
if tent_updated_attrs[attr]['timestamp'] == req.timestamp:
del tent_updated_attrs[attr]
output("Restarting request-> " + str(req))
send(('evalRequestFromApp', req), to=self.id)
else:
# No Conflict
# Add to Cache and Commit
output("No Conflict. Going to Commit.")
if req.sub_attrs_to_update:
for attr in req.sub_attrs_to_update:
#Commit
updated_cache[attr] = req.sub_attrs_to_update[attr]
output("Sub_Co Committing updates to DB")
send(('updateSubAttrs', updated_cache, req.sub_id), to=req.dbEmulator)
output("Sending Policy Decision from Sub_Co to App-> " + str(req.app_id))
send(('policyDecisionFromSub_Co', "Success"), to=req.app_id)
class Res_Co(process):
def setup(workers:set):
self.ongoingEvals = []
self.updated_cache = {}
def run():
await(len(listof(p,received(('done',), from_=p))) == 1)
def receive(msg=('done',), from_=p) :
output(str(self.id)+" shutting Down")
def receive(msg=('evalRequestFromSub_Co', req), from_= sub_coord_id):
output("Request from Sub_Co recvd at-> " + str(self.id))
#Append this request to Ongoing Evals
ongoingEvals.append(req)
#Update the ongong attributes with the list of committed ones.
for attr in req.res_attrs:
if attr in updated_cache:
req.res_attrs[attr] = updated_cache[attr]
# Get the worker ID from list of workers
workers_list = [p for p in workers]
w_id = workers_list[random.randint(0,len(workers_list)-1)]
output("Sending Request from Res_Co Worker-> " + str(w_id))
send(('evalRequestFromRes_Co', req), to=w_id)
def receive(msg=('conflictEvalRequestFromSub_Co', req), from_ = sub_coord_id):
conflict_decision = None
output("Received Req for Res Conflict eval at-> " + str(self.id))
if req.res_attrs_to_update:
for attr in req.res_attrs_to_update:
if attr in updated_cache:
if updated_cache[attr]['timestamp'] > req.timestamp:
conflict_decision = "Present"
# Someone Wrote on top of the value that you read. Conflict:
break
if conflict_decision == "Present":
# Restart
output("Resource Conflict-> Present")
output("Send Conflict msg to Sub_Co-> " + str(sub_coord_id))
send(('conflictEvalReplyFromRes_Co', conflict_decision, req), to=sub_coord_id)
else:
# Commit to Cache
output("No Conflict at the Resource Coordinator")
if req.sub_attrs_to_update:
for attr in req.res_attrs_to_update:
output("Res_Co## Updating the Cache")
updated_cache[attr] = req.res_attrs_to_update[attr]
output("Res Co Committing updates to DB")
send(('updateResAttrs', updated_cache, req.res_id), to=req.dbEmulator)
output("Send No Conflict msg to Sub_Co-> " + str(sub_coord_id))
send(('conflictEvalReplyFromRes_Co', conflict_decision, req), to=sub_coord_id)
class Worker(process):
def setup():
self.rules = []
self.sub_attr_dict = dict()
self.res_attr_dict = dict()
def receive(msg=('subAttrsFromDB', sub_attr_dict), from_= dbEmulator):
# Message sent by dbEmulator. Update the local copy of the DB as soon as DB sends it.
for attr in sub_attr_dict:
self.sub_attr_dict[attr] = sub_attr_dict[attr]
def receive(msg=('resAttrsFromDB', res_attr_dict), from_= dbEmulator):
# Message sent by dbEmulator. Update the local copy of the DB as soon as DB sends it.
for attr in res_attr_dict:
self.res_attr_dict[attr]= res_attr_dict[attr]
def create_rules(filename):
###
# This function reads the policy xml file and craetes a list of rules
# Which will be used by the worker for further policy evaluation.
# This process will run only once.
###
tree = ET.parse(filename)
root = tree.getroot()
rules = []
for rule in root.iter('rule'):
sub_attrs = {}
res_attrs = {}
action = {}
sub_attrs_to_update = {}
res_attrs_to_update = {}
rule_name = rule.attrib['name']
sc=rule.find('subjectCondition')
sub_id = sc.attrib['position']
for key in sc.attrib.keys():
if key != 'position':
sub_attrs[key] = sc.attrib[key]
rc=rule.find('resourceCondition')
if "id" in rc.attrib.keys():
res_id = rc.attrib['id']
else:
res_id = rc.attrib['type']
for key in rc.attrib.keys():
if key != 'id' and key != 'type':
res_attrs[key] = rc.attrib[key]
act=rule.find('action')
for key in act.attrib.keys():
action = act.attrib[key]
su=rule.find('subjectUpdate')
if su != None:
for key in su.attrib.keys():
sub_attrs_to_update[key] = su.attrib[key]
ru=rule.find('resourceUpdate')
if ru != None:
for key in ru.attrib.keys():
res_attrs_to_update[key] = ru.attrib[key]
# Create an object of the Rule Class. Append it to the rules list
temp_rule = Rule(rule_name, sub_id, res_id, action, sub_attrs, res_attrs, sub_attrs_to_update, res_attrs_to_update)
rules.append(temp_rule)
return rules
def policy(req, sub_attrs_for_policy_eval):
###
#This Routine evaluated the policy based on the rules read from the
#policy.xml file.
###
out = False
for rule in self.rules:
if (rule.sub_id == req.sub_id and rule.res_id == req.res_id and \
rule.action == req.action): #Sub_id, Res_Ids and actions Match
for attr in rule.sub_attrs:
if attr not in sub_attrs_for_policy_eval or \
rule.sub_attrs[attr] != sub_attrs_for_policy_eval[attr]:
# This Rule can not be applied. Go to next one.
out = True
break
if out == False:
for attr in req.res_attrs:
if attr not in rule.res_attrs or \
rule.res_attrs[attr] != req.res_attrs[attr]:
# This Rule can not be applied. Go to next one.
out = True
break
if out == False:
# This policy is applicable
output("Found a Matching Rule")
return rule.sub_attrs_to_update, rule.res_attrs_to_update
return None, None
def run():
self.rules = create_rules('policy-example.xml')
await((len(listof(p,received(('done',), from_=p))) == 1))
def receive(msg=('done',), from_=p) :
output(str(self.id)+" shutting Down")
def receive(msg=('evalRequestFromRes_Co', req), from_= res_coord_id):
output("Received Request from Res_Co at-> " + str(self.id))
# Here is how it will all go (In Order)-
# 1. Check what attrs are read from tent
# 2. Check for attrs read from cache
# 3. FOr the remaining attrs, consult the DB
sub_attrs_for_policy_eval = {}
for attr in req.sub_attrs:
if attr in req.attrs_read_from_tent:
sub_attrs_for_policy_eval[attr] = req.attrs_read_from_tent[attr]
elif attr in req.attrs_read_from_cache:
sub_attrs_for_policy_eval[attr] = req.attrs_read_from_cache[attr]
else:
# Load the attrs from cache (Replica of DB). Refer to the format of Sub_Dict_Cache
if req.sub_id in sub_attr_dict and attr in sub_attr_dict[req.sub_id]:
sub_attrs_for_policy_eval[attr] = sub_attr_dict[req.sub_id][attr]
output("Value Read before Rule-- " + str(sub_attrs_for_policy_eval))
req.sub_attrs_for_policy_eval = sub_attrs_for_policy_eval
(sub_attrs_to_update, res_attrs_to_update) = policy(req, sub_attrs_for_policy_eval)
req.sub_attrs_to_update = sub_attrs_to_update
req.res_attrs_to_update = res_attrs_to_update
output("Sending Decision from Worker to Sub_Co-> " + str(req.hashMap[req.sub_id]))
send(('decisionFromWorker', req), to=req.hashMap[req.sub_id])
def receive(msg=('updateFromDB', sub_attr_dict, res_attr_dict), from_=dbEmulator):
self.sub_attr_dict = sub_attr_dict
self.res_attr_dict = res_attr_dict
class DB_Emulator(process):
def setup(workers:set, db_config_file:str):
self.sub_attr_dict = dict() # Dict to hold the subject:attribute mapping
self.res_attr_dict = dict() # Dict to hold the resource:attribute mapping
self.minDBLatency = 0.0
self.maxDBLatency = 1.0
def run():
###
# Here we read from the DB_Config file to upload the attributes in the DB
# Only for the first time though.
###
config = configparser.ConfigParser()
config.read(db_config_file)
# This section parses the config file to create the final sub_attr_dict
sub_section = config["Subject"]
sub_id = sub_section['sub_id'].strip()
sub_attrs_list = sub_section['sub_attrs'].strip().split(',')
attr_dict = {}
if len(sub_attrs_list) >= 1:
for attrs in sub_attrs_list:
attr_dict[attrs.strip().split(':')[0]] = attrs.strip().split(':')[1]
self.sub_attr_dict[sub_id] = attr_dict # It has form - SubName : {Attr1:Value, Attr2:Value}
for w_id in workers:
output("Sending updates to worker-> " + str(w_id))
send(('subAttrsFromDB', self.sub_attr_dict), to=w_id)
# This section parses the config file to create the final res_attr_dict
res_section = config["Resource"]
res_id = res_section['res_id'].strip()
res_attrs_list = res_section['res_attrs'].strip().split(',')
attr_dict = {} # Temp Dict to hold all the attrs for a particular subject
if len(res_attrs_list) >=1 and all(v for v in res_attrs_list):
for attrs in res_attrs_list:
attr_dict[attrs.strip().split(':')[0]] = attrs.strip().split(':')[1]
self.res_attr_dict[res_id] = attr_dict # It has form - ResName : {Attr1:Value, Attr2:Value}
for w_id in workers:
output("Sending updates to worker-> " + str(w_id))
send(('resAttrsFromDB', self.res_attr_dict), to=w_id)
latency_section = config["Latency"]
self.minDBLatency = int(latency_section["minDBLatency"])
self.maxDBLatency = int(latency_section["maxDBLatency"])
await((len(listof(p,received(('done',), from_=p))) == 1)) # Always Runs
def receive(msg=('done',), from_= Master):
output("DONE recvd at the dbEmulator")
output("Dumping the DataBase")
output("Subject DataBase-> " + str(sub_attr_dict))
output("Resource DataBase-> " + str(res_attr_dict))
output(str(self.id)+" shutting Down")
def receive(msg=('getSubAttrs', sub_attrs, sub_id), from_= w_id):
###
# This routine returns the sub_attrs corresponding to
# the sub_id
###
output("Sending sub_attrs to worker->" + str(w_id))
send(('subAttrsFromDB', self.sub_attr_dict[sub_id]), to=w_id)
def receive(msg=('getResAttrs', res_attrs, res_id), from_= w_id):
###
# This routine returns the res_attrs corresponding to
# the res_id
###
output("Sending res_attrs to worker->" + str(w_id))
send(('resAttrsFromDB', self.res_attr_dict[res_id]), to=w_id)
def receive(msg=('updateSubAttrs', sub_attrs, sub_id), from_= sub_coord_id):
###
# This routine updated the sub_attrs in the DB after the latency time
# After it updates the Db, it waits for the latency, then sends to all the workers
###
for attr in sub_attrs:
self.sub_attr_dict[sub_id][attr] = sub_attrs[attr]
output("Recvd req to update by Sub_Co-> " + str(sub_coord_id))
waittime = random.uniform(minDBLatency, maxDBLatency)
output("Latency Chosen by the DB-> " + str(waittime))
time.sleep(waittime)
for w_id in workers:
output("Sending updates to worker-> " + str(w_id))
send(('subAttrsFromDB', self.sub_attr_dict), to=w_id)
def receive(msg=('updateResAttrs', res_attrs, res_id), from_= res_coord_id):
###
# This routine updates the sub_attrs in the DB after the latency time
###
for attr in res_attrs:
self.res_attr_dict[res_id][attr] = res_attrs[attr]
output("Recvd req to update by res co-> " + str(res_coord_id))
waittime = random.uniform(self.minDBLatency, self.maxDBLatency)
output("Latency Chosen by the DB-> " + str(waittime))
time.sleep(waittime)
for w_id in workers:
output("Sending updates to worker-> " + str(w_id))
send(('resAttrsFromDB', self.res_attr_dict), to=w_id)
class Master(process):
def setup(config_file_name:str, db_config_file:str):
pass
def run():
config = configparser.ConfigParser()
config.read(config_file_name)
output(str(config.sections()))
master_section = config['Master']
num_of_workers = int(master_section['num_of_workers'])
num_of_sub_co = int(master_section['num_of_sub_co'])
num_of_res_co = int(master_section['num_of_res_co'])
sub_id_section = config['sub-id-list']
res_id_section = config['res-id-list']
hashMap = {}
workers = new(Worker, [], num = num_of_workers)
sub_co = new(Sub_Co, [], num = num_of_sub_co)
res_co = new(Res_Co, [workers], num = num_of_res_co)
dbEmulator = new(DB_Emulator, [workers,db_config_file], num = 1)
sub_co_list = [p for p in sub_co]
res_co_list = [p for p in res_co]
sub_id_list = sub_id_section['sub_id_list'].strip().split(',')
res_id_list = res_id_section['res_id_list'].strip().split(',')
i = 0
for sub_id in sub_id_list:
hashMap[sub_id] = sub_co_list[i]
i = i + 1
i = (i % num_of_sub_co)
i = 0
for res_id in res_id_list:
hashMap[res_id] = res_co_list[i]
i = i + 1
i = (i % num_of_res_co)
output("Mapping: " + str(hashMap))
app_section = config['Application']
num_of_requests = int(app_section['num_of_request'])
output("number of Request:" + str(num_of_requests))
for i in range(1, num_of_requests +1):
req = app_section[str(i)].strip().split(",")
sub_attrs = {}
res_attrs = {}
for elem in req:
elem = elem.split("=")
if elem[0].strip() == "sub_id":
sub_id = elem[1]
sub_id_list.append(sub_id)
elif elem[0].strip() == "sub_attrs" and elem[1].strip() != "None":
sub_attrs_list = elem[1].split('|')
for e in sub_attrs_list:
sub_attrs[e.split(':')[0]] = e.split(':')[1]
elif elem[0].strip() == "res_id":
res_id = elem[1]
res_id_list.append(res_id)
elif elem[0].strip() == "res_attrs" and elem[1].strip() != "None":
res_attrs_list = elem[1].split('|')
for e in res_attrs_list:
res_attrs[e.split(':')[0]] = e.split(':')[1]
elif elem[0].strip() == "action":
action = elem[1]
req = Request(sub_id, res_id, hashMap, sub_attrs, res_attrs, action) # creating a new object
app = new(Application, [hashMap, sub_co, res_co, self.id,dbEmulator,req], num = 1)
output(str(app))
start(app)
#app = new(Application, [hashMap, sub_co, res_co, self.id, dbEmulator], num = num_of_clients)
start(sub_co | res_co | workers | dbEmulator)
await(len(listof(p,received(('okay',), from_=p))) == num_of_requests)
send(('done',), to=(sub_co | res_co | workers | dbEmulator))
output(str(self.id)+" shutting Down")
def receive(msg=('okay',), from_=p):
send(('done',), to=p)
def main():
config_file_name = str(sys.argv[1]) if len(sys.argv) > 1 else 'basic.config'
db_config_file = str(sys.argv[2]) if len(sys.argv) > 2 else 'dbconfig.config'
log_file_name = config_file_name.strip().split(".")[0]+".log"
output(log_file_name)
logging.getLogger('').handlers = []
logging.basicConfig(filename = log_file_name,filemode="w",level = logging.INFO)
master = new(Master,[config_file_name,db_config_file], num=1)
start(master)