generated from Patagia/template-nix
Compare commits
1 commit
f8c7dc96a2
...
d4b0b5d955
Author | SHA1 | Date | |
---|---|---|---|
d4b0b5d955 |
1 changed files with 16 additions and 10 deletions
|
@ -1,24 +1,30 @@
|
|||
use anyhow::Result;
|
||||
|
||||
use internal::ipc::patagia::io_patagia_hostd::{
|
||||
Call_Apply, Call_Describe, Machine, VarlinkInterface,
|
||||
};
|
||||
use internal::ipc::patagia::io_patagia_hostd;
|
||||
use internal::ipc::systemd::io_systemd_hostname::{self, VarlinkClientInterface};
|
||||
|
||||
const LISTEN_ADDRESS: &str = "unix:/tmp/patagia/io.patagia.hostd";
|
||||
|
||||
struct PatagiaHostd;
|
||||
|
||||
impl VarlinkInterface for PatagiaHostd {
|
||||
fn apply(&self, call: &mut dyn Call_Apply, machine: Machine) -> varlink::Result<()> {
|
||||
impl io_patagia_hostd::VarlinkInterface for PatagiaHostd {
|
||||
fn apply(
|
||||
&self,
|
||||
call: &mut dyn io_patagia_hostd::Call_Apply,
|
||||
machine: io_patagia_hostd::Machine,
|
||||
) -> varlink::Result<()> {
|
||||
// FIXME: Do something useful
|
||||
println!("Applying machine config: {:#?}", machine);
|
||||
call.reply()
|
||||
}
|
||||
|
||||
fn describe(&self, call: &mut dyn Call_Describe) -> varlink::Result<()> {
|
||||
// FIXME: Do something useful
|
||||
let machine = Machine {
|
||||
machineId: "123456789".to_string(),
|
||||
fn describe(&self, call: &mut dyn io_patagia_hostd::Call_Describe) -> varlink::Result<()> {
|
||||
let conn =
|
||||
varlink::Connection::with_address("unix:/run/systemd/io.systemd.Hostname").unwrap();
|
||||
let mut sd = io_systemd_hostname::VarlinkClient::new(conn);
|
||||
|
||||
let machine = io_patagia_hostd::Machine {
|
||||
machineId: sd.describe().call().unwrap().MachineID,
|
||||
nodeLabels: None,
|
||||
patagiaAgent: None,
|
||||
};
|
||||
|
@ -28,7 +34,7 @@ impl VarlinkInterface for PatagiaHostd {
|
|||
|
||||
fn main() -> Result<()> {
|
||||
let hostd = PatagiaHostd;
|
||||
let hostd_iface = internal::ipc::patagia::io_patagia_hostd::new(Box::new(hostd));
|
||||
let hostd_iface = io_patagia_hostd::new(Box::new(hostd));
|
||||
|
||||
let svc = varlink::VarlinkService::new(
|
||||
"io.patagia.hostd",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue