Skip to content

Commit

Permalink
Implement proper vm name passing
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander V. Nikolaev <[email protected]>
  • Loading branch information
avnik committed Aug 23, 2024
1 parent 1f01084 commit e51fa6a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
1 change: 1 addition & 0 deletions api/admin/admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ message RegistryResponse {

message ApplicationRequest {
string AppName = 1;
optional string VmName = 2;
}

message ApplicationResponse {
Expand Down
8 changes: 2 additions & 6 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,8 @@ impl AdminClient {
Ok(response.into_inner().cmd_status)
}

pub async fn start(&self, app: String, vm: Option<String>) -> 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<String>) -> 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(())
Expand Down
11 changes: 2 additions & 9 deletions src/admin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit e51fa6a

Please sign in to comment.