diff --git a/src/bin/api.rs b/src/bin/api.rs index 28497f4..d3d6a65 100644 --- a/src/bin/api.rs +++ b/src/bin/api.rs @@ -1,5 +1,4 @@ use anyhow::Error; -use chrono::Utc; use clap::Parser; use config::{Config, File}; use fedimint_tonic_lnd::connect; diff --git a/src/exchange.rs b/src/exchange.rs index a1e1c22..d82e04e 100644 --- a/src/exchange.rs +++ b/src/exchange.rs @@ -69,6 +69,12 @@ struct MempoolRates { pub eur: Option, } +impl Default for ExchangeRateCache { + fn default() -> Self { + Self::new() + } +} + impl ExchangeRateCache { pub fn new() -> Self { Self { diff --git a/src/host/proxmox.rs b/src/host/proxmox.rs index 8e25191..a640610 100644 --- a/src/host/proxmox.rs +++ b/src/host/proxmox.rs @@ -1,5 +1,5 @@ use anyhow::{anyhow, bail, Result}; -use log::{debug, error, info}; +use log::debug; use reqwest::{ClientBuilder, Method, Url}; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; diff --git a/src/lib.rs b/src/lib.rs index 24aebe6..6673279 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,8 +5,8 @@ pub mod host; pub mod invoice; pub mod nip98; pub mod provisioner; +pub mod router; pub mod settings; +pub mod ssh_client; pub mod status; pub mod worker; -pub mod router; -pub mod ssh_client; diff --git a/src/provisioner/lnvps.rs b/src/provisioner/lnvps.rs index ddfd91c..166c6d4 100644 --- a/src/provisioner/lnvps.rs +++ b/src/provisioner/lnvps.rs @@ -1,8 +1,8 @@ use crate::exchange::{ExchangeRateCache, Ticker}; use crate::host::get_host_client; use crate::host::proxmox::{ - ConfigureVm, CreateVm, DownloadUrlRequest, ProxmoxClient, ResizeDiskRequest, StorageContent, - TaskState, VmBios, VmConfig, + CreateVm, DownloadUrlRequest, ProxmoxClient, ResizeDiskRequest, StorageContent, VmBios, + VmConfig, }; use crate::provisioner::Provisioner; use crate::settings::{QemuConfig, SshConfig}; @@ -14,11 +14,8 @@ use fedimint_tonic_lnd::tonic::async_trait; use fedimint_tonic_lnd::Client; use ipnetwork::IpNetwork; use lnvps_db::hydrate::Hydrate; -use lnvps_db::{ - IpRange, LNVpsDb, Vm, VmCostPlanIntervalType, VmHost, VmHostKind, VmIpAssignment, VmOsImage, - VmPayment, -}; -use log::{error, info, warn}; +use lnvps_db::{IpRange, LNVpsDb, Vm, VmCostPlanIntervalType, VmIpAssignment, VmPayment}; +use log::info; use nostr::util::hex; use rand::random; use rand::seq::IteratorRandom; @@ -26,9 +23,7 @@ use reqwest::Url; use std::collections::HashSet; use std::net::IpAddr; use std::ops::Add; -use std::path::PathBuf; use std::time::Duration; -use tokio::time::sleep; pub struct LNVpsProvisioner { db: Box, @@ -146,9 +141,9 @@ impl Provisioner for LNVpsProvisioner { disk_id: pick_disk.id, mac_address: format!( "bc:24:11:{}:{}:{}", - hex::encode(&[random::()]), - hex::encode(&[random::()]), - hex::encode(&[random::()]) + hex::encode([random::()]), + hex::encode([random::()]), + hex::encode([random::()]) ), ..Default::default() }; diff --git a/src/router/mikrotik.rs b/src/router/mikrotik.rs index 3163389..b49509a 100644 --- a/src/router/mikrotik.rs +++ b/src/router/mikrotik.rs @@ -1,7 +1,6 @@ -use std::net::IpAddr; -use lnvps_db::VmIpAssignment; -use rocket::async_trait; use crate::router::Router; +use rocket::async_trait; +use std::net::IpAddr; pub struct MikrotikRouter { url: String, @@ -19,7 +18,12 @@ impl MikrotikRouter { #[async_trait] impl Router for MikrotikRouter { - async fn add_arp_entry(&self, ip: IpAddr, mac: &[u8; 6], comment: Option<&str>) -> anyhow::Result<()> { + async fn add_arp_entry( + &self, + ip: IpAddr, + mac: &[u8; 6], + comment: Option<&str>, + ) -> anyhow::Result<()> { todo!() } } diff --git a/src/status.rs b/src/status.rs index 1c1f707..12ef585 100644 --- a/src/status.rs +++ b/src/status.rs @@ -32,6 +32,12 @@ pub struct VmStateCache { state: Arc>>, } +impl Default for VmStateCache { + fn default() -> Self { + Self::new() + } +} + impl VmStateCache { pub fn new() -> Self { Self { diff --git a/src/worker.rs b/src/worker.rs index aebafe4..cd391e1 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -1,11 +1,11 @@ use crate::host::get_host_client; -use crate::host::proxmox::{ProxmoxClient, VmInfo, VmStatus}; +use crate::host::proxmox::{VmInfo, VmStatus}; use crate::provisioner::Provisioner; use crate::status::{VmRunningState, VmState, VmStateCache}; use anyhow::Result; use chrono::{Days, Utc}; use lnvps_db::LNVpsDb; -use log::{debug, error, info, warn}; +use log::{debug, error, info}; use std::ops::Add; use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};