kratactl/cli/network/
mod.rs

1use anyhow::Result;
2use clap::{Parser, Subcommand};
3use reservation::NetworkReservationCommand;
4use tonic::transport::Channel;
5
6use krata::events::EventStream;
7use krata::v1::control::control_service_client::ControlServiceClient;
8
9pub mod reservation;
10
11#[derive(Parser)]
12#[command(about = "Manage the network on the isolation engine")]
13pub struct NetworkCommand {
14    #[command(subcommand)]
15    subcommand: NetworkCommands,
16}
17
18impl NetworkCommand {
19    pub async fn run(
20        self,
21        client: ControlServiceClient<Channel>,
22        events: EventStream,
23    ) -> Result<()> {
24        self.subcommand.run(client, events).await
25    }
26}
27
28#[derive(Subcommand)]
29pub enum NetworkCommands {
30    Reservation(NetworkReservationCommand),
31}
32
33impl NetworkCommands {
34    pub async fn run(
35        self,
36        client: ControlServiceClient<Channel>,
37        events: EventStream,
38    ) -> Result<()> {
39        match self {
40            NetworkCommands::Reservation(reservation) => reservation.run(client, events).await,
41        }
42    }
43}