欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

zk白名单设置python脚本

程序员文章站 2022-07-14 11:03:29
...

1.生产zk所有目录添加白名单的命令 

from kazoo.client import KazooClient
zk = KazooClient(hosts='10.252.200.172:2181')
zk.start()
dir_= ''
hosts=''
print('setAcl '+'/'+' '+hosts)
def main(dir_):
        node = zk.get_children(dir_)
        length=len(node)
        for index  in range (length):
                node[index]='/'+node[index]
                print('setAcl '+dir_+node[index]+' '+hosts)
                main(dir_+node[index])
main('')
zk.stop()

2. 生产zk所有目录取消权限设置命令

from kazoo.client import KazooClient
zk = KazooClient(hosts='10.248.63.172:2181')
zk.start()
dir_= ''
print('setAcl '+'/'+' world:anyone:cdrwa')
def main(dir_):
        node = zk.get_children(dir_)
        length=len(node)
        for index  in range (length):
                node[index]='/'+node[index]
                print('setAcl '+dir_+node[index]+' world:anyone:cdrwa')
                main(dir_+node[index])
main('')
zk.stop()