From 4d0e6582ba039e92313e4a066490dc7f0685f8b7 Mon Sep 17 00:00:00 2001 From: Hannah Neary Date: Tue, 10 Dec 2024 11:41:56 +0000 Subject: [PATCH] clean up --- control-plane/src/orchestration.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/control-plane/src/orchestration.rs b/control-plane/src/orchestration.rs index d7a575c8..8ccfde83 100644 --- a/control-plane/src/orchestration.rs +++ b/control-plane/src/orchestration.rs @@ -21,12 +21,15 @@ pub enum OrchestrationError { } static EMPTY_VEC: Vec = Vec::new(); +static ENCLAVE_CID: &str = "2021"; +static EIF_PATH: &str = "enclave.eif"; +static NITRO_CLI: &str = "nitro-cli"; pub struct Orchestration; impl Orchestration { pub async fn shutdown_all_enclaves() -> Result { - let command = vec!["sh", "-c", "nitro-cli", "terminate-enclave", "--all"]; + let command = vec!["sh", "-c", NITRO_CLI, "terminate-enclave", "--all"]; Self::run_command_capture_stdout(&command).await } @@ -36,7 +39,7 @@ impl Orchestration { info!("[HOST] Checking for running enclaves..."); let running_enclaves = - Self::run_command_capture_stdout(&["nitro-cli", "describe-enclaves"]).await?; + Self::run_command_capture_stdout(&[NITRO_CLI, "describe-enclaves"]).await?; let enclaves: Value = serde_json::from_str(&running_enclaves)?; let enclaves_array = enclaves.as_array().unwrap_or(&EMPTY_VEC); if !enclaves_array.is_empty() { @@ -50,16 +53,16 @@ impl Orchestration { info!("Starting new enclave..."); let mut run_command = vec![ - "nitro-cli", + NITRO_CLI, "run-enclave", "--cpu-count", &run_config.num_cpus, "--memory", &run_config.ram_size_mib, "--enclave-cid", - "2021", + ENCLAVE_CID, "--eif-path", - "enclave.eif", + EIF_PATH, ]; if run_config.debug_mode == "true" { @@ -77,7 +80,7 @@ impl Orchestration { if run_config.debug_mode == "true" { info!("Attaching headless console for running enclaves..."); let running_enclaves = - Self::run_command_capture_stdout(&["nitro-cli", "describe-enclaves"]).await?; + Self::run_command_capture_stdout(&[NITRO_CLI, "describe-enclaves"]).await?; let enclaves: Value = serde_json::from_str(&running_enclaves)?; let enclaves_array = enclaves.as_array().unwrap_or(&EMPTY_VEC).clone(); for enclave in enclaves_array {