diff --git a/Cargo.lock b/Cargo.lock index 7aa88f4..a604d12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2868,9 +2868,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.135" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "itoa", "memchr", diff --git a/Cargo.toml b/Cargo.toml index fb7f183..d1a0b96 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,5 @@ slog = "2.7.0" slog-async = "2.8.0" tokio = { version = "1.43.0", features = ["full"] } tracing = "0.1.41" -tracing-core = "0.1.33" -tracing-chrome = "0.7.2" tracing-slog = { git = "https://github.com/oxidecomputer/tracing-slog", default-features = false } uuid = { version = "1", features = [ "serde", "v4" ] } diff --git a/hostd/src/bin/hostd-controller.rs b/hostd/src/bin/hostd-controller.rs index 66e5572..003671e 100644 --- a/hostd/src/bin/hostd-controller.rs +++ b/hostd/src/bin/hostd-controller.rs @@ -3,7 +3,6 @@ use anyhow::{anyhow, Result}; use clap::Parser; use dropshot::{ConfigDropshot, ServerBuilder}; use slog::Drain; -// use sqlx::PgPool; use std::net::SocketAddr; use std::str::FromStr; use std::sync::Arc; @@ -60,13 +59,8 @@ async fn main() -> Result<()> { slog::Logger::root(async_drain, slog::o!()) }; - // let database_url = args.database_url.unwrap(); - // dont connect to database pass null - // let pg = PgPool::connect(&database_url).await?; - - // sqlx::migrate!().run(&pg).await?; - - let ctx = ControllerContext::new(); + let dbus = zbus::Connection::system().await.unwrap(); + let ctx = ControllerContext::new(dbus); let api = api::api()?; diff --git a/hostd/src/context.rs b/hostd/src/context.rs index e50d955..8380c40 100644 --- a/hostd/src/context.rs +++ b/hostd/src/context.rs @@ -1,11 +1,11 @@ -// use sqlx::postgres::PgPool; +use zbus::Connection; pub struct ControllerContext { - // pub pg_pool: PgPool, + pub dbus: Connection, } impl ControllerContext { - pub fn new() -> ControllerContext { - ControllerContext {} + pub fn new(dbus: Connection) -> ControllerContext { + ControllerContext { dbus } } } diff --git a/hostd/src/machine.rs b/hostd/src/machine.rs index eb4c81e..57e4440 100644 --- a/hostd/src/machine.rs +++ b/hostd/src/machine.rs @@ -22,12 +22,11 @@ struct MachineInfo { pub async fn describe( rqctx: RequestContext<Arc<ControllerContext>>, ) -> Result<HttpResponseOk<MachineInfo>, HttpError> { - let conn = zbus::Connection::system().await.unwrap(); - let manager = zbus_systemd::hostname1::HostnamedProxy::new(&conn) + let hostnamed = zbus_systemd::hostname1::HostnamedProxy::new(&rqctx.context().dbus) .await .unwrap(); - let machine_id = manager + let machine_id = hostnamed .machine_id() .await .unwrap()