diff options
| -rw-r--r-- | src/main.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 3db3169..303d4f3 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -62,6 +62,7 @@ struct Common { | |||
| 62 | enum SubCmd { | 62 | enum SubCmd { |
| 63 | Net(NetArgs), | 63 | Net(NetArgs), |
| 64 | Run(RunArgs), | 64 | Run(RunArgs), |
| 65 | Clean(CleanArgs), | ||
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | #[derive(Debug, Args)] | 68 | #[derive(Debug, Args)] |
| @@ -188,6 +189,12 @@ struct RunArgs { | |||
| 188 | schedule: Option<PathBuf>, | 189 | schedule: Option<PathBuf>, |
| 189 | } | 190 | } |
| 190 | 191 | ||
| 192 | #[derive(Debug, Args)] | ||
| 193 | struct CleanArgs { | ||
| 194 | #[clap(flatten)] | ||
| 195 | common: Common, | ||
| 196 | } | ||
| 197 | |||
| 191 | #[derive(Debug, Clone)] | 198 | #[derive(Debug, Clone)] |
| 192 | struct MachineConfig { | 199 | struct MachineConfig { |
| 193 | machine: Machine, | 200 | machine: Machine, |
| @@ -217,6 +224,7 @@ async fn main() -> Result<()> { | |||
| 217 | NetSubCmd::Preview(args) => cmd_net_preview(args).await, | 224 | NetSubCmd::Preview(args) => cmd_net_preview(args).await, |
| 218 | }, | 225 | }, |
| 219 | SubCmd::Run(args) => cmd_run(args).await, | 226 | SubCmd::Run(args) => cmd_run(args).await, |
| 227 | SubCmd::Clean(args) => cmd_clean(args).await, | ||
| 220 | } | 228 | } |
| 221 | } | 229 | } |
| 222 | 230 | ||
| @@ -469,6 +477,18 @@ async fn cmd_run(args: RunArgs) -> Result<()> { | |||
| 469 | Ok(()) | 477 | Ok(()) |
| 470 | } | 478 | } |
| 471 | 479 | ||
| 480 | async fn cmd_clean(args: CleanArgs) -> Result<()> { | ||
| 481 | let context = context_from_common(&args.common).await?; | ||
| 482 | let machines = oar::job_list_machines(&context).await?; | ||
| 483 | machines_net_container_build(&context, &machines).await?; | ||
| 484 | machine::for_each(&machines, |machine| { | ||
| 485 | machine_containers_clean(&context, machine) | ||
| 486 | }) | ||
| 487 | .await?; | ||
| 488 | machines_clean(&context, &machines).await?; | ||
| 489 | Ok(()) | ||
| 490 | } | ||
| 491 | |||
| 472 | fn machine_containers_create_script(containers: &[ScheduledContainer]) -> String { | 492 | fn machine_containers_create_script(containers: &[ScheduledContainer]) -> String { |
| 473 | let mut script = String::default(); | 493 | let mut script = String::default(); |
| 474 | for (idx, container) in containers.iter().enumerate() { | 494 | for (idx, container) in containers.iter().enumerate() { |
