diff --git a/test/case/ietf_hardware/usb.py b/test/case/ietf_hardware/usb.py index 98a210c6..7f2983d3 100755 --- a/test/case/ietf_hardware/usb.py +++ b/test/case/ietf_hardware/usb.py @@ -7,12 +7,6 @@ import time import infamy.netconf as netconf from infamy.util import until,wait_boot -def remove_config(target): - running = target.get_config_dict("/ietf-hardware:hardware") - new = copy.deepcopy(running) - new["hardware"].clear() - target.put_diff_dicts("ietf-hardware",running,new) - with infamy.Test() as test: with test.step("Initialize"): env = infamy.Env(infamy.std_topology("1x1")) @@ -88,7 +82,7 @@ with infamy.Test() as test: until(lambda: usb.get_usb_state(target, available[0]) == "unlocked") with test.step("Remove all hardware configuration"): - remove_config(target) + target.delete_xpath("/ietf-hardware:hardware/component") with test.step("Verify USB ports locked"): for port in available: @@ -118,7 +112,7 @@ with infamy.Test() as test: until(lambda: usb.get_usb_state(target, port) == "unlocked") with test.step("Remove USB configuration, and reboot"): - remove_config(target) + target.delete_xpath("/ietf-hardware:hardware/component") target.copy("running", "startup") target.reboot() if wait_boot(target) == False: diff --git a/test/case/ietf_interfaces/iface_phys_address.py b/test/case/ietf_interfaces/iface_phys_address.py index e9e1689c..60a21d26 100755 --- a/test/case/ietf_interfaces/iface_phys_address.py +++ b/test/case/ietf_interfaces/iface_phys_address.py @@ -30,13 +30,9 @@ with infamy.Test() as test: assert mac == cmac with test.step(f"Remove custom MAC address"): - running = target.get_config_dict("/ietf-interfaces:interfaces") - new = copy.deepcopy(running) - for i in new["interfaces"]["interface"]: - if i["name"] == tport: - del i["phys-address"] - break - target.put_diff_dicts("ietf-interfaces", running, new) + xpath=target.get_iface_xpath(tport, "phys-address") + target.delete_xpath(xpath) + until(lambda: iface.get_phys_address(target, tport) == pmac) test.succeed() diff --git a/test/case/ietf_interfaces/ipv4_address.py b/test/case/ietf_interfaces/ipv4_address.py index f2899217..b3ef9933 100755 --- a/test/case/ietf_interfaces/ipv4_address.py +++ b/test/case/ietf_interfaces/ipv4_address.py @@ -40,17 +40,8 @@ with infamy.Test() as test: until(lambda: iface.address_exist(target, interface_name, new_ip_address, proto='static')) with test.step(f"Remove IPv4 addresses from {interface_name}"): - # Get current interface configuration - running = target.get_config_dict("/ietf-interfaces:interfaces") - - new = copy.deepcopy(running) - for i in new["interfaces"]["interface"]: - if i["name"] == interface_name and "ipv4" in i: - del i["ipv4"] - break - - target.put_diff_dicts("ietf-interfaces", running, new) - + xpath=target.get_iface_xpath(interface_name, path="ietf-ip:ipv4") + target.delete_xpath(xpath) with test.step("Get updated IP addresses"): until(lambda: iface.address_exist(target, interface_name, new_ip_address) == False) diff --git a/test/case/ietf_interfaces/vlan_ping.py b/test/case/ietf_interfaces/vlan_ping.py index 139cfa1d..c0be03db 100755 --- a/test/case/ietf_interfaces/vlan_ping.py +++ b/test/case/ietf_interfaces/vlan_ping.py @@ -64,10 +64,8 @@ with infamy.Test() as test: test_ping(hport,True) with test.step("Remove VLAN interface, and test again (should not be able to ping)"): - running = target.get_config_dict("/ietf-interfaces:interfaces") - new = copy.deepcopy(running) - new["interfaces"]["interface"] = [d for d in new["interfaces"]["interface"] if not (d["name"] == f"{tport}.10")] - target.put_diff_dicts("ietf-interfaces",running,new) + xpath=target.get_xpath("/ietf-interfaces:interfaces/interface", "name", f"{tport}.10") + target.delete_xpath(xpath) _, hport = env.ltop.xlate("host", "data") test_ping(hport,False) diff --git a/test/case/ietf_routing/static_routing.py b/test/case/ietf_routing/static_routing.py index 37e5de4d..9887da1d 100755 --- a/test/case/ietf_routing/static_routing.py +++ b/test/case/ietf_routing/static_routing.py @@ -183,12 +183,6 @@ def config_target2(target, link): } }) -def config_remove_routes(target): - running = target.get_config_dict("/ietf-routing:routing") - new = copy.deepcopy(running) - new["routing"]["control-plane-protocols"].clear() - target.put_diff_dicts("ietf-routing",running,new) - with infamy.Test() as test: with test.step("Initialize"): env = infamy.Env(infamy.std_topology("2x2")) @@ -224,7 +218,7 @@ with infamy.Test() as test: ns0.must_reach("2001:db8:3c4d:200::1") with test.step("Remove static routes on dut1"): - config_remove_routes(target1); + target1.delete_xpath("/ietf-routing:routing/control-plane-protocols") parallel(until(lambda: route.ipv4_route_exist(target1, "192.168.200.1/32") == False), until(lambda: route.ipv6_route_exist(target1, "2001:db8:3c4d:200::1/128") == False)) diff --git a/test/case/ietf_system/add_delete_user.py b/test/case/ietf_system/add_delete_user.py index 5cf65cde..4e0b9eb6 100755 --- a/test/case/ietf_system/add_delete_user.py +++ b/test/case/ietf_system/add_delete_user.py @@ -55,13 +55,8 @@ with infamy.Test() as test: assert user_found, f"User {username} not found" with test.step(f"Delete user ({username} / {hashed_password})"): - running = target.get_config_dict("/ietf-system:system") - new = copy.deepcopy(running) - for userx in new["system"]["authentication"]["user"]: - if userx["name"] == username: - del new["system"]["authentication"]["user"][username] - break - target.put_diff_dicts("ietf-system", running, new) + xpath=target.get_xpath("/ietf-system:system/authentication/user", "name", username) + target.delete_xpath(xpath) with test.step(f"Verify erasure of user ({username} / {hashed_password})"): running = target.get_config_dict("/ietf-system:system") diff --git a/test/case/infix_containers/container_basic.py b/test/case/infix_containers/container_basic.py index 2795b493..5c0fbcd3 100755 --- a/test/case/infix_containers/container_basic.py +++ b/test/case/infix_containers/container_basic.py @@ -23,11 +23,6 @@ with infamy.Test() as test: addr = target.address() with test.step(f"Create {NAME} container from bundled OCI image"): - target.put_config_dict("infix-services", { - "web": { - "enabled": False - } - }) target.put_config_dict("infix-containers", { "containers": { "container": [ diff --git a/test/case/infix_containers/container_bridge.py b/test/case/infix_containers/container_bridge.py index 28239ac6..cc4febc0 100755 --- a/test/case/infix_containers/container_bridge.py +++ b/test/case/infix_containers/container_bridge.py @@ -24,12 +24,6 @@ with infamy.Test() as test: with test.step(f"Create {NAME} container from bundled OCI image"): _, ifname = env.ltop.xlate("target", "data") enc = base64.b64encode(BODY.encode('utf-8')) - - target.put_config_dict("infix-services", { - "web": { - "enabled": False - } - }) target.put_config_dict("ietf-interfaces", { "interfaces": { "interface": [ diff --git a/test/case/infix_containers/container_phys.py b/test/case/infix_containers/container_phys.py index 457cee6a..6be93934 100755 --- a/test/case/infix_containers/container_phys.py +++ b/test/case/infix_containers/container_phys.py @@ -22,11 +22,6 @@ with infamy.Test() as test: with test.step(f"Create {NAME} container from bundled OCI image"): _, ifname = env.ltop.xlate("target", "data") - target.put_config_dict("infix-services", { - "web": { - "enabled": False - } - }) target.put_config_dict("ietf-interfaces", { "interfaces": { "interface": [ diff --git a/test/case/infix_containers/container_veth.py b/test/case/infix_containers/container_veth.py index 546d7981..b7a9860f 100755 --- a/test/case/infix_containers/container_veth.py +++ b/test/case/infix_containers/container_veth.py @@ -21,12 +21,6 @@ with infamy.Test() as test: with test.step(f"Create {NAME} container from bundled OCI image"): _, ifname = env.ltop.xlate("target", "data") - - target.put_config_dict("infix-services", { - "web": { - "enabled": False - } - }) target.put_config_dict("ietf-interfaces", { "interfaces": { "interface": [ diff --git a/test/case/misc/start_from_startup.py b/test/case/misc/start_from_startup.py index 14207dbd..42c8c7ac 100755 --- a/test/case/misc/start_from_startup.py +++ b/test/case/misc/start_from_startup.py @@ -4,12 +4,6 @@ import infamy from infamy.util import wait_boot import copy -def remove_config(target): - running = target.get_config_dict("/ietf-hardware:hardware") - new = copy.deepcopy(running) - new["hardware"].clear() - target.put_diff_dicts("ietf-hardware",running,new) - with infamy.Test() as test: with test.step("Initialize"): env = infamy.Env(infamy.std_topology("1x1")) @@ -21,7 +15,7 @@ with infamy.Test() as test: "hostname": "test" } }) - remove_config(target) + target.delete_xpath("/ietf-hardware:hardware/component") target.copy("running", "startup") with test.step("Reboot and wait for the unit to come back"): target.copy("running", "startup") @@ -32,7 +26,6 @@ with infamy.Test() as test: with test.step("Verify hostname"): data = target.get_dict("/ietf-system:system/hostname") - print(data) assert(data["system"]["hostname"] == "test") test.succeed()