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()
上一篇: Mybatis异常收集
下一篇: SpringMVC全局和局部的异常处理