Jan Kundrát | cf5c636 | 2020-01-16 22:54:47 +0100 | [diff] [blame] | 1 | import netconf_cli_py as nc |
| 2 | |
| 3 | c = nc.NetconfAccess(socketPath = "@NETOPEER_SOCKET_PATH@") |
| 4 | data = c.getItems("/ietf-netconf-server:netconf-server") |
| 5 | for (k, v) in data.items(): |
| 6 | print(f"{k}: {type(v)} {v}", flush=True) |
| 7 | |
| 8 | if len(data) == 0: |
| 9 | print("ERROR: No data returned from NETCONF") |
| 10 | exit(1) |
| 11 | |
| 12 | hello_timeout_xp = "/ietf-netconf-server:netconf-server/session-options/hello-timeout" |
| 13 | for EXPECTED in (599, 59, "61"): |
| 14 | c.setLeaf(hello_timeout_xp, EXPECTED) |
| 15 | c.commitChanges() |
| 16 | data = c.getItems(hello_timeout_xp) |
| 17 | if (data[hello_timeout_xp] != EXPECTED): |
| 18 | if isinstance(EXPECTED, str): |
| 19 | if str(data[hello_timeout_xp]) != EXPECTED: |
| 20 | print(f"ERROR: hello-timeout not updated (via string) to {EXPECTED}") |
| 21 | exit(1) |
| 22 | else: |
| 23 | print(f"ERROR: hello-timeout not updated to {EXPECTED}") |
| 24 | exit(1) |
| 25 | try: |
| 26 | c.setLeaf(hello_timeout_xp, "blesmrt") |
| 27 | c.commitChanges() |
| 28 | print("ERROR: setting integer to a string did not error out") |
| 29 | exit(1) |
| 30 | except RuntimeError: |
| 31 | pass |
| 32 | |
| 33 | exit(0) |