blob: ae317eed54ee574af1fce7b16351231e50c68a42 [file] [log] [blame]
Václav Kubernát654303f2020-07-31 13:16:54 +02001import sysrepo_subscription_py as sr_sub
Jan Kundrátcf5c6362020-01-16 22:54:47 +01002import netconf_cli_py as nc
3
4c = nc.NetconfAccess(socketPath = "@NETOPEER_SOCKET_PATH@")
Václav Kubernát654303f2020-07-31 13:16:54 +02005data = c.getItems("/ietf-netconf-monitoring:netconf-state/datastores")
Václav Kubernátcf9224f2020-06-02 09:55:29 +02006for (k, v) in data:
Jan Kundrátcf5c6362020-01-16 22:54:47 +01007 print(f"{k}: {type(v)} {v}", flush=True)
8
9if len(data) == 0:
10 print("ERROR: No data returned from NETCONF")
11 exit(1)
12
Václav Kubernát654303f2020-07-31 13:16:54 +020013subscription = sr_sub.SysrepoSubscription("example-schema")
14xpath = "/example-schema:leafInt32"
Jan Kundrátcf5c6362020-01-16 22:54:47 +010015for EXPECTED in (599, 59, "61"):
Václav Kubernát654303f2020-07-31 13:16:54 +020016 c.setLeaf(xpath, EXPECTED)
Jan Kundrátcf5c6362020-01-16 22:54:47 +010017 c.commitChanges()
Václav Kubernát654303f2020-07-31 13:16:54 +020018 data = c.getItems(xpath)
19 (_, value) = next(filter(lambda keyValue: keyValue[0] == xpath, data))
Václav Kubernátcf9224f2020-06-02 09:55:29 +020020 if value != EXPECTED:
Jan Kundrátcf5c6362020-01-16 22:54:47 +010021 if isinstance(EXPECTED, str):
Václav Kubernátcf9224f2020-06-02 09:55:29 +020022 if str(value) != EXPECTED:
Václav Kubernát654303f2020-07-31 13:16:54 +020023 print(f"ERROR: leafInt32 not updated (via string) to {EXPECTED}")
Jan Kundrátcf5c6362020-01-16 22:54:47 +010024 exit(1)
25 else:
Václav Kubernát654303f2020-07-31 13:16:54 +020026 print(f"ERROR: leafInt32 not updated to {EXPECTED}")
Jan Kundrátcf5c6362020-01-16 22:54:47 +010027 exit(1)
28try:
Václav Kubernát654303f2020-07-31 13:16:54 +020029 c.setLeaf(xpath, "blesmrt")
Jan Kundrátcf5c6362020-01-16 22:54:47 +010030 c.commitChanges()
31 print("ERROR: setting integer to a string did not error out")
32 exit(1)
33except RuntimeError:
34 pass
35
36exit(0)