Cleanup dependencies and code
we're so back
This commit is contained in:
parent
1023fdca8c
commit
295609a57d
1068
Cargo.lock
generated
1068
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -8,8 +8,9 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
figment = { version = "0.10.8", features = ["json", "toml", "env"] }
|
figment = { version = "0.10.8", features = ["json", "toml", "env"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
tarpc = { version = "0.31", features = ["tokio1", "unix"] }
|
tarpc = { version = "0.34", features = ["tokio1", "unix"] }
|
||||||
tokio = { version = "1.0", features = ["macros"] }
|
tokio = { version = "1.0", features = ["macros"] }
|
||||||
uuid = "1.2.2"
|
uuid = "1.2.2"
|
||||||
trust-dns-proto = { version = "0.22.0", features = ["serde-config"] }
|
# trust-dns-proto = { version = "0.23", features = ["serde-config"] }
|
||||||
log = "0.4.17"
|
hickory-proto = { version = "0.24", features = ["serde-config"] }
|
||||||
|
log = "0.4.17"
|
||||||
|
|
|
@ -4,8 +4,8 @@ use figment::{
|
||||||
providers::{Env, Format, Json, Toml},
|
providers::{Env, Format, Json, Toml},
|
||||||
Figment, Metadata, Provider,
|
Figment, Metadata, Provider,
|
||||||
};
|
};
|
||||||
|
use hickory_proto::rr::Name;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use trust_dns_proto::rr::Name;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct StorageConfig {
|
pub struct StorageConfig {
|
||||||
|
|
|
@ -5,7 +5,7 @@ pub mod config;
|
||||||
pub mod model;
|
pub mod model;
|
||||||
pub mod net;
|
pub mod net;
|
||||||
|
|
||||||
pub use trust_dns_proto;
|
pub use hickory_proto;
|
||||||
|
|
||||||
#[tarpc::service]
|
#[tarpc::service]
|
||||||
pub trait Nazrin {
|
pub trait Nazrin {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
use hickory_proto::rr::Name;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{fmt, net::Ipv4Addr};
|
use std::{fmt, net::Ipv4Addr};
|
||||||
use trust_dns_proto::rr::Name;
|
|
||||||
|
|
||||||
use crate::net::{cidr::CidrV4, mac::MacAddr};
|
use crate::net::{cidr::CidrV4, mac::MacAddr};
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,14 @@ nzr-api = { path = "../api" }
|
||||||
clap = { version = "4.0.26", features = ["derive"] }
|
clap = { version = "4.0.26", features = ["derive"] }
|
||||||
home = "0.5.4"
|
home = "0.5.4"
|
||||||
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
|
||||||
tokio-serde = { version = "0.8.0", features = ["bincode"] }
|
tokio-serde = { version = "0.9", features = ["bincode"] }
|
||||||
tarpc = { version = "0.31", features = ["tokio1", "unix", "serde-transport", "serde-transport-bincode"] }
|
tarpc = { version = "0.34", features = [
|
||||||
tabled = "0.10.0"
|
"tokio1",
|
||||||
|
"unix",
|
||||||
|
"serde-transport",
|
||||||
|
"serde-transport-bincode",
|
||||||
|
] }
|
||||||
|
tabled = "0.15"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.11"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::{CommandFactory, FromArgMatches, Parser, Subcommand};
|
use clap::{CommandFactory, FromArgMatches, Parser, Subcommand};
|
||||||
|
use nzr_api::hickory_proto::rr::Name;
|
||||||
use nzr_api::model;
|
use nzr_api::model;
|
||||||
use nzr_api::net::cidr::CidrV4;
|
use nzr_api::net::cidr::CidrV4;
|
||||||
use nzr_api::trust_dns_proto::rr::Name;
|
|
||||||
use nzr_api::{config, NazrinClient};
|
use nzr_api::{config, NazrinClient};
|
||||||
use std::any::{Any, TypeId};
|
use std::any::{Any, TypeId};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -328,8 +328,8 @@ async fn handle_command() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
let tabular: Vec<table::Instance> =
|
let tabular: Vec<table::Instance> =
|
||||||
instances?.iter().map(table::Instance::from).collect();
|
instances?.iter().map(table::Instance::from).collect();
|
||||||
let mut table = tabled::Table::new(&tabular);
|
let mut table = tabled::Table::new(tabular);
|
||||||
println!("{}", table.with(tabled::Style::psql()));
|
println!("{}", table.with(tabled::settings::Style::psql()));
|
||||||
}
|
}
|
||||||
InstanceCmd::Prune => (client.garbage_collect(tarpc::context::current()).await?)?,
|
InstanceCmd::Prune => (client.garbage_collect(tarpc::context::current()).await?)?,
|
||||||
},
|
},
|
||||||
|
@ -423,8 +423,8 @@ async fn handle_command() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
let tabular: Vec<table::Subnet> =
|
let tabular: Vec<table::Subnet> =
|
||||||
subnets?.iter().map(table::Subnet::from).collect();
|
subnets?.iter().map(table::Subnet::from).collect();
|
||||||
let mut table = tabled::Table::new(&tabular);
|
let mut table = tabled::Table::new(tabular);
|
||||||
println!("{}", table.with(tabled::Style::psql()));
|
println!("{}", table.with(tabled::settings::Style::psql()));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,35 +6,49 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tarpc = { version = "0.31", features = ["tokio1", "unix", "serde-transport", "serde-transport-bincode"] }
|
tarpc = { version = "0.34", features = [
|
||||||
tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "process"] }
|
"tokio1",
|
||||||
tokio-serde = { version = "0.8.0", features = ["bincode"] }
|
"unix",
|
||||||
|
"serde-transport",
|
||||||
|
"serde-transport-bincode",
|
||||||
|
] }
|
||||||
|
tokio = { version = "1", features = ["macros", "rt-multi-thread", "process"] }
|
||||||
|
tokio-serde = { version = "0.9", features = ["bincode"] }
|
||||||
sled = "0.34.7"
|
sled = "0.34.7"
|
||||||
# virt = "0.2.11"
|
virt = "0.4"
|
||||||
virt = { path = "../../libvirt-rust" }
|
# virt = { path = "../../libvirt-rust" }
|
||||||
fatfs = "0.3"
|
fatfs = "0.3"
|
||||||
uuid = { version = "1.2.2", features = ["v4", "fast-rng", "serde", "macro-diagnostics"] }
|
uuid = { version = "1.2.2", features = [
|
||||||
|
"v4",
|
||||||
|
"fast-rng",
|
||||||
|
"serde",
|
||||||
|
"macro-diagnostics",
|
||||||
|
] }
|
||||||
clap = { version = "4.0.26", features = ["derive"] }
|
clap = { version = "4.0.26", features = ["derive"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
# for new @attr support, awaiting 0.27.0
|
# for new @attr support, awaiting 0.27.0
|
||||||
quick-xml = { git = "https://github.com/tafia/quick-xml", rev = "fb079b6714d7238d5180aaa098c5f9b02dbcc7da", features = ["serialize"] }
|
quick-xml = { version = "0.36", features = ["serialize"] }
|
||||||
serde_with = "2.1.0"
|
# quick-xml = { git = "https://github.com/tafia/quick-xml", rev = "fb079b6714d7238d5180aaa098c5f9b02dbcc7da", features = [
|
||||||
|
# "serialize",
|
||||||
|
# ] }
|
||||||
|
serde_with = "2"
|
||||||
serde_yaml = "0.9.14"
|
serde_yaml = "0.9.14"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
libc = "0.2.137"
|
libc = "0.2.137"
|
||||||
home = "0.5.4"
|
home = "0.5.4"
|
||||||
stdext = "0.3.1"
|
stdext = "0.3.1"
|
||||||
zerocopy = "0.6.1"
|
zerocopy = "0.7"
|
||||||
nzr-api = { path = "../api" }
|
nzr-api = { path = "../api" }
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
async-trait = "0.1.60"
|
|
||||||
ciborium = "0.2.0"
|
ciborium = "0.2.0"
|
||||||
ciborium-io = "0.2.0"
|
ciborium-io = "0.2.0"
|
||||||
trust-dns-server = "0.22.0"
|
hickory-server = "0.24"
|
||||||
|
hickory-proto = { version = "0.24", features = ["serde-config"] }
|
||||||
|
async-trait = "0.1"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
syslog = "6.0.1"
|
syslog = "7"
|
||||||
nix = "0.26.1"
|
nix = { version = "0.29", features = ["user", "fs"] }
|
||||||
tempdir = "0.3.7"
|
tempfile = "3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
regex = "1"
|
regex = "1"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
|
|
||||||
use fatfs::FsOptions;
|
use fatfs::FsOptions;
|
||||||
|
use hickory_server::proto::rr::Name;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_with::skip_serializing_none;
|
use serde_with::skip_serializing_none;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::{prelude::*, Cursor};
|
use std::io::{prelude::*, Cursor};
|
||||||
use trust_dns_server::proto::rr::Name;
|
|
||||||
|
|
||||||
use nzr_api::net::{cidr::CidrV4, mac::MacAddr};
|
use nzr_api::net::{cidr::CidrV4, mac::MacAddr};
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,11 @@ use crate::ctrl::Storable;
|
||||||
use crate::ctx::Context;
|
use crate::ctx::Context;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::virt::VirtVolume;
|
use crate::virt::VirtVolume;
|
||||||
|
use hickory_server::proto::rr::Name;
|
||||||
use log::*;
|
use log::*;
|
||||||
use nzr_api::args;
|
use nzr_api::args;
|
||||||
use nzr_api::net::mac::MacAddr;
|
use nzr_api::net::mac::MacAddr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use trust_dns_server::proto::rr::Name;
|
|
||||||
|
|
||||||
const VIRT_MAC_OUI: &[u8] = &[0x02, 0xf1, 0x0f];
|
const VIRT_MAC_OUI: &[u8] = &[0x02, 0xf1, 0x0f];
|
||||||
|
|
||||||
|
@ -37,13 +37,10 @@ pub async fn new_instance(
|
||||||
// find the subnet corresponding to the interface
|
// find the subnet corresponding to the interface
|
||||||
let subnet = Subnet::get_by_key(ctx.db.clone(), args.subnet.as_bytes())
|
let subnet = Subnet::get_by_key(ctx.db.clone(), args.subnet.as_bytes())
|
||||||
.map_err(|er| cmd_error!("Unable to get interface: {}", er))?
|
.map_err(|er| cmd_error!("Unable to get interface: {}", er))?
|
||||||
.map_or(
|
.ok_or(cmd_error!(
|
||||||
Err(cmd_error!(
|
"Subnet {} wasn't found in database",
|
||||||
"Subnet {} wasn't found in database",
|
&args.subnet
|
||||||
&args.subnet
|
))?;
|
||||||
)),
|
|
||||||
Ok,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// bail if a domain already exists
|
// bail if a domain already exists
|
||||||
if let Ok(dom) = virt::domain::Domain::lookup_by_name(&ctx.virt.conn, &args.name) {
|
if let Ok(dom) = virt::domain::Domain::lookup_by_name(&ctx.virt.conn, &args.name) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ impl DomainBuilder {
|
||||||
/// > used to form the filename for storing the persistent
|
/// > used to form the filename for storing the persistent
|
||||||
/// > configuration file.
|
/// > configuration file.
|
||||||
pub fn name(mut self, name: &str) -> Self {
|
pub fn name(mut self, name: &str) -> Self {
|
||||||
self.domain.name = name.to_owned();
|
name.clone_into(&mut self.domain.name);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ impl IfaceBuilder {
|
||||||
/// qemu-system-x86_64 -net nic,model=? /dev/null
|
/// qemu-system-x86_64 -net nic,model=? /dev/null
|
||||||
/// ```
|
/// ```
|
||||||
pub fn model(mut self, model: &str) -> Self {
|
pub fn model(mut self, model: &str) -> Self {
|
||||||
self.iface.model.r#type = model.to_owned();
|
model.clone_into(&mut self.iface.model.r#type);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,8 +233,8 @@ impl DiskBuilder {
|
||||||
|
|
||||||
/// Set the target for the disk to attach to.
|
/// Set the target for the disk to attach to.
|
||||||
pub fn target(mut self, dev: &str, bus: &str) -> Self {
|
pub fn target(mut self, dev: &str, bus: &str) -> Self {
|
||||||
self.disk.target.bus = bus.to_owned();
|
bus.clone_into(&mut self.disk.target.bus);
|
||||||
self.disk.target.dev = dev.to_owned();
|
dev.clone_into(&mut self.disk.target.dev);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl std::error::Error for ContextError {}
|
||||||
impl InnerCtx {
|
impl InnerCtx {
|
||||||
fn new(config: Config) -> Result<Self, ContextError> {
|
fn new(config: Config) -> Result<Self, ContextError> {
|
||||||
let zones = ZoneData::new(&config.dns);
|
let zones = ZoneData::new(&config.dns);
|
||||||
let conn = Connect::open(&config.libvirt_uri).map_err(ContextError::Virt)?;
|
let conn = Connect::open(Some(&config.libvirt_uri)).map_err(ContextError::Virt)?;
|
||||||
virt::error::clear_error_callback();
|
virt::error::clear_error_callback();
|
||||||
|
|
||||||
let pools = PoolRefs {
|
let pools = PoolRefs {
|
||||||
|
|
|
@ -9,14 +9,12 @@ use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::{Mutex, RwLock};
|
use tokio::sync::{Mutex, RwLock};
|
||||||
|
|
||||||
use trust_dns_server::authority::{AuthorityObject, Catalog};
|
use hickory_proto::rr::Name;
|
||||||
use trust_dns_server::client::rr::{LowerName, RrKey};
|
use hickory_server::authority::{AuthorityObject, Catalog};
|
||||||
use trust_dns_server::proto::rr::{rdata::soa, RData, RecordSet};
|
use hickory_server::proto::rr::{rdata::soa, RData, RecordSet};
|
||||||
use trust_dns_server::server::{Request, RequestHandler, ResponseHandler, ResponseInfo};
|
use hickory_server::proto::rr::{LowerName, RrKey};
|
||||||
use trust_dns_server::{
|
use hickory_server::server::{Request, RequestHandler, ResponseHandler, ResponseInfo};
|
||||||
proto::rr::{Name, Record},
|
use hickory_server::{proto::rr::Record, store::in_memory::InMemoryAuthority};
|
||||||
store::in_memory::InMemoryAuthority,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct CatalogRef(Arc<RwLock<Catalog>>);
|
pub struct CatalogRef(Arc<RwLock<Catalog>>);
|
||||||
|
@ -32,12 +30,14 @@ macro_rules! make_serial {
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hickory_dns 0.24 still requires async_trait
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl RequestHandler for CatalogRef {
|
impl RequestHandler for CatalogRef {
|
||||||
async fn handle_request<R>(&self, request: &Request, response_handle: R) -> ResponseInfo
|
async fn handle_request<R: ResponseHandler>(
|
||||||
where
|
&self,
|
||||||
R: ResponseHandler,
|
request: &Request,
|
||||||
{
|
response_handle: R,
|
||||||
|
) -> ResponseInfo {
|
||||||
self.0
|
self.0
|
||||||
.read()
|
.read()
|
||||||
.await
|
.await
|
||||||
|
@ -74,7 +74,7 @@ pub fn make_rectree_with_soa(name: &Name, config: &DNSConfig) -> BTreeMap<RrKey,
|
||||||
let mut records: BTreeMap<RrKey, RecordSet> = BTreeMap::new();
|
let mut records: BTreeMap<RrKey, RecordSet> = BTreeMap::new();
|
||||||
let soa_key = RrKey::new(
|
let soa_key = RrKey::new(
|
||||||
LowerName::from(name),
|
LowerName::from(name),
|
||||||
trust_dns_server::proto::rr::RecordType::SOA,
|
hickory_server::proto::rr::RecordType::SOA,
|
||||||
);
|
);
|
||||||
let soa_rec = Record::from_rdata(
|
let soa_rec = Record::from_rdata(
|
||||||
name.clone(),
|
name.clone(),
|
||||||
|
@ -100,7 +100,7 @@ impl InnerZD {
|
||||||
InMemoryAuthority::new(
|
InMemoryAuthority::new(
|
||||||
dns_config.default_zone.clone(),
|
dns_config.default_zone.clone(),
|
||||||
records,
|
records,
|
||||||
trust_dns_server::authority::ZoneType::Primary,
|
hickory_server::authority::ZoneType::Primary,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -123,7 +123,7 @@ impl InnerZD {
|
||||||
let auth = InMemoryAuthority::new(
|
let auth = InMemoryAuthority::new(
|
||||||
name.clone(),
|
name.clone(),
|
||||||
make_rectree_with_soa(name, &self.config),
|
make_rectree_with_soa(name, &self.config),
|
||||||
trust_dns_server::authority::ZoneType::Primary,
|
hickory_server::authority::ZoneType::Primary,
|
||||||
false,
|
false,
|
||||||
)?;
|
)?;
|
||||||
self.import(&subnet.ifname.to_string(), auth).await;
|
self.import(&subnet.ifname.to_string(), auth).await;
|
||||||
|
@ -174,7 +174,7 @@ impl InnerZD {
|
||||||
zone.origin()
|
zone.origin()
|
||||||
);
|
);
|
||||||
|
|
||||||
let record = Record::from_rdata(fqdn, 3600, RData::A(addr));
|
let record = Record::from_rdata(fqdn, 3600, RData::A(addr.into()));
|
||||||
zone.upsert(record, 0).await;
|
zone.upsert(record, 0).await;
|
||||||
self.catalog()
|
self.catalog()
|
||||||
.0
|
.0
|
||||||
|
@ -194,7 +194,7 @@ impl InnerZD {
|
||||||
if let Some(zone) = zones.get_mut(interface) {
|
if let Some(zone) = zones.get_mut(interface) {
|
||||||
let hostname: LowerName = hostname.into();
|
let hostname: LowerName = hostname.into();
|
||||||
self.catalog.0.write().await.remove(&hostname);
|
self.catalog.0.write().await.remove(&hostname);
|
||||||
let key = RrKey::new(hostname, trust_dns_server::proto::rr::RecordType::A);
|
let key = RrKey::new(hostname, hickory_server::proto::rr::RecordType::A);
|
||||||
Ok(zone.records_mut().await.remove(&key).is_some())
|
Ok(zone.records_mut().await.remove(&key).is_some())
|
||||||
} else {
|
} else {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use tempdir::TempDir;
|
use tempfile::TempDir;
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
|
|
||||||
use crate::ctrl::virtxml::SizeInfo;
|
use crate::ctrl::virtxml::SizeInfo;
|
||||||
|
@ -101,7 +101,7 @@ where
|
||||||
Fut: Future<Output = std::io::Result<std::process::Output>>,
|
Fut: Future<Output = std::io::Result<std::process::Output>>,
|
||||||
{
|
{
|
||||||
let qi_path = qemu_img_path()?;
|
let qi_path = qemu_img_path()?;
|
||||||
let img_dir = TempDir::new("nazrin")?;
|
let img_dir = TempDir::with_prefix("nazrin")?;
|
||||||
let img_path = img_dir.path().join("img");
|
let img_path = img_dir.path().join("img");
|
||||||
|
|
||||||
let qi_out = func(Command::new(&qi_path), &img_path)
|
let qi_out = func(Command::new(&qi_path), &img_path)
|
||||||
|
|
|
@ -11,12 +11,12 @@ mod test;
|
||||||
mod virt;
|
mod virt;
|
||||||
|
|
||||||
use crate::ctrl::{net::Subnet, Storable};
|
use crate::ctrl::{net::Subnet, Storable};
|
||||||
|
use hickory_server::ServerFuture;
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use log::*;
|
use log::*;
|
||||||
use nzr_api::config;
|
use nzr_api::config;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use tokio::net::UdpSocket;
|
use tokio::net::UdpSocket;
|
||||||
use trust_dns_server::ServerFuture;
|
|
||||||
|
|
||||||
#[tokio::main(flavor = "multi_thread")]
|
#[tokio::main(flavor = "multi_thread")]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use futures::{future, StreamExt};
|
||||||
use nzr_api::{args, model, Nazrin};
|
use nzr_api::{args, model, Nazrin};
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -35,7 +36,6 @@ impl NzrServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tarpc::server]
|
|
||||||
impl Nazrin for NzrServer {
|
impl Nazrin for NzrServer {
|
||||||
async fn new_instance(
|
async fn new_instance(
|
||||||
self,
|
self,
|
||||||
|
@ -55,7 +55,7 @@ impl Nazrin for NzrServer {
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut pt = prog_task.write().await;
|
let mut pt = prog_task.write().await;
|
||||||
pt.status_text = "Starting instance...".to_owned();
|
"Starting instance...".clone_into(&mut pt.status_text);
|
||||||
pt.percentage = 90.0;
|
pt.percentage = 90.0;
|
||||||
}
|
}
|
||||||
if let Some(addr) = addr {
|
if let Some(addr) = addr {
|
||||||
|
@ -281,6 +281,10 @@ pub async fn serve(ctx: Context, zones: ZoneData) -> Result<(), Box<dyn std::err
|
||||||
let transport = tarpc::serde_transport::new(framed, Bincode::default());
|
let transport = tarpc::serde_transport::new(framed, Bincode::default());
|
||||||
BaseChannel::with_defaults(transport)
|
BaseChannel::with_defaults(transport)
|
||||||
.execute(NzrServer::new(ctx, zones).serve())
|
.execute(NzrServer::new(ctx, zones).serve())
|
||||||
|
.for_each(|rpc| {
|
||||||
|
tokio::spawn(rpc);
|
||||||
|
future::ready(())
|
||||||
|
})
|
||||||
.await;
|
.await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ impl VirtVolume {
|
||||||
let svol = StorageVol::create_xml(pool, &xml, flags)?;
|
let svol = StorageVol::create_xml(pool, &xml, flags)?;
|
||||||
|
|
||||||
if xmldata.vol_type() == Some(VolType::Qcow2) {
|
if xmldata.vol_type() == Some(VolType::Qcow2) {
|
||||||
let size = xmldata.capacity.unwrap().clone();
|
let size = xmldata.capacity.unwrap();
|
||||||
let src_img = img::create_qcow2(size).await?;
|
let src_img = img::create_qcow2(size).await?;
|
||||||
|
|
||||||
let stream = match Stream::new(&svol.get_connect().map_err(PoolError::VirtError)?, 0) {
|
let stream = match Stream::new(&svol.get_connect().map_err(PoolError::VirtError)?, 0) {
|
||||||
|
@ -93,7 +93,7 @@ impl VirtVolume {
|
||||||
return Err(Box::new(PoolError::CantUpload(er)));
|
return Err(Box::new(PoolError::CantUpload(er)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Self::upload_img(&*src_img, stream)?;
|
Self::upload_img(&src_img, stream)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
@ -125,7 +125,7 @@ impl VirtVolume {
|
||||||
|
|
||||||
let src_path = self.get_path().map_err(PoolError::NoPath)?;
|
let src_path = self.get_path().map_err(PoolError::NoPath)?;
|
||||||
|
|
||||||
let src_img = img::clone_qcow2(src_path, size.clone())
|
let src_img = img::clone_qcow2(src_path, size)
|
||||||
.await
|
.await
|
||||||
.map_err(PoolError::QemuError)?;
|
.map_err(PoolError::QemuError)?;
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ impl VirtVolume {
|
||||||
return Err(PoolError::CantUpload(er));
|
return Err(PoolError::CantUpload(er));
|
||||||
}
|
}
|
||||||
|
|
||||||
Self::upload_img(&*src_img, stream)?;
|
Self::upload_img(&src_img, stream)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
inner: cloned,
|
inner: cloned,
|
||||||
|
|
Loading…
Reference in a new issue