Created
January 29, 2020 19:22
-
-
Save prabhatsharma/5e20e905bc1da526c5c7c9c266a46949 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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