0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 17:51:53 +00:00

CLI module: sending enable, disable and show route

No parsing yet
This commit is contained in:
Maria Matejka 2024-07-11 15:29:28 +02:00
parent c87ff6088a
commit 7e9a5a44af
2 changed files with 21 additions and 7 deletions

View File

@ -97,19 +97,19 @@ async def main():
dest_cli = CLI(MinimalistTransport(h.control_socket, "dest")) dest_cli = CLI(MinimalistTransport(h.control_socket, "dest"))
print(await asyncio.gather(*[ print(await asyncio.gather(*[
h.control_socket.send_cmd("run_in", where, "./birdc", "-l", "show", "route", "table", "all") where.show_route()
for where in ("src", "dest") for where in (src_cli, dest_cli)
])) ]))
await asyncio.sleep(1) await asyncio.sleep(1)
for p in ("p170", "p180", "p190", "p200"): for p in ("p170", "p180", "p190", "p200"):
print(await h.control_socket.send_cmd("run_in", "src", "./birdc", "-l", "enable", p)) await src_cli.enable(p)
await asyncio.sleep(1) await asyncio.sleep(1)
shr = await asyncio.gather(*[ shr = await asyncio.gather(*[
h.control_socket.send_cmd("run_in", where, "./birdc", "-l", "show", "route", "table", "all") where.show_route()
for where in ("src", "dest") for where in (src_cli, dest_cli)
]) ])
print(shr[0]["out"].decode(), shr[1]["out"].decode()) print(shr[0]["out"].decode(), shr[1]["out"].decode())
@ -117,8 +117,8 @@ async def main():
await asyncio.sleep(1) await asyncio.sleep(1)
print(await asyncio.gather(*[ print(await asyncio.gather(*[
h.control_socket.send_cmd("run_in", where, "./birdc", "-l", "show", "route", "table", "all") where.show_route()
for where in ("src", "dest") for where in (src_cli, dest_cli)
])) ]))
print(await asyncio.gather(*[ print(await asyncio.gather(*[

View File

@ -7,3 +7,17 @@ class CLI:
async def down(self): async def down(self):
return await self.transport.send_cmd("down") return await self.transport.send_cmd("down")
async def enable(self, proto: str):
return await self.transport.send_cmd("enable", proto)
async def disable(self, proto: str):
return await self.transport.send_cmd("disable", proto)
async def show_route(self, table=["all"]):
cmd = [ "show", "route" ]
for t in table:
cmd.append("table")
cmd.append(t)
return await self.transport.send_cmd(*cmd)