ungleich-game/test-etcd.py
Nico Schottelius 42d10d3079 add etcd tests
2019-05-25 22:18:09 +02:00

26 lines
728 B
Python

import etcd
import json
client = etcd.Client(port=2379) # this will create a client against etcd server running on localhost on port 4001
some_vm = {}
some_vm['network'] = {}
some_vm['network']['ipv6'] = []
some_vm['network']['ipv6'].append("2a0a:e5c0:4::42/64")
some_vm['network']['ipv6'].append("2a0a:e5c0:1::42/64")
for node in range(20000):
client.delete('/nodes/n{}'.format(node), j)
for node in range(200):
ip = some_vm['network']['ipv6'].append("2a0a:e5c0:3::{}/64".format(node))
j = json.dumps(some_vm)
client.write('/nodes/n{}'.format(node), j)
result = client.read('/nodes', recursive=True, sorted=True)
print(result)
for child in result.children:
print("%s: %s" % (child.key,child.value))