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") |
Václav Kubernát | cf9224f | 2020-06-02 09:55:29 +0200 | [diff] [blame] | 5 | for (k, v) in data: |
Jan Kundrát | cf5c636 | 2020-01-16 22:54:47 +0100 | [diff] [blame] | 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) |
Václav Kubernát | cf9224f | 2020-06-02 09:55:29 +0200 | [diff] [blame] | 17 | (_, value) = next(filter(lambda keyValue: keyValue[0] == hello_timeout_xp, data)) |
| 18 | if value != EXPECTED: |
Jan Kundrát | cf5c636 | 2020-01-16 22:54:47 +0100 | [diff] [blame] | 19 | if isinstance(EXPECTED, str): |
Václav Kubernát | cf9224f | 2020-06-02 09:55:29 +0200 | [diff] [blame] | 20 | if str(value) != EXPECTED: |
Jan Kundrát | cf5c636 | 2020-01-16 22:54:47 +0100 | [diff] [blame] | 21 | print(f"ERROR: hello-timeout not updated (via string) to {EXPECTED}") |
| 22 | exit(1) |
| 23 | else: |
| 24 | print(f"ERROR: hello-timeout not updated to {EXPECTED}") |
| 25 | exit(1) |
| 26 | try: |
| 27 | c.setLeaf(hello_timeout_xp, "blesmrt") |
| 28 | c.commitChanges() |
| 29 | print("ERROR: setting integer to a string did not error out") |
| 30 | exit(1) |
| 31 | except RuntimeError: |
| 32 | pass |
| 33 | |
| 34 | exit(0) |