in openr/py/openr/cli/commands/decision.py [0:0]
def _run(self, client: OpenrCtrl.Client, *args, **kwargs):
policy = None
try:
policy = client.getRibPolicy()
except ctrl_types.OpenrError as e:
print("Error: ", str(e), "\nSystem standard error: ", sys.stderr)
return
# Convert the prefixes to readable format
assert policy is not None
# NOTE: We don't do explicit effor to print policy in
print("> RibPolicy")
print(f" Validity: {policy.ttl_secs}s")
for stmt in policy.statements:
prefixes: List[str] = []
if stmt.matcher.prefixes:
prefixes = [ipnetwork.sprint_prefix(p) for p in stmt.matcher.prefixes]
tags = stmt.matcher.tags or []
action = stmt.action.set_weight or ctrl_types.RibRouteActionWeight()
print(f" Statement: {stmt.name}")
if prefixes:
print(f" Prefix Match List: {', '.join(prefixes)}")
if tags:
print(f" Tags Match List: {', '.join(tags)}")
print(" Action Set Weight:")
print(f" Default: {action.default_weight}")
print(" Area:")
for area, weight in action.area_to_weight.items():
print(f" {area}: {weight}")
print(" Neighbor:")
for neighbor, weight in action.neighbor_to_weight.items():
print(f" {neighbor}: {weight}")