mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
test: infamy: allow easy debugging of differences in config data
Unclear if the libyang merge operation actually does it's job of merging all the data properly in the restconf backend. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
committed by
Tobias Waldekranz
parent
dc5c7732d7
commit
a90a39e8d8
@@ -308,20 +308,24 @@ class Device(Transport):
|
||||
break
|
||||
|
||||
def put_config_dicts(self, models):
|
||||
"""PUT full configuration of all models to running-config"""
|
||||
config = ""
|
||||
infer_put_dict(self.name, models)
|
||||
|
||||
for model in models.keys():
|
||||
mod = self.ly.get_module(model)
|
||||
lyd = mod.parse_data_dict(models[model], no_state=True, validate=False)
|
||||
config+=lyd.print_mem("xml", with_siblings=True, pretty=False)+"\n"
|
||||
config += lyd.print_mem("xml", with_siblings=True, pretty=False) + "\n"
|
||||
# print(f"Send new XML config: {config}")
|
||||
return self.put_config(config)
|
||||
|
||||
def put_config_dict(self, modname, edit):
|
||||
"""Convert Python dictionary to XMl and send as configuration"""
|
||||
mod = self.ly.get_module(modname)
|
||||
lyd = mod.parse_data_dict(edit, no_state=True, validate=False)
|
||||
return self.put_config(lyd.print_mem("xml", with_siblings=True, pretty=False))
|
||||
config = lyd.print_mem("xml", with_siblings=True, pretty=False)
|
||||
# print(f"Send new XML config: {config}")
|
||||
return self.put_config(config)
|
||||
|
||||
def call(self, call):
|
||||
"""Call RPC, XML version"""
|
||||
|
||||
@@ -265,6 +265,7 @@ class Device(Transport):
|
||||
return {container: v}
|
||||
|
||||
def put_config_dicts(self, models):
|
||||
"""PUT full configuration of all models to running-config"""
|
||||
infer_put_dict(self.name, models)
|
||||
running = self.get_running()
|
||||
|
||||
@@ -273,8 +274,9 @@ class Device(Transport):
|
||||
lyd = mod.parse_data_dict(models[model], no_state=True, validate=False)
|
||||
running.merge(lyd)
|
||||
|
||||
return self.put_datastore("running", json.loads(running.print_mem("json", with_siblings=True, pretty=False)))
|
||||
|
||||
cfg = running.print_mem("json", with_siblings=True, pretty=True)
|
||||
# print(f"PUT new running-config: {cfg}")
|
||||
return self.put_datastore("running", json.loads(cfg))
|
||||
|
||||
def put_config_dict(self, modname, edit):
|
||||
"""Add @edit to running config and put the whole configuration"""
|
||||
@@ -298,8 +300,9 @@ class Device(Transport):
|
||||
|
||||
change = mod.parse_data_dict(edit, no_state=True, validate=False)
|
||||
running.merge_module(change)
|
||||
data = json.loads(running.print_mem("json", with_siblings=True,
|
||||
pretty=False))
|
||||
cfg = running.print_mem("json", with_siblings=True, pretty=False)
|
||||
# print(f"PUT new running-config: {cfg}")
|
||||
data = json.loads(cfg)
|
||||
|
||||
return self.put_datastore("running", data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user