mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-22 17:43:14 +00:00
Syncfile option passing to client
Provide a mechanism for a syncfiles to indicate options to the client. This will be used for owner=, group=, and permissions= options.
This commit is contained in:
parent
a0ca3d3122
commit
a676eb0b83
@ -343,7 +343,8 @@ def handle_request(env, start_response):
|
||||
return
|
||||
if 'GET' == operation:
|
||||
status, output = syncfiles.get_syncresult(nodename)
|
||||
start_response(status, ())
|
||||
output = json.dumps(output)
|
||||
start_response(status, (('Content-Type', 'application/json')))
|
||||
yield output
|
||||
return
|
||||
elif env['PATH_INFO'].startswith('/self/remoteconfig/status'):
|
||||
|
@ -36,6 +36,7 @@ class SyncList(object):
|
||||
self.replacemap = {}
|
||||
self.appendmap = {}
|
||||
self.mergemap = {}
|
||||
self.optmap = {}
|
||||
with open(filename, 'r') as slfile:
|
||||
slist = slfile.read()
|
||||
entries = slist.split('\n')
|
||||
@ -71,10 +72,32 @@ class SyncList(object):
|
||||
break
|
||||
else:
|
||||
continue
|
||||
optparts = v.split()
|
||||
v = optparts[0]
|
||||
optparts = optparts[1:]
|
||||
else:
|
||||
k = ent
|
||||
kparts = []
|
||||
optparts = []
|
||||
currparts = kparts
|
||||
for part in ent.split():
|
||||
if part[0] == '(':
|
||||
currparts = optparts
|
||||
currparts.append(part)
|
||||
k = ' '.join(kparts)
|
||||
v = None
|
||||
entopts = {}
|
||||
if optparts:
|
||||
if optparts[0][0] != '(' or optparts[-1][-1] != ')':
|
||||
raise Exception("Unsupported syntax in syncfile: " + ent)
|
||||
opts = ','.join(optparts)
|
||||
opts = [1:-1]
|
||||
for opt in opts.split(','):
|
||||
optname, optval = opt.split('=')
|
||||
entopts[optname] = optval
|
||||
currmap[k] = v
|
||||
targ = v if v else k
|
||||
for f in targ.split():
|
||||
self.optmap[f] = entopts
|
||||
|
||||
|
||||
def sync_list_to_node(sl, node, suffixes):
|
||||
@ -119,7 +142,11 @@ def sync_list_to_node(sl, node, suffixes):
|
||||
raise
|
||||
finally:
|
||||
shutil.rmtree(targdir)
|
||||
return output
|
||||
retval = {
|
||||
'options': sl.optmap,
|
||||
'output': output,
|
||||
}
|
||||
return output # need dictionary with output and options
|
||||
|
||||
def stage_ent(currmap, ent, targdir, appendexist=False):
|
||||
dst = currmap[ent]
|
||||
|
Loading…
Reference in New Issue
Block a user