mirror of
https://gitlab.com/d3tn/ud3tn.git
synced 2026-08-13 12:33:27 +02:00
python-ud3tn-utils: Add AAP + AAP2 tools
- Moves `tools/aap` + `tools/aap2` to `python-ud3tn-utils/aap*/bin/` to add the scripts to the python package - Adds a `main()` function to each script to reference it - Define `logger` as global variable - Adds a symbolic link to keep compatibility with existing tooling - Moves `tools/aap/aap_test.py` to `test/functional/` - Adds additional dependencies (pyd3tn, cbor) to python-ud3tn-utils and the corresponding nix package - Add scripts to python-ud3tn-utils `pyproject.toml` Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
This commit is contained in:
parent
2055faa2b3
commit
fa6d159d10
32 changed files with 224 additions and 57 deletions
|
|
@ -244,13 +244,13 @@ aap-test:
|
|||
- rm -f ./ud3tn.socket
|
||||
- UBSAN_OPTIONS=print_stacktrace=1 build/posix/ud3tn -L 4 & UD3TN1_PID=$!
|
||||
- while ! [ -r ./ud3tn.socket ]; do sleep 0.1; done
|
||||
- python tools/aap/aap_test.py
|
||||
- python test/functional/aap_test.py
|
||||
- kill -TERM $UD3TN1_PID
|
||||
- echo "Waiting for uD3TN to exit gracefully - if it doesn't, check for sanitizer warnings."
|
||||
- wait $UD3TN1_PID
|
||||
- UBSAN_OPTIONS=print_stacktrace=1 build/posix/ud3tn -e "dtn://ud3tn2.dtn/" -a '::1' -p 4242 -S ud3tn2.aap2.socket & UD3TN2_PID=$!
|
||||
- while ! nc -z localhost 4242; do sleep 0.1; done
|
||||
- python tools/aap/aap_test.py --tcp '::1' 4242
|
||||
- python test/functional/aap_test.py --tcp '::1' 4242
|
||||
- kill -TERM $UD3TN2_PID
|
||||
- echo "Waiting for uD3TN to exit gracefully - if it doesn't, check for sanitizer warnings."
|
||||
- wait $UD3TN2_PID
|
||||
|
|
@ -425,7 +425,7 @@ ipv6-compatibility-test:
|
|||
# Check v4 reception of the correct bundle at ud3tn2
|
||||
- timeout -v 5 python tools/aap/aap_receive.py --tcp 127.0.0.1 4243 --agentid sink --count 1 --verify-pl PAYLOAD --newline -vv
|
||||
# Check that v6 does _not_ work on ud3tn2
|
||||
- "if timeout -v 1 python tools/aap/aap_test.py --tcp '::1' 4243; then echo 'Error: Should not be able to connect via IPv6 here.'; false; else true; fi"
|
||||
- "if timeout -v 1 python test/functional/aap_test.py --tcp '::1' 4243; then echo 'Error: Should not be able to connect via IPv6 here.'; false; else true; fi"
|
||||
- kill -TERM $UD3TN1_PID
|
||||
- kill -TERM $UD3TN2_PID
|
||||
- kill -TERM $DISPATCHER_PID
|
||||
|
|
@ -523,7 +523,7 @@ python-unittests:
|
|||
- pip install -e "pyd3tn"
|
||||
- pip install -e "python-ud3tn-utils"
|
||||
- pytest pyd3tn/pyd3tn/*
|
||||
- pytest tools/aap2/*
|
||||
- pytest python-ud3tn-utils/ud3tn_utils/aap2/bin/*
|
||||
|
||||
license-check:
|
||||
stage: code_quality_test
|
||||
|
|
@ -546,8 +546,7 @@ python-stylecheck:
|
|||
- source /ud3tn_venv/bin/activate
|
||||
- pip install -e "pyd3tn"
|
||||
- pip install -e "python-ud3tn-utils"
|
||||
- pip install -e "python-ud3tn-utils"
|
||||
- python -m flake8 pyd3tn python-ud3tn-utils test/integration tools/aap tools/aap2 tools/cla --max-complexity=12 --exclude=generated
|
||||
- python -m flake8 pyd3tn python-ud3tn-utils test/integration tools/cla --max-complexity=12 --exclude=generated
|
||||
|
||||
coverage-test:
|
||||
stage: code_quality_test
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
in
|
||||
{
|
||||
rec {
|
||||
ud3tn = pkgs.stdenv.mkDerivation {
|
||||
pname = "ud3tn";
|
||||
version = "0.13.0";
|
||||
|
|
@ -45,13 +45,17 @@
|
|||
pyd3tn = with pkgs.python3Packages; buildPythonPackage {
|
||||
name = "pyd3tn";
|
||||
src = ./pyd3tn;
|
||||
format = "pyproject";
|
||||
nativeBuildInputs = [ setuptools ];
|
||||
propagatedBuildInputs = [ cbor ];
|
||||
};
|
||||
|
||||
python-ud3tn-utils = with pkgs.python3Packages; buildPythonPackage {
|
||||
name = "ud3tn-utils";
|
||||
src = ./python-ud3tn-utils;
|
||||
propagatedBuildInputs = [ protobuf setuptools ];
|
||||
format = "pyproject";
|
||||
nativeBuildInputs = [ setuptools ];
|
||||
propagatedBuildInputs = [ cbor protobuf pyd3tn ];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ authors = [
|
|||
]
|
||||
requires-python = ">=3.8"
|
||||
dependencies = [
|
||||
"cbor==1.0.0",
|
||||
"protobuf==4.24.4",
|
||||
"pyd3tn==0.13.0",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
cbor==1.0.0
|
||||
protobuf==4.24.4
|
||||
pyd3tn==0.13.0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
|
||||
# encoding: utf-8
|
||||
"""Python library for the µD3TN project"""
|
||||
|
||||
from . import config
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
|
||||
# encoding: utf-8
|
||||
from .aap_client import AAPClient, AAPTCPClient, AAPUnixClient
|
||||
from .aap_message import AAPMessage, AAPMessageType, InsufficientAAPDataError
|
||||
|
||||
|
|
|
|||
2
python-ud3tn-utils/ud3tn_utils/aap/bin/__init__.py
Normal file
2
python-ud3tn-utils/ud3tn_utils/aap/bin/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
|
||||
# encoding: utf-8
|
||||
|
|
@ -3,21 +3,22 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
from ud3tn_utils.aap import AAPTCPClient, AAPUnixClient
|
||||
|
||||
from ud3tn_utils.config import ConfigMessage, make_contact
|
||||
|
||||
|
||||
from helpers import (
|
||||
from ud3tn_utils.aap.bin.helpers import (
|
||||
add_socket_group_parser_arguments,
|
||||
add_verbosity_parser_argument,
|
||||
initialize_logger,
|
||||
get_config_eid,
|
||||
)
|
||||
from ud3tn_utils.config import ConfigMessage, make_contact
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
import sys
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
@ -58,6 +59,7 @@ if __name__ == "__main__":
|
|||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
logger.warning(
|
||||
|
|
@ -94,3 +96,7 @@ if __name__ == "__main__":
|
|||
aap_client.register()
|
||||
dest_eid = args.dest_eid or aap_client.node_eid
|
||||
aap_client.send_bundle(get_config_eid(dest_eid), msg)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -13,8 +13,7 @@ import sys
|
|||
|
||||
from ud3tn_utils.aap import AAPTCPClient, AAPUnixClient
|
||||
from ud3tn_utils.config import ConfigMessage, unix2dtn, Contact
|
||||
|
||||
from helpers import get_config_eid
|
||||
from ud3tn_utils.aap.bin.helpers import get_config_eid
|
||||
|
||||
|
||||
def get_nodes_data(nodesData):
|
||||
|
|
@ -155,8 +154,7 @@ def configure_nodes(contactPlan, nodes: dict):
|
|||
continue
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="reads the text file",
|
||||
)
|
||||
|
|
@ -183,3 +181,7 @@ if __name__ == "__main__":
|
|||
|
||||
args = parser.parse_args()
|
||||
configure_nodes(args.plan, get_nodes_data(args.nodes))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -6,12 +6,19 @@
|
|||
A tool that sends received bundles back to the sender.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from ud3tn_utils.aap import AAPUnixClient, AAPTCPClient, AAPMessage
|
||||
from helpers import add_common_parser_arguments, initialize_logger
|
||||
from ud3tn_utils.aap.aap_message import AAPMessageType
|
||||
from ud3tn_utils.aap.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
initialize_logger,
|
||||
)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_echo(aap_client):
|
||||
|
|
@ -46,7 +53,7 @@ def run_echo(aap_client):
|
|||
logger.debug("Sent a bundle back to '%s'", msg.eid)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="sends received bundles back to the sender",
|
||||
)
|
||||
|
|
@ -54,6 +61,7 @@ if __name__ == "__main__":
|
|||
add_common_parser_arguments(parser)
|
||||
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity + 1) # log INFO by default
|
||||
|
||||
if args.tcp:
|
||||
|
|
@ -65,3 +73,7 @@ if __name__ == "__main__":
|
|||
with AAPUnixClient(address=args.socket) as aap_client:
|
||||
aap_client.register(args.agentid)
|
||||
run_echo(aap_client)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -9,6 +9,7 @@ between.
|
|||
"""
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
|
|
@ -16,8 +17,14 @@ import time
|
|||
import threading
|
||||
|
||||
from ud3tn_utils.aap import AAPUnixClient, AAPTCPClient, AAPMessage
|
||||
from helpers import add_common_parser_arguments, initialize_logger
|
||||
from ud3tn_utils.aap.aap_message import AAPMessageType
|
||||
from ud3tn_utils.aap.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
initialize_logger,
|
||||
)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _send_pings(aap_client, destination, interval, count, stop_event, timeout):
|
||||
|
|
@ -153,7 +160,7 @@ def run_aap_ping(aap_client, destination, interval, count, logger, timeout):
|
|||
stop_event.set()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description=(
|
||||
"send bundles to a given EID, wait for responses, "
|
||||
|
|
@ -196,6 +203,7 @@ if __name__ == "__main__":
|
|||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity + 1) # log INFO by default
|
||||
|
||||
if args.tcp:
|
||||
|
|
@ -209,3 +217,7 @@ if __name__ == "__main__":
|
|||
aap_client.register(args.agentid)
|
||||
run_aap_ping(aap_client, args.destination, args.interval,
|
||||
args.count, logger, args.timeout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -3,14 +3,21 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import cbor # type: ignore
|
||||
|
||||
from pyd3tn.bundle7 import Bundle
|
||||
from ud3tn_utils.aap import AAPUnixClient, AAPTCPClient
|
||||
from helpers import add_common_parser_arguments, initialize_logger
|
||||
from ud3tn_utils.aap.aap_message import AAPMessageType
|
||||
from ud3tn_utils.aap.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
initialize_logger,
|
||||
)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_aap_recv(aap_client, max_count, output, verify_pl, newline):
|
||||
|
|
@ -59,7 +66,7 @@ def run_aap_recv(aap_client, max_count, output, verify_pl, newline):
|
|||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="register an agent with uD3TN and wait for bundles",
|
||||
)
|
||||
|
|
@ -90,6 +97,7 @@ if __name__ == "__main__":
|
|||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
try:
|
||||
|
|
@ -115,3 +123,7 @@ if __name__ == "__main__":
|
|||
)
|
||||
finally:
|
||||
args.output.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -3,14 +3,22 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
import cbor
|
||||
|
||||
from ud3tn_utils.aap import AAPTCPClient, AAPUnixClient
|
||||
from helpers import add_common_parser_arguments, initialize_logger
|
||||
from ud3tn_utils.aap.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
initialize_logger,
|
||||
)
|
||||
from pyd3tn.bundle7 import (BibeProtocolDataUnit, Bundle,
|
||||
PayloadBlock, PrimaryBlock)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def build_bpdu(inner_source, inner_dest, payload):
|
||||
"""Encapsulates a regular bundle with the chosen payload
|
||||
in a BIBE Administrative Record, thus forming a BIBE Bundle.
|
||||
|
|
@ -40,7 +48,7 @@ def build_bpdu(inner_source, inner_dest, payload):
|
|||
return cbor.dumps(bibe_ar.record_data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
import sys
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
@ -75,6 +83,7 @@ if __name__ == "__main__":
|
|||
payload = sys.stdin.buffer.read()
|
||||
sys.stdin.buffer.close()
|
||||
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
is_bibe = (
|
||||
|
|
@ -104,3 +113,7 @@ if __name__ == "__main__":
|
|||
bpdu,
|
||||
is_bibe,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -5,11 +5,12 @@
|
|||
"""Script to send a bundle and receive a specified number of bundles."""
|
||||
|
||||
import argparse
|
||||
import cbor
|
||||
import logging
|
||||
import io
|
||||
import sys
|
||||
|
||||
import cbor
|
||||
|
||||
from pyd3tn.bundle7 import Bundle
|
||||
from ud3tn_utils.aap import (
|
||||
AAPClient,
|
||||
|
|
@ -17,8 +18,13 @@ from ud3tn_utils.aap import (
|
|||
AAPUnixClient,
|
||||
AAPMessageType,
|
||||
)
|
||||
from ud3tn_utils.aap.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
initialize_logger,
|
||||
)
|
||||
|
||||
from helpers import add_common_parser_arguments, initialize_logger
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _send_and_recv(aap_client: AAPClient, dest_eid: str, payload: bytes,
|
||||
|
|
@ -87,9 +93,9 @@ def _parse_args():
|
|||
return parser.parse_args()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
def main():
|
||||
args = _parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
payload = args.PAYLOAD.read()
|
||||
|
|
@ -115,3 +121,7 @@ if __name__ == "__main__":
|
|||
aap_client.disconnect()
|
||||
finally:
|
||||
args.output.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -3,14 +3,21 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from google.protobuf.internal import encoder
|
||||
|
||||
from helpers import add_common_parser_arguments, initialize_logger
|
||||
|
||||
from ud3tn_utils.aap import AAPUnixClient, AAPTCPClient
|
||||
from ud3tn_utils.storage_agent import StorageCall, StorageOperation
|
||||
from ud3tn_utils.aap.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
initialize_logger,
|
||||
)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _init_parser():
|
||||
|
|
@ -46,10 +53,10 @@ def _init_parser():
|
|||
return parser
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
def main():
|
||||
parser = _init_parser()
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
cmd = StorageCall()
|
||||
|
|
@ -74,3 +81,7 @@ if __name__ == "__main__":
|
|||
with aap_client:
|
||||
aap_client.register()
|
||||
aap_client.send_bundle(args.storage_agent_eid, proto_msg)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
|
||||
# encoding: utf-8
|
||||
from .aap2_client import (
|
||||
AAP2AsyncClient,
|
||||
AAP2AsyncTCPClient,
|
||||
|
|
|
|||
2
python-ud3tn-utils/ud3tn_utils/aap2/bin/__init__.py
Normal file
2
python-ud3tn-utils/ud3tn_utils/aap2/bin/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
|
||||
# encoding: utf-8
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
|
||||
from pyd3tn.eid import get_node_id
|
||||
|
||||
|
|
@ -18,7 +19,7 @@ from ud3tn_utils.aap2 import (
|
|||
DispatchResult,
|
||||
ResponseStatus,
|
||||
)
|
||||
from helpers import (
|
||||
from ud3tn_utils.aap2.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
get_secret_from_args,
|
||||
initialize_logger,
|
||||
|
|
@ -31,6 +32,9 @@ VALID_DISPATCH_REASONS = (
|
|||
)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_static_bdm(aap2_client, routing_dict):
|
||||
logger.info("Waiting for dispatch event...")
|
||||
|
||||
|
|
@ -74,7 +78,7 @@ def run_static_bdm(aap2_client, routing_dict):
|
|||
))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="bundle dispatcher module using a static table",
|
||||
)
|
||||
|
|
@ -85,6 +89,7 @@ if __name__ == "__main__":
|
|||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
with open(args.routing_table_file) as f:
|
||||
|
|
@ -104,3 +109,7 @@ if __name__ == "__main__":
|
|||
logger.info("AAP 2.0 agent registered and configured as BDM!")
|
||||
logger.info("Assigned agent secret: '%s'", secret)
|
||||
run_static_bdm(aap2_client, routing_dict)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
import argparse
|
||||
import asyncio
|
||||
import dataclasses
|
||||
import logging
|
||||
import re
|
||||
import time
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ from ud3tn_utils.storage_agent import (
|
|||
StorageCall,
|
||||
StorageOperation,
|
||||
)
|
||||
from helpers import (
|
||||
from ud3tn_utils.aap2.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
get_secret_from_args,
|
||||
initialize_logger,
|
||||
|
|
@ -75,6 +76,8 @@ VALID_SCHEDULE_DISPATCH_REASONS = (
|
|||
DispatchReason.DISPATCH_REASON_NO_FIB_ENTRY,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class ContactDefinition:
|
||||
|
|
@ -924,6 +927,7 @@ async def _process_dispatch_event(
|
|||
|
||||
|
||||
def _process_config(
|
||||
aap2_rpc_client: AAP2AsyncClient,
|
||||
adu: BundleADU,
|
||||
payload: bytes,
|
||||
contact_set: Set[ContactDefinition],
|
||||
|
|
@ -1039,6 +1043,7 @@ async def run_compat_bdm(
|
|||
elif msg.WhichOneof("msg") == "adu":
|
||||
_, payload = await aap2_sub_client.receive_adu(msg.adu)
|
||||
fwd_dict_new = _process_config(
|
||||
aap2_rpc_client,
|
||||
msg.adu,
|
||||
payload,
|
||||
contact_set,
|
||||
|
|
@ -1111,7 +1116,7 @@ async def execute_bdm(
|
|||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description=(
|
||||
"bundle dispatcher module realizing the uD3TN v0.13 forwarding"
|
||||
|
|
@ -1144,6 +1149,7 @@ if __name__ == "__main__":
|
|||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
if args.tcp:
|
||||
|
|
@ -1164,6 +1170,10 @@ if __name__ == "__main__":
|
|||
))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
def test_parse_config():
|
||||
assert _parse_config(
|
||||
"1(dtn://ud3tn2.dtn/):(mtcp:127.0.0.1:4223)::["
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
from ud3tn_utils.aap2 import (
|
||||
AAP2TCPClient,
|
||||
|
|
@ -13,7 +14,7 @@ from ud3tn_utils.aap2 import (
|
|||
ResponseStatus,
|
||||
)
|
||||
from ud3tn_utils.config import ConfigMessage, make_contact
|
||||
from helpers import (
|
||||
from ud3tn_utils.aap2.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
get_config_eid,
|
||||
get_secret_from_args,
|
||||
|
|
@ -21,7 +22,10 @@ from helpers import (
|
|||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
import sys
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
@ -58,6 +62,7 @@ if __name__ == "__main__":
|
|||
help="specify an EID reachable via the node",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
if not args.schedule:
|
||||
|
|
@ -101,3 +106,7 @@ if __name__ == "__main__":
|
|||
aap2_client.receive_response().response_status ==
|
||||
ResponseStatus.RESPONSE_STATUS_SUCCESS
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
from ud3tn_utils.aap2 import (
|
||||
AAP2TCPClient,
|
||||
|
|
@ -14,14 +15,17 @@ from ud3tn_utils.aap2 import (
|
|||
LinkStatus,
|
||||
ResponseStatus,
|
||||
)
|
||||
from helpers import (
|
||||
from ud3tn_utils.aap2.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
get_secret_from_args,
|
||||
initialize_logger,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="configure a FIB entry via AAP 2.0",
|
||||
)
|
||||
|
|
@ -50,6 +54,7 @@ if __name__ == "__main__":
|
|||
help="if set, do not initiate a link update (only update the FIB)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
if args.tcp:
|
||||
|
|
@ -89,3 +94,7 @@ if __name__ == "__main__":
|
|||
aap2_client.receive_response().response_status ==
|
||||
ResponseStatus.RESPONSE_STATUS_SUCCESS
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -9,6 +9,7 @@ between.
|
|||
"""
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
|
|
@ -21,7 +22,7 @@ from ud3tn_utils.aap2 import (
|
|||
BundleADU,
|
||||
ResponseStatus,
|
||||
)
|
||||
from helpers import (
|
||||
from ud3tn_utils.aap2.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
add_keepalive_parser_argument,
|
||||
get_secret_from_args,
|
||||
|
|
@ -29,6 +30,9 @@ from helpers import (
|
|||
)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _send_pings(
|
||||
aap2_client,
|
||||
destination,
|
||||
|
|
@ -230,7 +234,7 @@ def run_aap_ping(
|
|||
stop_event.set()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description=(
|
||||
"send bundles to a given EID, wait for responses, "
|
||||
|
|
@ -274,6 +278,7 @@ if __name__ == "__main__":
|
|||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity + 1) # log INFO by default
|
||||
|
||||
if args.tcp:
|
||||
|
|
@ -301,3 +306,7 @@ if __name__ == "__main__":
|
|||
logger,
|
||||
args.timeout,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import cbor # type: ignore
|
||||
|
|
@ -14,7 +15,7 @@ from ud3tn_utils.aap2 import (
|
|||
BundleADUFlags,
|
||||
ResponseStatus,
|
||||
)
|
||||
from helpers import (
|
||||
from ud3tn_utils.aap2.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
add_keepalive_parser_argument,
|
||||
get_secret_from_args,
|
||||
|
|
@ -22,6 +23,9 @@ from helpers import (
|
|||
)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_aap_recv(aap2_client, max_count, output, verify_pl, newline):
|
||||
logger.info("Waiting for bundles...")
|
||||
counter = 0
|
||||
|
|
@ -86,7 +90,7 @@ def run_aap_recv(aap2_client, max_count, output, verify_pl, newline):
|
|||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="register an agent with uD3TN and wait for bundles",
|
||||
)
|
||||
|
|
@ -118,6 +122,7 @@ if __name__ == "__main__":
|
|||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
try:
|
||||
|
|
@ -143,3 +148,7 @@ if __name__ == "__main__":
|
|||
)
|
||||
finally:
|
||||
args.output.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
import cbor
|
||||
|
||||
from ud3tn_utils.aap2 import (
|
||||
|
|
@ -13,7 +15,7 @@ from ud3tn_utils.aap2 import (
|
|||
BundleADUFlags,
|
||||
ResponseStatus,
|
||||
)
|
||||
from helpers import (
|
||||
from ud3tn_utils.aap2.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
get_secret_from_args,
|
||||
initialize_logger,
|
||||
|
|
@ -26,6 +28,9 @@ from pyd3tn.bundle7 import (
|
|||
)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def build_bpdu(inner_source, inner_dest, payload):
|
||||
"""Encapsulates a regular bundle with the chosen payload
|
||||
in a BIBE Administrative Record, thus forming a BIBE Bundle.
|
||||
|
|
@ -55,7 +60,7 @@ def build_bpdu(inner_source, inner_dest, payload):
|
|||
return cbor.dumps(bibe_ar.record_data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
import sys
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
@ -95,6 +100,7 @@ if __name__ == "__main__":
|
|||
payload = sys.stdin.buffer.read()
|
||||
sys.stdin.buffer.close()
|
||||
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
is_bibe = (
|
||||
|
|
@ -143,3 +149,7 @@ if __name__ == "__main__":
|
|||
aap2_client.receive_response().response_status ==
|
||||
ResponseStatus.RESPONSE_STATUS_SUCCESS
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -3,16 +3,11 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from google.protobuf.internal import encoder
|
||||
|
||||
from helpers import (
|
||||
add_common_parser_arguments,
|
||||
get_secret_from_args,
|
||||
initialize_logger,
|
||||
)
|
||||
|
||||
from ud3tn_utils.aap2 import (
|
||||
AAP2TCPClient,
|
||||
AAP2UnixClient,
|
||||
|
|
@ -21,9 +16,17 @@ from ud3tn_utils.aap2 import (
|
|||
BundleADUFlags,
|
||||
ResponseStatus,
|
||||
)
|
||||
from ud3tn_utils.aap2.bin.helpers import (
|
||||
add_common_parser_arguments,
|
||||
get_secret_from_args,
|
||||
initialize_logger,
|
||||
)
|
||||
from ud3tn_utils.storage_agent import StorageCall, StorageOperation
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _init_parser():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="send StorageAgent commands via uD3TN's AAP2 interface",
|
||||
|
|
@ -85,10 +88,10 @@ def _init_parser():
|
|||
return parser
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
def main():
|
||||
parser = _init_parser()
|
||||
args = parser.parse_args()
|
||||
global logger
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
cmd = StorageCall()
|
||||
|
|
@ -145,3 +148,7 @@ if __name__ == "__main__":
|
|||
aap2_client.receive_response().response_status ==
|
||||
ResponseStatus.RESPONSE_STATUS_SUCCESS
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -5,7 +5,8 @@
|
|||
import argparse
|
||||
|
||||
from ud3tn_utils.aap import AAPUnixClient, AAPTCPClient
|
||||
from helpers import add_socket_group_parser_arguments
|
||||
from ud3tn_utils.aap.bin.helpers import add_socket_group_parser_arguments
|
||||
|
||||
|
||||
AGENT_ID = "testagent"
|
||||
|
||||
1
tools/aap
Symbolic link
1
tools/aap
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../python-ud3tn-utils/ud3tn_utils/aap/bin
|
||||
1
tools/aap2
Symbolic link
1
tools/aap2
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../python-ud3tn-utils/ud3tn_utils/aap2/bin
|
||||
Loading…
Add table
Add a link
Reference in a new issue