Skip to content

Instantly share code, notes, and snippets.

@prabhatsharma
Created January 29, 2020 19:22
Show Gist options
  • Select an option

  • Save prabhatsharma/5e20e905bc1da526c5c7c9c266a46949 to your computer and use it in GitHub Desktop.

Select an option

Save prabhatsharma/5e20e905bc1da526c5c7c9c266a46949 to your computer and use it in GitHub Desktop.
from kazoo.client import KazooClient
connection_string = "zookeeper-headless.zookeeper.svc.cluster.local:2181"
zk = KazooClient(hosts=connection_string)
zk.start()
def get_node(path="/"):
if zk.exists(path):
children = zk.get_children(path)
if len(children)>0:
item = ""
for child in children:
if path[len(path)-1] == "/":
item = "/" + child
print(item)
elif path[0] == "/":
item = path + "/" + child
print(item)
else:
item = "/" + path + "/" + child
print(item)
get_node(item)
get_node("/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment