blob: b04eb24ec8239a211e75a35d9a02a6c4701cc82f [file] [log] [blame]
Jan Kundrátcf5c6362020-01-16 22:54:47 +01001import netconf_cli_py as nc
2
3c = nc.NetconfAccess(socketPath = "@NETOPEER_SOCKET_PATH@")
4data = c.getItems("/ietf-netconf-server:netconf-server")
Václav Kubernátcf9224f2020-06-02 09:55:29 +02005for (k, v) in data:
Jan Kundrátcf5c6362020-01-16 22:54:47 +01006 print(f"{k}: {type(v)} {v}", flush=True)
7
8if len(data) == 0:
9 print("ERROR: No data returned from NETCONF")
10 exit(1)
11
12hello_timeout_xp = "/ietf-netconf-server:netconf-server/session-options/hello-timeout"
13for 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átcf9224f2020-06-02 09:55:29 +020017 (_, value) = next(filter(lambda keyValue: keyValue[0] == hello_timeout_xp, data))
18 if value != EXPECTED:
Jan Kundrátcf5c6362020-01-16 22:54:47 +010019 if isinstance(EXPECTED, str):
Václav Kubernátcf9224f2020-06-02 09:55:29 +020020 if str(value) != EXPECTED:
Jan Kundrátcf5c6362020-01-16 22:54:47 +010021 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)
26try:
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)
31except RuntimeError:
32 pass
33
34exit(0)