scrapli 2.0.0a2__py3-none-macosx_11_0_arm64.whl → 2.0.0a4__py3-none-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scrapli/__init__.py +2 -1
- scrapli/cli.py +34 -66
- scrapli/ffi.py +1 -1
- scrapli/ffi_mapping.py +3 -4
- scrapli/ffi_mapping_cli.py +42 -22
- scrapli/ffi_mapping_netconf.py +28 -60
- scrapli/ffi_types.py +42 -2
- scrapli/lib/libscrapli.0.0.1-alpha.13.dylib +0 -0
- scrapli/netconf.py +36 -147
- scrapli/transport.py +71 -130
- {scrapli-2.0.0a2.dist-info → scrapli-2.0.0a4.dist-info}/METADATA +1 -1
- {scrapli-2.0.0a2.dist-info → scrapli-2.0.0a4.dist-info}/RECORD +15 -15
- scrapli/lib/libscrapli.0.0.1-alpha.10.dylib +0 -0
- {scrapli-2.0.0a2.dist-info → scrapli-2.0.0a4.dist-info}/WHEEL +0 -0
- {scrapli-2.0.0a2.dist-info → scrapli-2.0.0a4.dist-info}/licenses/LICENSE +0 -0
- {scrapli-2.0.0a2.dist-info → scrapli-2.0.0a4.dist-info}/top_level.txt +0 -0
scrapli/ffi_mapping_netconf.py
CHANGED
@@ -13,6 +13,7 @@ from ctypes import (
|
|
13
13
|
from _ctypes import POINTER
|
14
14
|
|
15
15
|
from scrapli.ffi_types import (
|
16
|
+
CANCEL,
|
16
17
|
CancelPointer,
|
17
18
|
DriverPointer,
|
18
19
|
IntPointer,
|
@@ -606,7 +607,9 @@ class LibScrapliNetconfMapping:
|
|
606
607
|
return self._alloc(logger_callback, host, port, transport_kind)
|
607
608
|
|
608
609
|
def open(
|
609
|
-
self,
|
610
|
+
self,
|
611
|
+
ptr: DriverPointer,
|
612
|
+
operation_id: OperationIdPointer,
|
610
613
|
) -> int:
|
611
614
|
"""
|
612
615
|
Open the driver at ptr.
|
@@ -616,7 +619,6 @@ class LibScrapliNetconfMapping:
|
|
616
619
|
Args:
|
617
620
|
ptr: the ptr to the libscrapli netconf object.
|
618
621
|
operation_id: c_int pointer that is filled with the operation id to poll for completion.
|
619
|
-
cancel: bool pointer that can be set to true to cancel the operation.
|
620
622
|
|
621
623
|
Returns:
|
622
624
|
int: return code, non-zero value indicates an error. technically a c_uint8 converted by
|
@@ -626,13 +628,16 @@ class LibScrapliNetconfMapping:
|
|
626
628
|
N/A
|
627
629
|
|
628
630
|
"""
|
629
|
-
return self._open(
|
631
|
+
return self._open(
|
632
|
+
ptr,
|
633
|
+
operation_id,
|
634
|
+
CANCEL,
|
635
|
+
)
|
630
636
|
|
631
637
|
def close(
|
632
638
|
self,
|
633
639
|
ptr: DriverPointer,
|
634
640
|
operation_id: OperationIdPointer,
|
635
|
-
cancel: CancelPointer,
|
636
641
|
force: c_bool,
|
637
642
|
) -> int:
|
638
643
|
"""
|
@@ -643,7 +648,6 @@ class LibScrapliNetconfMapping:
|
|
643
648
|
Args:
|
644
649
|
ptr: the ptr to the libscrapli netconf object.
|
645
650
|
operation_id: c_int pointer that is filled with the operation id to poll for completion.
|
646
|
-
cancel: bool pointer that can be set to true to cancel the operation.
|
647
651
|
force: bool indicating if the connection should skip sending close-session rpc or not
|
648
652
|
|
649
653
|
Returns:
|
@@ -657,7 +661,7 @@ class LibScrapliNetconfMapping:
|
|
657
661
|
return self._close(
|
658
662
|
ptr,
|
659
663
|
operation_id,
|
660
|
-
|
664
|
+
CANCEL,
|
661
665
|
force,
|
662
666
|
)
|
663
667
|
|
@@ -938,7 +942,6 @@ class LibScrapliNetconfMapping:
|
|
938
942
|
*,
|
939
943
|
ptr: DriverPointer,
|
940
944
|
operation_id: OperationIdPointer,
|
941
|
-
cancel: CancelPointer,
|
942
945
|
payload: c_char_p,
|
943
946
|
base_namespace_prefix: c_char_p,
|
944
947
|
extra_namespaces: c_char_p,
|
@@ -951,7 +954,6 @@ class LibScrapliNetconfMapping:
|
|
951
954
|
Args:
|
952
955
|
ptr: ptr to the netconf object
|
953
956
|
operation_id: int pointer to fill with the id of the submitted operation
|
954
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
955
957
|
payload: the payload to write into the outer rpc element
|
956
958
|
base_namespace_prefix: prefix to use for hte base/default netconf base namespace
|
957
959
|
extra_namespaces: extra namespace::prefix pairs (using "::" as split there), and
|
@@ -970,7 +972,7 @@ class LibScrapliNetconfMapping:
|
|
970
972
|
return self._raw_rpc(
|
971
973
|
ptr,
|
972
974
|
operation_id,
|
973
|
-
|
975
|
+
CANCEL,
|
974
976
|
payload,
|
975
977
|
base_namespace_prefix,
|
976
978
|
extra_namespaces,
|
@@ -981,7 +983,6 @@ class LibScrapliNetconfMapping:
|
|
981
983
|
*,
|
982
984
|
ptr: DriverPointer,
|
983
985
|
operation_id: OperationIdPointer,
|
984
|
-
cancel: CancelPointer,
|
985
986
|
source: c_char_p,
|
986
987
|
filter_: c_char_p,
|
987
988
|
filter_type: c_char_p,
|
@@ -997,7 +998,6 @@ class LibScrapliNetconfMapping:
|
|
997
998
|
Args:
|
998
999
|
ptr: ptr to the netconf object
|
999
1000
|
operation_id: int pointer to fill with the id of the submitted operation
|
1000
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1001
1001
|
source: source data store to get config from
|
1002
1002
|
filter_: filter to apply
|
1003
1003
|
filter_type: filter type (subtree|xpath)
|
@@ -1016,7 +1016,7 @@ class LibScrapliNetconfMapping:
|
|
1016
1016
|
return self._get_config(
|
1017
1017
|
ptr,
|
1018
1018
|
operation_id,
|
1019
|
-
|
1019
|
+
CANCEL,
|
1020
1020
|
source,
|
1021
1021
|
filter_,
|
1022
1022
|
filter_type,
|
@@ -1030,7 +1030,6 @@ class LibScrapliNetconfMapping:
|
|
1030
1030
|
*,
|
1031
1031
|
ptr: DriverPointer,
|
1032
1032
|
operation_id: OperationIdPointer,
|
1033
|
-
cancel: CancelPointer,
|
1034
1033
|
config: c_char_p,
|
1035
1034
|
target: c_char_p,
|
1036
1035
|
) -> int:
|
@@ -1042,7 +1041,6 @@ class LibScrapliNetconfMapping:
|
|
1042
1041
|
Args:
|
1043
1042
|
ptr: ptr to the netconf object
|
1044
1043
|
operation_id: int pointer to fill with the id of the submitted operation
|
1045
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1046
1044
|
config: the config to send
|
1047
1045
|
target: the target datastore
|
1048
1046
|
|
@@ -1057,7 +1055,7 @@ class LibScrapliNetconfMapping:
|
|
1057
1055
|
return self._edit_config(
|
1058
1056
|
ptr,
|
1059
1057
|
operation_id,
|
1060
|
-
|
1058
|
+
CANCEL,
|
1061
1059
|
config,
|
1062
1060
|
target,
|
1063
1061
|
)
|
@@ -1067,7 +1065,6 @@ class LibScrapliNetconfMapping:
|
|
1067
1065
|
*,
|
1068
1066
|
ptr: DriverPointer,
|
1069
1067
|
operation_id: OperationIdPointer,
|
1070
|
-
cancel: CancelPointer,
|
1071
1068
|
target: c_char_p,
|
1072
1069
|
source: c_char_p,
|
1073
1070
|
) -> int:
|
@@ -1079,7 +1076,6 @@ class LibScrapliNetconfMapping:
|
|
1079
1076
|
Args:
|
1080
1077
|
ptr: ptr to the netconf object
|
1081
1078
|
operation_id: int pointer to fill with the id of the submitted operation
|
1082
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1083
1079
|
target: the target/destination datastore to copy to
|
1084
1080
|
source: the source datastore to copy from
|
1085
1081
|
|
@@ -1094,7 +1090,7 @@ class LibScrapliNetconfMapping:
|
|
1094
1090
|
return self._copy_config(
|
1095
1091
|
ptr,
|
1096
1092
|
operation_id,
|
1097
|
-
|
1093
|
+
CANCEL,
|
1098
1094
|
target,
|
1099
1095
|
source,
|
1100
1096
|
)
|
@@ -1104,7 +1100,6 @@ class LibScrapliNetconfMapping:
|
|
1104
1100
|
*,
|
1105
1101
|
ptr: DriverPointer,
|
1106
1102
|
operation_id: OperationIdPointer,
|
1107
|
-
cancel: CancelPointer,
|
1108
1103
|
target: c_char_p,
|
1109
1104
|
) -> int:
|
1110
1105
|
"""
|
@@ -1115,7 +1110,6 @@ class LibScrapliNetconfMapping:
|
|
1115
1110
|
Args:
|
1116
1111
|
ptr: ptr to the netconf object
|
1117
1112
|
operation_id: int pointer to fill with the id of the submitted operation
|
1118
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1119
1113
|
target: the target/destination datastore to delete
|
1120
1114
|
|
1121
1115
|
Returns:
|
@@ -1129,7 +1123,7 @@ class LibScrapliNetconfMapping:
|
|
1129
1123
|
return self._delete_config(
|
1130
1124
|
ptr,
|
1131
1125
|
operation_id,
|
1132
|
-
|
1126
|
+
CANCEL,
|
1133
1127
|
target,
|
1134
1128
|
)
|
1135
1129
|
|
@@ -1138,7 +1132,6 @@ class LibScrapliNetconfMapping:
|
|
1138
1132
|
*,
|
1139
1133
|
ptr: DriverPointer,
|
1140
1134
|
operation_id: OperationIdPointer,
|
1141
|
-
cancel: CancelPointer,
|
1142
1135
|
target: c_char_p,
|
1143
1136
|
) -> int:
|
1144
1137
|
"""
|
@@ -1149,7 +1142,6 @@ class LibScrapliNetconfMapping:
|
|
1149
1142
|
Args:
|
1150
1143
|
ptr: ptr to the netconf object
|
1151
1144
|
operation_id: int pointer to fill with the id of the submitted operation
|
1152
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1153
1145
|
target: the target/destination datastore to lock
|
1154
1146
|
|
1155
1147
|
Returns:
|
@@ -1163,7 +1155,7 @@ class LibScrapliNetconfMapping:
|
|
1163
1155
|
return self._lock(
|
1164
1156
|
ptr,
|
1165
1157
|
operation_id,
|
1166
|
-
|
1158
|
+
CANCEL,
|
1167
1159
|
target,
|
1168
1160
|
)
|
1169
1161
|
|
@@ -1172,7 +1164,6 @@ class LibScrapliNetconfMapping:
|
|
1172
1164
|
*,
|
1173
1165
|
ptr: DriverPointer,
|
1174
1166
|
operation_id: OperationIdPointer,
|
1175
|
-
cancel: CancelPointer,
|
1176
1167
|
target: c_char_p,
|
1177
1168
|
) -> int:
|
1178
1169
|
"""
|
@@ -1183,7 +1174,6 @@ class LibScrapliNetconfMapping:
|
|
1183
1174
|
Args:
|
1184
1175
|
ptr: ptr to the netconf object
|
1185
1176
|
operation_id: int pointer to fill with the id of the submitted operation
|
1186
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1187
1177
|
target: the target/destination datastore to lock
|
1188
1178
|
|
1189
1179
|
Returns:
|
@@ -1197,7 +1187,7 @@ class LibScrapliNetconfMapping:
|
|
1197
1187
|
return self._unlock(
|
1198
1188
|
ptr,
|
1199
1189
|
operation_id,
|
1200
|
-
|
1190
|
+
CANCEL,
|
1201
1191
|
target,
|
1202
1192
|
)
|
1203
1193
|
|
@@ -1206,7 +1196,6 @@ class LibScrapliNetconfMapping:
|
|
1206
1196
|
*,
|
1207
1197
|
ptr: DriverPointer,
|
1208
1198
|
operation_id: OperationIdPointer,
|
1209
|
-
cancel: CancelPointer,
|
1210
1199
|
filter_: c_char_p,
|
1211
1200
|
filter_type: c_char_p,
|
1212
1201
|
filter_namespace_prefix: c_char_p,
|
@@ -1221,7 +1210,6 @@ class LibScrapliNetconfMapping:
|
|
1221
1210
|
Args:
|
1222
1211
|
ptr: ptr to the netconf object
|
1223
1212
|
operation_id: int pointer to fill with the id of the submitted operation
|
1224
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1225
1213
|
filter_: filter to apply
|
1226
1214
|
filter_type: filter type (subtree|xpath)
|
1227
1215
|
filter_namespace_prefix: optional prefix for filter namespace
|
@@ -1239,7 +1227,7 @@ class LibScrapliNetconfMapping:
|
|
1239
1227
|
return self._get(
|
1240
1228
|
ptr,
|
1241
1229
|
operation_id,
|
1242
|
-
|
1230
|
+
CANCEL,
|
1243
1231
|
filter_,
|
1244
1232
|
filter_type,
|
1245
1233
|
filter_namespace_prefix,
|
@@ -1252,7 +1240,6 @@ class LibScrapliNetconfMapping:
|
|
1252
1240
|
*,
|
1253
1241
|
ptr: DriverPointer,
|
1254
1242
|
operation_id: OperationIdPointer,
|
1255
|
-
cancel: CancelPointer,
|
1256
1243
|
) -> int:
|
1257
1244
|
"""
|
1258
1245
|
Execute a close-config rpc operation.
|
@@ -1262,7 +1249,6 @@ class LibScrapliNetconfMapping:
|
|
1262
1249
|
Args:
|
1263
1250
|
ptr: ptr to the netconf object
|
1264
1251
|
operation_id: int pointer to fill with the id of the submitted operation
|
1265
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1266
1252
|
|
1267
1253
|
Returns:
|
1268
1254
|
int: return code, non-zero value indicates an error. technically a c_uint8 converted by
|
@@ -1275,7 +1261,7 @@ class LibScrapliNetconfMapping:
|
|
1275
1261
|
return self._close_session(
|
1276
1262
|
ptr,
|
1277
1263
|
operation_id,
|
1278
|
-
|
1264
|
+
CANCEL,
|
1279
1265
|
)
|
1280
1266
|
|
1281
1267
|
def kill_session(
|
@@ -1283,7 +1269,6 @@ class LibScrapliNetconfMapping:
|
|
1283
1269
|
*,
|
1284
1270
|
ptr: DriverPointer,
|
1285
1271
|
operation_id: OperationIdPointer,
|
1286
|
-
cancel: CancelPointer,
|
1287
1272
|
session_id: c_int,
|
1288
1273
|
) -> int:
|
1289
1274
|
"""
|
@@ -1294,7 +1279,6 @@ class LibScrapliNetconfMapping:
|
|
1294
1279
|
Args:
|
1295
1280
|
ptr: ptr to the netconf object
|
1296
1281
|
operation_id: int pointer to fill with the id of the submitted operation
|
1297
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1298
1282
|
session_id: the session id to kill
|
1299
1283
|
|
1300
1284
|
Returns:
|
@@ -1308,7 +1292,7 @@ class LibScrapliNetconfMapping:
|
|
1308
1292
|
return self._kill_session(
|
1309
1293
|
ptr,
|
1310
1294
|
operation_id,
|
1311
|
-
|
1295
|
+
CANCEL,
|
1312
1296
|
session_id,
|
1313
1297
|
)
|
1314
1298
|
|
@@ -1317,7 +1301,6 @@ class LibScrapliNetconfMapping:
|
|
1317
1301
|
*,
|
1318
1302
|
ptr: DriverPointer,
|
1319
1303
|
operation_id: OperationIdPointer,
|
1320
|
-
cancel: CancelPointer,
|
1321
1304
|
) -> int:
|
1322
1305
|
"""
|
1323
1306
|
Execute a commit rpc operation.
|
@@ -1327,7 +1310,6 @@ class LibScrapliNetconfMapping:
|
|
1327
1310
|
Args:
|
1328
1311
|
ptr: ptr to the netconf object
|
1329
1312
|
operation_id: int pointer to fill with the id of the submitted operation
|
1330
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1331
1313
|
|
1332
1314
|
Returns:
|
1333
1315
|
int: return code, non-zero value indicates an error. technically a c_uint8 converted by
|
@@ -1340,7 +1322,7 @@ class LibScrapliNetconfMapping:
|
|
1340
1322
|
return self._commit(
|
1341
1323
|
ptr,
|
1342
1324
|
operation_id,
|
1343
|
-
|
1325
|
+
CANCEL,
|
1344
1326
|
)
|
1345
1327
|
|
1346
1328
|
def discard(
|
@@ -1348,7 +1330,6 @@ class LibScrapliNetconfMapping:
|
|
1348
1330
|
*,
|
1349
1331
|
ptr: DriverPointer,
|
1350
1332
|
operation_id: OperationIdPointer,
|
1351
|
-
cancel: CancelPointer,
|
1352
1333
|
) -> int:
|
1353
1334
|
"""
|
1354
1335
|
Execute a discard rpc operation.
|
@@ -1358,7 +1339,6 @@ class LibScrapliNetconfMapping:
|
|
1358
1339
|
Args:
|
1359
1340
|
ptr: ptr to the netconf object
|
1360
1341
|
operation_id: int pointer to fill with the id of the submitted operation
|
1361
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1362
1342
|
|
1363
1343
|
Returns:
|
1364
1344
|
int: return code, non-zero value indicates an error. technically a c_uint8 converted by
|
@@ -1371,7 +1351,7 @@ class LibScrapliNetconfMapping:
|
|
1371
1351
|
return self._discard(
|
1372
1352
|
ptr,
|
1373
1353
|
operation_id,
|
1374
|
-
|
1354
|
+
CANCEL,
|
1375
1355
|
)
|
1376
1356
|
|
1377
1357
|
def cancel_commit(
|
@@ -1379,7 +1359,6 @@ class LibScrapliNetconfMapping:
|
|
1379
1359
|
*,
|
1380
1360
|
ptr: DriverPointer,
|
1381
1361
|
operation_id: OperationIdPointer,
|
1382
|
-
cancel: CancelPointer,
|
1383
1362
|
) -> int:
|
1384
1363
|
"""
|
1385
1364
|
Execute a cancel-commit rpc operation.
|
@@ -1389,7 +1368,6 @@ class LibScrapliNetconfMapping:
|
|
1389
1368
|
Args:
|
1390
1369
|
ptr: ptr to the netconf object
|
1391
1370
|
operation_id: int pointer to fill with the id of the submitted operation
|
1392
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1393
1371
|
|
1394
1372
|
Returns:
|
1395
1373
|
int: return code, non-zero value indicates an error. technically a c_uint8 converted by
|
@@ -1402,7 +1380,7 @@ class LibScrapliNetconfMapping:
|
|
1402
1380
|
return self._cancel_commit(
|
1403
1381
|
ptr,
|
1404
1382
|
operation_id,
|
1405
|
-
|
1383
|
+
CANCEL,
|
1406
1384
|
)
|
1407
1385
|
|
1408
1386
|
def validate(
|
@@ -1410,7 +1388,6 @@ class LibScrapliNetconfMapping:
|
|
1410
1388
|
*,
|
1411
1389
|
ptr: DriverPointer,
|
1412
1390
|
operation_id: OperationIdPointer,
|
1413
|
-
cancel: CancelPointer,
|
1414
1391
|
source: c_char_p,
|
1415
1392
|
) -> int:
|
1416
1393
|
"""
|
@@ -1421,7 +1398,6 @@ class LibScrapliNetconfMapping:
|
|
1421
1398
|
Args:
|
1422
1399
|
ptr: ptr to the netconf object
|
1423
1400
|
operation_id: int pointer to fill with the id of the submitted operation
|
1424
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1425
1401
|
source: datastore to validate
|
1426
1402
|
|
1427
1403
|
Returns:
|
@@ -1435,7 +1411,7 @@ class LibScrapliNetconfMapping:
|
|
1435
1411
|
return self._validate(
|
1436
1412
|
ptr,
|
1437
1413
|
operation_id,
|
1438
|
-
|
1414
|
+
CANCEL,
|
1439
1415
|
source,
|
1440
1416
|
)
|
1441
1417
|
|
@@ -1444,7 +1420,6 @@ class LibScrapliNetconfMapping:
|
|
1444
1420
|
*,
|
1445
1421
|
ptr: DriverPointer,
|
1446
1422
|
operation_id: OperationIdPointer,
|
1447
|
-
cancel: CancelPointer,
|
1448
1423
|
identifier: c_char_p,
|
1449
1424
|
version: c_char_p,
|
1450
1425
|
format_: c_char_p,
|
@@ -1457,7 +1432,6 @@ class LibScrapliNetconfMapping:
|
|
1457
1432
|
Args:
|
1458
1433
|
ptr: ptr to the netconf object
|
1459
1434
|
operation_id: int pointer to fill with the id of the submitted operation
|
1460
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1461
1435
|
identifier: schema identifier to get
|
1462
1436
|
version: optional schema version to request
|
1463
1437
|
format_: schema format to apply
|
@@ -1473,7 +1447,7 @@ class LibScrapliNetconfMapping:
|
|
1473
1447
|
return self._get_schema(
|
1474
1448
|
ptr,
|
1475
1449
|
operation_id,
|
1476
|
-
|
1450
|
+
CANCEL,
|
1477
1451
|
identifier,
|
1478
1452
|
version,
|
1479
1453
|
format_,
|
@@ -1484,7 +1458,6 @@ class LibScrapliNetconfMapping:
|
|
1484
1458
|
*,
|
1485
1459
|
ptr: DriverPointer,
|
1486
1460
|
operation_id: OperationIdPointer,
|
1487
|
-
cancel: CancelPointer,
|
1488
1461
|
source: c_char_p,
|
1489
1462
|
filter_: c_char_p,
|
1490
1463
|
filter_type: c_char_p,
|
@@ -1504,7 +1477,6 @@ class LibScrapliNetconfMapping:
|
|
1504
1477
|
Args:
|
1505
1478
|
ptr: ptr to the netconf object
|
1506
1479
|
operation_id: int pointer to fill with the id of the submitted operation
|
1507
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1508
1480
|
source: source datastore to get data from
|
1509
1481
|
filter_: filter to apply to the get-config (or not if empty string)
|
1510
1482
|
filter_type: type of filter to apply, subtree|xpath
|
@@ -1527,7 +1499,7 @@ class LibScrapliNetconfMapping:
|
|
1527
1499
|
return self._get_data(
|
1528
1500
|
ptr,
|
1529
1501
|
operation_id,
|
1530
|
-
|
1502
|
+
CANCEL,
|
1531
1503
|
source,
|
1532
1504
|
filter_,
|
1533
1505
|
filter_type,
|
@@ -1545,7 +1517,6 @@ class LibScrapliNetconfMapping:
|
|
1545
1517
|
*,
|
1546
1518
|
ptr: DriverPointer,
|
1547
1519
|
operation_id: OperationIdPointer,
|
1548
|
-
cancel: CancelPointer,
|
1549
1520
|
target: c_char_p,
|
1550
1521
|
content: c_char_p,
|
1551
1522
|
) -> int:
|
@@ -1557,7 +1528,6 @@ class LibScrapliNetconfMapping:
|
|
1557
1528
|
Args:
|
1558
1529
|
ptr: ptr to the netconf object
|
1559
1530
|
operation_id: int pointer to fill with the id of the submitted operation
|
1560
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1561
1531
|
target: datastore to target
|
1562
1532
|
content: full payload content to send
|
1563
1533
|
|
@@ -1572,7 +1542,7 @@ class LibScrapliNetconfMapping:
|
|
1572
1542
|
return self._edit_data(
|
1573
1543
|
ptr,
|
1574
1544
|
operation_id,
|
1575
|
-
|
1545
|
+
CANCEL,
|
1576
1546
|
target,
|
1577
1547
|
content,
|
1578
1548
|
)
|
@@ -1582,7 +1552,6 @@ class LibScrapliNetconfMapping:
|
|
1582
1552
|
*,
|
1583
1553
|
ptr: DriverPointer,
|
1584
1554
|
operation_id: OperationIdPointer,
|
1585
|
-
cancel: CancelPointer,
|
1586
1555
|
action: c_char_p,
|
1587
1556
|
) -> int:
|
1588
1557
|
"""
|
@@ -1593,7 +1562,6 @@ class LibScrapliNetconfMapping:
|
|
1593
1562
|
Args:
|
1594
1563
|
ptr: ptr to the netconf object
|
1595
1564
|
operation_id: int pointer to fill with the id of the submitted operation
|
1596
|
-
cancel: bool pointer that can be set to true to cancel the operation
|
1597
1565
|
action: the action to send
|
1598
1566
|
|
1599
1567
|
Returns:
|
@@ -1607,6 +1575,6 @@ class LibScrapliNetconfMapping:
|
|
1607
1575
|
return self._action(
|
1608
1576
|
ptr,
|
1609
1577
|
operation_id,
|
1610
|
-
|
1578
|
+
CANCEL,
|
1611
1579
|
action,
|
1612
1580
|
)
|
scrapli/ffi_types.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"""scrapli.ffi_types"""
|
2
2
|
|
3
3
|
from ctypes import (
|
4
|
-
CFUNCTYPE,
|
5
4
|
POINTER,
|
5
|
+
PYFUNCTYPE,
|
6
6
|
Structure,
|
7
7
|
c_bool,
|
8
8
|
c_char_p,
|
@@ -14,6 +14,7 @@ from ctypes import (
|
|
14
14
|
c_void_p,
|
15
15
|
cast,
|
16
16
|
)
|
17
|
+
from logging import Logger
|
17
18
|
from typing import TypeAlias
|
18
19
|
|
19
20
|
DriverPointer = c_void_p
|
@@ -29,6 +30,10 @@ IntPointer: TypeAlias = POINTER(c_int) # type: ignore[valid-type]
|
|
29
30
|
U64Pointer: TypeAlias = POINTER(c_uint64) # type: ignore[valid-type]
|
30
31
|
BoolPointer: TypeAlias = POINTER(c_bool) # type: ignore[valid-type]
|
31
32
|
|
33
|
+
# cancellation is handled via timeout in python (vs context cancellation in go), so just have
|
34
|
+
# an always false cancellation pointer
|
35
|
+
CANCEL = CancelPointer(c_bool(False))
|
36
|
+
|
32
37
|
|
33
38
|
class ZigU64Slice(Structure):
|
34
39
|
"""
|
@@ -151,4 +156,39 @@ def to_c_string(s: str) -> c_char_p:
|
|
151
156
|
return c_char_p(s.encode(encoding="utf-8"))
|
152
157
|
|
153
158
|
|
154
|
-
|
159
|
+
# PYFUNCTYPE holds the gil during the call which *seems* to matter/be important since
|
160
|
+
# the zig bits will be tickling the logger (via the callback)
|
161
|
+
LogFuncCallback: TypeAlias = PYFUNCTYPE(None, c_uint8, POINTER(ZigSlice)) # type: ignore[valid-type]
|
162
|
+
|
163
|
+
|
164
|
+
def ffi_logger_wrapper(logger: Logger) -> LogFuncCallback:
|
165
|
+
"""
|
166
|
+
Closure that accepts logger instance and returns a ffi logger callback
|
167
|
+
|
168
|
+
Args:
|
169
|
+
logger: the logger to wrap for use in the zig bits
|
170
|
+
|
171
|
+
Returns:
|
172
|
+
LogFuncCallback: the logger callback
|
173
|
+
|
174
|
+
Raises:
|
175
|
+
N/A
|
176
|
+
|
177
|
+
"""
|
178
|
+
|
179
|
+
def _cb(level: c_uint8, message: ZigSlicePointer) -> None:
|
180
|
+
match level:
|
181
|
+
case 0:
|
182
|
+
logger.debug(message.contents.get_decoded_contents())
|
183
|
+
case 1:
|
184
|
+
logger.info(message.contents.get_decoded_contents())
|
185
|
+
case 2:
|
186
|
+
logger.warning(message.contents.get_decoded_contents())
|
187
|
+
case 3:
|
188
|
+
logger.critical(message.contents.get_decoded_contents())
|
189
|
+
case 4:
|
190
|
+
logger.fatal(message.contents.get_decoded_contents())
|
191
|
+
case _:
|
192
|
+
return
|
193
|
+
|
194
|
+
return LogFuncCallback(_cb)
|
Binary file
|