-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsul-parser.py
More file actions
38 lines (27 loc) · 910 Bytes
/
consul-parser.py
File metadata and controls
38 lines (27 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import consul
import sys, getopt, argparse
import pprint
c = consul.Consul()
pp = pprint.PrettyPrinter(indent=3)
def get_consul_keys(key, recurse=False, token=None, dc=None):
keys = c.kv.get(key)[1]
print (pp.pprint(keys))
return keys
def main(argv):
#TODO
# parser = argparse.ArgumentParser(description='Work with Consul Key Values.')
# parser.add_argument('keys', metavar='N', type=string, nargs='+',
# help='an integer for the accumulator')
# parser.add_argument('--sum', dest='accumulate', action='store_const',
# const=sum, default=max,
# help='sum the integers (default: find the max)')
#
# args = parser.parse_args()
action = argv[1]
key = argv[2]
recurse = True if argv[3] else False
print (key)
if action == "get":
get_consul_keys(key, recurse=True)
if __name__ == "__main__":
main(sys.argv[0:])