def get(request, path='/'): node_dict = {'path': path, 'acl':[], 'data':'', 'stat':[]} stat,acls = zkutils._get_acl(zh,path) if stat != False: acls = zkutils.AclSet(acls).to_display_dict() for acl in acls: hostname = "all" if acl['scheme'] == 'ip': try: hostname = socket.gethostbyaddr(acl['id'])[0] except socket.herror,errmsg: hostname = 'Unknow host' acl['host'] = hostname # javascript conflict with 'id' key. acl['acl_id'] = acl['id'] acl.pop('id') node_dict['acl'].append(acl)
def get(request, path='/'): node_dict = {'path': path, 'acl': [], 'data': '', 'stat': []} stat, acls = zkutils._get_acl(zh, path) if stat != False: acls = zkutils.AclSet(acls).to_display_dict() for acl in acls: hostname = "all" if acl['scheme'] == 'ip': try: hostname = socket.gethostbyaddr(acl['id'])[0] except socket.herror, errmsg: hostname = 'Unknow host' acl['host'] = hostname # javascript conflict with 'id' key. acl['acl_id'] = acl['id'] acl.pop('id') node_dict['acl'].append(acl)
ret = zk.set(zh, path, data, stat['version']) except IOError, errmsg: update_stat += ("Set data error: %s"%str(errmsg)) # set acl for this node if 'acl' in request.POST: # add control machine into list. control_masters = list(zkconfig.control_machines) control_masters.append("127.0.0.1") control_masters.append(socket.gethostbyname(socket.gethostname())) control_masters = list(set(control_masters)) acl_set = zkutils.AclSet(["ip:%s:31" %(id) for id in control_masters]) # user added acl acl_str = request.POST['acl'] acl_set.addmany(acl_str.split()) stat, oldacls = zkutils._get_acl(zh, path) if stat == False: update_stat += "Get old acls failed" else: if 'isappend' in request.POST and request.POST['isappend'] == 'on': acl_set.addmany(oldacls) try: ret = zk.set_acl(zh, path, stat['aversion'], acl_set.to_dict()) if ret is not zk.OK: raise IOError("set acl failed") # apply to ephemeral child children = zkutils._get_children(zh, path) if children[0] == False: raise IOError('get children failed') for child in children[1]: child_path = os.path.join(path, child)
ret = zk.set(zh, path, data, stat['version']) except IOError, errmsg: update_stat += ("Set data error: %s" % str(errmsg)) # set acl for this node if 'acl' in request.POST: # add control machine into list. control_masters = list(zkconfig.control_machines) control_masters.append("127.0.0.1") control_masters.append(socket.gethostbyname(socket.gethostname())) control_masters = list(set(control_masters)) acl_set = zkutils.AclSet(["ip:%s:31" % (id) for id in control_masters]) # user added acl acl_str = request.POST['acl'] acl_set.addmany(acl_str.split()) stat, oldacls = zkutils._get_acl(zh, path) if stat == False: update_stat += "Get old acls failed" else: if 'isappend' in request.POST and request.POST['isappend'] == 'on': acl_set.addmany(oldacls) try: ret = zk.set_acl(zh, path, stat['aversion'], acl_set.to_dict()) if ret is not zk.OK: raise IOError("set acl failed") # apply to ephemeral child children = zkutils._get_children(zh, path) if children[0] == False: raise IOError('get children failed') for child in children[1]: child_path = os.path.join(path, child)