mirror of
https://gitlab.com/d3tn/ud3tn.git
synced 2026-08-13 12:33:27 +02:00
Add AAP2 link configuration tool
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This commit is contained in:
parent
62cd97ba2f
commit
ec00f0d89e
1 changed files with 77 additions and 0 deletions
77
tools/aap2/aap2_configure_link.py
Normal file
77
tools/aap2/aap2_configure_link.py
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
|
||||
# encoding: utf-8
|
||||
|
||||
import argparse
|
||||
|
||||
from ud3tn_utils.aap2 import (
|
||||
AAP2TCPClient,
|
||||
AAP2UnixClient,
|
||||
AAPMessage,
|
||||
AuthType,
|
||||
Link,
|
||||
LinkStatus,
|
||||
ResponseStatus,
|
||||
)
|
||||
from helpers import add_common_parser_arguments, initialize_logger
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(
|
||||
description="configure a FIB entry via AAP 2.0",
|
||||
)
|
||||
add_common_parser_arguments(parser)
|
||||
parser.add_argument(
|
||||
"NODE_ID",
|
||||
help="the next-hop node ID to be configured",
|
||||
)
|
||||
parser.add_argument(
|
||||
"CLA_ADDR",
|
||||
help="the CLA address used to reach the next hop",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-d", "--delete",
|
||||
action="store_true",
|
||||
help="if set, the entry will be deleted",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-n", "--no-link",
|
||||
action="store_true",
|
||||
help="if set, do not initiate a link update (only update the FIB)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
logger = initialize_logger(args.verbosity)
|
||||
|
||||
if args.tcp:
|
||||
aap2_client = AAP2TCPClient(address=args.tcp)
|
||||
else:
|
||||
aap2_client = AAP2UnixClient(address=args.socket)
|
||||
with aap2_client:
|
||||
secret = aap2_client.configure(
|
||||
args.agentid,
|
||||
subscribe=False,
|
||||
secret=args.secret,
|
||||
auth_type=AuthType.AUTH_TYPE_FIB_CONTROL,
|
||||
)
|
||||
logger.info("Assigned agent secret: '%s'", secret)
|
||||
if args.no_link:
|
||||
target_link_status = LinkStatus.LINK_STATUS_UNSPECIFIED
|
||||
elif args.delete:
|
||||
target_link_status = LinkStatus.LINK_STATUS_TEARDOWN
|
||||
else:
|
||||
target_link_status = LinkStatus.LINK_STATUS_ACTIVE
|
||||
logger.info(
|
||||
"Sending link update for '%s' via '%s': %s",
|
||||
args.NODE_ID,
|
||||
args.CLA_ADDR,
|
||||
target_link_status,
|
||||
)
|
||||
aap2_client.send(AAPMessage(link=Link(
|
||||
status=target_link_status,
|
||||
peer_node_id=args.NODE_ID,
|
||||
peer_cla_addr=args.CLA_ADDR,
|
||||
)))
|
||||
assert (
|
||||
aap2_client.receive_response().response_status ==
|
||||
ResponseStatus.RESPONSE_STATUS_SUCCESS
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue