awlane | 1cec233 | 2025-04-24 17:24:47 -0500 | [diff] [blame] | 1 | from mininet.net import Mininet |
| 2 | from minindn.util import is_valid_hostid, run_popen |
| 3 | |
| 4 | class StateExecutor: |
| 5 | def __init__(self, net: Mininet): |
| 6 | self.net = net |
| 7 | |
| 8 | async def get_fib(self, node_id): |
| 9 | """UI Function: Get the NFDC status report and ifconfig as the fib""" |
| 10 | if not is_valid_hostid(self.net, node_id): |
| 11 | if node_id in self.net: |
| 12 | node = self.net[node_id] |
| 13 | return { "id": node_id, "fib": f"Node is not a host ({node.__class__.__name__})" } |
| 14 | return |
| 15 | |
| 16 | node = self.net[node_id] |
| 17 | nfd_status = run_popen(node, "nfdc status report".split()).decode("utf-8") |
| 18 | ifconfig = run_popen(node, "ifconfig".split()).decode("utf-8") |
| 19 | output = nfd_status + "\n" + ifconfig |
| 20 | return { |
| 21 | "id": node_id, |
| 22 | "fib": output, |
| 23 | } |