diff --git a/api/admin/admin.proto b/api/admin/admin.proto index 9fde13b..7ad1757 100644 --- a/api/admin/admin.proto +++ b/api/admin/admin.proto @@ -33,6 +33,7 @@ message RegistryResponse { message ApplicationRequest { string AppName = 1; + optional string VmName = 2; } message ApplicationResponse { diff --git a/client/src/client.rs b/client/src/client.rs index 9b4e915..cb24754 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -76,12 +76,8 @@ impl AdminClient { Ok(response.into_inner().cmd_status) } - pub async fn start(&self, app: String, vm: Option) -> anyhow::Result<()> { - let app_name = match vm { - Some(vm_name) => format!("{app}:{vm_name}"), - None => app, - }; - let request = pb::admin::ApplicationRequest { app_name }; + pub async fn start(&self, app_name: String, vm_name: Option) -> anyhow::Result<()> { + let request = pb::admin::ApplicationRequest { app_name, vm_name }; let response = self.connect_to().await?.start_application(request).await?; // Ok(response.into_inner().cmd_status) Ok(()) diff --git a/src/admin/server.rs b/src/admin/server.rs index 5ade7ec..6401af8 100644 --- a/src/admin/server.rs +++ b/src/admin/server.rs @@ -231,19 +231,12 @@ impl AdminServiceImpl { self.registry.register(entry) } - fn parse_app_vm_pair(app_and_vm: &str) -> (&str, Option<&str>) { - if let Some((app, vm)) = app_and_vm.split_once(":") { - (app, Some(vm)) - } else { - (app_and_vm, None) - } - } - pub async fn start_app(&self, req: ApplicationRequest) -> anyhow::Result<()> { if self.state != State::VmsRegistered { info!("not all required system-vms are registered") } - let (name, vm) = Self::parse_app_vm_pair(&req.app_name); + let name = req.app_name; + let vm = req.vm_name.as_deref(); let vm_name = format_vm_name(&name, vm); let systemd_agent = format_service_name(&name, vm);