aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2025-08-11 11:06:40 +0100
committerdiogo464 <[email protected]>2025-08-11 11:06:40 +0100
commit9266fe01db3de3f1142df1b52f70929e75580c0b (patch)
tree77cd97ffa25960bcdb5f71d4911f552a8e03e3b0
parent0ec99bc3e9a59f12f38a4180e49391800bc25f64 (diff)
added clean command
-rw-r--r--src/main.rs20
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 {
62enum SubCmd { 62enum 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)]
193struct CleanArgs {
194 #[clap(flatten)]
195 common: Common,
196}
197
191#[derive(Debug, Clone)] 198#[derive(Debug, Clone)]
192struct MachineConfig { 199struct 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
480async 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
472fn machine_containers_create_script(containers: &[ScheduledContainer]) -> String { 492fn 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() {